/* ============================================================
   BASE : police, remise à zéro, typographie, champs de formulaire
   et petites classes utilitaires partagées par toutes les vues.
============================================================ */

/* Inter est servie depuis notre propre site : pas de dépendance à un service externe, affichage plus rapide. */
@font-face {
  font-family: "Inter Variable";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url("../../assets/fonts/inter-latin-ext-wght-normal.woff2") format("woff2-variations"), url("../../assets/fonts/inter-latin-ext-wght-normal.woff2") format("woff2");
  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;
}
@font-face {
  font-family: "Inter Variable";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url("../../assets/fonts/inter-latin-wght-normal.woff2") format("woff2-variations"), url("../../assets/fonts/inter-latin-wght-normal.woff2") format("woff2");
  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;
}

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

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; height: 100%; }

body {
  margin: 0;
  min-height: 100%;
  color: var(--text);
  background: var(--bg);
  font-family: var(--font);
  font-size: var(--text-base);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

h1, h2, h3, h4, h5, p, figure, blockquote, dl, dd { margin: 0; }
h1, h2, h3, h4 { color: var(--text); font-weight: 600; line-height: 1.25; letter-spacing: -0.014em; }
ul, ol { margin: 0; padding: 0; list-style: none; }
img, svg, video { max-width: 100%; }
img { display: block; }
a { color: var(--primary-text); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, textarea, select { font: inherit; color: inherit; margin: 0; }
button { border: 0; padding: 0; background: transparent; cursor: pointer; -webkit-tap-highlight-color: transparent; text-align: inherit; }
button:disabled { cursor: not-allowed; }
summary { cursor: pointer; }
hr { border: 0; border-top: 1px solid var(--border); margin: 0; }
strong, b { font-weight: 600; }
[hidden] { display: none !important; }

::selection { background: var(--primary-soft-2); color: var(--text); }

/* Barres de défilement discrètes (ordinateur). */
@media (hover: hover) {
  * { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
  ::-webkit-scrollbar { width: 10px; height: 10px; }
  ::-webkit-scrollbar-track { background: transparent; }
  ::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 20px; border: 3px solid transparent; background-clip: content-box; }
  ::-webkit-scrollbar-thumb:hover { background: var(--text-4); border: 3px solid transparent; background-clip: content-box; }
}

/* Le contour de sélection n'apparaît qu'au clavier : visible et net, jamais gênant à la souris. */
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--brand-500); outline-offset: 2px; border-radius: var(--radius-sm); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}

/* ---------- Utilitaires ---------- */
.hidden { display: none !important; }
.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; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.tabular, .num { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.grow { flex: 1 1 auto; min-width: 0; }
.row { display: flex; align-items: center; gap: var(--space-3); }
.row-wrap { display: flex; align-items: center; gap: var(--space-2) var(--space-3); flex-wrap: wrap; }
.stack { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-4); }
.stack-sm { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-2); }
.stack-lg { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-6); }
.spread { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }
.only-mobile { display: none !important; }
@media (max-width: 767px) { .only-mobile { display: revert !important; } .only-desktop { display: none !important; } }

/* ---------- Icônes ---------- */
.icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; display: inline-block; vertical-align: middle; }
.icon-xs { width: 14px; height: 14px; }
.icon-sm { width: 16px; height: 16px; }
.icon-lg { width: 22px; height: 22px; }
.icon-xl { width: 28px; height: 28px; stroke-width: 1.6; }
.icon-spin { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Texte ---------- */
.muted { color: var(--text-3); font-size: var(--text-sm); line-height: 1.55; }
.subtle { color: var(--text-4); }
.eyebrow { margin: 0 0 var(--space-1); font-size: var(--text-2xs); font-weight: 600; letter-spacing: 0.07em; text-transform: uppercase; color: var(--text-3); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger { color: var(--danger); }
.text-primary { color: var(--primary-text); }
.field-hint, .field-note, .hint { font-size: var(--text-xs); font-weight: 400; color: var(--text-3); line-height: 1.5; }
kbd { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 5px; border: 1px solid var(--border); border-bottom-width: 2px; background: var(--surface-2); color: var(--text-3); font: 600 var(--text-2xs)/1 var(--font); }

/* ---------- Champs ---------- */
input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="hidden"]):not([type="range"]),
textarea, select {
  width: 100%;
  min-height: var(--control);
  padding: 8px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
  font-size: var(--text-base);
  line-height: 1.4;
  box-shadow: var(--shadow-xs);
  transition: var(--transition);
  appearance: none;
  -webkit-appearance: none;
}
textarea { min-height: 96px; resize: vertical; line-height: 1.55; }
select {
  padding-right: 36px; cursor: pointer; text-overflow: ellipsis;
  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='%236b778c' stroke-width='2.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 10px center; background-size: 16px;
}
input::placeholder, textarea::placeholder { color: var(--text-4); opacity: 1; }
input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):hover, textarea:hover, select:hover { border-color: var(--text-4); }
input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):focus, textarea:focus, select:focus { border-color: var(--brand-500); box-shadow: var(--ring); outline: none; }
input:disabled, textarea:disabled, select:disabled { background: var(--surface-2); color: var(--text-4); cursor: not-allowed; box-shadow: none; }
input[type="time"], input[type="date"] { font-variant-numeric: tabular-nums; }
input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; }
input[type="number"] { -moz-appearance: textfield; }
input[type="number"]::-webkit-outer-spin-button, input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
/* Le remplissage automatique du navigateur garde nos couleurs. */
input:-webkit-autofill { -webkit-text-fill-color: var(--text); box-shadow: 0 0 0 1000px var(--surface) inset, var(--shadow-xs); caret-color: var(--text); }

/* Cases à cocher et boutons radio dessinés : identiques sur tous les téléphones. */
input[type="checkbox"], input[type="radio"] {
  appearance: none; -webkit-appearance: none; flex: none; cursor: pointer;
  width: 18px; height: 18px; margin: 0; border: 1.5px solid var(--border-strong); background: var(--surface);
  display: inline-grid; place-content: center; transition: var(--transition); vertical-align: middle;
}
input[type="checkbox"] { border-radius: 5px; }
input[type="radio"] { border-radius: 50%; }
input[type="checkbox"]::before { content: ""; width: 10px; height: 10px; transform: scale(0); transition: transform var(--fast) var(--ease); background: #fff; clip-path: polygon(14% 52%, 0 66%, 38% 100%, 100% 22%, 86% 10%, 37% 72%); }
input[type="radio"]::before { content: ""; width: 8px; height: 8px; border-radius: 50%; transform: scale(0); transition: transform var(--fast) var(--ease); background: #fff; }
input[type="checkbox"]:hover, input[type="radio"]:hover { border-color: var(--brand-500); }
input[type="checkbox"]:checked, input[type="radio"]:checked { background: var(--primary); border-color: var(--primary); }
input[type="checkbox"]:checked::before, input[type="radio"]:checked::before { transform: scale(1); }
input[type="checkbox"]:disabled, input[type="radio"]:disabled { opacity: 0.5; cursor: not-allowed; }
input[type="checkbox"]:focus-visible, input[type="radio"]:focus-visible { outline: 2px solid var(--brand-500); outline-offset: 2px; }

label { cursor: pointer; }

/* Champ = libellé + contrôle + aide. */
.field { display: grid; gap: 6px; min-width: 0; align-content: start; }
.field > label, .field > .field-label, .field-label { font-size: var(--text-sm); font-weight: 600; color: var(--text); cursor: default; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.field-label .optional, .optional { font-weight: 400; color: var(--text-3); font-size: var(--text-xs); }
.field-row { display: grid; gap: var(--space-4); grid-template-columns: repeat(2, minmax(0, 1fr)); }
.field-row-3 { display: grid; gap: var(--space-4); grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field-error { color: var(--danger); font-size: var(--text-xs); font-weight: 500; }
.form-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-5); }
.form-actions { display: flex; align-items: center; justify-content: flex-end; gap: var(--space-2); flex-wrap: wrap; }
/* Formulaires historiques : un <label> qui contient son texte puis son champ. */
label.field, .label-field { display: grid; gap: 6px; font-size: var(--text-sm); font-weight: 600; color: var(--text); cursor: default; }

/* Champ avec icône ou suffixe (ex. « FCFA », « % »). */
.input-group { position: relative; display: flex; align-items: center; }
.input-group > .icon { position: absolute; left: 11px; color: var(--text-4); pointer-events: none; width: 16px; height: 16px; }
.input-group > .icon + input { padding-left: 34px !important; }
.input-suffix { position: relative; display: flex; align-items: center; }
.input-suffix > span { position: absolute; right: 12px; color: var(--text-3); font-size: var(--text-sm); font-weight: 500; pointer-events: none; }
.input-suffix > input { padding-right: 56px !important; }

/* Indicatif pays + numéro local côte à côte. */
.phone-field-row { display: flex; gap: var(--space-2); }
.phone-field-row select { flex: 0 1 210px; min-width: 132px; }
.phone-field-row input { flex: 1 1 140px; min-width: 0; }

/* Sélecteur de fichier : le bouton natif (souvent en anglais) est remplacé par un bouton stylé. */
.file-control { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; position: relative; }
.file-control input[type="file"] { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; pointer-events: none; }
.file-control-name { font-size: var(--text-sm); color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.file-control:has(input:focus-visible) .btn, .file-control:has(input:focus-visible) .ghost-button { outline: 2px solid var(--brand-500); outline-offset: 2px; }

.checkbox-row { display: flex; align-items: flex-start; gap: 10px; font-weight: 500; font-size: var(--text-base); color: var(--text); }
.checkbox-row input { margin-top: 2px; }

/* Sur téléphone : champs plus hauts et texte en 16 px (iOS ne zoome alors pas sur le champ). */
@media (max-width: 767px) {
  body { font-size: var(--text-md); }
  input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="hidden"]):not([type="range"]), textarea, select { font-size: 1rem; min-height: var(--control-lg); }
  .field-row, .field-row-3 { grid-template-columns: minmax(0, 1fr); }
  input[type="checkbox"], input[type="radio"] { width: 20px; height: 20px; }
}
