/* ==========================================================================
   Olama / Olama — design system (tokens, base, composants partagés)
   Toutes les couleurs sont centralisées ici.
   ========================================================================== */

@font-face {
  font-family: "Bricolage Grotesque";
  src: url("../fonts/bricolage-grotesque-latin-standard-normal.woff2") format("woff2");
  font-weight: 200 800;
  font-stretch: 75% 100%;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Bricolage Grotesque";
  src: url("../fonts/bricolage-grotesque-latin-ext-standard-normal.woff2") format("woff2");
  font-weight: 200 800;
  font-stretch: 75% 100%;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  /* Palette */
  --night-950: #040915;      /* bleu nuit très profond */
  --night-900: #070f22;
  --night-850: #0b1530;
  --night-800: #101c3b;
  --night-700: #1a2a52;
  --ink-900: #0d1220;        /* noir bleuté (texte) */
  --ink-700: #2b3346;
  --ink-500: #5a6378;
  --ink-400: #7c8497;
  --paper-50: #f5f5f2;       /* blanc cassé */
  --paper-0: #ffffff;
  --gray-100: #eeeef0;
  --gray-200: #e2e3e7;
  --gray-300: #cfd2d9;
  --electric-300: #8fb8ff;
  --electric-400: #5c97ff;
  --electric-500: #2f6dff;   /* accent bleu électrique */
  --electric-600: #1f55e0;
  --electric-050: #edf3ff;
  --signal-cyan: #5fd4ff;    /* réservé aux dégradés technologiques */

  /* Couleurs sémantiques (sobres) */
  --success-600: #157a52;
  --success-050: #e8f6ef;
  --warning-600: #a1600a;
  --warning-050: #fdf3e2;
  --danger-600: #b42335;
  --danger-050: #fcebed;
  --info-600: var(--electric-600);
  --info-050: var(--electric-050);

  /* Rôles */
  --bg: var(--paper-50);
  --surface: var(--paper-0);
  --text: var(--ink-900);
  --text-muted: var(--ink-500);
  --border: var(--gray-200);
  --border-strong: var(--gray-300);
  --accent: var(--electric-500);
  --accent-hover: var(--electric-600);
  --focus: 0 0 0 3px rgba(47, 109, 255, .35);

  --on-dark: #eef1f8;
  --on-dark-muted: #9aa5c0;
  --border-dark: rgba(255, 255, 255, .09);
  --surface-dark: rgba(255, 255, 255, .035);

  --gradient-tech: linear-gradient(120deg, var(--electric-400) 0%, var(--signal-cyan) 100%);
  --gradient-blue: linear-gradient(165deg, #6aa9ff 0%, #2f6dff 52%, #1f4fd6 100%);

  /* Typographie */
  --font-sans: "Bricolage Grotesque", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Bricolage Grotesque", system-ui, sans-serif;
  --font-mono: ui-monospace, "SFMono-Regular", "Cascadia Mono", Consolas, monospace;
  --fs-xs: .8125rem;
  --fs-sm: .9375rem;
  --fs-md: 1.0625rem;
  --fs-lg: 1.1875rem;
  --fs-h4: 1.25rem;
  --fs-h3: clamp(1.375rem, 1.1rem + .9vw, 1.625rem);
  --fs-h2: clamp(2rem, 1.3rem + 2.6vw, 3.25rem);
  --fs-h1: clamp(2.6rem, 1.5rem + 4.6vw, 5rem);

  /* Espacements & formes */
  --space-section: clamp(4.5rem, 3rem + 6vw, 8rem);
  --container: 1200px;
  --gutter: clamp(1.25rem, .8rem + 2vw, 2rem);
  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --shadow-sm: 0 1px 2px rgba(13, 18, 32, .06);
  --shadow: 0 1px 2px rgba(13, 18, 32, .04), 0 8px 24px -12px rgba(13, 18, 32, .14);
  --shadow-lg: 0 24px 48px -24px rgba(4, 9, 21, .35);
  --ease: cubic-bezier(.2, .7, .2, 1);
}

/* ---- Base ------------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--fs-md);
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img, svg { display: block; max-width: 100%; }
img { height: auto; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }
h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.08;
  letter-spacing: -.03em;
  margin: 0 0 .6em;
  color: inherit;
}
h1 { font-size: var(--fs-h1); letter-spacing: -.04em; }
h2 { font-size: var(--fs-h2); }
h3 { font-size: var(--fs-h3); line-height: 1.25; }
h4 { font-size: var(--fs-h4); line-height: 1.3; }
p { margin: 0 0 1em; }
.h2 { font-size: var(--fs-h2); } .h3 { font-size: var(--fs-h3); } .h4 { font-size: var(--fs-h4); }
ul, ol { margin: 0; padding: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--radius-sm); }
::selection { background: var(--electric-500); color: #fff; }
hr { border: 0; border-top: 1px solid var(--border); margin: 2rem 0; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: 1rem; top: -4rem; z-index: 1000; padding: .6rem 1rem; background: var(--paper-0); color: var(--ink-900); border-radius: var(--radius-sm); }
.skip-link:focus { top: 1rem; }
[hidden] { display: none !important; }

.icon { width: 1.25em; height: 1.25em; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.icon-sm { width: 1rem; height: 1rem; }
.icon-lg { width: 1.5rem; height: 1.5rem; }

.container { width: 100%; max-width: var(--container); margin-inline: auto; padding-inline: var(--gutter); }
.container-narrow { max-width: 820px; }
.muted { color: var(--text-muted); }
.small { font-size: var(--fs-sm); }
.xsmall { font-size: var(--fs-xs); }
.nowrap { white-space: nowrap; }
.text-center { text-align: center; }
.mt-0 { margin-top: 0; } .mb-0 { margin-bottom: 0; }
.mt-1 { margin-top: .5rem; } .mt-2 { margin-top: 1rem; } .mt-3 { margin-top: 1.5rem; } .mt-4 { margin-top: 2rem; }
.mb-1 { margin-bottom: .5rem; } .mb-2 { margin-bottom: 1rem; } .mb-3 { margin-bottom: 1.5rem; } .mb-4 { margin-bottom: 2rem; }
.stack > * + * { margin-top: 1rem; }
.cluster { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; }
.split { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.grid-2 { display: grid; gap: 1.5rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); }
.grid-3 { display: grid; gap: 1.5rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); }

/* ---- Boutons ---------------------------------------------------------- */
.btn {
  --btn-bg: var(--accent);
  --btn-fg: #fff;
  --btn-border: transparent;
  display: inline-flex; align-items: center; justify-content: center; gap: .55rem;
  min-height: 44px; padding: .65rem 1.2rem;
  font-size: var(--fs-sm); font-weight: 600; line-height: 1.2; letter-spacing: -.005em;
  color: var(--btn-fg); background: var(--btn-bg);
  border: 1px solid var(--btn-border); border-radius: 999px;
  cursor: pointer; text-align: center; white-space: nowrap;
  transition: background-color .18s var(--ease), border-color .18s var(--ease), color .18s var(--ease), transform .18s var(--ease);
}
.btn:hover { --btn-bg: var(--accent-hover); color: var(--btn-fg); }
.btn:active { transform: translateY(1px); }
.btn .icon { width: 1.05rem; height: 1.05rem; transition: transform .2s var(--ease); }
.btn:hover .icon-arrow { transform: translateX(3px); }
.btn-lg { min-height: 52px; padding: .85rem 1.5rem; font-size: var(--fs-md); }
.btn-sm { min-height: 36px; padding: .45rem .85rem; font-size: var(--fs-xs); }
.btn-block { width: 100%; }
.btn-secondary { --btn-bg: var(--surface); --btn-fg: var(--ink-900); --btn-border: var(--border-strong); }
.btn-secondary:hover { --btn-bg: var(--gray-100); --btn-fg: var(--ink-900); }
.btn-ghost { --btn-bg: transparent; --btn-fg: var(--ink-700); }
.btn-ghost:hover { --btn-bg: var(--gray-100); --btn-fg: var(--ink-900); }
.btn-danger { --btn-bg: var(--danger-600); }
.btn-danger:hover { --btn-bg: #951b2b; }
.btn-success { --btn-bg: var(--success-600); }
.btn-success:hover { --btn-bg: #0f6242; }
.btn-light { --btn-bg: var(--paper-0); --btn-fg: var(--night-950); }
.btn-light:hover { --btn-bg: var(--electric-050); --btn-fg: var(--night-950); }
.btn-outline-light { --btn-bg: transparent; --btn-fg: var(--on-dark); --btn-border: rgba(255,255,255,.22); }
.btn-outline-light:hover { --btn-bg: rgba(255,255,255,.07); --btn-fg: #fff; }
.btn[disabled], .btn.is-loading { opacity: .6; pointer-events: none; }
.btn.is-loading::after {
  content: ""; width: 1rem; height: 1rem; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.link-arrow { display: inline-flex; align-items: center; gap: .4rem; font-weight: 600; font-size: var(--fs-sm); }
.link-arrow .icon { width: 1rem; height: 1rem; transition: transform .2s var(--ease); }
.link-arrow:hover .icon { transform: translateX(3px); }

/* ---- Formulaires ------------------------------------------------------ */
.field { display: flex; flex-direction: column; gap: .4rem; }
.field + .field, .form-row + .field, .field + .form-row { margin-top: 1.1rem; }
.form-row { display: grid; gap: 1.1rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); }
.form-row + .form-row { margin-top: 1.1rem; }
.form-row > .field, .form-row > div > .field:first-child { margin-top: 0; }
.label { font-size: var(--fs-sm); font-weight: 600; color: var(--ink-700); }
.label .optional { font-weight: 400; color: var(--text-muted); }
.label .req { color: var(--danger-600); margin-left: .15rem; }
.hint { font-size: var(--fs-xs); color: var(--text-muted); margin: 0; }
.input, .select, .textarea {
  width: 100%; min-height: 46px; padding: .65rem .85rem;
  font-size: var(--fs-sm); line-height: 1.4;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  transition: border-color .15s, box-shadow .15s;
}
.textarea { min-height: 120px; resize: vertical; }
.select {
  appearance: none; padding-right: 2.4rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%235a6378' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .8rem center;
}
.input:hover, .select:hover, .textarea:hover { border-color: var(--ink-400); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus); }
.input::placeholder, .textarea::placeholder { color: var(--ink-400); }
.is-invalid .input, .is-invalid .select, .is-invalid .textarea, .input.is-invalid { border-color: var(--danger-600); }
.field-error { font-size: var(--fs-xs); color: var(--danger-600); margin: 0; display: flex; gap: .35rem; align-items: center; }
.input-group { position: relative; }
.input-group .input { padding-right: 3rem; }
.input-group .input-action {
  position: absolute; right: .35rem; top: 50%; transform: translateY(-50%);
  width: 36px; height: 36px; display: grid; place-items: center;
  border: 0; background: none; color: var(--ink-500); cursor: pointer; border-radius: var(--radius-sm);
}
.input-group .input-action:hover { color: var(--ink-900); background: var(--gray-100); }
.check { display: flex; gap: .7rem; align-items: flex-start; font-size: var(--fs-sm); cursor: pointer; line-height: 1.45; }
.check input { width: 18px; height: 18px; margin: .1rem 0 0; accent-color: var(--accent); flex-shrink: 0; }
.choice-grid { display: grid; gap: .6rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 210px), 1fr)); }
.choice {
  position: relative; display: flex; align-items: center; gap: .65rem;
  padding: .75rem .9rem; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); cursor: pointer; font-size: var(--fs-sm); font-weight: 500;
  transition: border-color .15s, background-color .15s;
}
.choice:hover { border-color: var(--ink-400); }
.choice input { accent-color: var(--accent); width: 17px; height: 17px; margin: 0; }
.choice:has(input:checked) { border-color: var(--accent); background: var(--electric-050); }
.choice:has(input:focus-visible) { box-shadow: var(--focus); }
.hp-field { position: absolute !important; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.password-meter { height: 4px; border-radius: 2px; background: var(--gray-200); overflow: hidden; }
.password-meter span { display: block; height: 100%; width: 0; background: var(--danger-600); transition: width .25s, background-color .25s; }

/* ---- Alertes & badges ------------------------------------------------- */
.alert {
  display: flex; gap: .75rem; align-items: flex-start;
  padding: .9rem 1rem; border-radius: var(--radius-sm);
  font-size: var(--fs-sm); border: 1px solid transparent; line-height: 1.5;
}
.alert .icon { margin-top: .1rem; }
.alert p:last-child, .alert ul:last-child { margin-bottom: 0; }
.alert ul { padding-left: 1.1rem; }
.alert-success { background: var(--success-050); color: var(--success-600); border-color: rgba(21,122,82,.18); }
.alert-error { background: var(--danger-050); color: var(--danger-600); border-color: rgba(180,35,53,.18); }
.alert-warning { background: var(--warning-050); color: var(--warning-600); border-color: rgba(161,96,10,.2); }
.alert-info { background: var(--info-050); color: var(--info-600); border-color: rgba(47,109,255,.18); }
.alert-close { margin-left: auto; background: none; border: 0; color: inherit; cursor: pointer; padding: 0; opacity: .7; }
.alert-close:hover { opacity: 1; }

.badge {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .2rem .6rem; border-radius: 999px;
  font-size: var(--fs-xs); font-weight: 600; line-height: 1.5; white-space: nowrap;
  background: var(--gray-100); color: var(--ink-700);
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.badge-plain::before { display: none; }
.badge-success { background: var(--success-050); color: var(--success-600); }
.badge-warning { background: var(--warning-050); color: var(--warning-600); }
.badge-danger { background: var(--danger-050); color: var(--danger-600); }
.badge-info, .badge-progress { background: var(--info-050); color: var(--info-600); }
.badge-muted { background: var(--gray-100); color: var(--ink-500); }
.badge-accent { background: var(--electric-500); color: #fff; }
.badge-accent::before { display: none; }

/* ---- Cartes ----------------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: clamp(1.25rem, 1rem + 1vw, 1.75rem);
}
.card-header { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.card-header h2, .card-header h3 { margin: 0; font-size: var(--fs-h4); }
.card-flush { padding: 0; overflow: hidden; }
.card-flush .card-header { padding: 1.25rem 1.5rem 0; }

/* ---- Barres de progression (largeur appliquée par JS, CSP stricte) ---- */
.progress { height: 8px; background: var(--gray-200); border-radius: 999px; overflow: hidden; }
.progress-bar { height: 100%; width: 0; background: var(--gradient-tech); border-radius: inherit; transition: width .6s var(--ease); }

/* ---- Modale de confirmation ------------------------------------------ */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 900; display: grid; place-items: center; padding: 1rem;
  background: rgba(4, 9, 21, .55); backdrop-filter: blur(2px);
  animation: fade-in .15s ease;
}
.modal {
  width: min(100%, 460px); background: var(--surface); border-radius: var(--radius);
  padding: 1.5rem; box-shadow: var(--shadow-lg);
}
.modal h2 { font-size: var(--fs-h4); margin-bottom: .5rem; }
.modal-actions { display: flex; justify-content: flex-end; gap: .6rem; margin-top: 1.5rem; flex-wrap: wrap; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

/* ---- Toasts ----------------------------------------------------------- */
.toast-region { position: fixed; right: 1rem; bottom: 1rem; z-index: 950; display: grid; gap: .5rem; width: min(380px, calc(100% - 2rem)); }
.toast-region .alert { box-shadow: var(--shadow); background-color: var(--surface); animation: toast-in .25s var(--ease); }
@keyframes toast-in { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---- Pages d'erreur / installation ----------------------------------- */
.plain-page { min-height: 100vh; display: grid; place-items: center; padding: 2rem 1rem; background: var(--night-950); color: var(--on-dark); }
.plain-card { width: min(100%, 640px); background: var(--surface); color: var(--text); border-radius: var(--radius-lg); padding: clamp(1.5rem, 1rem + 2vw, 2.5rem); box-shadow: var(--shadow-lg); }
.plain-card h1 { font-size: var(--fs-h2); }
.error-code { font-family: var(--font-display); font-weight: 800; font-size: 4.5rem; line-height: 1; letter-spacing: -.04em; background: var(--gradient-tech); -webkit-background-clip: text; background-clip: text; color: transparent; margin-bottom: 1rem; }
.check-list { list-style: none; display: grid; gap: .5rem; }
.check-list li { display: flex; gap: .6rem; align-items: flex-start; font-size: var(--fs-sm); }
.check-list .ok { color: var(--success-600); }
.check-list .ko { color: var(--danger-600); }
.check-list .warn { color: var(--warning-600); }
.secret-box { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 1.05rem; background: var(--night-900); color: #fff; padding: .9rem 1rem; border-radius: var(--radius-sm); word-break: break-all; }

/* ---- Logo ------------------------------------------------------------- */
.logo { display: inline-flex; align-items: center; gap: .6rem; color: inherit; font-family: var(--font-display); font-weight: 800; letter-spacing: -.02em; }
.logo:hover { color: inherit; }
.logo { flex-shrink: 0; }
.logo-mark { width: 28px; height: 28px; flex-shrink: 0; }
.logo-word { font-size: 1.45rem; font-weight: 700; letter-spacing: -.045em; line-height: 1; }
.logo-sub { font-family: var(--font-mono); font-weight: 500; font-size: .66rem; letter-spacing: .12em; text-transform: uppercase; color: var(--text-muted); padding-left: .65rem; margin-left: .1rem; border-left: 1px solid currentColor; border-left-color: var(--border-strong); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}
.logo-dot { fill: var(--electric-500); }

/* ---- Logo Olama (images) : déclinaison claire / sombre selon le fond ---- */
.logo-img { display: block; height: 30px; width: auto; }
.logo-img-ondark { display: none; }
