/*
 * Figma : SideNav et SideNav/Item, BottomNav et BottomNav/Item, MobileHeader,
 * TopBar, Tabs/Onglet, Stepper et Stepper/Étape.
 * Entrée courante : [aria-current="page"] (ou aria-selected pour un onglet).
 */
@layer components {
  /* SideNav : 260 de large, postes tablette et bureau. */
  .side-nav {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: var(--space-6);
    width: var(--layout-nav-width);
    min-height: 100%;
    padding: var(--space-4);
    border-right: var(--stroke-1) solid var(--color-border-subtle);
    background: var(--color-surface-raised);
  }

  .side-nav__top {
    display: flex;
    flex-direction: column;
    gap: var(--space-6);
  }

  .side-nav__top .logo { align-self: flex-start; }

  .side-nav__list {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
  }

  .side-nav__item {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    min-height: var(--control-height-md);
    padding: 0 var(--space-3);
    border-radius: var(--radius-md);
    color: var(--color-text-primary);
    font: var(--text-label-m);
    text-decoration: none;
  }

  .side-nav__item .icon {
    width: 1.25rem;
    height: 1.25rem;
    color: var(--color-text-secondary);
  }

  .side-nav__item .badge { margin-left: auto; }

  .side-nav__item:hover { background: var(--color-surface-sunken); }

  .side-nav__item[aria-current="page"] {
    background: var(--color-surface-selected);
    color: var(--color-text-heading);
  }

  .side-nav__item[aria-current="page"] .icon { color: var(--color-text-heading); }

  .side-nav__account {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
    padding: var(--space-2);
    border: var(--stroke-1) solid var(--color-border-subtle);
    border-radius: var(--radius-md);
    background: var(--color-surface-page);
    color: var(--color-text-secondary);
  }

  /* BottomNav : téléphone. Seule l'entrée courante affiche son libellé. */
  .bottom-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-1);
    border-radius: var(--radius-full);
    background: var(--color-surface-raised);
    box-shadow: var(--shadow-card);
  }

  .bottom-nav__item {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-1);
    min-width: 3.125rem; /* 50 */
    height: 3.125rem;
    border-radius: var(--radius-full);
    color: var(--color-text-secondary);
    font: var(--text-label-s);
    text-decoration: none;
  }

  .bottom-nav__item .icon {
    width: 1.5rem;
    height: 1.5rem;
  }

  .bottom-nav__label {
    position: absolute;
    overflow: hidden;
    width: 1px;
    height: 1px;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .bottom-nav__item[aria-current="page"] {
    padding: 0 var(--space-3);
    background: var(--color-surface-selected);
    color: var(--color-text-heading);
  }

  .bottom-nav__item[aria-current="page"] .bottom-nav__label {
    position: static;
    overflow: visible;
    width: auto;
    height: auto;
    clip-path: none;
  }

  /* MobileHeader : titre centré (défaut), surtitre et titre, marque. */
  .mobile-header {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--layout-margin-mobile);
  }

  .mobile-header__title {
    flex: 1;
    min-width: 0;
    color: var(--color-text-heading);
    font: var(--text-title-s);
    text-align: center;
  }

  .mobile-header__titles {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-width: 0;
  }

  .mobile-header__titles .mobile-header__title {
    font: var(--text-title-l);
    text-align: left;
  }

  .mobile-header__overline {
    color: var(--color-text-secondary);
    font: var(--text-label-s);
  }

  .mobile-header--brand { justify-content: space-between; }

  /* TopBar : application (défaut) ou public. */
  .top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-5);
    padding: var(--space-3) var(--layout-margin-desktop);
    border-bottom: var(--stroke-1) solid var(--color-border-subtle);
  }

  .top-bar--public {
    padding-block: var(--space-2);
    background: var(--color-surface-raised);
  }

  .top-bar__brand,
  .top-bar__links,
  .top-bar__tools {
    display: flex;
    align-items: center;
  }

  .top-bar__brand { gap: var(--space-8); }
  .top-bar__links { gap: var(--space-6); }
  .top-bar__tools { gap: var(--space-3); }

  .top-bar__link {
    border-radius: var(--radius-xs);
    color: var(--color-text-primary);
    font: var(--text-label-m);
    text-decoration: none;
  }

  .top-bar__link:hover { color: var(--color-text-heading); }

  .top-bar__title {
    color: var(--color-text-heading);
    font: var(--text-title-m);
  }

  @media (max-width: 47.99em) {
    .top-bar {
      gap: var(--space-3);
      padding-inline: var(--layout-margin-mobile);
    }

    .top-bar__links { display: none; }
  }

  /* Tabs. L'écart entre onglets n'est pas fixé par le composant Figma. */
  .tabs {
    display: flex;
    gap: var(--space-4);
    overflow-x: auto;
    border-bottom: var(--stroke-1) solid var(--color-border-subtle);
  }

  .tabs__tab {
    display: inline-flex;
    flex: none;
    align-items: center;
    gap: var(--space-2);
    min-height: var(--control-height-md);
    padding: var(--space-2) var(--space-1);
    border: 0;
    border-bottom: var(--stroke-2) solid transparent;
    border-radius: var(--radius-xs) var(--radius-xs) 0 0;
    background: transparent;
    color: var(--color-text-secondary);
    font: var(--text-label-m);
    text-decoration: none;
    cursor: pointer;
  }

  .tabs__tab:hover {
    border-bottom-color: var(--color-border-default);
    color: var(--color-text-primary);
  }

  .tabs__tab[aria-selected="true"],
  .tabs__tab[aria-current="page"] {
    border-bottom-color: var(--color-border-selected);
    color: var(--color-text-heading);
  }

  /* Stepper : étape faite, en cours, à venir, en erreur. */
  .stepper {
    display: flex;
    flex-direction: column;
  }

  .stepper__step {
    display: flex;
    gap: var(--space-3);
  }

  .stepper__marker {
    display: flex;
    flex: none;
    flex-direction: column;
    align-items: center;
    gap: var(--space-1);
    width: 1.875rem;
  }

  .stepper__dot {
    display: inline-flex;
    flex: none;
    align-items: center;
    justify-content: center;
    width: 1.875rem;
    height: 1.875rem;
    border: var(--stroke-1) solid var(--color-border-control);
    border-radius: var(--radius-full);
    background: var(--color-surface-raised);
  }

  .stepper__line {
    flex: 1;
    width: 2px;
    min-height: 2.1875rem; /* 35 */
    background: var(--color-border-default);
  }

  .stepper__step:last-child .stepper__line { visibility: hidden; }

  .stepper__text {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: var(--space-1);
    min-width: 0;
    padding: var(--space-1) 0 var(--space-4);
  }

  .stepper__label {
    color: var(--color-text-secondary);
    font: var(--text-label-m);
  }

  .stepper__detail {
    color: var(--color-text-secondary);
    font: var(--text-body-s);
  }

  .stepper__step--done .stepper__label,
  .stepper__step--current .stepper__label {
    color: var(--color-text-primary);
  }

  .stepper__step--done .stepper__dot {
    border-color: var(--color-success-icon);
    background: var(--color-success-icon) center / 100% no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30' fill='none' stroke='%23fff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M8.5 15.5l4.5 4.5 8.5-9'/%3E%3C/svg%3E");
  }

  .stepper__step--done .stepper__line { background: var(--color-success-icon); }

  .stepper__step--current .stepper__dot {
    border-width: var(--stroke-2);
    border-color: var(--color-border-selected);
    background-image: radial-gradient(circle, var(--color-action-primary) 0 5px, transparent 5.5px);
  }

  .stepper__step--error .stepper__dot {
    border-width: var(--stroke-2);
    border-color: var(--color-danger-icon);
    background: var(--color-danger-bg);
    color: var(--color-danger-icon);
  }

  .stepper__step--error .stepper__dot .icon {
    width: 1rem;
    height: 1rem;
  }

  .stepper__step--error .stepper__label,
  .stepper__step--error .stepper__detail {
    color: var(--color-danger-fg);
  }
}
