/* ==========================================================================
   Interface v2 — section « Courriers » (refonte UX, 25/08/2026)
   ==========================================================================
   Compagnon de ui-v2-courriers.js. Tout est scopé html.ui-v2 et préfixé
   v2co- (co comme courriers) : sans la v2, ce fichier ne change RIEN.
   Jetons de design-tokens.css (thème clair posé par la coquille) et
   variables de ui-v2.css (--v2-bordure-douce). Règles du cahier : cartes
   blanches radius 12 bordées var(--v2-bordure-douce), boutons/champs
   radius 8, pastilles radius 4, cibles 44 px, H1 PT Serif, UNE primaire
   cuivre par écran, pas de nappe cuivre.

   Deux étages :
   1. le chrome v2 posé par le JS — la barre d'onglets (.v2co-onglets, qui
      redessine le .subnav v1 rendu TEL QUEL par ongletsCourriers) et
      l'en-tête d'écran (.v2co-entete) ;
   2. la peau #main.v2co-v1 — restyle LÉGER des contenus restés en logique
      v1 : les huit pastilles d'étape de l'assistant (.cr-etape) deviennent
      des puces claires numérotées (le numéro est déjà dans leur texte),
      cartes (.card, .cr-carte), listes (.list-row), pastilles de statut
      (les classes v1 .badge-ok/-warn/-info/-danger, telles que crStatutBadge
      et crBadgePages les écrivent — « Envois et scans » est une liste de
      .list-row, pas un tableau), champs, menu ⋯ et alertes ambre. Les
      primaires RÉPÉTÉS par ligne ou par carte (« Utiliser ce modèle »,
      « Suivi et statuts ») sont démis en boutons bordés : la primaire
      cuivre de l'écran reste unique — « Continuer »/« Générer » dans le
      parcours, « + Écrire un modèle » dans l'en-tête des Modèles.
   ========================================================================== */

/* ------------------------------------------- onglets soulignés cuivre */
/* Le .subnav v1 vit tel quel DANS le nav v2 : mêmes liens, mêmes gardes —
   seul le dessin change (même trait que les Appels et Devis & Factures). */
html.ui-v2 .v2co-onglets .subnav {
  display: flex;
  gap: 22px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--v2-bordure-douce);
  flex-wrap: wrap;
}
html.ui-v2 .v2co-onglets .subnav a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 2px;
  margin-right: 0;
  font-size: 14px;
  color: var(--texte-attenue);
  text-decoration: none;
  border-bottom: 2px solid transparent;
}
html.ui-v2 .v2co-onglets .subnav a:hover { color: var(--sobria-nuit); }
html.ui-v2 .v2co-onglets .subnav a.active {
  color: var(--sobria-nuit);
  font-weight: 600;
  border-bottom-color: var(--sobria-cuivre);
}

/* ------------------------------------------------------ en-tête d'écran */
html.ui-v2 .v2co-entete {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin: 0 0 18px;
}
html.ui-v2 .v2co-entete h1 {
  margin: 0;
  font-family: var(--font-head, "PT Serif", Georgia, serif);
  font-size: 28px;
  line-height: 1.2;
  color: var(--sobria-nuit);
}
html.ui-v2 .v2co-soustitre {
  margin: 6px 0 0;
  font-size: 13.5px;
  color: var(--texte-attenue);
  max-width: 72ch;
}
/* Les nœuds v1 déplacés ici (bouton, compteur) gardent classes et id. */
html.ui-v2 .v2co-entete-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
html.ui-v2 .v2co-entete-actions .meta { font-size: 13px; }

/* ==========================================================================
   Peau v2co-v1 — le contenu v1, éclairci. La logique et la structure ne
   bougent pas ; les variables inversées de ui-v2.css font déjà le gros du
   thème clair, ici on aligne le dessin sur le v2.
   ========================================================================== */

/* ---- titres de section restés en v1 (« Lots générés », groupes…) ------ */
html.ui-v2 #main.v2co-v1 .page-head { margin-bottom: 10px; }
html.ui-v2 #main.v2co-v1 .page-head h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--sobria-nuit);
}

/* ---- cartes ----------------------------------------------------------- */
html.ui-v2 #main.v2co-v1 .card {
  background: var(--fond-surface, #fff);
  border: 1px solid var(--v2-bordure-douce);
  border-radius: 12px;
  box-shadow: var(--ombre-1, 0 1px 2px rgba(20, 33, 59, .06));
}
html.ui-v2 #main.v2co-v1 .card h2,
html.ui-v2 #main.v2co-v1 .card h3 { color: var(--sobria-nuit); }
/* Le survol v1 (blanc translucide) est invisible sur fond blanc. */
html.ui-v2 #main.v2co-v1 .list-row:hover { background: rgba(20, 33, 59, .04); }

/* ---- les huit étapes de l'assistant : puces claires numérotées -------- */
html.ui-v2 #main.v2co-v1 .cr-etapes { gap: 8px; margin-bottom: 20px; }
html.ui-v2 #main.v2co-v1 .cr-etape {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 14px;
  border-radius: 999px;
  font-size: 12.5px;
  background: var(--fond-surface, #fff);
  border: 1px solid var(--v2-bordure-douce);
  color: var(--texte-attenue);
}
html.ui-v2 #main.v2co-v1 .cr-etape.done {
  color: var(--sobria-nuit);
  background: var(--fond-surface-2, #f6f3ea);
}
html.ui-v2 #main.v2co-v1 .cr-etape.active {
  color: var(--sobria-nuit);
  font-weight: 600;
  border-color: var(--sobria-cuivre);
  background: #f9f1ea;               /* teinte cuivre, accent — pas une nappe */
}
html.ui-v2 #main.v2co-v1 button.cr-etape:hover {
  border-color: var(--sobria-cuivre);
  color: var(--sobria-nuit);
}

/* ---- cartes de modèle de l'étape 1 ------------------------------------ */
html.ui-v2 #main.v2co-v1 .cr-carte {
  background: var(--fond-surface, #fff);
  border: 1px solid var(--v2-bordure-douce);
  border-radius: 12px;
  box-shadow: var(--ombre-1, 0 1px 2px rgba(20, 33, 59, .06));
}
html.ui-v2 #main.v2co-v1 .cr-carte.selectionnee { border-color: var(--sobria-cuivre); }

/* ---- pastilles de statut : les classes v1, en pastel v2 ---------------
   crStatutBadge (Envois et scans), crBadgePages, badges des listes et du
   QR écrivent .badge badge-ok|warn|info|danger : on les repeint, on n'en
   crée aucune. Mêmes teintes que les autres modules v2 (lisibles sur
   blanc, mesure du 07/08 pour le rouge). */
html.ui-v2 #main.v2co-v1 .badge {
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.3;
  padding: 3px 8px;
}
html.ui-v2 #main.v2co-v1 .badge-ok     { background: #eaf5ee; color: #3f8f5f; }
html.ui-v2 #main.v2co-v1 .badge-warn   { background: #fdf3e3; color: #9a6b1a; }
html.ui-v2 #main.v2co-v1 .badge-info   { background: #eef3fb; color: #2f5fa8; }
html.ui-v2 #main.v2co-v1 .badge-danger { background: #fbeeec; color: #a3392b; }

/* ---- boutons ---------------------------------------------------------- */
html.ui-v2 #main.v2co-v1 .btn {
  min-height: 36px;
  padding: 6px 14px;
  border: 1px solid var(--v2-bordure-douce);
  border-radius: 8px;
  background: var(--fond-surface, #fff);
  color: var(--texte);
  font-size: 13.5px;
  cursor: pointer;
}
html.ui-v2 #main.v2co-v1 .btn:hover { background: #faf8f3; filter: none; }
html.ui-v2 #main.v2co-v1 .btn-sm { min-height: 32px; padding: 4px 10px; font-size: 12.5px; }
html.ui-v2 #main.v2co-v1 .btn:disabled { opacity: .55; cursor: default; }
html.ui-v2 #main.v2co-v1 .btn-primary {
  border: 0;
  background: var(--sobria-cuivre);
  color: #fff;
  font-weight: 600;
}
html.ui-v2 #main.v2co-v1 .btn-primary:hover { background: #b06c33; }
html.ui-v2 #main.v2co-v1 .btn-primary:disabled { background: #d9b391; opacity: 1; }
/* La primaire de l'en-tête (déplacée par le JS) garde le cuivre. */
html.ui-v2 .v2co-entete-actions .btn-primary {
  min-height: 40px;
  border: 0;
  border-radius: 8px;
  background: var(--sobria-cuivre);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  padding: 6px 16px;
  font-size: 13.5px;
}
html.ui-v2 .v2co-entete-actions .btn-primary:hover { background: #b06c33; }
/* Les primaires RÉPÉTÉS par ligne ou par carte redeviennent des boutons
   bordés : une seule primaire cuivre par écran. Le geste reste entier —
   seul le costume change ; le survol dit encore l'action principale. */
html.ui-v2 #main.v2co-v1 .list-row .btn-primary,
html.ui-v2 #main.v2co-v1 .cr-carte .btn-primary {
  border: 1px solid var(--v2-bordure-douce);
  background: var(--fond-surface, #fff);
  color: var(--texte);
  font-weight: 500;
}
html.ui-v2 #main.v2co-v1 .list-row .btn-primary:hover,
html.ui-v2 #main.v2co-v1 .cr-carte .btn-primary:hover {
  border-color: var(--sobria-cuivre);
  color: #a05f27;                    /* cuivre assombri, AA sur blanc */
  background: #faf8f3;
}

/* ---- champs ----------------------------------------------------------- */
html.ui-v2 #main.v2co-v1 input:not([type="checkbox"]):not([type="radio"]),
html.ui-v2 #main.v2co-v1 select,
html.ui-v2 #main.v2co-v1 textarea {
  min-height: 38px;
  padding: 6px 10px;
  border: 1px solid var(--v2-bordure-douce);
  border-radius: 8px;
  background: var(--fond-surface, #fff);
  color: var(--texte);
  font-size: 13.5px;
  font-family: inherit;
}
html.ui-v2 #main.v2co-v1 textarea { min-height: 64px; resize: vertical; }
html.ui-v2 #main.v2co-v1 input[type="checkbox"],
html.ui-v2 #main.v2co-v1 input[type="radio"] {
  width: 16px;
  height: 16px;
  accent-color: var(--sobria-cuivre);
}

/* ---- menu ⋯ des modèles, diagnostic replié ---------------------------- */
html.ui-v2 #main.v2co-v1 .cr-menu {
  background: var(--fond-surface, #fff);
  border: 1px solid var(--v2-bordure-douce);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(20, 33, 59, .14);
}
html.ui-v2 #main.v2co-v1 .cr-menu button {
  color: var(--texte);
  border-radius: 8px;
}
html.ui-v2 #main.v2co-v1 .cr-menu button:hover { background: #faf8f3; }
html.ui-v2 #main.v2co-v1 .cr-diag summary { color: var(--texte-attenue); }
html.ui-v2 #main.v2co-v1 .cr-diag[open] summary { color: var(--sobria-nuit); }

/* ---- suggestions de P.S. (étape 7) ------------------------------------ */
html.ui-v2 #main.v2co-v1 .cr-ps-chip {
  background: var(--fond-surface, #fff);
  border: 1px solid var(--v2-bordure-douce);
  color: var(--texte-attenue);
}
html.ui-v2 #main.v2co-v1 .cr-ps-chip:hover {
  color: var(--sobria-nuit);
  border-color: var(--sobria-cuivre);
}

/* ---- avertissements ambre (doublons, hors catégorie) ------------------
   Ambre et jamais rouge, comme en v1 : rien n'est encore parti. Pas de
   display posé ici — ces blocs se montrent et se cachent par [hidden]. */
html.ui-v2 #main.v2co-v1 .cr-doublons,
html.ui-v2 #main.v2co-v1 .cr-alerte {
  background: #fdf3e3;
  border-left: 3px solid #d9a03c;
  border-radius: 8px;
}

/* --------------------------------------------------------------- mobile */
@media (max-width: 767px) {
  html.ui-v2 .v2co-onglets .subnav {
    gap: 16px;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 2px;
  }
  html.ui-v2 .v2co-entete { flex-direction: column; align-items: flex-start; }
  html.ui-v2 .v2co-entete h1 { font-size: 24px; }
}
