/* =========================================================================
   WESTAFE — Design system partagé (extrait des maquettes du dossier SIGI/)
   Thème sombre + accent or. Chargé sur toutes les pages.
   ========================================================================= */

:root {
  --gold: #C9A84C;
  --gold-light: #E8C96A;
  --gold-dim: #8B6F2E;
  --bg-deep: #0A0C0F;
  --bg-card: #111318;
  --bg-surface: #181C23;
  --border-subtle: #252A34;
  --text-primary: #F0EDE8;
  --text-muted: #8A8F9B;
  --danger: #DC2626;
  --success: #4ADE80;

  /* Tokens dérivés (adaptés par thème) */
  --card-shadow:
    0 0 0 1px rgba(201,168,76,0.08),
    0 32px 64px rgba(0,0,0,0.6),
    0 0 120px rgba(201,168,76,0.05);
  --input-placeholder: #40454F;
  --left-panel-bg: linear-gradient(160deg, #0E1117 0%, #0A0C0F 100%);
  --btn-gold-ink: #0A0C0F;
  --table-row-border: rgba(37,42,52,0.6);
}

/* =========================================================================
   Thème CLAIR — activé par la classe `theme-light` sur <html>.
   Redéfinit uniquement les tokens : tout le reste du design system pointe
   déjà vers ces variables, donc l'ensemble bascule automatiquement.
   ========================================================================= */
html.theme-light {
  --gold: #B0862B;
  --gold-light: #C9A84C;
  --gold-dim: #A8782A;
  --bg-deep: #F4F1EA;
  --bg-card: #FFFFFF;
  --bg-surface: #EFEBE1;
  --border-subtle: #E2DCCE;
  --text-primary: #1A1D23;
  --text-muted: #6B7280;
  --danger: #DC2626;
  --success: #16A34A;

  --card-shadow:
    0 0 0 1px rgba(176,134,43,0.08),
    0 18px 40px rgba(26,29,35,0.10),
    0 2px 8px rgba(26,29,35,0.06);
  --input-placeholder: #9CA3AF;
  --left-panel-bg: linear-gradient(160deg, #FBF9F4 0%, #F1ECE1 100%);
  --btn-gold-ink: #FFFFFF;
  --table-row-border: rgba(226,220,206,0.9);
}

* { box-sizing: border-box; }

body {
  font-family: 'DM Sans', sans-serif;
  background-color: var(--bg-deep);
  color: var(--text-primary);
  min-height: 100vh;
  margin: 0;
}

h1, h2, h3, .display { font-family: 'Playfair Display', serif; }

/* --- Fonds décoratifs ---------------------------------------------------- */
.bg-pattern {
  position: fixed; inset: 0; z-index: 0;
  background:
    radial-gradient(ellipse 80% 60% at 70% 40%, rgba(201,168,76,0.06) 0%, transparent 60%),
    radial-gradient(ellipse 60% 80% at 20% 70%, rgba(201,168,76,0.04) 0%, transparent 50%),
    var(--bg-deep);
}
.grid-overlay {
  position: fixed; inset: 0; z-index: 0;
  background-image:
    linear-gradient(rgba(201,168,76,0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(201,168,76,0.04) 1px, transparent 1px);
  background-size: 60px 60px;
}
.noise {
  position: fixed; inset: 0; z-index: 0; opacity: 0.025;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
}

/* --- Ligne dorée & logo -------------------------------------------------- */
.gold-line {
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  border-radius: 999px;
}
.logo-mark {
  width: 48px; height: 48px;
  border: 1.5px solid var(--gold-dim);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(201,168,76,0.08);
}

/* --- Carte --------------------------------------------------------------- */
.sigi-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  box-shadow: var(--card-shadow);
  position: relative; z-index: 10;
  animation: fadeUp 0.6s cubic-bezier(0.16,1,0.3,1) both;
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(24px); }
  to { opacity: 1; transform: translateY(0); }
}

/* --- Champs -------------------------------------------------------------- */
.field-label {
  font-size: 0.72rem; font-weight: 600; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--text-muted); margin-bottom: 6px;
  display: block;
}
.sigi-input {
  width: 100%;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 12px 16px;
  color: var(--text-primary);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.925rem;
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
}
.sigi-input:focus {
  border-color: var(--gold-dim);
  box-shadow: 0 0 0 3px rgba(201,168,76,0.12);
}
.sigi-input::placeholder { color: var(--input-placeholder); }
.sigi-input:disabled { opacity: 0.6; cursor: not-allowed; }

.input-wrapper { position: relative; }
.input-wrapper .toggle-pass {
  position: absolute; right: 14px; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer; color: var(--text-muted);
  padding: 0; display: flex; align-items: center;
}
.input-wrapper .toggle-pass:hover { color: var(--gold); }

/* --- Bouton doré --------------------------------------------------------- */
.btn-gold {
  width: 100%; padding: 13px;
  background: linear-gradient(135deg, var(--gold) 0%, #A8782A 100%);
  border: none; border-radius: 10px;
  color: var(--btn-gold-ink); font-family: 'DM Sans', sans-serif;
  font-weight: 600; font-size: 0.925rem; letter-spacing: 0.04em;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.15s, box-shadow 0.2s;
  box-shadow: 0 4px 20px rgba(201,168,76,0.25);
  position: relative; overflow: hidden;
}
.btn-gold:hover {
  opacity: 0.92; transform: translateY(-1px);
  box-shadow: 0 8px 28px rgba(201,168,76,0.35);
}
.btn-gold:active { transform: translateY(0); }
.btn-gold:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

/* --- Alertes ------------------------------------------------------------- */
.alert-error-custom {
  background: rgba(220,38,38,0.1);
  border: 1px solid rgba(220,38,38,0.25);
  border-radius: 10px; padding: 12px 16px;
  font-size: 0.85rem; color: #FCA5A5;
  display: flex; align-items: center; gap: 10px;
  animation: fadeUp 0.3s ease both;
}
.alert-success-custom {
  background: rgba(74,222,128,0.08);
  border: 1px solid rgba(74,222,128,0.25);
  border-radius: 10px; padding: 12px 16px;
  font-size: 0.85rem; color: #86EFAC;
  display: flex; align-items: center; gap: 10px;
}
/* Ni échec ni succès : l'opération a abouti mais réclame un arbitrage humain. */
.alert-warning-custom {
  background: rgba(245,158,11,0.10);
  border: 1px solid rgba(245,158,11,0.30);
  border-radius: 10px; padding: 12px 16px;
  font-size: 0.85rem; color: #FCD34D;
  display: flex; align-items: flex-start; gap: 10px;
}

/* --- Panneau de marque (colonne gauche des pages d'auth) ----------------- */
.left-panel {
  background: var(--left-panel-bg);
  border-right: 1px solid var(--border-subtle);
  position: relative; overflow: hidden;
}
.left-panel::before {
  content: ''; position: absolute; bottom: -100px; left: -100px;
  width: 400px; height: 400px; border-radius: 50%;
  background: radial-gradient(circle, rgba(201,168,76,0.08) 0%, transparent 70%);
  pointer-events: none;
}

/* --- Checkbox ------------------------------------------------------------ */
.sigi-checkbox {
  width: 16px; height: 16px;
  border: 1.5px solid var(--border-subtle);
  border-radius: 4px; background: var(--bg-surface);
  appearance: none; cursor: pointer;
  transition: border-color 0.2s, background 0.2s; flex-shrink: 0;
}
.sigi-checkbox:checked { background: var(--gold); border-color: var(--gold); }
.sigi-checkbox:checked::after {
  content: '✓'; display: block; text-align: center;
  font-size: 10px; color: var(--btn-gold-ink); font-weight: 700; line-height: 14px;
}

/* --- Bouton bascule de thème (clair / sombre) ---------------------------- */
.theme-toggle {
  width: 34px; height: 34px; border-radius: 9px;
  border: 1px solid var(--border-subtle); background: var(--bg-surface);
  color: var(--text-muted); cursor: pointer; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}
.theme-toggle:hover { color: var(--gold); border-color: var(--gold-dim); }
.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }
html.theme-light .theme-toggle .icon-sun { display: block; }
html.theme-light .theme-toggle .icon-moon { display: none; }

/* --- Indicateur HTMX en cours de requête --------------------------------- */
.htmx-indicator { opacity: 0; transition: opacity 0.2s; }
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator { opacity: 1; }

@media (max-width: 768px) { .left-panel { display: none; } }
