/* ==========================================================================
   Estafette : mise en page
   Coquille du backoffice (menu latéral, barre du haut, contenu)
   et écrans de connexion (panneau de marque + carte de formulaire).
   Menu latéral fixe au-delà de 1024 px, tiroir en dessous.
   ========================================================================== */

/* Logo --------------------------------------------------------------------- */

.logo {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  color: inherit;
  text-decoration: none;
}

.logo-mark {
  width: 2rem;
  height: 2rem;
  flex: none;
  border-radius: 0.5rem;
  box-shadow: 0 0 0 1px rgba(245, 239, 228, 0.08);
}

.logo-word {
  font-family: var(--font-display);
  font-size: 1.375rem;
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1;
  padding-bottom: 0.12em;
}

/* Au chargement, le bras safran du E se détache et glisse en place (une fois). */
.logo-animated .logo-arm { animation: arm-depart 1.1s var(--ease) 0.35s both; }

@keyframes arm-depart {
  0% { transform: translateX(-6.5px); }
  55% { transform: translateX(1.5px); }
  100% { transform: none; }
}

/* Voies de messages : signature visuelle (panneau de connexion, accueil) ----- */

/* Les voies n'apparaissent qu'à droite du texte : les messages « partent » vers le bord. */
.lanes {
  --lanes-from: 50%;
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  -webkit-mask-image:
    linear-gradient(90deg, transparent var(--lanes-from), #000 calc(var(--lanes-from) + 22%)),
    linear-gradient(180deg, transparent, #000 18%, #000 82%, transparent);
  -webkit-mask-composite: source-in;
  mask-image:
    linear-gradient(90deg, transparent var(--lanes-from), #000 calc(var(--lanes-from) + 22%)),
    linear-gradient(180deg, transparent, #000 18%, #000 82%, transparent);
  mask-composite: intersect;
}

.lane {
  position: absolute;
  left: 0;
  right: 0;
  top: var(--y);
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(245, 239, 228, 0.09) 18%, rgba(245, 239, 228, 0.09) 82%, transparent);
}

.lane i {
  position: absolute;
  top: -4px;
  left: -12%;
  width: var(--w, 2.75rem);
  height: 9px;
  border-radius: var(--radius-pill);
  background: rgba(245, 239, 228, 0.22);
  animation: lane-run var(--d, 11s) linear infinite;
  animation-delay: var(--delay, 0s);
}

.lane.is-priority i {
  background: var(--saffron);
  box-shadow: 0 0 16px rgba(244, 169, 52, 0.6);
}

@keyframes lane-run {
  from { left: -12%; }
  to { left: 108%; }
}

@media (prefers-reduced-motion: reduce) {
  .lane i { animation: none; left: var(--rest, 30%); }
}

/* Coquille ------------------------------------------------------------------ */

.shell {
  min-height: 100vh;
  min-height: 100dvh;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  width: var(--sidebar-width);
  padding: var(--space-4) var(--space-3);
  padding-left: max(var(--space-3), env(safe-area-inset-left, 0px));
  background:
    radial-gradient(140% 50% at 0% 100%, rgba(18, 103, 122, 0.35), transparent 70%),
    var(--side-bg);
  color: var(--side-fg);
  overflow-y: auto;
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-3) var(--space-6);
}

.sidebar-head .sidebar-brand {
  color: var(--side-fg-strong);
  border-radius: var(--radius);
  text-decoration: none;
}

.sidebar-head .sidebar-close { display: none; }

.nav {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  flex: 1;
}

.nav-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-label {
  padding: 0 var(--space-3) var(--space-1);
  color: var(--side-muted);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.nav-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: 2.5rem;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius);
  color: var(--side-fg);
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 0.15s var(--ease), color 0.15s var(--ease);
}

.nav-link > span:not(.nav-tag) {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-link .icon {
  color: var(--side-muted);
  transition: color 0.15s var(--ease);
}

.nav-link:hover {
  background: var(--side-hover);
  color: var(--side-fg-strong);
}

.nav-link.active {
  background: var(--side-active);
  color: var(--side-fg-strong);
}

.nav-link.active::before {
  content: "";
  position: absolute;
  top: 0.5rem;
  bottom: 0.5rem;
  left: calc(-1 * var(--space-3));
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--saffron);
}

.nav-link.active .icon { color: var(--saffron); }

.nav-link:focus-visible { outline-color: var(--saffron); }

.nav-tag {
  margin-left: auto;
  padding: 0.05rem 0.45rem;
  border: 1px solid var(--side-line);
  border-radius: var(--radius-pill);
  color: var(--side-muted);
  font-size: 0.6875rem;
  font-weight: 500;
}

.sidebar-foot {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-3) var(--space-1);
  border-top: 1px solid var(--side-line);
  color: var(--side-muted);
  font-size: var(--text-xs);
}

.sidebar-foot::before {
  content: "";
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 3px rgba(69, 176, 122, 0.18);
}

.sidebar-backdrop { display: none; }

.main {
  min-width: 0;
  margin-left: var(--sidebar-width);
}

/* Barre du haut ------------------------------------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  height: var(--topbar-height);
  padding: 0 var(--space-8);
  padding-right: max(var(--space-8), env(safe-area-inset-right, 0px));
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
}

.topbar .topbar-menu,
.topbar .topbar-brand { display: none; }

.topbar-spacer { flex: 1; }

/* Fil d'Ariane (pages de détail) : page parente › page actuelle */
.breadcrumb {
  min-width: 0;
  font-size: var(--text-sm);
}

.breadcrumb ol {
  display: flex;
  align-items: center;
  min-width: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

.breadcrumb li {
  display: flex;
  align-items: center;
  min-width: 0;
}

.breadcrumb a {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-2);
  margin-left: calc(-1 * var(--space-2));
  border-radius: var(--radius);
  color: var(--fg-muted);
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  transition: color 0.12s var(--ease), background-color 0.12s var(--ease);
}

.breadcrumb a:hover {
  color: var(--fg);
  background: var(--surface-3);
}

.breadcrumb [aria-current="page"] {
  color: var(--fg);
  font-weight: 600;
}

.breadcrumb [aria-current="page"] span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.breadcrumb-separator {
  flex: none;
  width: 0.95rem;
  height: 0.95rem;
  margin: 0 var(--space-1);
  color: var(--fg-subtle);
}

.breadcrumb-back { display: none; }

@media (prefers-reduced-motion: reduce) {
  .breadcrumb a { transition: none; }
}

/* Contenu -------------------------------------------------------------------- */

.content {
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--space-8) var(--space-8) var(--space-12);
  padding-right: max(var(--space-8), env(safe-area-inset-right, 0px));
}

.content:focus { outline: none; }

/* Pas d'animation d'apparition dans le backoffice : la page affichée par le serveur est reconstruite
   dès que la connexion interactive s'établit, et l'animation se rejouerait (scintillement). */
@keyframes page-in {
  from { opacity: 0; transform: translateY(6px); }
}

/* Menu du compte ------------------------------------------------------------ */

.user-menu-trigger {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-2) var(--space-1) var(--space-1);
  border-radius: var(--radius-pill);
  font-weight: 600;
  font-size: var(--text-sm);
}

.user-menu-trigger:hover { background: var(--surface-3); }

.user-menu-trigger .icon { color: var(--fg-subtle); }

.avatar {
  display: inline-grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  flex: none;
  border-radius: 50%;
  background: hsl(var(--avatar-hue, 192) 42% 28%);
  color: #FFFFFF;
  font-family: var(--font-display);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.02em;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}

/* Bouton de thème : affiche la lune en clair, le soleil en sombre */
.theme-toggle .theme-icon-sun { display: none; }

:root[data-theme="dark"] .theme-toggle .theme-icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .theme-icon-moon { display: none; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .theme-icon-sun { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .theme-icon-moon { display: none; }
}

/* Petits écrans : le menu latéral devient un tiroir -------------------------- */

@media (max-width: 1024px) {
  .sidebar {
    width: min(18rem, 86vw);
    transform: translateX(-100%);
    transition: transform 0.25s var(--ease), visibility 0.25s;
    visibility: hidden;
    box-shadow: var(--shadow-lg);
  }

  .sidebar-head .sidebar-close {
    display: inline-grid;
    color: var(--side-fg);
  }

  .sidebar-head .sidebar-close:hover {
    background: var(--side-hover);
    color: var(--side-fg-strong);
  }

  .nav-open .sidebar {
    transform: none;
    visibility: visible;
  }

  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 35;
    display: block;
    background: var(--overlay);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s var(--ease);
  }

  .nav-open .sidebar-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  .main { margin-left: 0; }

  .topbar {
    padding-left: max(var(--space-4), env(safe-area-inset-left, 0px));
    padding-right: max(var(--space-4), env(safe-area-inset-right, 0px));
  }

  .topbar .topbar-menu { display: inline-grid; }

  .topbar .topbar-brand {
    display: inline-flex;
    color: var(--fg);
    text-decoration: none;
  }

  .topbar-brand .logo-mark { width: 1.75rem; height: 1.75rem; }
  .topbar-brand .logo-word { font-size: 1.25rem; }

  /* Sur mobile, le fil d'Ariane devient un simple retour vers la page parente, à la place du logo. */
  .topbar:has(.breadcrumb) .topbar-brand { display: none; }
  .breadcrumb [aria-current="page"] { display: none; }
  .breadcrumb-back { display: inline; width: 1rem; height: 1rem; }
  .breadcrumb a { margin-left: 0; }

  .content {
    padding: var(--space-6) var(--space-4) var(--space-10);
    padding-left: max(var(--space-4), env(safe-area-inset-left, 0px));
    padding-right: max(var(--space-4), env(safe-area-inset-right, 0px));
  }
}

@media (max-width: 640px) {
  .user-menu-name,
  .user-menu-trigger > .icon { display: none; }
  .user-menu-trigger { padding: var(--space-1); }
}

/* Écrans de connexion -------------------------------------------------------- */

.auth {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  min-height: 100vh;
  min-height: 100dvh;
}

.auth-brand {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--space-10);
  padding: var(--space-10) clamp(2rem, 5vw, 4.5rem);
  overflow: hidden;
  background:
    radial-gradient(90% 70% at 15% 105%, rgba(18, 103, 122, 0.7), transparent 65%),
    radial-gradient(60% 50% at 100% 0%, rgba(244, 169, 52, 0.08), transparent 70%),
    var(--ink);
  color: var(--side-fg);
}

.auth-brand .lanes { --lanes-from: 58%; }

.auth-brand > :not(.lanes) {
  position: relative;
  z-index: 1;
}

.auth-brand .logo { color: var(--paper); }
.auth-brand .logo-mark { width: 2.5rem; height: 2.5rem; border-radius: 0.65rem; }
.auth-brand .logo-word { font-size: 1.625rem; }

.auth-brand-body {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
  max-width: 30rem;
  margin-block: auto;
}

.auth-brand-title {
  color: var(--paper);
  font-family: var(--font-display);
  font-size: clamp(2rem, 3vw, 2.875rem);
  font-weight: 700;
  line-height: 1.08;
  letter-spacing: -0.035em;
  text-wrap: balance;
}

.auth-brand-title em {
  color: var(--saffron);
  font-style: normal;
}

.auth-brand-lead {
  max-width: 27rem;
  margin-bottom: var(--space-2);
  color: var(--side-fg);
  font-size: var(--text-lg);
  line-height: 1.5;
}

/* Aperçu de la file d'envoi, dans le panneau de marque */
.glimpse {
  display: flex;
  flex-direction: column;
  max-width: 27rem;
  border: 1px solid rgba(245, 239, 228, 0.12);
  border-radius: var(--radius-lg);
  background: rgba(7, 21, 24, 0.45);
  box-shadow: 0 24px 60px -20px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.glimpse-head {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid rgba(245, 239, 228, 0.08);
  color: var(--side-muted);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.glimpse-head::before {
  content: "";
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: #45B07A;
  box-shadow: 0 0 0 3px rgba(69, 176, 122, 0.2);
}

.glimpse ul {
  margin: 0;
  padding: var(--space-1) 0;
  list-style: none;
}

.glimpse li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--space-1) var(--space-3);
  padding: var(--space-3) var(--space-4);
  animation: glimpse-in 0.6s var(--ease) both;
}

.glimpse li + li { border-top: 1px solid rgba(245, 239, 228, 0.06); }
.glimpse li:nth-child(2) { animation-delay: 0.15s; }
.glimpse li:nth-child(3) { animation-delay: 0.3s; }

@keyframes glimpse-in {
  from { opacity: 0; transform: translateX(-10px); }
}

.glimpse-subject {
  min-width: 0;
  overflow: hidden;
  color: var(--paper);
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.glimpse-meta {
  grid-column: 1;
  color: var(--side-muted);
  font-size: var(--text-xs);
}

.glimpse .chip {
  grid-row: 1 / span 2;
  grid-column: 2;
}

.glimpse .chip-info { --chip: #3BA7BF; --chip-soft: rgba(59, 167, 191, 0.16); --chip-fg: #9AD6E4; }
.glimpse .chip-ok { --chip: #45B07A; --chip-soft: rgba(69, 176, 122, 0.16); --chip-fg: #8FD9B1; }
.glimpse .chip-warn { --chip: #E0912F; --chip-soft: rgba(224, 145, 47, 0.16); --chip-fg: #F2BE7C; }

.auth-main {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-5);
  padding: var(--space-10) var(--space-6);
  background:
    radial-gradient(70% 50% at 50% 0%, color-mix(in srgb, var(--primary-soft) 70%, transparent), transparent 70%),
    var(--bg);
}

.auth-card {
  width: 100%;
  max-width: 29rem;
  padding: var(--space-8) var(--space-8) var(--space-8);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--surface);
  box-shadow: var(--shadow);
  animation: page-in 0.4s var(--ease) both;
}

.auth-foot {
  color: var(--fg-subtle);
  font-size: var(--text-xs);
  letter-spacing: 0.04em;
}

@media (max-width: 960px) {
  .auth { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }

  .auth-brand {
    gap: var(--space-4);
    padding: var(--space-8) max(var(--space-5), env(safe-area-inset-right, 0px)) var(--space-8) max(var(--space-5), env(safe-area-inset-left, 0px));
  }

  .auth-brand-body { gap: 0; }
  .auth-brand .lanes { display: none; }
  .auth-brand-title { font-size: 1.5rem; }
  .auth-brand-lead,
  .glimpse { display: none; }

  .auth-main {
    justify-content: flex-start;
    padding: var(--space-6) max(var(--space-4), env(safe-area-inset-right, 0px)) var(--space-10) max(var(--space-4), env(safe-area-inset-left, 0px));
  }
}

@media (max-width: 480px) {
  .auth-card { padding: var(--space-6) var(--space-5); }
}
