/*
|--------------------------------------------------------------------------
| Agência PSI
|--------------------------------------------------------------------------
| Criado e desenvolvido por Leonardo Nohama
|
| Tecnologia aplicada à escuta.
| Estrutura para o cuidado.
|
| Arquivo: src/assets/layout/_menu.scss
| Data: 2026
| Local: São Carlos/SP — Brasil
|--------------------------------------------------------------------------
| © 2026 — Todos os direitos reservados
|--------------------------------------------------------------------------
*/

@use 'mixins' as *;

/* ── Sidebar container ─────────────────────────────────────── */
.layout-sidebar {
  position: fixed;
  width: 20rem;
  height: calc(100vh - 56px);
  z-index: 999;
  overflow-y: auto;
  overflow-x: hidden;
  user-select: none;
  top: 56px;
  left: 0;
  transition:
    transform var(--layout-section-transition-duration),
    left var(--layout-section-transition-duration);
  background-color: var(--surface-card);
  border-radius: 0;
  padding: 0;
  scrollbar-width: thin;
  scrollbar-color: var(--surface-border) transparent;

  &::-webkit-scrollbar       { width: 4px; }
  &::-webkit-scrollbar-track { background: transparent; }
  &::-webkit-scrollbar-thumb { background: var(--surface-border); border-radius: 4px; }
}

/* ── Menu list ─────────────────────────────────────────────── */
.layout-menu {
  margin: 0;
  padding: 0.5rem 0 2rem;
  list-style-type: none;

  /* ── Section header ─────────────────────────────────────── */
  .layout-root-menuitem {
    > .layout-menuitem-root-text {
      font-size: 0.6rem;
      text-transform: uppercase;
      font-weight: 800;
      letter-spacing: 0.11em;
      color: var(--text-color-secondary);
      opacity: 0.45;
      padding: 1.1rem 1.25rem 0.3rem;
      margin: 0;
    }

    > a { display: none; }
  }

  /* ── Active toggler ─────────────────────────────────────── */
  a.active-menuitem > .layout-submenu-toggler,
  li.active-menuitem > a .layout-submenu-toggler {
    transform: rotate(-180deg);
  }

  /* ── Links ──────────────────────────────────────────────── */
  ul {
    margin: 0;
    padding: 0 0.625rem;
    list-style-type: none;

    a {
      display: flex;
      align-items: center;
      position: relative;
      outline: 0 none;
      color: var(--text-color-secondary);
      cursor: pointer;
      padding: 0.48rem 0.75rem;
      border-radius: 8px;
      font-size: 0.825rem;
      font-weight: 500;
      line-height: 1.4;
      transition: background 0.12s, color 0.12s;
      gap: 0;

      .layout-menuitem-icon {
        font-size: 0.85rem;
        flex-shrink: 0;
        opacity: 0.6;
        margin-right: 0.6rem;
        transition: opacity 0.12s;
        width: 1rem;
        text-align: center;
        color: var(--primary-color);
      }

      .layout-menuitem-text {
        flex: 1;
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
      }

      .layout-submenu-toggler {
        font-size: 68%;
        margin-left: auto;
        padding-left: 0.35rem;
        transition: transform var(--element-transition-duration);
        opacity: 0.4;
        flex-shrink: 0;
      }

      &.active-route {
        font-weight: 600;
        color: var(--primary-color);
        background: color-mix(in srgb, var(--primary-color) 9%, transparent);

        .layout-menuitem-icon { opacity: 1; }
        .layout-submenu-toggler { opacity: 0.6; }
      }

      &:hover {
        background: var(--surface-ground);
        color: var(--text-color);

        .layout-menuitem-icon { opacity: 0.85; }
      }

      &:focus {
        @include focused-inset();
      }
    }

    /* ── Sub-items ────────────────────────────────────────── */
    ul {
      padding: 0;
      overflow: hidden;
      border-radius: 0;

      li a {
        font-size: 0.8rem;
        padding: 0.4rem 0.75rem 0.4rem 2.1rem;
        font-weight: 400;
        opacity: 0.9;
      }

      li li a { padding-left: 2.9rem; }
      li li li a { padding-left: 3.5rem; }
      li li li li a { padding-left: 4rem; }
      li li li li li a { padding-left: 4.5rem; }
      li li li li li li a { padding-left: 5rem; }
    }
  }
}

/* ── Submenu transition ────────────────────────────────────── */
.layout-submenu-enter-from,
.layout-submenu-leave-to {
  max-height: 0;
}

.layout-submenu-enter-to,
.layout-submenu-leave-from {
  max-height: 1000px;
}

.layout-submenu-leave-active {
  overflow: hidden;
  transition: max-height 0.35s cubic-bezier(0, 1, 0, 1);
}

.layout-submenu-enter-active {
  overflow: hidden;
  transition: max-height 0.45s ease-in-out;
}
