/* ==========================================================================
   Processa / Pipelina — Import CSV — Feuille de style
   Design sobre professionnel. Palette alignée sur la page produit Pipelina.
   ========================================================================== */

:root {
  /* Couleurs de marque (reprises de la page produit) */
  --bleu-nuit: #0f2540;
  --bleu-nuit-2: #16335a;
  --bleu: #1d4e8f;
  --bleu-clair: #3b74c4;
  --accent: #1f9d8f;
  --accent-fonce: #157a6e;
  --ardoise: #5b6b80;

  /* Neutres */
  --texte: #1b2735;
  --texte-doux: #51617a;
  --gris-clair: #f4f6f9;
  --gris-tres-clair: #fafbfc;
  --gris-bord: #e2e8f0;
  --gris-bord-fort: #cbd5e1;
  --blanc: #ffffff;

  /* États sémantiques (contrastes AA sur fond clair) */
  --succes: #157a6e;
  --succes-bg: #e7f5f2;
  --succes-bord: #b9e2da;
  --alerte: #a15c00;
  --alerte-bg: #fdf4e3;
  --alerte-bord: #f0d8a8;
  --erreur: #b3261e;
  --erreur-bg: #fdeceb;
  --erreur-bord: #f3c4c0;
  --info-bg: #eaf1fa;
  --info-bord: #cadcf2;

  --ombre: 0 1px 2px rgba(15, 37, 64, .04), 0 8px 24px rgba(15, 37, 64, .06);
  --ombre-forte: 0 12px 40px rgba(15, 37, 64, .12);
  --radius: 14px;
  --radius-s: 9px;
  --focus: 0 0 0 3px rgba(59, 116, 196, .45);

  --police: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --police-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

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

body {
  font-family: var(--police);
  color: var(--texte);
  line-height: 1.6;
  background: var(--gris-clair);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--bleu); text-decoration: none; }
a:hover { text-decoration: underline; }
a:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 4px; }

svg { display: block; }
.hidden { display: none !important; }

/* ---- En-tête ---------------------------------------------------------- */
.site-header {
  background: var(--blanc);
  border-bottom: 1px solid var(--gris-bord);
}
.site-header .wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 24px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  font-weight: 700;
  color: var(--bleu-nuit);
  font-size: 1.05rem;
  letter-spacing: -.01em;
}
.brand .mark { color: var(--accent); }
.brand .sub {
  font-weight: 500;
  color: var(--texte-doux);
  font-size: .82rem;
  border-left: 1px solid var(--gris-bord-fort);
  padding-left: 12px;
  margin-left: 2px;
}

/* ---- Trame de page ---------------------------------------------------- */
.wrap { max-width: 860px; margin: 0 auto; width: 100%; }
main { flex: 1 0 auto; padding: 40px 24px 56px; }

.page-intro { text-align: center; margin-bottom: 28px; }
.page-intro h1 {
  color: var(--bleu-nuit);
  font-size: 1.7rem;
  font-weight: 700;
  letter-spacing: -.02em;
  margin-bottom: 8px;
}
.page-intro p {
  color: var(--texte-doux);
  font-size: 1.02rem;
  max-width: 560px;
  margin: 0 auto;
}

.card {
  background: var(--blanc);
  border: 1px solid var(--gris-bord);
  border-radius: var(--radius);
  box-shadow: var(--ombre);
  padding: 28px;
}

/* ---- Zone de dépôt (État 1) ------------------------------------------ */
.dropzone {
  position: relative;
  border: 2px dashed var(--gris-bord-fort);
  border-radius: var(--radius);
  background: var(--gris-tres-clair);
  padding: 48px 28px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease, box-shadow .15s ease;
}
.dropzone:hover { border-color: var(--bleu-clair); background: #f7faff; }
.dropzone:focus-visible { outline: none; box-shadow: var(--focus); border-color: var(--bleu-clair); }
.dropzone.is-dragover {
  border-color: var(--accent);
  background: var(--succes-bg);
  box-shadow: 0 0 0 4px rgba(31, 157, 143, .12);
}
.dropzone.is-dragover .dz-icon { color: var(--accent-fonce); transform: translateY(-2px); }

.dz-icon {
  color: var(--bleu-clair);
  margin: 0 auto 14px;
  width: 46px; height: 46px;
  transition: transform .15s ease, color .15s ease;
}
.dz-title { font-size: 1.15rem; font-weight: 600; color: var(--bleu-nuit); margin-bottom: 4px; }
.dz-sub { color: var(--texte-doux); font-size: .95rem; }
.dz-sub .link-like { color: var(--bleu); font-weight: 600; text-decoration: underline; }
.dz-hint {
  margin-top: 18px;
  font-size: .82rem;
  color: var(--ardoise);
  display: flex;
  gap: 6px 16px;
  justify-content: center;
  flex-wrap: wrap;
}
.dz-hint span { display: inline-flex; align-items: center; gap: 5px; }

/* ---- Boutons ---------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: inherit;
  font-size: .96rem;
  font-weight: 600;
  line-height: 1;
  padding: 12px 20px;
  border-radius: var(--radius-s);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
  white-space: nowrap;
}
.btn:focus-visible { outline: none; box-shadow: var(--focus); }
.btn svg { width: 18px; height: 18px; }
.btn-primary { background: var(--bleu); color: #fff; }
.btn-primary:hover { background: var(--bleu-nuit-2); }
.btn-primary:disabled { background: var(--gris-bord-fort); color: #fff; cursor: not-allowed; }
.btn-secondary { background: var(--blanc); color: var(--texte); border-color: var(--gris-bord-fort); }
.btn-secondary:hover { background: var(--gris-clair); border-color: var(--ardoise); }
.btn-block { width: 100%; }
.btn-row { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 22px; }
.btn-row .btn-primary { flex: 1 1 auto; }

/* ---- Résumé de validation (État 3a) ---------------------------------- */
.file-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--info-bg);
  border: 1px solid var(--info-bord);
  border-radius: var(--radius-s);
  margin-bottom: 22px;
}
.file-banner svg { width: 22px; height: 22px; color: var(--bleu); flex: none; }
.file-banner .fb-name { font-weight: 600; color: var(--bleu-nuit); word-break: break-all; }
.file-banner .fb-meta { color: var(--texte-doux); font-size: .85rem; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 22px;
}
.stat {
  background: var(--gris-tres-clair);
  border: 1px solid var(--gris-bord);
  border-radius: var(--radius-s);
  padding: 16px;
  text-align: center;
}
.stat .num { font-size: 1.7rem; font-weight: 700; color: var(--bleu-nuit); letter-spacing: -.02em; }
.stat .lbl { font-size: .8rem; color: var(--texte-doux); margin-top: 2px; }

/* Signaux (positifs / attention) */
.signals { display: flex; flex-direction: column; gap: 8px; margin-bottom: 22px; }
.signal {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-s);
  font-size: .9rem;
  border: 1px solid transparent;
}
.signal svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.signal.ok { background: var(--succes-bg); border-color: var(--succes-bord); color: var(--succes); }
.signal.warn { background: var(--alerte-bg); border-color: var(--alerte-bord); color: var(--alerte); }
.signal strong { font-weight: 700; }

.preview-label {
  font-size: .82rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--ardoise);
  font-weight: 700;
  margin-bottom: 8px;
}
.table-scroll {
  overflow-x: auto;
  border: 1px solid var(--gris-bord);
  border-radius: var(--radius-s);
  -webkit-overflow-scrolling: touch;
}
table.preview {
  border-collapse: collapse;
  width: 100%;
  font-size: .84rem;
  white-space: nowrap;
}
table.preview th {
  background: var(--gris-clair);
  color: var(--bleu-nuit);
  font-weight: 600;
  text-align: left;
  padding: 9px 12px;
  border-bottom: 1px solid var(--gris-bord);
  position: sticky;
  top: 0;
}
table.preview td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--gris-bord);
  color: var(--texte);
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
}
table.preview tr:last-child td { border-bottom: none; }
table.preview td.cell-flag { color: var(--erreur); }

/* ---- États de traitement / feedback ---------------------------------- */
.state-block { text-align: center; padding: 20px 8px; }
.state-block .state-icon { width: 52px; height: 52px; margin: 0 auto 16px; }
.state-block h2 {
  font-size: 1.3rem;
  color: var(--bleu-nuit);
  font-weight: 700;
  margin-bottom: 8px;
}
.state-block p { color: var(--texte-doux); max-width: 520px; margin: 0 auto 6px; }

/* Spinner (envoi en cours) */
.spinner {
  width: 46px; height: 46px;
  margin: 0 auto 18px;
  border: 4px solid var(--gris-bord);
  border-top-color: var(--bleu);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 2.4s; }
  .dropzone, .dz-icon { transition: none; }
}

.progress-track {
  height: 6px;
  background: var(--gris-bord);
  border-radius: 999px;
  overflow: hidden;
  max-width: 320px;
  margin: 18px auto 0;
}
.progress-bar {
  height: 100%;
  width: 40%;
  background: var(--bleu);
  border-radius: 999px;
  animation: indet 1.4s ease-in-out infinite;
}
@keyframes indet {
  0% { margin-left: -40%; }
  100% { margin-left: 100%; }
}

.state-icon.ok { color: var(--succes); }
.state-icon.err { color: var(--erreur); }

/* Encadré d'erreur bloquante (État 3b / 5b) */
.error-box {
  text-align: left;
  background: var(--erreur-bg);
  border: 1px solid var(--erreur-bord);
  border-radius: var(--radius-s);
  padding: 16px 18px;
  margin: 18px auto 0;
  max-width: 620px;
}
.error-box.warnbox { background: var(--alerte-bg); border-color: var(--alerte-bord); }
.error-box .eb-title { font-weight: 700; color: var(--erreur); display: flex; gap: 8px; align-items: center; margin-bottom: 6px; }
.error-box.warnbox .eb-title { color: var(--alerte); }
.error-box .eb-title svg { width: 18px; height: 18px; flex: none; }
.error-box p { color: var(--texte); margin: 4px 0; }
.error-box ul { margin: 8px 0 4px 20px; color: var(--texte); }
.error-box code {
  font-family: var(--police-mono);
  font-size: .85em;
  background: rgba(15, 37, 64, .06);
  padding: 1px 6px;
  border-radius: 5px;
}

/* Détail technique dépliable */
details.tech {
  margin: 16px auto 0;
  max-width: 620px;
  text-align: left;
  border: 1px solid var(--gris-bord);
  border-radius: var(--radius-s);
  background: var(--gris-tres-clair);
}
details.tech > summary {
  cursor: pointer;
  padding: 10px 14px;
  font-size: .85rem;
  color: var(--texte-doux);
  font-weight: 600;
  list-style: none;
}
details.tech > summary::-webkit-details-marker { display: none; }
details.tech > summary::before { content: "▸ "; color: var(--ardoise); }
details.tech[open] > summary::before { content: "▾ "; }
details.tech pre {
  font-family: var(--police-mono);
  font-size: .78rem;
  padding: 0 14px 14px;
  color: var(--texte);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 220px;
  overflow: auto;
}

.next-action {
  margin-top: 6px;
  font-size: .95rem;
}

/* ---- Pied de page ----------------------------------------------------- */
.site-footer {
  flex-shrink: 0;
  border-top: 1px solid var(--gris-bord);
  background: var(--blanc);
  color: var(--texte-doux);
  font-size: .84rem;
}
.site-footer .wrap {
  padding: 18px 24px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.site-footer a { color: var(--bleu); }

/* Lien "sr-only" pour l'accessibilité */
.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;
}

/* ---- Responsive ------------------------------------------------------- */
@media (max-width: 640px) {
  main { padding: 28px 16px 40px; }
  .card { padding: 20px; }
  .page-intro h1 { font-size: 1.4rem; }
  .stat-grid { grid-template-columns: 1fr; }
  .stat { display: flex; align-items: baseline; gap: 10px; text-align: left; }
  .stat .num { font-size: 1.3rem; }
  .dropzone { padding: 34px 18px; }
  .btn-row { flex-direction: column; }
  .site-header .brand .sub { display: none; }
}
