/* ==========================================================================
   PRO UI : couche de lisibilité et de cohérence (V1 + V2)
   Chargée EN DERNIER (après style.css et v2.css).

   Échelle typographique (12 px = plancher absolu, jamais en dessous) :
     --fs-xs   12px  badges, pastilles, légendes courtes
     --fs-sm   13px  texte secondaire, aides, statuts, messages d'erreur
     --fs-md   14px  navigation, boutons, tableaux, métadonnées
     --fs-base 15px  texte courant, champs de formulaire
     --fs-lg   17px  sous-titres
     --fs-xl   20px  titres de section
     --fs-2xl  24px  titres de page

   Le préfixe :root:root augmente volontairement la spécificité pour passer
   devant les règles historiques de style.css et v2.css. À retirer quand ces
   règles auront été nettoyées à la source.
   ========================================================================== */

:root {
  --fs-xs: 0.71875rem;
  --fs-sm: 0.78125rem;
  --fs-md: 0.84375rem;
  --fs-base: 0.90625rem;
  --fs-lg: 1.03125rem;
  --fs-xl: 1.21875rem;
  --fs-2xl: 1.46875rem;
  --lh-tight: 1.3;
  --lh-base: 1.55;
  --control-h: 2.5rem;       /* 40px : champs et boutons principaux */
  --control-h-compact: 2.25rem; /* 36px : filtres et barres d'outils denses */
}

/* Contraste : le texte « faible » passe de ~2,6:1 / 3,3:1 à ≥ 4,5:1 (WCAG AA) */
:root:root { --text-faint: #6b7280; }
html[data-ui="v2"]:root { --text-faint: #737373; }

/* 1. Base ------------------------------------------------------------------ */
:root:root body {
  font-size: var(--fs-base);
  line-height: var(--lh-base);
}
:root:root :is(h1, h2, h3, h4) { line-height: var(--lh-tight); text-wrap: balance; }
:root:root :is(p, li) { text-wrap: pretty; }

/* Chiffres alignés : crédits, scores, KPI, tableaux */
:root:root :is(table, .badge-score, .taux-pill, .v2-credits__value, .dv2-kpi .v, .dv2-sc, .quota-badge, .credits-alert-message) {
  font-variant-numeric: tabular-nums;
}

/* 2. Navigation ------------------------------------------------------------ */
:root:root :is(.header-nav-item, .user-menu-item, .user-menu-section-toggle, .admin-nav-link, .ws-tab, .nav-title) {
  font-size: var(--fs-md);
}

/* 3. Champs de formulaire (étaient à 12-13px) ------------------------------- */
:root:root :is(
  input:is([type="text"], [type="email"], [type="password"], [type="search"], [type="tel"], [type="url"], [type="number"], [type="date"], [type="datetime-local"]),
  select
) {
  font-size: 12.5px;
  line-height: 1.4;
  min-height: var(--control-h);
}
:root:root textarea {
  font-size: var(--fs-base);
  line-height: 1.5;
  min-height: 5rem;
}
/* Filtres et barres d'outils : un cran plus compact, même lisibilité */
:root:root :is(.df-input, .df-select, .directory-search input, .audit-select-rename-form input, .saved-offer-select) {
  font-size: var(--fs-md);
  min-height: var(--control-h-compact);
}
:root:root :is(label, .field-label label) {font-size: 12.5px; padding-left: 3%; }

/* 4. Boutons --------------------------------------------------------------- */
:root:root :is(
  .btn-analyze, .btn-reset, .btn-reanalyze, .btn-logout, .btn-add-criterion, .btn-u-action,
  .dv2-btn, .dv2-cta, .ro-generate-btn, .hub-featured-cta, .reverse-match-audit-btn
) {
  font-size: var(--fs-md);
  font-weight: 600;
  line-height: 1.25;
  min-height: var(--control-h);
}

/* 5. Texte secondaire : plancher à 13px ------------------------------------ */
:root:root :is(
  .action-help, .dropzone-hint, .field-optional, .reverse-match-hint, .df-hint, .dispo-hint,
  .lot-offer-hint, .batch-upload-hint, .analyse-optional-hint, .credit-shortfall-hint,
  .avatar-edit-hint, .beginner-guide-note, .analysis-mode-disclaimer, .wizard-credit-note,
  .directory-count, .help-rail-lead, .help-rail-tips li, .hub-card-desc, .gauge-caption,
  .batch-match-item-file, .batch-match-item-status, .batch-document-item-main span,
  .batch-document-item-status, .lot-item-status, .mobile-action-status, .dispo-status,
  .directory-preview-meta, .candidate-item-date, .candidate-item-ville, .candidate-item-poste,
  .reverse-match-result-meta, .directory-document-nav-label, .credit-action-note__hint
) {
  font-size: var(--fs-sm);
  line-height: 1.5;
}

/* Éléments de contenu principaux d'une liste : 14px */
:root:root :is(.candidate-item-name, .batch-match-item-main strong, .directory-document-nav-btn, .hub-card-title) {
  font-size: var(--fs-md);
}

/* Messages d'erreur : lisibles et jamais plus petits que le texte d'aide */
:root:root :is(.error-msg, .error-msg-retry, .avatar-edit-error, .audit-select-rename-error, .batch-item-save-error, .batch-match-item-error) {
  font-size: var(--fs-sm);
  line-height: 1.45;
  font-weight: 500;
}

/* 6. Badges et pastilles : 12px mini, sans compression ----------------------- */
:root:root :is(
  .badge-score, .badge-noscore, .badge-profile-kind, .hub-card-badge, .hub-available-badge,
  .quota-badge, .online-badge, .taux-pill, .df-tag-chip, .df-tag-badge, .directory-preview-tag,
  .step-chip, .audit-select-option-tag, .reverse-match-audit-badge
) {
  font-size: var(--fs-xs);
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: 0;
}

/* 7. Tableaux : en-têtes sobres, pas de capitales ---------------------------- */
:root:root :is(th, .criteria-table th) {
  font-size: var(--fs-sm);
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
}

/* 8. Accessibilité --------------------------------------------------------- */
/* Focus clavier visible et uniforme (la V2 garde son propre anneau) */
:root:not([data-ui="v2"]) :is(a, button, [role="button"], summary, [tabindex]:not([tabindex="-1"])):focus-visible {
  outline: 2px solid var(--orange-dark, #c2410c);
  outline-offset: 2px;
}

/* Écrans tactiles : cibles de 44px */
@media (pointer: coarse) {
  :root:root :is(.btn-analyze, .btn-reset, .btn-reanalyze, .btn-logout, .btn-u-action, .dv2-btn, .dv2-cta, .header-nav-item, .user-menu-item) {
    min-height: 2.75rem;
  }
}

/* Mobile : 16px dans les champs, sinon iOS zoome la page à la saisie */
@media (max-width: 768px) {
  :root:root :is(
    input:is([type="text"], [type="email"], [type="password"], [type="search"], [type="tel"], [type="url"], [type="number"], [type="date"], [type="datetime-local"]),
    select, textarea
  ) {
    font-size: 0.9688rem;
  }
}

/* Respect de « réduire les animations » (les indicateurs de chargement restent animés) */
@media (prefers-reduced-motion: reduce) {
  *:not([class*="spinner"]):not([class*="progress"]),
  *:not([class*="spinner"]):not([class*="progress"])::before,
  *:not([class*="spinner"]):not([class*="progress"])::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}


/* ==========================================================================
   PARTIE 2 : finition visuelle et interactions
   ========================================================================== */

/* 9. Décor : le filigrane orange en bas à droite de la V1 disparaît ---------- */
:root:not([data-ui="v2"]) body::before,
:root:not([data-ui="v2"]) body::after {
  display: none !important;
}

/* 10. États des contrôles : transitions, focus, erreur, désactivé ------------- */
:root:root :is(button, a, input, select, textarea, summary) {
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}
:root:root :is(input, select, textarea):not([type="checkbox"], [type="radio"], [type="file"], [type="range"]):focus-visible {
  border-color: var(--orange-dark, #c2410c);
  box-shadow: 0 0 0 3px var(--orange-tint, #fff1e8);
  outline: none;
}
/* Erreur de saisie : uniquement après interaction (pas au chargement) */
:root:root :is(input, select, textarea):user-invalid {
  border-color: var(--low, #b91c1c);
}
:root:root :is(input, select, textarea):user-invalid:focus-visible {
  box-shadow: 0 0 0 3px var(--low-bg, #fef2f2);
}
:root:root :is(button, input, select, textarea)[disabled],
:root:root :is(.btn-analyze, .btn-reset, .btn-plan)[aria-disabled="true"] {
  cursor: not-allowed;
}
:root:root ::placeholder {
  color: var(--text-faint);
  opacity: 1;
}
:root:root ::selection {
  background: var(--orange-tint, #fff1e8);
  color: var(--text, #171717);
}

/* 11. Tableaux : lecture facilitée ------------------------------------------- */
:root:root :is(.pricing-table, .users-table, .cvs-table, .usage-table, .trash-table, .backup-table, .dot-table, .fact-table, .adal-table, .admoff-table, .criteria-table) {
  border-collapse: collapse;
}
:root:root :is(.pricing-table, .users-table, .cvs-table, .usage-table, .trash-table, .backup-table, .dot-table, .fact-table, .adal-table, .admoff-table, .criteria-table) th {
  color: var(--text-muted);
  background: transparent;
  border-bottom: 1px solid var(--border);
  padding-top: 0.7rem;
  padding-bottom: 0.7rem;
  white-space: nowrap;
}
:root:root :is(.pricing-table, .users-table, .cvs-table, .usage-table, .trash-table, .backup-table, .dot-table, .fact-table, .adal-table, .admoff-table, .criteria-table) td {
  padding-top: 0.7rem;
  padding-bottom: 0.7rem;
  vertical-align: middle;
}
:root:root :is(.pricing-table, .users-table, .cvs-table, .usage-table, .trash-table, .backup-table, .dot-table, .fact-table, .adal-table, .admoff-table) tbody tr:hover > td {
  background: var(--bg, #fafafa);
}
/* Colonnes numériques : alignées à droite, chiffres tabulaires */
:root:root :is(td.num, th.num) {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* 12. États vides et chargement : centrés, lisibles ---------------------------- */
:root:root :is(.directory-empty, .directory-loading) {
  text-align: center;
  color: var(--text-muted);
  font-size: var(--fs-md);
  line-height: 1.5;
  padding: 2.5rem 1rem;
}

/* 13. Page Tarifs : cartes d'offres ------------------------------------------- */
:root:root .plans-grid {
  gap: 1.25rem;
  align-items: stretch;
}
:root:root .plan-card {
  background: var(--surface, #fff);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
:root:root .plan-card:hover,
:root:root .plan-card:focus-within {
  border-color: var(--text-faint);
  box-shadow: var(--shadow-md);
}
:root:root .plan-card .plan-name {
  font-size: var(--fs-base);
  font-weight: 600;
  margin: 0 0 0.75rem;
}
/* Le prix est l'information n°1 : grand, en encre, tabulaire ; l'orange reste pour l'action */
:root:root .plan-card .plan-price {
  font-size: 1.7188rem;
  line-height: 1.1;
  font-weight: 650;
  letter-spacing: -0.01em;
  color: var(--text);
  margin: 0 0 0.35rem;
  font-variant-numeric: tabular-nums;
}
:root:root .plan-card .plan-credits {
  font-size: var(--fs-md);
  font-weight: 600;
  color: var(--text);
  margin: 0 0 0.2rem;
}
:root:root .plan-card .plan-validity {
  font-size: var(--fs-sm);
  font-style: normal;
  color: var(--text-muted);
  margin: 0 0 0.9rem;
}
:root:root .plan-card .plan-desc {
  font-size: var(--fs-sm);
  line-height: 1.55;
  color: var(--text-muted);
  margin: 0.5rem 0 1.25rem;
}
:root:root .btn-plan {
  min-height: var(--control-h);
  font-size: var(--fs-md);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
}
:root:root .btn-plan--table {
  min-height: var(--control-h-compact);
}
:root:root .enterprise-box {
  border-style: solid;
  border-color: var(--border);
  background: var(--surface, #fff);
}
:root:root .tarifs-footnote {
  font-size: var(--fs-sm);
}
