/*
 * An editor that slides in from the right of a list table, like the flow editor's step settings. There's no overlay,
 * so the menu and the table stay usable while it's open. See assets/js/admin/sidebar-editor.js
 */
.gh-sidebar-editor {
  position: fixed;
  top: var(--wp-admin--admin-bar--height, 32px);
  right: 0;
  bottom: 0;
  // like modals, the pane is moved to the end of the page when it opens, so it's above the ones open before it
  z-index: 10000;
  box-sizing: border-box;
  width: clamp(480px, 45vw, 760px);
  max-width: 100vw;
  overflow-y: auto;
  background-color: var(--gh-background-color);
  border-left: 1px solid var(--gh-dark-15);
  box-shadow: -5px 0 30px 0 rgba(4, 45, 70, 0.1);
  transform: translateX(100%);
  visibility: hidden;
  transition: transform 0.3s ease-out, visibility 0s linear 0.3s;

  &.open {
    transform: none;
    visibility: visible;
    transition: transform 0.3s ease-out;
  }

  .gh-sidebar-editor-inner {
    padding: 0 20px 20px;
  }

  // the name and save button stay in view while the editor scrolls
  .gh-sidebar-editor-header {
    position: sticky;
    top: 0;
    z-index: 10;
    margin: 0 -20px;
    border-radius: 0;
    border-width: 0 0 1px;
  }

  // what the header shows in place of a name field, like a contact's picture and name
  .gh-sidebar-editor-title {
    flex: 1;
    min-width: 0;

    > * {
      min-width: 0;
    }

    img {
      flex-shrink: 0;
      border-radius: var(--gh-border-radius);
    }

    h2 {
      margin: 0;
      font-size: 16px;
    }

    :is(h2, .description) {
      display: block;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
  }

  // the name field gives up the room, not the buttons
  .gh-sidebar-editor-buttons {
    flex-shrink: 0;
  }

  // wide enough for labels like "Inactive" and "Hidden", the switch is sized for "Yes" and "No"
  .gh-sidebar-editor-toggle label.gh-switch {
    width: 76px;

    input:checked + .slider:before {
      transform: translateX(56px);
    }
  }

  // fields rendered by PHP for the old edit screens' form tables, stacked to fit the narrower pane
  .gh-sidebar-editor-server-fields {
    &:empty {
      display: none;
    }

    .form-table {
      margin: 0;

      th, td {
        display: block;
        width: auto;
        padding: 0 0 5px;
      }

      tr + tr th {
        padding-top: 10px;
      }

      :is(input[type="text"], select, textarea) {
        width: 100%;
        max-width: none;
      }
    }
  }

  @media (max-width: 782px) {
    width: 100vw;
  }
}

// the row of the item that's open
#the-list tr.gh-sidebar-editing,
#the-list tr.gh-sidebar-editing > :is(th, td) {
  background: var(--gh-primary-7);
}

#the-list tr.gh-sidebar-editing .row-title {
  font-weight: 700;
}
