/**
 * Thème v2 — coque ERP (navbar, fond, blocs courants).
 * Activé uniquement avec body.theme-v2-preview (après module-colors-dynamic).
 */
body.theme-v2-preview {
  color: rgba(255, 255, 255, 0.92);
  background:
    radial-gradient(1200px 600px at 80% 20%, rgba(46, 107, 255, 0.35), transparent 60%),
    radial-gradient(900px 500px at 15% 15%, rgba(94, 59, 255, 0.25), transparent 55%),
    radial-gradient(1000px 700px at 65% 85%, rgba(46, 235, 255, 0.08), transparent 60%),
    linear-gradient(180deg, var(--v2-bg0), var(--v2-bg1)) !important;
  background-attachment: fixed !important;

  /* Compat unified-module-style.css (évite fonds gris/clair en preview v2) */
  --bg-card: rgba(14, 26, 58, 0.78);
  --border-primary: var(--v2-stroke);
  --border-secondary: var(--v2-stroke);
  --shadow-card: 0 14px 40px rgba(0, 0, 0, 0.45);
  --bg-hover: rgba(46, 235, 255, 0.08);
}

body.theme-v2-preview.dev-mode-active {
  background:
    radial-gradient(1200px 600px at 80% 20%, rgba(46, 107, 255, 0.25), transparent 60%),
    linear-gradient(180deg, var(--v2-bg0), #1a0f24) !important;
}

body.theme-v2-preview main {
  min-height: calc(100vh - 56px);
}

/* ——— Navbar ——— */
body.theme-v2-preview nav.modern-navbar,
body.theme-v2-preview nav.professional-navbar {
  background: linear-gradient(180deg, rgba(6, 11, 26, 0.92), rgba(6, 11, 26, 0.75)) !important;
  border-bottom: 1px solid var(--v2-stroke) !important;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

body.theme-v2-preview nav.modern-navbar .navbar-brand-modern,
body.theme-v2-preview nav.modern-navbar .brand-title-modern {
  color: rgba(255, 255, 255, 0.95) !important;
}

body.theme-v2-preview nav.modern-navbar .brand-subtitle-modern {
  color: var(--v2-muted2) !important;
}

body.theme-v2-preview nav.modern-navbar .nav-link-modern,
body.theme-v2-preview nav.modern-navbar .nav-link.dropdown-toggle {
  color: rgba(255, 255, 255, 0.88) !important;
}

body.theme-v2-preview nav.modern-navbar .nav-link-modern:hover,
body.theme-v2-preview nav.modern-navbar .nav-link.dropdown-toggle:hover {
  color: #fff !important;
}

body.theme-v2-preview nav.modern-navbar .navbar-toggler {
  border-color: rgba(255, 255, 255, 0.25);
  filter: invert(1);
}

body.theme-v2-preview .dropdown-menu-modern {
  background: rgba(14, 26, 58, 0.98) !important;
  border: 1px solid var(--v2-stroke) !important;
  box-shadow: var(--v2-shadow);
}

body.theme-v2-preview .dropdown-item-modern {
  color: rgba(255, 255, 255, 0.9) !important;
}

body.theme-v2-preview .dropdown-item-modern:hover,
body.theme-v2-preview .dropdown-item-modern:focus {
  background: rgba(255, 255, 255, 0.08) !important;
  color: #fff !important;
}

body.theme-v2-preview .dropdown-divider {
  border-color: var(--v2-stroke) !important;
}

body.theme-v2-preview nav.modern-navbar .btn-outline-secondary {
  border-color: rgba(255, 255, 255, 0.25);
  color: rgba(255, 255, 255, 0.9);
  background: rgba(255, 255, 255, 0.06);
}

body.theme-v2-preview nav.modern-navbar .btn-outline-secondary:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

/* ——— Texte utilitaire ——— */
body.theme-v2-preview .text-muted {
  color: var(--v2-muted) !important;
}

/* ——— Cartes & listes ——— */
body.theme-v2-preview .card {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.03));
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.92);
}

/* Cartes ERP (unified-module-style) */
body.theme-v2-preview .erp-card {
  background: linear-gradient(180deg, rgba(14, 26, 58, 0.58), rgba(6, 11, 26, 0.52)) !important;
  border: 1px solid var(--v2-stroke) !important;
  box-shadow: var(--v2-shadow) !important;
  color: rgba(255, 255, 255, 0.92) !important;
}

body.theme-v2-preview .card-header {
  border-bottom-color: var(--v2-stroke);
  color: inherit;
}

body.theme-v2-preview .list-group-item {
  background: rgba(6, 11, 26, 0.35);
  border-color: var(--v2-stroke);
  color: rgba(255, 255, 255, 0.9);
}

/* ——— Tableaux ——— */
body.theme-v2-preview .table {
  color: rgba(255, 255, 255, 0.9);
  --bs-table-bg: transparent;
  --bs-table-striped-bg: rgba(255, 255, 255, 0.04);
  --bs-table-hover-bg: rgba(255, 255, 255, 0.08);
  --bs-table-border-color: var(--v2-stroke);
}

/* Tableaux unifiés (unified-module-style) */
body.theme-v2-preview .erp-table {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.03)) !important;
  border: 1px solid var(--v2-stroke) !important;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.45) !important;
}

body.theme-v2-preview .erp-table thead,
body.theme-v2-preview .erp-table thead th {
  background: rgba(6, 11, 26, 0.96) !important;
  color: rgba(255, 255, 255, 0.94) !important;
  border-color: var(--v2-stroke) !important;
}

/* Colonnes triables (unified-module-style applique du blanc en legacy via .sortable-col) */
/* Note: `unified-module-style.css` cible souvent `body.module-…` + `!important`.
   On ajoute `[class*="module-"]` pour dépasser la spécificité sans sur-mesure. */
html body.theme-v2-preview[class*="module-"] .erp-table thead th,
html body.theme-v2-preview[class*="module-"] .erp-table thead th * {
  background: rgba(6, 11, 26, 0.96) !important;
  background-color: rgba(6, 11, 26, 0.96) !important;
  color: rgba(255, 255, 255, 0.94) !important;
}

html body.theme-v2-preview[class*="module-"] .erp-table thead th.sortable-col,
html body.theme-v2-preview[class*="module-"] .erp-table thead th.sortable-col * {
  background: rgba(6, 11, 26, 0.96) !important;
  background-color: rgba(6, 11, 26, 0.96) !important;
  color: rgba(255, 255, 255, 0.94) !important;
}

body.theme-v2-preview .erp-table td {
  background: rgba(255, 255, 255, 0.03) !important;
  border-bottom-color: var(--v2-stroke) !important;
  color: rgba(255, 255, 255, 0.9) !important;
}

body.theme-v2-preview .erp-table tbody tr:nth-child(even) td {
  background: rgba(255, 255, 255, 0.055) !important;
}

/* Hover cyan par défaut uniquement si le tableau n’active pas l’effet rowfx (option B) */
body.theme-v2-preview .erp-table:not(.erp-table--rowfx) tbody tr:hover td {
  background: rgba(46, 235, 255, 0.09) !important;
}

/* ——— Hover lignes "clickable-row" (couleur module) ———
   Legacy (public/css/app.css) force un gris via `.clickable-row:hover{... !important}`.
   En preview v2, on préfère une mise en évidence basée sur la couleur du module (`--primary` de module-colors-dynamic). */
@supports (color: color-mix(in srgb, black, white)) {
  html body.theme-v2-preview[class*="module-"] .clickable-row:hover,
  html body.theme-v2-preview[class*="module-"] .clickable-row:hover td {
    background-color: color-mix(in srgb, var(--primary, var(--v2-brand)) 18%, transparent) !important;
  }
}
@supports not (color: color-mix(in srgb, black, white)) {
  html body.theme-v2-preview[class*="module-"] .clickable-row:hover,
  html body.theme-v2-preview[class*="module-"] .clickable-row:hover td {
    background-color: rgba(var(--module-color-rgb, 46, 107, 255), 0.14) !important;
  }
}

/* Variante: tables non "erp-table" qui utilisent encore `tr:hover` en legacy */
@supports (color: color-mix(in srgb, black, white)) {
  html body.theme-v2-preview[class*="module-"] table tbody tr.clickable-row:hover,
  html body.theme-v2-preview[class*="module-"] table tbody tr.clickable-row:hover td {
    background-color: color-mix(in srgb, var(--primary, var(--v2-brand)) 18%, transparent) !important;
  }
}
@supports not (color: color-mix(in srgb, black, white)) {
  html body.theme-v2-preview[class*="module-"] table tbody tr.clickable-row:hover td {
    background-color: rgba(var(--module-color-rgb, 46, 107, 255), 0.14) !important;
  }
}

/* Hover "module" pour les listes unified (même sans .clickable-row), hors rowfx */
@supports (color: color-mix(in srgb, black, white)) {
  html body.theme-v2-preview[class*="module-"] .erp-table:not(.erp-table--rowfx) tbody tr:hover,
  html body.theme-v2-preview[class*="module-"] .erp-table:not(.erp-table--rowfx) tbody tr:hover td {
    background-color: color-mix(in srgb, var(--primary, var(--v2-brand)) 18%, transparent) !important;
  }
}
@supports not (color: color-mix(in srgb, black, white)) {
  html body.theme-v2-preview[class*="module-"] .erp-table:not(.erp-table--rowfx) tbody tr:hover,
  html body.theme-v2-preview[class*="module-"] .erp-table:not(.erp-table--rowfx) tbody tr:hover td {
    background-color: rgba(var(--module-color-rgb, 46, 107, 255), 0.14) !important;
  }
}

body.theme-v2-preview .table thead th {
  background: rgba(6, 11, 26, 0.96);
  color: rgba(255, 255, 255, 0.85);
  border-color: var(--v2-stroke);
}

/* ——— Formulaires ——— */
body.theme-v2-preview .form-control,
body.theme-v2-preview .form-select {
  background-color: rgba(6, 11, 26, 0.55);
  border-color: rgba(255, 255, 255, 0.15);
  color: rgba(255, 255, 255, 0.95);
}

body.theme-v2-preview .form-control:focus,
body.theme-v2-preview .form-select:focus {
  background-color: rgba(6, 11, 26, 0.75);
  border-color: var(--v2-brand);
  color: #fff;
  box-shadow: 0 0 0 0.2rem rgba(46, 107, 255, 0.25);
}

body.theme-v2-preview .form-label {
  color: rgba(255, 255, 255, 0.8);
}

/* ——— En-têtes de page module (unified-module-style) ——— */
body.theme-v2-preview .module-header {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.03)) !important;
  border: 1px solid var(--v2-stroke) !important;
  color: rgba(255, 255, 255, 0.95) !important;
}

body.theme-v2-preview .module-header h1,
body.theme-v2-preview .module-header .h1,
body.theme-v2-preview .module-header h2,
body.theme-v2-preview .module-header h3 {
  color: inherit !important;
}

/* ——— Alertes ——— */
body.theme-v2-preview .alert {
  border-width: 1px;
}

body.theme-v2-preview .alert-secondary,
body.theme-v2-preview .alert-light {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--v2-stroke);
  color: rgba(255, 255, 255, 0.9);
}

/* ——— Modales Bootstrap ——— */
body.theme-v2-preview .modal-content {
  background: rgba(14, 26, 58, 0.98);
  border: 1px solid var(--v2-stroke);
  color: rgba(255, 255, 255, 0.92);
}

body.theme-v2-preview .modal-header {
  border-bottom-color: var(--v2-stroke);
}

body.theme-v2-preview .modal-footer {
  border-top-color: var(--v2-stroke);
}

/* Bouton « ? » (bandeau filtres) : même verre que les .erp-filter-btn / .erp-filter-btn-main */
body.theme-v2-preview .erp-filter-bar .erp-help-btn.erp-filter-btn {
  background: rgba(255, 255, 255, 0.1) !important;
  border: 1px solid rgba(255, 255, 255, 0.28) !important;
  color: #fff !important;
  box-shadow: none !important;
}

body.theme-v2-preview .erp-filter-bar .erp-help-btn.erp-filter-btn:hover {
  background: rgba(255, 255, 255, 0.18) !important;
  border-color: rgba(255, 255, 255, 0.34) !important;
  color: #fff !important;
}

body.theme-v2-preview .erp-filter-bar .erp-help-btn.erp-filter-btn i {
  color: #fff !important;
}

/* Modale d’aide (#erpModuleHelpModal) — hors #appModal ; alignée cockpit + couleur module via data-modal-module */
body.theme-v2-preview #erpModuleHelpModal .modal-content {
  background: rgba(14, 26, 58, 0.98) !important;
  border: 1px solid var(--v2-stroke) !important;
  box-shadow: var(--v2-shadow) !important;
  color: rgba(255, 255, 255, 0.92) !important;
}

body.theme-v2-preview #erpModuleHelpModal .modal-header {
  background-image: none !important;
  border-bottom: 1px solid var(--v2-stroke) !important;
  padding: 1rem 1.25rem !important;
  color: #fff !important;
}

body.theme-v2-preview #erpModuleHelpModal .modal-header .modal-title,
body.theme-v2-preview #erpModuleHelpModal .modal-header .modal-title * {
  color: #fff !important;
  font-size: 1.15rem !important;
  font-weight: 600 !important;
  line-height: 1.35 !important;
}

body.theme-v2-preview #erpModuleHelpModal .modal-body {
  background: rgba(6, 11, 26, 0.55) !important;
  color: rgba(255, 255, 255, 0.92) !important;
}

body.theme-v2-preview #erpModuleHelpModal .erp-help-modal-intro,
body.theme-v2-preview #erpModuleHelpModal .erp-help-modal-list,
body.theme-v2-preview #erpModuleHelpModal .erp-help-modal-list li {
  color: rgba(255, 255, 255, 0.88) !important;
}

/*
 * Fermeture : même pattern que #appModal (barres CSS ::before/::after) — pas d’invert Bootstrap.
 */
body.theme-v2-preview #erpModuleHelpModal .modal-header .btn-close,
body.theme-v2-preview #erpModuleHelpModal .modal-header .erp-modal-close {
  filter: none !important;
  opacity: 1 !important;
  box-sizing: border-box !important;
  width: 2.125rem !important;
  height: 2.125rem !important;
  min-width: 2.125rem !important;
  min-height: 2.125rem !important;
  padding: 0 !important;
  margin: 0 0 0 auto !important;
  border: none !important;
  border-radius: 10px !important;
  background: rgba(255, 255, 255, 0.14) !important;
  background-image: none !important;
  background-size: auto !important;
  --erp-modal-close-bar: rgba(255, 255, 255, 0.96);
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  flex-shrink: 0 !important;
  position: relative !important;
}

body.theme-v2-preview #erpModuleHelpModal .modal-header .btn-close::before,
body.theme-v2-preview #erpModuleHelpModal .modal-header .btn-close::after,
body.theme-v2-preview #erpModuleHelpModal .modal-header .erp-modal-close::before,
body.theme-v2-preview #erpModuleHelpModal .modal-header .erp-modal-close::after {
  content: "" !important;
  position: absolute !important;
  top: 50% !important;
  left: 50% !important;
  width: 0.95rem !important;
  height: 2px !important;
  margin: 0 !important;
  padding: 0 !important;
  pointer-events: none !important;
  border-radius: 1px !important;
  background-color: var(--erp-modal-close-bar, rgba(255, 255, 255, 0.96)) !important;
  display: block !important;
}

body.theme-v2-preview #erpModuleHelpModal .modal-header .btn-close::before,
body.theme-v2-preview #erpModuleHelpModal .modal-header .erp-modal-close::before {
  transform: translate(-50%, -50%) rotate(45deg) !important;
}

body.theme-v2-preview #erpModuleHelpModal .modal-header .btn-close::after,
body.theme-v2-preview #erpModuleHelpModal .modal-header .erp-modal-close::after {
  transform: translate(-50%, -50%) rotate(-45deg) !important;
}

body.theme-v2-preview #erpModuleHelpModal .modal-header .btn-close:hover,
body.theme-v2-preview #erpModuleHelpModal .modal-header .erp-modal-close:hover {
  background-color: rgba(255, 255, 255, 0.24) !important;
  filter: none !important;
}

body.theme-v2-preview #erpModuleHelpModal[data-modal-module="home"] .modal-header {
  background: var(--clr-admin, #495057) !important;
}

body.theme-v2-preview #erpModuleHelpModal[data-modal-module="admin"] .modal-header {
  background: var(--clr-admin, #495057) !important;
}

body.theme-v2-preview #erpModuleHelpModal[data-modal-module="clients"] .modal-header {
  background: var(--clr-clients, #0d6efd) !important;
}

body.theme-v2-preview #erpModuleHelpModal[data-modal-module="employes"] .modal-header {
  background: var(--clr-employes, #6f42c1) !important;
}

body.theme-v2-preview #erpModuleHelpModal[data-modal-module="techniciens"] .modal-header {
  background: var(--clr-techniciens, #20c997) !important;
}

body.theme-v2-preview #erpModuleHelpModal[data-modal-module="machines"] .modal-header {
  background: var(--clr-machines, #fd7e14) !important;
}

body.theme-v2-preview #erpModuleHelpModal[data-modal-module="articles"] .modal-header {
  background: var(--clr-articles, #198754) !important;
}

body.theme-v2-preview #erpModuleHelpModal[data-modal-module="grille-tarifaire"] .modal-header {
  background: var(--clr-grille-tarifaire, #0d6efd) !important;
}

html body.theme-v2-preview #erpModuleHelpModal[data-modal-module="fournisseurs"] .modal-header {
  background: var(--clr-fournisseurs, #6c757d) !important;
}

/* Fournisseurs : puces liste + intro lisibles avec teinte module (évite rendu « générique »). */
html body.theme-v2-preview #erpModuleHelpModal[data-modal-module="fournisseurs"] .erp-help-modal-intro {
  border-left: 3px solid color-mix(in srgb, var(--clr-fournisseurs, #6c757d) 70%, transparent) !important;
  padding-left: 0.85rem !important;
  margin-bottom: 1rem !important;
}

html body.theme-v2-preview #erpModuleHelpModal[data-modal-module="fournisseurs"] .erp-help-modal-list li::marker {
  color: var(--clr-fournisseurs, #6c757d) !important;
}

body.theme-v2-preview #erpModuleHelpModal[data-modal-module="outillage"] .modal-header {
  background: var(--clr-outillage, #fd7e14) !important;
}

body.theme-v2-preview #erpModuleHelpModal[data-modal-module="marques"] .modal-header {
  background: var(--clr-marques, #20c997) !important;
}

body.theme-v2-preview #erpModuleHelpModal[data-modal-module="tickets"] .modal-header {
  background: var(--clr-tickets, #dc3545) !important;
}

body.theme-v2-preview #erpModuleHelpModal[data-modal-module="tasks"] .modal-header {
  background: var(--clr-tasks, #17a2b8) !important;
}

body.theme-v2-preview #erpModuleHelpModal[data-modal-module="procedures"] .modal-header {
  background: var(--clr-procedures, #ec4899) !important;
}

body.theme-v2-preview #erpModuleHelpModal[data-modal-module="faq"] .modal-header {
  background: var(--clr-faq, #E23C12) !important;
}

body.theme-v2-preview #erpModuleHelpModal[data-modal-module="devis"] .modal-header {
  background: var(--clr-devis, #17a2b8) !important;
}

body.theme-v2-preview #erpModuleHelpModal[data-modal-module="contrats"] .modal-header {
  background: var(--clr-contrats, #6366f1) !important;
}

body.theme-v2-preview #erpModuleHelpModal[data-modal-module="carnets"] .modal-header {
  background: var(--clr-carnets, #0b1b3a) !important;
}

body.theme-v2-preview #erpModuleHelpModal[data-modal-module="forecast"] .modal-header {
  background: var(--clr-forecast, #17a2b8) !important;
}

body.theme-v2-preview #erpModuleHelpModal[data-modal-module="factures"] .modal-header,
body.theme-v2-preview #erpModuleHelpModal[data-modal-module="relances"] .modal-header,
body.theme-v2-preview #erpModuleHelpModal[data-modal-module="notes-credit"] .modal-header,
body.theme-v2-preview #erpModuleHelpModal[data-modal-module="invoice-templates"] .modal-header,
body.theme-v2-preview #erpModuleHelpModal[data-modal-module="factures-intelligente"] .modal-header {
  background: var(--clr-factures, var(--bs-primary)) !important;
}

/* Financier: ne pas forcer la teinte Factures sur Relances */
body.theme-v2-preview #erpModuleHelpModal[data-modal-module="relances"] .modal-header {
  background: var(--clr-relances, var(--clr-factures, var(--bs-primary))) !important;
}

/* Aide — recurring-contracts : utiliser la couleur custom du module */
body.theme-v2-preview #erpModuleHelpModal[data-modal-module="recurring-contracts"] .modal-header {
  background: var(--clr-recurring-contracts, var(--clr-factures, #4169e1)) !important;
}

body.theme-v2-preview #erpModuleHelpModal[data-modal-module="statistics"] .modal-header {
  background: var(--clr-reporting, #0b7285) !important;
}

body.theme-v2-preview .btn-close {
  filter: invert(1);
}

/* #appModal : pattern cockpit erp-modal-close (barres CSS ::before/::after) — pas d'invert Bootstrap */
body.theme-v2-preview #appModal .modal-header .btn-close.erp-modal-close,
body.theme-v2-preview #appModal[data-modal-module] .modal-header .btn-close,
body.theme-v2-preview .modal#appModal .modal-header .btn-close.erp-modal-close {
  filter: none !important;
  background-image: none !important;
}

body.theme-v2-preview .alert-success,
body.theme-v2-preview .alert-info,
body.theme-v2-preview .alert-warning,
body.theme-v2-preview .alert-danger {
  border-width: 1px;
}

body.theme-v2-preview .nav-tabs .nav-link {
  color: rgba(255, 255, 255, 0.75);
  border-color: transparent;
}

body.theme-v2-preview .nav-tabs .nav-link.active {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--v2-stroke);
  color: #fff;
}

body.theme-v2-preview .breadcrumb {
  --bs-breadcrumb-divider-color: var(--v2-muted2);
}

body.theme-v2-preview .breadcrumb-item,
body.theme-v2-preview .breadcrumb-item a {
  color: var(--v2-muted);
}

body.theme-v2-preview .breadcrumb-item.active {
  color: rgba(255, 255, 255, 0.92);
}

/* Impression / PDF navigateur : fond clair pour éviter pages noires */
@media print {
  body.theme-v2-preview {
    background: #fff !important;
    color: #000 !important;
  }

  body.theme-v2-preview nav.modern-navbar,
  body.theme-v2-preview nav.professional-navbar {
    background: #fff !important;
    border-bottom: 1px solid #ccc !important;
    backdrop-filter: none !important;
  }

  body.theme-v2-preview .card,
  body.theme-v2-preview .table,
  body.theme-v2-preview .modal-content {
    background: #fff !important;
    color: #000 !important;
    border-color: #ccc !important;
    box-shadow: none !important;
  }
}
