@import "../../theme.scss";

$gray-100: #f0f0f0;
// sideconvo's own --radius-md (styles/tokens.css) is 12px — larger than biogrid's
// $border-radius (6px) — used here (not $border-radius) to match its pill shape exactly.
$nav-item-radius: 12px;
// Selected nav item color — sideconvo's own --color-primary (styles/tokens.css),
// used here instead of biogrid's purple $secondary for the active/selected state only.
$nav-active-color: #5f5bf3;

/**
 * Sidebar Navigation Styles
 *
 * Ported from sideconvo-wp-plugin's sidebar.css, matched to its styles/tokens.css
 * pixel values. Color mapping only:
 * var(--color-primary) -> $secondary, var(--color-primary-lighter) -> rgba($secondary, .08),
 * var(--color-text-primary/secondary/tertiary) -> $primary / $text-secondary / $text-placeholder,
 * var(--color-gray-100) -> $gray-100.
 */

#sfsync-settings-page .sidebar {
  display: flex;
  flex-direction: column;
  height: 100%;
  position: relative;
  padding: 32px 0;
  // White sidebar against the page's light gray background (matches
  // sideconvo's white sidebar + --color-bg-secondary content area split).
  background: $primary-bg;

  /* ========================================
     LOGO / BRANDING
     ======================================== */

  &__logo {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 7px;
    padding: 0 16px 16px;

    h1,
    h2 {
      margin: 0;
      line-height: normal !important;
    }

    h1 {
      font-size: 2rem;
      color: inherit;
    }

    h2 {
      font-size: 0.85rem;
      color: $secondary;
      font-weight: 500;
    }

    svg {
      height: 26px;
      width: auto;
    }
  }

  /* ========================================
     SECTIONS
     ======================================== */

  &__section {
    margin-bottom: 8px;
  }

  &__section-header {
    font-size: 0.75rem;
    font-weight: 600;
    color: $text-placeholder;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    padding: 8px 16px 6px;
    margin-top: 8px;
  }

  &__divider {
    height: 1px;
    background: $border-default;
    margin: 16px 12px;
  }

  /* ========================================
     NAVIGATION MENU
     ======================================== */

  &__menu {
    list-style: none;
    margin: 0;
    padding: 0 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
  }

  &__menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: $nav-item-radius;
    font-size: 0.875rem;
    font-weight: 500;
    color: $text-secondary;
    text-decoration: none;
    transition: all 200ms ease-out;
    cursor: pointer;
    position: relative;
    overflow: visible;
    min-height: 40px;

    /* Hover background */
    &::before {
      content: "";
      position: absolute;
      left: 0;
      top: 0;
      width: 100%;
      height: 100%;
      background: $gray-100;
      border-radius: $nav-item-radius;
      opacity: 0;
      transform: scale(0.95);
      transition: all 200ms ease-out;
      z-index: -1;
    }

    &:hover::before {
      opacity: 1;
      transform: scale(1);
    }

    &:hover {
      color: $primary;
    }

    /* Active state */
    &--active {
      color: $nav-active-color;
      background: rgba($nav-active-color, 0.08);
      box-shadow: 0 0 0 1px rgba($nav-active-color, 0.15);
      font-weight: 600;

      &::before {
        display: none;
      }

      &:hover {
        color: $nav-active-color;
        background: rgba($nav-active-color, 0.08);
        box-shadow: 0 0 0 1px rgba($nav-active-color, 0.25);
      }

      /* Active indicator bar */
      &::after {
        content: "";
        position: absolute;
        left: 0;
        top: 50%;
        transform: translateY(-50%);
        width: 3px;
        height: 60%;
        background: $nav-active-color;
        border-radius: 0 999px 999px 0;
      }

      .sidebar__menu-icon {
        color: $nav-active-color;
        transform: scale(1.05);
      }
    }

    /* Disabled state */
    &--disabled {
      color: $text-disabled;
      pointer-events: none;

      &::before {
        display: none;
      }
    }

    /* Menu item text */
    span:not(.sidebar__menu-icon) {
      flex: 1;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
  }

  /* Icon styling - overflow:visible is critical, prevents stroke/shape clipping */
  &__menu-icon {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: visible;
    transition: transform 200ms ease-out;

    svg {
      width: 100%;
      height: 100%;
      display: block;
      overflow: visible;
      // fill: currentColor !important;
    }
  }

  &__menu-item:hover .sidebar__menu-icon {
    transform: scale(1.08);
  }

  /* ========================================
     MOBILE VARIANT
     ======================================== */

  &--mobile {
    display: flex;
    justify-content: space-between;
    background-color: white;
    margin-bottom: 1rem;
    padding: 32px;
    border-radius: 8px;
    position: relative;
    box-shadow: $shadow-sm;
    min-width: 450px;

    .menu-icon {
      all: unset;
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;

      svg {
        height: 28px;
        width: 28px;
        transform: scale(1);
        transition: transform 0.3s ease;
        fill: currentColor;

        &:hover {
          transform: scale(1.1);
        }
      }
    }

    .sidebar__logo {
      padding: 0;
      flex-direction: row;
      align-items: center;

      h2 {
        font-size: 1.4rem;
      }
    }

    .menu-list-container {
      display: none;
      position: absolute;
      top: 0;
      left: 0;
      transform: translateY(84px);
      width: 100%;
      background-color: white;
      padding: 8px 32px 32px;
      box-shadow:
        rgba(0, 0, 0, 0.01) 0px 8px 4px -1px,
        rgba(0, 0, 0, 0.06) 0px 2px 4px -1px;
      border-bottom-right-radius: 8px;
      border-bottom-left-radius: 8px;
      z-index: 999;

      html[dir="rtl"] & {
        left: unset;
        right: 0;
      }

      &.show-container {
        display: block;
      }
    }
  }
}

.config-items-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;

  .config-item-submenu {
    padding-left: 10px;
    margin-top: -10px;
  }
}
