/* ===========================================
   Navigation
   ===========================================
   BEM: .nav, .nav__item, .account-switcher
   =========================================== */

@layer components {
  .nav {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
  }

  .nav__item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    min-height: 2.75rem;
    padding: 0 var(--space-3);
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    color: var(--color-text-muted);
    text-decoration: none;
    border-radius: var(--radius-md);

    &:hover {
      color: var(--color-text);
      background-color: var(--color-gray-100);
    }

    &.is-active {
      font-weight: var(--font-semibold);
      color: var(--color-text);
      background-color: var(--color-gray-100);
    }
  }

  .nav__icon {
    flex-shrink: 0;
    width: 1.25rem;
    height: 1.25rem;
  }

  .nav__badge {
    margin-left: auto;
    font-size: var(--text-sm);
    color: var(--color-text-muted);
  }

  .nav--horizontal {
    flex-direction: row;
  }

  /* ===========================================
     Account Switcher
     =========================================== */

  .account-switcher {
    position: relative;
  }

  .account-switcher__menu {
    min-width: 14rem;
  }

  .account-switcher__section-label {
    padding: var(--space-2) var(--space-3) var(--space-1);
    font-size: var(--text-sm);
    color: var(--color-text-muted);
  }

  .account-switcher__item {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    width: 100%;
    min-height: 2.5rem;
    padding: var(--space-2) var(--space-3);
    font: inherit;
    font-size: var(--text-sm);
    color: var(--color-text);
    text-align: left;
    background: none;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;

    &:hover,
    &.is-active {
      background-color: var(--color-gray-100);
    }

    &.is-active .account-switcher__account-name {
      font-weight: var(--font-semibold);
    }
  }

  .account-switcher__account-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* Role shown as quiet text, not a coloured pill */
  .account-switcher__role {
    font-size: var(--text-sm);
    color: var(--color-text-muted);
  }

  [data-theme="dark"] {
    .nav__item:hover,
    .nav__item.is-active,
    .account-switcher__item:hover,
    .account-switcher__item.is-active {
      background-color: var(--color-hover);
    }
  }
}
