/* ==========================================================================
   public/styles/meptools-design-system.css
   Socle CSS Maître Unique — MEPtools.ia (Charte Windows 11 Pro / WinUI 3 / Mica)
   Partagé entre le site vitrine (landing.html), le Bureau (/app) et les 16 modules.
   ========================================================================== */

:root,
[data-theme="light"] {
  /* Surfaces Windows 11 Pro (Mica / Card / Acrylic) */
  --mep-ds-bg: #F3F3F3;
  --mep-ds-surface: #FFFFFF;
  --mep-ds-surface-subtle: #F9F9F9;
  --mep-ds-acrylic: rgba(243, 243, 243, 0.86);
  --mep-ds-border: rgba(0, 0, 0, 0.08);
  --mep-ds-border-strong: rgba(0, 0, 0, 0.16);
  --mep-ds-text: #1A1A1A;
  --mep-ds-text-secondary: #434343;
  --mep-ds-text-muted: #5F5F5F;

  /* Accent Windows 11 Pro */
  --mep-ds-accent: #0078D4;
  --mep-ds-accent-hover: #106EBE;
  --mep-ds-accent-soft: rgba(0, 120, 212, 0.10);
  --mep-ds-close-hover: #E81123;

  /* Géométrie & Ombres WinUI 3 */
  --mep-ds-radius-sm: 6px;
  --mep-ds-radius-md: 8px;
  --mep-ds-radius-lg: 12px;
  --mep-ds-shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.06);
  --mep-ds-shadow-md: 0 8px 24px rgba(0, 0, 0, 0.12);
  --mep-ds-shadow-win11: 0 18px 48px rgba(0, 0, 0, 0.22);
  --mep-ds-topbar-h: 40px;

  /* Typographie système Windows 11 Pro */
  --mep-ds-font: "Segoe UI Variable Text", "Segoe UI Variable", "Segoe UI", "Inter", system-ui, -apple-system, sans-serif;
  --mep-ds-mono: "JetBrains Mono", "Cascadia Code", Consolas, ui-monospace, monospace;

  /* Variables Win11 consommées par <mep-window> et mep-window-shell.css */
  --win11-border: rgba(0, 0, 0, 0.08);
  --win11-border-active: rgba(0, 0, 0, 0.14);
  --win11-mica-bg: rgba(243, 243, 243, 0.88);
  --win11-mica-inactive-bg: rgba(243, 243, 243, 0.74);
  --win11-acrylic-bg: rgba(249, 249, 249, 0.88);
  --win11-accent: #0078D4;
  --win11-close-hover: #E81123;
  --win11-shadow-active: 0 18px 48px rgba(0, 0, 0, 0.22);
  --win11-shadow-inactive: 0 8px 24px rgba(0, 0, 0, 0.12);
}

[data-theme="dark"] {
  /* Surfaces Windows 11 Pro Sombre (Mica #202020 / Card #2B2B2B) */
  --mep-ds-bg: #202020;
  --mep-ds-surface: #2B2B2B;
  --mep-ds-surface-subtle: #252525;
  --mep-ds-acrylic: rgba(32, 32, 32, 0.86);
  --mep-ds-border: rgba(255, 255, 255, 0.14);
  --mep-ds-border-strong: rgba(255, 255, 255, 0.22);
  --mep-ds-text: #F5F5F5;
  --mep-ds-text-secondary: #D4D4D4;
  --mep-ds-text-muted: #A6A6A6;

  /* Accent Windows 11 Pro Sombre */
  --mep-ds-accent: #60CDFF;
  --mep-ds-accent-hover: #4CC2FF;
  --mep-ds-accent-soft: rgba(96, 205, 255, 0.14);
  --mep-ds-close-hover: #E81123;

  --mep-ds-shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.28);
  --mep-ds-shadow-md: 0 12px 32px rgba(0, 0, 0, 0.40);
  --mep-ds-shadow-win11: 0 18px 48px rgba(0, 0, 0, 0.42);

  --win11-border: rgba(255, 255, 255, 0.12);
  --win11-border-active: rgba(255, 255, 255, 0.18);
  --win11-mica-bg: rgba(32, 32, 32, 0.88);
  --win11-mica-inactive-bg: rgba(32, 32, 32, 0.72);
  --win11-acrylic-bg: rgba(43, 43, 43, 0.88);
  --win11-accent: #60CDFF;
  --win11-close-hover: #E81123;
  --win11-shadow-active: 0 18px 48px rgba(0, 0, 0, 0.45);
  --win11-shadow-inactive: 0 10px 28px rgba(0, 0, 0, 0.28);
}

/* Typographie & Scrollbars Windows 11 Pro */
body {
  font-family: var(--mep-ds-font);
}

/* Contrôles WinUI 3 globaux (Inputs, Selects, Textareas, Boutons) */
input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]),
select,
textarea {
  font-family: var(--mep-ds-font);
  border-radius: var(--mep-ds-radius-sm);
  transition: border-color 0.14s ease, box-shadow 0.14s ease, background-color 0.14s ease;
}

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

button,
.cad-btn-primary,
.cad-btn-secondary,
.tm-btn,
.mep-btn {
  font-family: var(--mep-ds-font);
  border-radius: var(--mep-ds-radius-sm);
}

/* Indicateur actif WinUI 3 en pilule 3px sur les onglets & liens actifs */
.mt-mod-link,
.tm-tab,
.mep-tab,
[role="tab"] {
  position: relative;
}

.mt-mod-link.is-active::after,
.tm-tab.is-active::after,
.mep-tab.active::after,
[role="tab"][aria-selected="true"]::after {
  content: "";
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 0;
  height: 3px;
  border-radius: 999px;
  background: var(--mep-ds-accent);
}

/* Modales & Dialogues centrés WinUI 3 (fond flouté + coins 12px + ombre Win11) */
dialog,
.modal-backdrop,
.mep-modal-backdrop,
.viewer-modal-backdrop,
#mep-pricing-auth-modal {
  backdrop-filter: blur(12px) saturate(140%);
  -webkit-backdrop-filter: blur(12px) saturate(140%);
}

dialog,
.modal-dialog,
.modal-card,
.mep-modal-card,
.viewer-modal-card {
  border-radius: var(--mep-ds-radius-lg) !important;
  border: 1px solid var(--mep-ds-border) !important;
  box-shadow: var(--mep-ds-shadow-win11) !important;
  background: var(--mep-ds-surface);
  color: var(--mep-ds-text);
}

/* Marque MEPtools unifiée (zéro style inline) */
.mep-brand-logo-img {
  height: 44px;
  width: auto;
  flex-shrink: 0;
  filter: drop-shadow(0 4px 10px rgba(2, 6, 23, 0.24));
  transition: transform 0.18s ease;
}

.mep-brand-wordmark {
  display: inline-flex;
  align-items: baseline;
  font-family: var(--mep-ds-font);
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1;
}

.mep-brand-wordmark-mep {
  color: var(--mep-ds-accent);
}

.mep-brand-wordmark-tools {
  color: var(--mep-ds-text);
}

/* Barre de navigation unifiée Fluent Acrylic (meptools-navbar.js — 40px Win11) */
#meptools-unified-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--mep-ds-topbar-h);
  background: var(--mep-ds-acrylic);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border-bottom: 1px solid var(--mep-ds-border);
  color: var(--mep-ds-text);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 12px;
  font-family: var(--mep-ds-font);
  font-size: 12px;
  z-index: 99990;
  box-shadow: var(--mep-ds-shadow-sm);
}

body.has-meptools-unified-nav {
  padding-top: var(--mep-ds-topbar-h);
}

@media (max-width: 960px) {
  #meptools-unified-nav {
    position: sticky;
    height: auto;
    min-height: var(--mep-ds-topbar-h);
    flex-wrap: wrap;
    padding: 6px 10px;
    row-gap: 6px;
  }

  #meptools-unified-nav .mt-nav-left,
  #meptools-unified-nav .mt-nav-right {
    flex-wrap: wrap;
  }

  body.has-meptools-unified-nav {
    padding-top: 0;
  }
}

/* Anti-double barre de titre en mode ?embed=1 (fenêtres MDI du Bureau) */
html.mep-embed-mode #meptools-unified-nav,
html[data-embed="1"] #meptools-unified-nav,
body.nm-embedded #meptools-unified-nav,
html.mep-embed-mode .hvac-topbar,
html[data-embed="1"] .hvac-topbar,
html.mep-embed-mode .tm-brand,
html[data-embed="1"] .tm-brand,
/* Masque les headers globaux redondants en embed — PAS le ribbon VisioMEP Zoom. */
html.mep-embed-mode body > header:first-of-type:not(.tm-topbar):not(.visio-topbar):not(.visio-ribbon),
html[data-embed="1"] body > header:first-of-type:not(.tm-topbar):not(.visio-topbar):not(.visio-ribbon) {
  display: none !important;
}

/* Empêche #meptools-unified-nav (40px) de recouvrir la barre d'outils SynMEP (.studio-topbar) */
body.has-meptools-unified-nav .studio-topbar {
  top: var(--mep-ds-topbar-h) !important;
}

body.has-meptools-unified-nav #synmep-folios-bacs-bar {
  margin-top: 42px;
}

html.mep-embed-mode body.has-meptools-unified-nav,
html[data-embed="1"] body.has-meptools-unified-nav,
body.nm-embedded.has-meptools-unified-nav {
  padding-top: 0 !important;
}

.mt-nav-left,
.mt-nav-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.mt-btn-desktop {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: var(--mep-ds-radius-sm);
  background: var(--mep-ds-accent);
  color: #ffffff;
  font-weight: 600;
  font-size: 12px;
  text-decoration: none;
  border: 1px solid transparent;
  transition: background 0.15s ease;
}

[data-theme="dark"] .mt-btn-desktop {
  color: #0B192C;
}

.mt-btn-desktop:hover {
  background: var(--mep-ds-accent-hover);
}

.mt-project-pill {
  font-family: var(--mep-ds-mono);
  font-size: 11px;
  font-weight: 700;
  color: var(--mep-ds-accent);
  background: var(--mep-ds-accent-soft);
  border: 1px solid var(--mep-ds-border-strong);
  border-radius: 999px;
  padding: 2px 9px;
}

.mt-nav-modules {
  display: flex;
  align-items: center;
  gap: 3px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 2px 4px;
  background: var(--mep-ds-surface-subtle);
  border: 1px solid var(--mep-ds-border);
  border-radius: var(--mep-ds-radius-md);
}

.mt-nav-modules::-webkit-scrollbar {
  display: none;
}

.mt-mod-link {
  color: var(--mep-ds-text-secondary);
  text-decoration: none;
  font-size: 11.5px;
  font-weight: 500;
  padding: 5px 8px;
  border-radius: var(--mep-ds-radius-sm);
  white-space: nowrap;
  transition: background 0.12s ease, color 0.12s ease;
}

.mt-mod-link:hover {
  background: var(--mep-ds-accent-soft);
  color: var(--mep-ds-accent);
}

.mt-mod-link.is-active {
  background: var(--mep-ds-surface);
  color: var(--mep-ds-accent);
  font-weight: 700;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

/* Grille de présentation des 16 applications (4×4 symétrique sur desktop, style Bureau Squircle) */
.mep-suite-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}
@media (max-width: 1080px) {
  .mep-suite-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (max-width: 600px) {
  .mep-suite-grid {
    grid-template-columns: 1fr;
  }
}

.mep-suite-tile {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--mep-ds-surface);
  border: 1px solid var(--mep-ds-border);
  border-radius: var(--mep-ds-radius-lg);
  padding: 16px;
  text-decoration: none;
  color: var(--mep-ds-text);
  box-shadow: var(--mep-ds-shadow-sm);
  transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}

.mep-suite-tile:hover {
  transform: translateY(-2px);
  border-color: var(--mep-ds-accent);
  box-shadow: var(--mep-ds-shadow-md);
}

.mep-suite-tile.is-featured {
  border-color: var(--mep-ds-accent);
  background: linear-gradient(180deg, var(--mep-ds-accent-soft) 0%, var(--mep-ds-surface) 45%);
}

.mep-suite-tile-hdr {
  display: flex;
  align-items: center;
  gap: 12px;
}

.mep-suite-tile-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--mep-ds-text);
}

.mep-suite-tile-badge {
  display: inline-block;
  margin-top: 2px;
  font-family: var(--mep-ds-mono);
  font-size: 10px;
  font-weight: 700;
  color: var(--mep-ds-accent);
}

.mep-suite-tile-desc {
  margin: 0;
  font-size: 12px;
  line-height: 1.45;
  color: var(--mep-ds-text-muted);
}

.mep-squircle-badge {
  width: 44px;
  height: 44px;
  border-radius: 11px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.16), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

/* =========================================================================
   GARDE-FOU UNIVERSEL DE CONTRASTE FOND / TEXTE (100 % DES 16 MODULES)
   Élimine tout texte blanc sur fond blanc, noir sur fond noir, ou couleur sur même couleur
   ========================================================================= */
html[data-theme="light"] :is(button, a)[style*="background:#0067"],
html[data-theme="light"] :is(button, a)[style*="background: #0067"],
html[data-theme="light"] :is(button, a)[style*="background:#0078"],
html[data-theme="light"] :is(button, a)[style*="background: #0078"],
html[data-theme="light"] :is(button, a)[style*="background:#1d4ed8"],
html[data-theme="light"] :is(button, a)[style*="background:#1e3a8a"],
html[data-theme="light"] :is(button, a)[style*="background:#1e40af"],
html[data-theme="light"] :is(button, a)[style*="background:#2563eb"],
html[data-theme="light"] :is(button, a)[style*="background:#7c3aed"],
html[data-theme="light"] :is(button, a)[style*="background:#0891b2"],
html[data-theme="light"] :is(button, a)[style*="background:#059669"],
html[data-theme="light"] :is(button, a)[style*="background:#0f766e"],
html[data-theme="light"] :is(button, a)[style*="background:#065f46"],
html[data-theme="light"] :is(button, a)[style*="background:#dc2626"],
html[data-theme="light"] :is(button, a)[style*="background:#ea580c"],
html[data-theme="light"] :is(button, a)[style*="background:#0f172a"],
html[data-theme="light"] :is(button, a)[style*="background:#1e293b"] {
  color: #FFFFFF !important;
}

html[data-theme="light"] :is(button, a)[style*="background:#0067"] *,
html[data-theme="light"] :is(button, a)[style*="background:#0078"] *,
html[data-theme="light"] :is(button, a)[style*="background:#1d4ed8"] *,
html[data-theme="light"] :is(button, a)[style*="background:#1e3a8a"] *,
html[data-theme="light"] :is(button, a)[style*="background:#1e40af"] *,
html[data-theme="light"] :is(button, a)[style*="background:#2563eb"] *,
html[data-theme="light"] :is(button, a)[style*="background:#7c3aed"] *,
html[data-theme="light"] :is(button, a)[style*="background:#0891b2"] *,
html[data-theme="light"] :is(button, a)[style*="background:#059669"] *,
html[data-theme="light"] :is(button, a)[style*="background:#0f766e"] *,
html[data-theme="light"] :is(button, a)[style*="background:#dc2626"] *,
html[data-theme="light"] :is(button, a)[style*="background:#ea580c"] *,
html[data-theme="light"] :is(button, a)[style*="background:#0f172a"] *,
html[data-theme="light"] :is(button, a)[style*="background:#1e293b"] * {
  color: #FFFFFF !important;
}

/* En-têtes de modales sombres explicites : toujours texte blanc #FFFFFF */
.gm-modal-hdr, .gm-modal-hdr *,
.print-modal-toolbar, .print-modal-toolbar strong,
#adm-toast, #picmep-toast {
  color: #FFFFFF !important;
}

/* Contrôles de formulaire lisibles en mode clair & sombre sur tous les modules */
html[data-theme="light"] body:not(#dao-a4-body):not(#gabarit-a4-body) :is(input:not([type="checkbox"]):not([type="radio"]):not([type="color"]), select, textarea) {
  background-color: #FFFFFF;
  color: #0F172A;
  border-color: #CBD5E1;
}

html[data-theme="dark"] body:not(#dao-a4-body):not(#gabarit-a4-body) :is(input:not([type="checkbox"]):not([type="radio"]):not([type="color"]), select, textarea) {
  background-color: #1E2433;
  color: #F8FAFC;
  border-color: #3B465E;
}

/* Neutralisation des bandeaux sombres inline hérités en Mode Clair (hors modales/toasts/boutons) */
html[data-theme="light"] :is(div, section, aside, p)[style*="background: #14171c"],
html[data-theme="light"] :is(div, section, aside, p)[style*="background:#14171c"],
html[data-theme="light"] :is(div, section, aside, p)[style*="background:#111419"],
html[data-theme="light"] :is(div, section, aside, p)[style*="background:#141923"] {
  background: #F1F5F9 !important;
  color: #0F172A !important;
  border-color: #CBD5E1 !important;
}


/* === DIFFÉRENCIATION VISUELLE AFFAIRE ACTIVE VS AFFAIRES DÉSACTIVÉES (TOUS MODULES) === */
option.mt-proj-opt-active {
  color: #005FB8 !important;
  font-weight: 700 !important;
  background-color: #EFF6FF !important;
}
option.mt-proj-opt-inactive,
option.mt-proj-opt-placeholder {
  color: #94A3B8 !important;
  font-weight: 300 !important;
}
