/* ==========================================================================
   public/styles/meptools-win11-override.css
   Couche finale d'harmonisation Windows 11 Pro (injectée en fin de <head>)
   Alignement 100 % sur le style & la police des fenêtres <mep-window> :
   - Police unique : 'Segoe UI Variable Text', 'Segoe UI', system-ui, sans-serif
   - Rendu net Windows 11 (-webkit-font-smoothing: auto, letter-spacing: 0)
   - Graisses apaisées (400 Regular pour l'UI, 600 SemiBold max pour titres/KPIs)
   - Contrôles WinUI 3 (coins 6px-8px, focus border-bottom 2px #0078D4 / #60CDFF)
   ========================================================================== */

html,
body {
  font-family: 'Segoe UI Variable Text', 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, sans-serif !important;
  -webkit-font-smoothing: auto;
  letter-spacing: 0;
}

body :where(
  div, span, p, a, button, input, select, textarea, label,
  table, thead, tbody, tr, th, td,
  h1, h2, h3, h4, h5, h6,
  ul, ol, li, nav, header, footer, aside, section, main, article, dialog, summary, details
):not(code):not(pre):not(kbd):not(samp):not(.font-mono):not(.mep-code-chip):not(.mt-project-pill) {
  font-family: 'Segoe UI Variable Text', 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, sans-serif !important;
  letter-spacing: 0 !important;
  -webkit-font-smoothing: auto;
}

/* Harmonisation des graisses façon Windows 11 Pro (zéro graisse 800/900 agressive) */
body :where(button, input, select, textarea, label, p, li, td, a, span):not(strong):not(b):not(.mep-kpi-value) {
  font-weight: 400;
}

body :where(h1, h2, h3, h4, h5, h6, th, strong, b, .mep-kpi-value, .tm-brand-title) {
  font-weight: 600 !important;
}

/* Contrôles WinUI 3 uniformisés sur tous les modules */
input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]),
select,
textarea {
  border-radius: 6px !important;
}

input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):focus,
select:focus,
textarea:focus {
  outline: none !important;
  border-bottom: 2px solid var(--mep-ds-accent, #0078D4) !important;
}

button {
  border-radius: 6px;
}

/* Bouton primaire Win11 Pro garanti (contraste blanc sur bleu #0078D4 sur tous les modules) */
.mep-win11-primary-btn {
  background: #0078D4 !important;
  color: #FFFFFF !important;
  border: 1px solid #0078D4 !important;
  border-radius: 6px !important;
  padding: 5px 12px !important;
  font-weight: 600 !important;
  cursor: pointer;
}
.mep-win11-primary-btn:hover {
  background: #106EBE !important;
}

/* Modales & dialogues Win11 */
dialog,
.modal-dialog,
.modal-card,
.mep-modal-card,
.viewer-modal-card {
  border-radius: 12px !important;
  box-shadow: var(--mep-ds-shadow-win11, 0 18px 48px rgba(0, 0, 0, 0.22)) !important;
}

/* Scrollbars fines Windows 11 Pro (toutes fenêtres & modules) */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(120, 120, 120, 0.32);
  border-radius: 999px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(120, 120, 120, 0.54);
}

/* ==========================================================================
   PONT UNIVERSEL WINDOWS 11 PRO / MICA LIGHT ([data-theme="light"])
   Harmonise automatiquement tous les modules & studios hérités (CctpMEP,
   AdmMEP, GanttMEP, AccepMEP, Appels d'Offres, Outils MEP...) sur la charte
   Windows 11 Pro sans texte blanc sur fond blanc.
   ========================================================================== */
[data-theme="light"] {
  --bg-darkest: #F3F3F3 !important;
  --bg-void: #F3F3F3 !important;
  --bg-base: #F3F3F3 !important;
  --bg-surface: #FFFFFF !important;
  --bg-card: #FFFFFF !important;
  --bg-elevated: #F9F9F9 !important;
  --bg-surface-elevated: #F9F9F9 !important;
  --bg-input: #FFFFFF !important;
  --border-normal: rgba(0, 0, 0, 0.12) !important;
  --border-subtle: rgba(0, 0, 0, 0.07) !important;
  --border-focus: #0078D4 !important;
  --accent-blue: #0078D4 !important;
  --accent-cyan: #005FB8 !important;
  --text-main: #1A1A1A !important;
  --text-muted: #5F5F5F !important;
  --text-dim: #6B6B6B !important;
  --ao-bg: #F3F3F3 !important;
  --ao-surface: #FFFFFF !important;
  --ao-border: rgba(0, 0, 0, 0.10) !important;
  --ao-text: #1A1A1A !important;
  --ao-muted: #5F5F5F !important;
  --ao-cyan: #0078D4 !important;
}

/* Portail Appels d'Offres en thème clair Windows 11 Pro */
[data-theme="light"] .ao-header {
  background: rgba(243, 243, 243, 0.92) !important;
  border-bottom-color: rgba(0, 0, 0, 0.08) !important;
}
[data-theme="light"] .ao-nav a {
  color: #434343 !important;
}
[data-theme="light"] .ao-nav a:hover,
[data-theme="light"] .ao-nav a[aria-current="page"] {
  color: #0078D4 !important;
}
[data-theme="light"] body:has(.ao-header) {
  background-color: #F3F3F3 !important;
  background-image: none !important;
  color: #1A1A1A !important;
}
[data-theme="light"] .ao-h1 {
  color: #1A1A1A !important;
}
[data-theme="light"] .ao-sub,
[data-theme="light"] .ao-card-meta,
[data-theme="light"] .ao-status-bar {
  color: #5F5F5F !important;
}
[data-theme="light"] .ao-win-panel {
  background: #FFFFFF !important;
  border-color: rgba(0, 0, 0, 0.10) !important;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06) !important;
}
[data-theme="light"] .ao-win-titlebar {
  background: #F9F9F9 !important;
  border-bottom-color: rgba(0, 0, 0, 0.08) !important;
  color: #1A1A1A !important;
}
[data-theme="light"] .ao-filters {
  border-bottom-color: rgba(0, 0, 0, 0.08) !important;
}
[data-theme="light"] .ao-input,
[data-theme="light"] .ao-select {
  background: #FFFFFF !important;
  color: #1A1A1A !important;
  border-color: rgba(0, 0, 0, 0.16) !important;
}
[data-theme="light"] .ao-btn-primary {
  background: #0078D4 !important;
  border-color: #0078D4 !important;
  color: #FFFFFF !important;
}
[data-theme="light"] .ao-btn-ghost {
  background: #F9F9F9 !important;
  border-color: rgba(0, 0, 0, 0.16) !important;
  color: #1A1A1A !important;
}
[data-theme="light"] .ao-btn-ghost:hover {
  background: #EFF6FC !important;
  border-color: #0078D4 !important;
  color: #0078D4 !important;
}
[data-theme="light"] .ao-card {
  background: #F9F9F9 !important;
  border-color: rgba(0, 0, 0, 0.10) !important;
  color: #1A1A1A !important;
}
[data-theme="light"] .ao-card:hover {
  background: #FFFFFF !important;
  border-color: #0078D4 !important;
}
[data-theme="light"] .ao-card-title {
  color: #1A1A1A !important;
}
[data-theme="light"] .ao-card-summary {
  color: #434343 !important;
}
[data-theme="light"] .ao-card-actions {
  border-top-color: rgba(0, 0, 0, 0.08) !important;
}
[data-theme="light"] .ao-badge {
  color: #434343 !important;
  border-color: rgba(0, 0, 0, 0.12) !important;
  background: #FFFFFF !important;
}
[data-theme="light"] .ao-badge.is-internal {
  background: #DFF6DD !important;
  border-color: #A7DFB0 !important;
  color: #0F7B0F !important;
}
[data-theme="light"] .ao-badge.is-external {
  background: #EFF6FC !important;
  border-color: #CFE4FA !important;
  color: #005FB8 !important;
}
[data-theme="light"] .ao-badge.is-cat {
  background: #EEF2FF !important;
  border-color: #C7D2FE !important;
  color: #3730A3 !important;
}

/* Harmonisation universelle des tableaux WinUI 3 */
[data-theme="light"] table thead th {
  background-color: #F9F9F9;
  color: #434343;
  border-bottom: 1px solid rgba(0, 0, 0, 0.10);
}
[data-theme="light"] table tbody td {
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

/* Finition Windows 11 Pro pour la modale B2B & folios SynoMEP */
[data-theme="light"] .studio-b2b-pane,
[data-theme="light"] .b2b-kpi,
[data-theme="light"] .b2b-table,
[data-theme="light"] .b2b-search-input {
  background: #FFFFFF !important;
  color: #1A1A1A !important;
  border-color: rgba(0, 0, 0, 0.12) !important;
}
[data-theme="light"] .b2b-table th {
  background: #F9F9F9 !important;
  color: #434343 !important;
}

/* ZÉRO TEXTE NOIR SUR FOND NOIR en Thème Clair (CctpMEP, GanttMEP, AccepMEP) */
[data-theme="light"] .pane-hdr,
[data-theme="light"] .clause-compiled-preview,
[data-theme="light"] .clause-template-edit,
[data-theme="light"] .option-choice,
[data-theme="light"] .ai-issue-card,
[data-theme="light"] .lot-tab,
[data-theme="light"] .pic-lot-loading-card,
[data-theme="light"] .print-modal-toolbar,
[data-theme="light"] .gantt-scroll-wrap,
[data-theme="light"] .gantt-header-row,
[data-theme="light"] .timeline-4d-card,
[data-theme="light"] .timmep-dialog,
[data-theme="light"] .dlg-footer,
[data-theme="light"] .section-hdr,
[data-theme="light"] .coprec-obs-row,
[data-theme="light"] .opr-toolbar,
[data-theme="light"] .opr-form-card,
[data-theme="light"] .snag-status-select,
[data-theme="light"] .snag-compare-card,
[data-theme="light"] .snag-compare-col,
[data-theme="light"] .btn-check-status,
[data-theme="light"] .opr-filter-btn,
[data-theme="light"] .btn-photo-stage {
  background: #FFFFFF !important;
  background-color: #FFFFFF !important;
  color: #1A1A1A !important;
  border-color: rgba(0, 0, 0, 0.12) !important;
}
[data-theme="light"] .lot-tab.active,
[data-theme="light"] .opr-filter-btn.active {
  background: #0078D4 !important;
  color: #FFFFFF !important;
  border-color: #0078D4 !important;
}
[data-theme="light"] .metric-bar-track,
[data-theme="light"] .t4d-progress-track {
  background: rgba(0, 0, 0, 0.08) !important;
}

/* ZÉRO TEXTE NOIR SUR FOND NOIR en Thème Sombre Windows 11 Pro ([data-theme="dark"]) */
[data-theme="dark"] {
  --bg-darkest: #202020 !important;
  --bg-void: #202020 !important;
  --bg-base: #202020 !important;
  --bg-surface: #2B2B2B !important;
  --bg-card: #2B2B2B !important;
  --bg-elevated: #323232 !important;
  --bg-surface-elevated: #323232 !important;
  --bg-input: #252525 !important;
  --border-normal: rgba(255, 255, 255, 0.14) !important;
  --border-subtle: rgba(255, 255, 255, 0.08) !important;
  --text-main: #F5F5F5 !important;
  --text-muted: #C8C8C8 !important;
  --text-dim: #A6A6A6 !important;
}
[data-theme="dark"] body {
  color: #F5F5F5;
}
[data-theme="dark"] input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]),
[data-theme="dark"] select,
[data-theme="dark"] textarea {
  background-color: #252525;
  color: #F5F5F5;
  border-color: rgba(255, 255, 255, 0.16);
}
[data-theme="dark"] table thead th {
  background-color: #252525;
  color: #E2E8F0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}
[data-theme="dark"] table tbody td {
  color: #F5F5F5;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
