/* ==========================================================================
   Portail d'Administration - Feuille de Styles Authentification
   Requiert /dashboard/assets/tokens.css
   ========================================================================== */

*, *::before, *::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html, body {
  min-height: 100%;
  margin: 0;
}

body {
  font-family: var(--font-sans);
  color: var(--ink);
  background-color: var(--bg-canvas);
  background-image:
    radial-gradient(680px circle at 8% 8%, rgba(12, 107, 93, 0.12), transparent 66%),
    radial-gradient(560px circle at 92% 92%, rgba(184, 132, 34, 0.09), transparent 68%),
    linear-gradient(to right, var(--bg-canvas-grid) 1px, transparent 1px),
    linear-gradient(to bottom, var(--bg-canvas-grid) 1px, transparent 1px);
  background-size: auto, auto, 44px 44px, 44px 44px;
  -webkit-font-smoothing: antialiased;
}

/* Sceau fin en tête de page */
.seal-strip {
  position: fixed;
  inset: 0 0 auto 0;
  height: 3px;
  background: var(--seal-band);
  z-index: 50;
}

.auth-viewport {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: clamp(1rem, 2.8vw, 2rem);
  gap: 0.9rem;
}

.auth-shell {
  width: min(740px, 100%);
  display: grid;
  grid-template-columns: 272px minmax(0, 1fr);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--bg-surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-shell);
  animation: shellEnter 320ms var(--ease-out) both;
}

@keyframes shellEnter {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ---- COLONNE GAUCHE ARDOISE ---- */
.auth-brand-pane {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 1.2rem;
  padding: 1.55rem 1.35rem;
  color: var(--rail-ink);
  background:
    radial-gradient(120% 85% at 0% 0%, rgba(184, 132, 34, 0.14), transparent 55%),
    radial-gradient(90% 70% at 100% 100%, rgba(48, 203, 177, 0.08), transparent 60%),
    linear-gradient(170deg, var(--bg-rail) 0%, var(--bg-rail-deep) 100%);
  border-right: 1px solid var(--rail-border);
  overflow: hidden;
}

.auth-brand-pane::after {
  content: '';
  position: absolute;
  inset: auto 0 0 0;
  height: 3px;
  background: var(--seal-band);
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 0.78rem;
  position: relative;
  z-index: 1;
}

.brand-crest {
  width: 44px;
  height: 44px;
  border-radius: 11px;
  background: #ffffff;
  padding: 3px;
  border: 1px solid rgba(255, 255, 255, 0.32);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.34), 0 0 0 3px rgba(48, 203, 177, 0.14);
  flex-shrink: 0;
  overflow: hidden;
  display: grid;
  place-items: center;
}

.brand-crest img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.brand-name strong {
  display: block;
  font-family: var(--font-display);
  font-size: 0.99rem;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: #ffffff;
  line-height: 1.18;
}

.brand-name span {
  display: block;
  margin-top: 2px;
  font-size: 0.71rem;
  color: var(--rail-muted);
}

/* Schéma architectural */
.corridor-visual {
  position: relative;
  z-index: 1;
  padding: 0.85rem;
  border-radius: 12px;
  border: 1px solid rgba(147, 179, 174, 0.18);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.045) 0%, rgba(255, 255, 255, 0.018) 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.corridor-visual svg {
  width: 100%;
  height: auto;
  display: block;
}

.corridor-pulse {
  stroke-dasharray: 5 6;
  animation: dashFlow 20s linear infinite;
}

@keyframes dashFlow {
  to { stroke-dashoffset: -120; }
}

.corridor-caption {
  margin: 0.55rem 0 0;
  padding-top: 0.45rem;
  border-top: 1px solid rgba(147, 179, 174, 0.12);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 0.61rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: #9de0d1;
}

.pane-copy {
  position: relative;
  z-index: 1;
}

.pane-copy h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.04rem;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.015em;
  color: #ffffff;
}

.pane-copy p {
  margin: 0.42rem 0 0.8rem;
  font-size: 0.78rem;
  line-height: 1.5;
  color: var(--rail-muted);
}

.pane-pillars {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.42rem;
}

.pane-pillars li {
  display: flex;
  align-items: center;
  gap: 0.48rem;
  font-size: 0.74rem;
  color: #dbece9;
}

.pane-pillars li svg {
  width: 13px;
  height: 13px;
  color: #e0b356;
  flex-shrink: 0;
}

/* ---- COLONNE DROITE FORMULAIRE COMPACT ---- */
.auth-form-pane {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(1.45rem, 3vw, 1.95rem) clamp(1.4rem, 3.2vw, 2.05rem);
  background: var(--bg-surface);
  min-width: 0;
}

.form-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  margin-bottom: 1.05rem;
}

.mobile-brand {
  display: none;
  align-items: center;
  gap: 0.6rem;
}

.mobile-brand img {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  object-fit: contain;
  background: #ffffff;
  border: 1px solid var(--line);
  padding: 2px;
}

.mobile-brand strong {
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--ink);
}

.context-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  height: 28px;
  padding: 0 11px;
  border-radius: 999px;
  background: var(--emerald-soft);
  border: 1px solid var(--emerald-border);
  font-size: 0.71rem;
  font-weight: 600;
  color: var(--emerald);
  white-space: nowrap;
}

.context-pill::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--brass);
}

.theme-switch {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.38rem;
  height: 28px;
  padding: 0 11px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--bg-surface-alt);
  color: var(--ink-2);
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 150ms, color 150ms, background-color 150ms, transform 80ms;
}

.theme-switch:hover {
  border-color: var(--emerald);
  color: var(--emerald);
  background: var(--emerald-soft);
}

.theme-switch:active {
  transform: translateY(0.5px);
}

.theme-switch svg {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
}

.auth-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.26rem, 1.9vw, 1.48rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
  color: var(--ink);
}

.auth-subtitle {
  margin: 0.35rem 0 1.05rem;
  font-size: 0.83rem;
  line-height: 1.48;
  color: var(--ink-3);
}

.auth-alert {
  display: none;
  margin-bottom: 0.9rem;
  padding: 0.7rem 0.88rem;
  border-radius: 9px;
  border: 1px solid var(--err-border);
  border-left: 4px solid var(--err);
  background: var(--err-bg);
  color: var(--err);
  font-size: 0.8rem;
  font-weight: 500;
  line-height: 1.42;
}

.auth-alert.visible {
  display: block;
}

.auth-alert.status-ok {
  border-color: var(--ok-border);
  border-left-color: var(--ok);
  background: var(--ok-bg);
  color: var(--ok);
}

/* Tous les champs prennent 100% de la largeur disponible */
.auth-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.85rem;
  margin: 0;
  width: 100%;
}

.auth-form[hidden],
.auth-field[hidden] {
  display: none;
}

.auth-form.shake {
  animation: gentleShake 340ms cubic-bezier(0.36, 0.07, 0.19, 0.97) 1;
}

@keyframes gentleShake {
  20%, 60% { transform: translateX(-4px); }
  40%, 80% { transform: translateX(4px); }
}

.auth-field {
  width: 100%;
  min-width: 0;
}

.field-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.34rem;
}

.auth-field > label,
.field-head label {
  display: block;
  margin-bottom: 0.34rem;
  font-size: 0.79rem;
  font-weight: 600;
  color: var(--ink-2);
}

.field-head label {
  margin-bottom: 0;
}

.input-wrap {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: var(--bg-surface-alt);
  transition: border-color 150ms, box-shadow 150ms, background-color 150ms;
}

.input-wrap:hover {
  border-color: var(--emerald-border);
}

.input-wrap:focus-within {
  border-color: var(--emerald);
  box-shadow: 0 0 0 3px var(--ring);
  background: var(--bg-surface);
}

.input-wrap.is-invalid {
  border-color: var(--err);
  box-shadow: 0 0 0 3px var(--err-bg);
}

.input-icon {
  position: absolute;
  left: 0.78rem;
  width: 15px;
  height: 15px;
  color: var(--ink-3);
  pointer-events: none;
  transition: color 150ms;
}

.input-wrap:focus-within .input-icon {
  color: var(--emerald);
}

.input-wrap input {
  width: 100%;
  height: 41px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--ink);
  font: 400 0.87rem/1.2 var(--font-sans);
  padding: 0 0.85rem 0 2.35rem;
}

.input-wrap.no-icon input {
  padding-left: 0.85rem;
}

.input-wrap input[readonly] {
  background: var(--bg-surface-alt);
  color: var(--ink-3);
  cursor: default;
}

.input-wrap input::placeholder {
  color: var(--ink-3);
  opacity: 0.72;
}

.input-wrap input:focus {
  outline: none;
}

.input-wrap.has-pw input {
  padding-right: 2.65rem;
  font-family: var(--font-mono);
  letter-spacing: 0.02em;
}

.input-wrap.has-pw input::placeholder {
  font-family: var(--font-sans);
  letter-spacing: 0;
  font-size: 0.83rem;
}

.pw-eye {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--ink-3);
  cursor: pointer;
  transition: background-color 140ms, color 140ms, border-color 140ms;
}

.pw-eye svg {
  width: 16px;
  height: 16px;
}

.pw-eye:hover {
  background: var(--bg-surface);
  border-color: var(--line);
  color: var(--emerald);
}

.auth-otp-input {
  width: 100%;
  height: 50px;
  border: 1.5px solid var(--line-strong);
  border-radius: 10px;
  background: var(--bg-surface-alt);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: 0.34em;
  text-align: center;
  font-variant-numeric: tabular-nums;
  transition: border-color 150ms, box-shadow 150ms, background-color 150ms;
}

.auth-otp-input:focus,
.auth-recovery-input:focus {
  outline: none;
  border-color: var(--emerald);
  box-shadow: 0 0 0 3px var(--ring);
  background: var(--bg-surface);
}

.auth-recovery-input {
  width: 100%;
  height: 44px;
  border: 1.5px solid var(--line-strong);
  border-radius: 9px;
  background: var(--bg-surface-alt);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 0.98rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-align: center;
  transition: border-color 150ms, box-shadow 150ms, background-color 150ms;
}

.auth-hint {
  margin: 0.38rem 0 0;
  font-size: 0.74rem;
  color: var(--ink-3);
  line-height: 1.44;
}

.auth-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.auth-remember {
  display: inline-flex;
  align-items: center;
  gap: 0.48rem;
  font-size: 0.79rem;
  color: var(--ink-2);
  cursor: pointer;
  user-select: none;
}

.auth-remember input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
}

.auth-check {
  width: 1.04rem;
  height: 1.04rem;
  flex-shrink: 0;
  display: inline-grid;
  place-items: center;
  border: 1.5px solid var(--line-strong);
  border-radius: 5px;
  background: var(--bg-surface-alt);
  transition: border-color 150ms, background-color 150ms;
}

.auth-check::after {
  content: '';
  width: 0.27rem;
  height: 0.5rem;
  margin-top: -0.08rem;
  border: solid #ffffff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg) scale(0);
  transition: transform 150ms var(--ease-out);
}

.auth-remember input:checked + .auth-check {
  border-color: var(--emerald);
  background: var(--emerald);
}

.auth-remember input:checked + .auth-check::after {
  transform: rotate(45deg) scale(1);
}

.auth-remember input:focus-visible + .auth-check {
  outline: 2px solid var(--brass);
  outline-offset: 2px;
}

.auth-link,
.auth-link-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--emerald);
  text-decoration: none;
  background: transparent;
  border: 0;
  padding: 4px 6px;
  margin: -4px -6px;
  border-radius: 6px;
  font-family: inherit;
  cursor: pointer;
  transition: background-color 140ms, color 140ms;
}

.auth-link:hover,
.auth-link-btn:hover {
  background: var(--emerald-soft);
  color: var(--emerald-hover);
  text-decoration: none;
}

.auth-pill-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 30px;
  padding: 0 11px;
  border-radius: 7px;
  border: 1px solid var(--line-strong);
  background: var(--bg-surface);
  color: var(--ink-2);
  font-family: inherit;
  font-size: 0.74rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: var(--shadow-xs);
  transition: border-color 140ms, color 140ms, background-color 140ms;
}

.auth-pill-btn:hover {
  border-color: var(--emerald);
  color: var(--emerald);
  background: var(--emerald-soft);
}

.auth-submit {
  width: 100%;
  height: 43px;
  margin-top: 0.15rem;
  border: 1px solid var(--btn-primary-border);
  border-radius: 9px;
  background: var(--btn-primary-bg);
  color: var(--btn-primary-ink);
  font: 600 0.88rem/1 var(--font-sans);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: var(--btn-primary-shadow);
  transition: background 150ms, transform 90ms, box-shadow 150ms;
}

.auth-submit:hover {
  background: var(--btn-primary-hover);
}

.auth-submit:active {
  transform: translateY(1px);
}

.auth-submit:disabled {
  opacity: 0.65;
  cursor: not-allowed;
  transform: none;
}

.auth-submit:focus-visible,
.pw-eye:focus-visible,
.theme-switch:focus-visible,
.auth-link:focus-visible,
.auth-link-btn:focus-visible,
.auth-pill-btn:focus-visible {
  outline: 2px solid var(--brass);
  outline-offset: 2px;
}

.auth-links {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-top: 0.25rem;
}

/* ---- JAUGE DE ROBUSTESSE COMPACTE (2x2) ---- */
.auth-strength {
  width: 100%;
  padding: 0.65rem 0.82rem;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--bg-surface-alt);
}

.auth-strength-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.74rem;
  margin-bottom: 0.38rem;
}

.auth-strength-label {
  color: var(--ink-3);
  font-weight: 600;
}

.auth-strength-value {
  font-weight: 700;
  color: var(--ink-2);
}

.auth-strength-meter {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
  margin-bottom: 0.45rem;
}

.auth-strength-bar {
  height: 4px;
  border-radius: 999px;
  background: var(--line);
  transition: background-color 180ms;
}

.auth-strength-bar.is-active.level-weak { background: var(--err); }
.auth-strength-bar.is-active.level-medium { background: var(--brass); }
.auth-strength-bar.is-active.level-good { background: var(--ok); }

.auth-strength-tips {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.24rem 0.65rem;
  font-size: 0.7rem;
  line-height: 1.35;
  color: var(--ink-3);
}

.auth-strength-tips li::before {
  content: '○ ';
  font-family: var(--font-mono);
  opacity: 0.6;
}

.auth-strength-tips li.met {
  color: var(--ok);
  font-weight: 600;
}

.auth-strength-tips li.met::before {
  content: '✓ ';
  opacity: 1;
}

/* ---- ENRÔLEMENT 2FA & SECOURS ---- */
.auth-qr-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.55rem;
  padding: 0.88rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg-surface-alt);
  text-align: center;
}

.auth-qr-box img {
  width: 148px;
  height: 148px;
  border-radius: 10px;
  background: #ffffff;
  padding: 6px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}

.secret-copy-row {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.auth-secret-pill {
  font-family: var(--font-mono);
  font-size: 0.73rem;
  letter-spacing: 0.06em;
  background: var(--bg-surface);
  border: 1px solid var(--line-strong);
  padding: 5px 10px;
  border-radius: 7px;
  color: var(--ink);
  word-break: break-all;
}

.auth-recovery-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 7px;
  padding: 0.78rem;
  border: 1px solid var(--ok-border);
  background: var(--ok-bg);
  border-radius: 9px;
}

.auth-recovery-code {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--ink);
  background: var(--bg-surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 8px;
  text-align: center;
}

.auth-legal-strip {
  font-size: 0.72rem;
  color: var(--ink-3);
  text-align: center;
  letter-spacing: 0.01em;
}

/* ---- RESPONSIVE ---- */
@media (max-width: 820px) {
  .auth-shell {
    grid-template-columns: 1fr;
    max-width: 420px;
  }
  .auth-brand-pane {
    display: none;
  }
  .mobile-brand {
    display: inline-flex;
  }
}

@media (max-width: 480px) {
  .auth-strength-tips {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  .auth-shell,
  .corridor-pulse,
  .auth-form.shake {
    animation: none;
    transition: none;
  }
}
