/* =========================================================
   Jet Menu • Nav Settings UI
   ========================================================= */

/* Root variables */
.jet-menu-nav-settings-root {
  --jm-radius: 4px;
  --jm-radius-lg: 6px;

  --jm-border: #dcdcde;
  --jm-border2: #e2e4e7;

  --jm-bg: #f6f7f7;
  --jm-surface: #ffffff;
  --jm-text: #1d2327;
  --jm-text-subtle: #50575e;

  --jm-accent: var(--wp-admin-theme-color);
  --jm-accent-soft: color-mix(in srgb, var(--jm-accent) 18%, transparent);

  --jm-shadow: 0 1px 0 rgba(0,0,0,.04);
}

.jet-menu-nav-settings-root {
  padding-right: 20px;
  color: var(--jm-text);

  .components-select-control__input {
    height: 36px !important;
    min-height: 36px !important;
  }
}

/* =========================================================
   Layout
   ========================================================= */

#jet-menus-app {
  margin-top: 16px;
}

.jet-menu-nav-settings {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
  margin-top: 20px;
}

@media (max-width: 1120px) {
  .jet-menu-nav-settings {
    grid-template-columns: 1fr;
  }

  .jet-menu-nav-settings__panel {
    position: static;
  }
}

.jet-menu-nav-settings__col {
  min-width: 0;
}

.jet-menu-nav-settings__panel {
  position: static;
  top: auto;
}

/* =========================================================
   Card
   ========================================================= */

.jet-menu-card__body {
  padding: 0 !important;
}

.jet-menu-card__head {
  padding: 14px 16px;
  min-height: 65px;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-bottom: 1px solid var(--jm-border2);
}

.jet-menu-card__title {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--jm-text);
  line-height: 20px;
}

.jet-menu-card__saving {
  margin-left: 8px;
  font-size: 12px;
  opacity: 0.7;
}

.jet-menu-card__content {
  padding: 16px;
  max-width: 900px;
}

/* =========================================================
   Add list
   ========================================================= */

.jet-menu-addlist {
  margin-top: 10px;
  max-height: 260px;
  overflow: auto;
  border: 1px solid var(--jm-border);
  border-radius: var(--jm-radius);
  padding: 8px;
  background: var(--jm-surface);
  box-shadow: var(--jm-shadow);
}

/* =========================================================
   Editor (generic panel)
   ========================================================= */

.jet-menu-editor {
  background: #fff;
  border: 1px solid var(--jm-border);
  border-radius: 8px;
  overflow: hidden;
}

.jet-menu-editor__header {
  padding: 10px 12px;
  border-bottom: 1px solid var(--jm-border2);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.jet-menu-editor__body {
  padding: 12px;
}

/* =========================================================
   Inline editor inside tree node
   ========================================================= */

.jet-menu-tree__inline-editor {
  margin-top: -20px;
  padding: 18px 12px 12px;
  border: 1px solid var(--jm-border);
  border-radius: var(--jm-radius);
  background: var(--jm-bg);
  + .jet-menu-tree__node {
    margin-top: 10px;
  }
}

.jet-menu-tree__inline-row {
  margin-bottom: 12px;
}

.jet-menu-tree__inline-row .components-notice {
  margin: 8px 0 0;
  padding: 2px 3px 2px 8px;
  font-size: 12px;
}

.jet-menu-tree__inline-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-wrap: wrap;
  padding-top: 8px;
  border-top: 1px solid var(--jm-border2);
}

/* =========================================================
   Tree item (new style)
   ========================================================= */

.jet-menu-tree__item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  margin-bottom: 10px;
  border: 1px solid var(--jm-border);
  border-radius: var(--jm-radius);
  background: var(--jm-surface);
  box-shadow: var(--jm-shadow);
  cursor: pointer;
  user-select: none;
}

.jet-menu-tree__item:hover {
  background: #f6f7f7;
}

.jet-menu-tree__item:focus-within {
  box-shadow: 0 0 0 2px var(--jm-accent-soft), var(--jm-shadow);
  border-color: color-mix(in srgb, var(--jm-accent) 55%, var(--jm-border));
}

.jet-menu-tree__item.is-selected {
  border-color: var(--jm-accent);
  box-shadow: 0 0 0 1px var(--jm-accent) inset, var(--jm-shadow);
}

/* DnD highlight (dataset-driven, older approach) */
.jet-menu-tree__item.is-drag-over {
  outline: 2px dashed #2271b1;
  outline-offset: 2px;
}

.jet-menu-tree__item.is-drag-over[data-drop-mode="before"] {
  box-shadow: 0 -3px 0 0 #2271b1 inset;
}

.jet-menu-tree__item.is-drag-over[data-drop-mode="after"] {
  box-shadow: 0 3px 0 0 #2271b1 inset;
}

.jet-menu-tree__item.is-drag-over[data-drop-mode="child"] {
  box-shadow: 0 0 0 2px rgba(34, 113, 177, 0.35) inset;
}

/* DnD placeholder overlay (line approach) */
.jet-menu-tree__drop-placeholder {
  pointer-events: none;
  position: absolute;
  left: 8px;
  right: 8px;
  height: 0;
  display: none;
}

.jet-menu-tree__drop-placeholder.is-before,
.jet-menu-tree__drop-placeholder.is-after {
  display: block;
  border-top: 2px solid var(--jm-accent);
  opacity: 0.9;
}

.jet-menu-tree__drop-placeholder.is-before {
  top: 0;
}

.jet-menu-tree__drop-placeholder.is-after {
  bottom: 0;
}

.jet-menu-tree__item.is-drop-child {
  outline: 2px solid var(--jm-accent);
  outline-offset: 2px;
  border-radius: var(--jm-radius);
}

/* =========================================================
   Menu item (WP-like box style, legacy)
   ========================================================= */

.jet-menu-tree {
  margin-top: 12px;
}

.jet-menu-item {
  background: #fff;
  border: 1px solid #dcdcde;
  border-radius: 4px;
  margin: 0 0 10px;
  overflow: hidden;
}

.jet-menu-item.is-selected {
  border-color: #2271b1;
  box-shadow: 0 0 0 1px #2271b1;
}

.jet-menu-item__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  cursor: pointer;
  background: #f6f7f7;
}

.jet-menu-item__row:hover {
  background: #f0f0f1;
}

.jet-menu-item__title {
  font-weight: 600;
  color: #1d2327;
  line-height: 1.3;
}

.jet-menu-item__actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}

.jet-menu-item__panel {
  padding: 12px;
  border-top: 1px solid #dcdcde;
  background: #fff;
}

.jet-menu-item__panel > .components-button {
  margin-bottom: 10px;
}

.jm-source .components-button.is-primary {
  margin-top: 12px;
}

.jet-menu-item__panel-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* =========================================================
   Iframe (legacy)
   ========================================================= */

.jet-edit-frame {
  width: 100%;
  min-height: 640px;
  border: 0;
  display: block;
}

/* =========================================================
   Left panel (wp.components Panel) • Active/opened state
   ========================================================= */

.jet-menu-nav-settings__panel {

  .jet-menu-card__body > .components-panel {
    padding: 16px;
    box-sizing: border-box;
    background: transparent;
    border: 0;
  }

  .components-panel__body {
    margin: 0 0 12px;
    border: 1px solid var(--jm-border);
    border-radius: var(--jm-radius);
    background: var(--jm-surface);
    box-shadow: var(--jm-shadow);
    overflow: hidden;

    &:last-child {
      margin-bottom: 0;
    }
  }

  .components-panel__body-title {
    margin: 0;
  }

  .components-panel__body-toggle {
    min-height: 48px;
    padding: 12px 16px;
    background: transparent;
    color: var(--jm-text);
    font-weight: 600;
  }

  .components-panel__body {

    &.is-opened {

      > .components-panel__body-title {
        background: var(--jm-bg);
        border-bottom: 1px solid var(--jm-border2);
        margin-bottom: 12px;
      }

      > .jm-source {

        > *:first-child {
          margin-top: 0;
        }

        > *:last-child {
          margin-bottom: 0;
        }
      }

    }
  }
}