/* Extension non destructive du CSS AdminKit */
:root { color-scheme: light; }
html[data-theme="dark"] { color-scheme: dark; --ew-bg:#171b26; --ew-card:#232938; --ew-text:#e8ecf5; --ew-muted:#aab4c6; --ew-border:#3a4354; }
html[data-theme="dark"] body,html[data-theme="dark"] .main,html[data-theme="dark"] .content { background:var(--ew-bg)!important; color:var(--ew-text)!important; }
html[data-theme="dark"] .navbar-bg,html[data-theme="dark"] .footer,html[data-theme="dark"] .card,html[data-theme="dark"] .dropdown-menu,html[data-theme="dark"] .list-group-item { background:var(--ew-card)!important; color:var(--ew-text)!important; border-color:var(--ew-border)!important; }
html[data-theme="dark"] .card-header,html[data-theme="dark"] .card-body,html[data-theme="dark"] .card-title,html[data-theme="dark"] h1,html[data-theme="dark"] h2,html[data-theme="dark"] h3,html[data-theme="dark"] h4,html[data-theme="dark"] h5,html[data-theme="dark"] h6,html[data-theme="dark"] p,html[data-theme="dark"] .nav-link,html[data-theme="dark"] .footer { color:var(--ew-text)!important; }
html[data-theme="dark"] .text-muted,html[data-theme="dark"] .text-secondary { color:var(--ew-muted)!important; }
html[data-theme="dark"] .form-control,html[data-theme="dark"] .form-select,html[data-theme="dark"] .input-group-text { background:#1b2030; border-color:var(--ew-border); color:var(--ew-text); }
html[data-theme="dark"] .form-control::placeholder { color:var(--ew-muted); }
html[data-theme="dark"] .table { --bs-table-color:var(--ew-text); --bs-table-bg:var(--ew-card); --bs-table-border-color:var(--ew-border); color:var(--ew-text); }
html[data-theme="dark"] .btn-outline-secondary { color:var(--ew-text); border-color:var(--ew-border); }
html[data-theme="dark"] .dropdown-item { color:var(--ew-text); }
html[data-theme="dark"] .dropdown-item:hover { background:#343d50; }
html[data-theme="dark"] .sidebar { background:#141b2c; }
html[data-theme="dark"] .sidebar-content { background:#141b2c; }
html[data-theme="dark"] .sidebar-link:hover { background:#24324a; }

/* Correctif v2.0.1 : panneaux Bienvenue / Informations en mode sombre */
html[data-theme="dark"] .card,
html[data-theme="dark"] .card > .card-header,
html[data-theme="dark"] .card > .card-body,
html[data-theme="dark"] .card > .card-footer {
  background-color: var(--ew-card) !important;
  color: var(--ew-text) !important;
  border-color: var(--ew-border) !important;
}
html[data-theme="dark"] .card .bg-white,
html[data-theme="dark"] .card .bg-light {
  background-color: var(--ew-card) !important;
}
html[data-theme="dark"] .card code { color: #a9bfff; }

/* Edelweiss Core v2 — interrupteur de thème compact et aligné */
.ew-topbar-actions { display:flex; flex-direction:row; align-items:center; gap:1rem; }
.ew-theme-toggle { display:inline-flex; align-items:center; justify-content:center; gap:.65rem; min-height:40px; padding:5px 11px 5px 7px; border:1px solid #dfe5ef; border-radius:999px; background:#f8faff; color:#475569; font:600 .82rem/1.2 inherit; font-size:.82rem; font-weight:600; white-space:nowrap; cursor:pointer; transition:background .2s,border-color .2s,color .2s,box-shadow .2s; }
.ew-theme-toggle:hover { background:#eef3ff; border-color:#b9c9e9; }
.ew-theme-toggle:focus-visible { outline:3px solid #7ba8ff; outline-offset:3px; }
.ew-theme-track { position:relative; display:inline-flex; align-items:center; justify-content:space-between; width:54px; height:29px; padding:0 7px; border-radius:999px; background:#dbe8ff; color:#526b94; flex-shrink:0; }
.ew-theme-track svg { width:14px; height:14px; z-index:1; }
.ew-theme-thumb { position:absolute; top:3px; left:3px; width:23px; height:23px; border-radius:50%; background:#fff; box-shadow:0 1px 4px #1a355333; transition:transform .22s ease; }
.ew-theme-label { display:inline-block; min-width:77px; text-align:left; }
.ew-profile-link { display:inline-flex!important; align-items:center; min-height:40px; }
html[data-theme="dark"] .ew-theme-toggle { background:#262e40; color:#e8ecf5; border-color:#414c62; }
html[data-theme="dark"] .ew-theme-toggle:hover { background:#303a50; border-color:#687b9b; }
html[data-theme="dark"] .ew-theme-track { background:#46547b; color:#e6ebff; }
html[data-theme="dark"] .ew-theme-thumb { transform:translateX(25px); background:#f5f7ff; }
@media(max-width:575.98px) { .ew-topbar-actions { gap:.35rem; } .ew-theme-toggle { padding:5px; } .ew-theme-label { display:none; } }

/* Edelweiss v2 — palette d'accents accessible, indépendante du mode de luminosité */
:root,html[data-color="blue"] { --ew-accent:#3b7ddd; --ew-accent-hover:#2c65b9; --ew-accent-rgb:59,125,221; }
html[data-color="indigo"] { --ew-accent:#6366f1; --ew-accent-hover:#4f46e5; --ew-accent-rgb:99,102,241; }
html[data-color="purple"] { --ew-accent:#8b5cf6; --ew-accent-hover:#7c3aed; --ew-accent-rgb:139,92,246; }
html[data-color="pink"] { --ew-accent:#db2777; --ew-accent-hover:#be185d; --ew-accent-rgb:219,39,119; }
html[data-color="red"] { --ew-accent:#dc3545; --ew-accent-hover:#b91c1c; --ew-accent-rgb:220,53,69; }
html[data-color="orange"] { --ew-accent:#ea580c; --ew-accent-hover:#c2410c; --ew-accent-rgb:234,88,12; }
html[data-color="teal"] { --ew-accent:#0d9488; --ew-accent-hover:#0f766e; --ew-accent-rgb:13,148,136; }
html[data-color="green"] { --ew-accent:#198754; --ew-accent-hover:#146c43; --ew-accent-rgb:25,135,84; }
html[data-theme="dark"][data-color="blue"] { --ew-accent:#76aaff; --ew-accent-hover:#94bdff; --ew-accent-rgb:118,170,255; }
html[data-theme="dark"][data-color="indigo"] { --ew-accent:#a5a6ff; --ew-accent-hover:#c0c1ff; --ew-accent-rgb:165,166,255; }
html[data-theme="dark"][data-color="purple"] { --ew-accent:#c4a2ff; --ew-accent-hover:#d7c2ff; --ew-accent-rgb:196,162,255; }
html[data-theme="dark"][data-color="pink"] { --ew-accent:#f58bbb; --ew-accent-hover:#ffadd2; --ew-accent-rgb:245,139,187; }
html[data-theme="dark"][data-color="red"] { --ew-accent:#ff8b92; --ew-accent-hover:#ffadb2; --ew-accent-rgb:255,139,146; }
html[data-theme="dark"][data-color="orange"] { --ew-accent:#ffac70; --ew-accent-hover:#ffc49c; --ew-accent-rgb:255,172,112; }
html[data-theme="dark"][data-color="teal"] { --ew-accent:#57d8c8; --ew-accent-hover:#8be6db; --ew-accent-rgb:87,216,200; }
html[data-theme="dark"][data-color="green"] { --ew-accent:#67d8a0; --ew-accent-hover:#91e8b9; --ew-accent-rgb:103,216,160; }
/* Bootstrap 5 + AdminKit : variables et composants d'accent */
html { --bs-primary:var(--ew-accent); --bs-primary-rgb:var(--ew-accent-rgb); }
html .btn-primary { --bs-btn-bg:var(--ew-accent); --bs-btn-border-color:var(--ew-accent); --bs-btn-hover-bg:var(--ew-accent-hover); --bs-btn-hover-border-color:var(--ew-accent-hover); --bs-btn-active-bg:var(--ew-accent-hover); --bs-btn-active-border-color:var(--ew-accent-hover); --bs-btn-focus-shadow-rgb:var(--ew-accent-rgb); }
html[data-theme="dark"] .btn-primary { --bs-btn-color:#101827; --bs-btn-hover-color:#101827; --bs-btn-active-color:#101827; }
html .btn-outline-primary { --bs-btn-color:var(--ew-accent); --bs-btn-border-color:var(--ew-accent); --bs-btn-hover-bg:var(--ew-accent); --bs-btn-hover-border-color:var(--ew-accent); }
html .text-primary,html a:not(.btn):not(.sidebar-link):not(.nav-link) { color:var(--ew-accent); }
html .bg-primary { background-color:var(--ew-accent)!important; }
html .border-primary { border-color:var(--ew-accent)!important; }
html .form-control:focus,html .form-select:focus { border-color:var(--ew-accent); box-shadow:0 0 0 .2rem rgba(var(--ew-accent-rgb),.2); }
html .sidebar-item.active > .sidebar-link { border-left-color:var(--ew-accent); }
html .sidebar-item.active > .sidebar-link i,html .sidebar-item.active > .sidebar-link svg { color:var(--ew-accent); }
html .page-link { color:var(--ew-accent); }
html .page-item.active .page-link { background:var(--ew-accent); border-color:var(--ew-accent); }
html .form-check-input:checked { background-color:var(--ew-accent); border-color:var(--ew-accent); }
html .progress-bar { background-color:var(--ew-accent); }
.ew-color-dropdown { display:flex; align-items:center; }
.ew-color-trigger { display:inline-flex; align-items:center; justify-content:center; gap:.5rem; min-height:40px; border:1px solid #dfe5ef; border-radius:999px; background:#f8faff; color:#475569; padding:6px 12px; font-size:.82rem; font-weight:600; cursor:pointer; }
.ew-color-trigger:hover { background:#eef3ff; }
.ew-color-trigger:focus-visible,.ew-color-option:focus-visible { outline:3px solid var(--ew-accent); outline-offset:3px; }
.ew-color-current { display:inline-block; width:16px; height:16px; border-radius:50%; background:var(--ew-accent); box-shadow:0 0 0 3px rgba(var(--ew-accent-rgb),.18); }
.ew-color-menu { width:250px; padding:14px; border-radius:14px; }
.ew-color-heading { font-weight:700; font-size:.85rem; margin-bottom:12px; }
.ew-color-grid { display:grid; grid-template-columns:repeat(4,1fr); gap:12px; }
.ew-color-option { width:42px; height:42px; border-radius:12px; background:transparent; border:2px solid transparent; display:grid; place-items:center; cursor:pointer; }
.ew-color-option span { width:26px; height:26px; border-radius:50%; background:var(--swatch); display:block; }
.ew-color-option:hover { background:rgba(var(--ew-accent-rgb),.1); }
.ew-color-option.is-active { border-color:var(--ew-accent); }
.ew-color-hint { font-size:.72rem; line-height:1.4; margin-top:12px; color:#6b7280; }
html[data-theme="dark"] .ew-color-trigger { background:#262e40; color:#e8ecf5; border-color:#414c62; }
html[data-theme="dark"] .ew-color-trigger:hover { background:#303a50; }
html[data-theme="dark"] .ew-color-hint { color:#aab4c6; }
@media(max-width:575.98px) { .ew-color-trigger { padding:7px 10px; } .ew-color-trigger-label { display:none; } .ew-topbar-actions { gap:.4rem; } }

/* Alertes sémantiques, indépendantes de la palette d'accent */
html { --ew-success-bg:#e9f8f0;--ew-success-border:#b7e5cd;--ew-success-fg:#12633d;--ew-success-icon:#198754;--ew-warning-bg:#fff6df;--ew-warning-border:#f4d995;--ew-warning-fg:#815400;--ew-warning-icon:#ad7100;--ew-danger-bg:#fff0f0;--ew-danger-border:#f2bfc2;--ew-danger-fg:#9f2631;--ew-danger-icon:#c93c47;--ew-info-bg:#eaf4ff;--ew-info-border:#bad8fb;--ew-info-fg:#225a90;--ew-info-icon:#2876b8; }
html[data-theme="dark"] { --ew-success-bg:#173a2e;--ew-success-border:#2d7658;--ew-success-fg:#b7f2d1;--ew-success-icon:#69d9a0;--ew-warning-bg:#40351c;--ew-warning-border:#82682b;--ew-warning-fg:#ffe2a0;--ew-warning-icon:#ffd074;--ew-danger-bg:#43252d;--ew-danger-border:#8e4654;--ew-danger-fg:#ffc6cd;--ew-danger-icon:#ff9ca8;--ew-info-bg:#1d354e;--ew-info-border:#3b658e;--ew-info-fg:#c1e3ff;--ew-info-icon:#8ac8ff; }
html .ew-alert.alert { display:flex;align-items:flex-start;gap:12px;padding:14px 16px;border:1px solid;border-radius:12px;box-shadow:none; }
html .ew-alert.alert-success {background:var(--ew-success-bg);border-color:var(--ew-success-border);color:var(--ew-success-fg)}
html .ew-alert.alert-warning {background:var(--ew-warning-bg);border-color:var(--ew-warning-border);color:var(--ew-warning-fg)}
html .ew-alert.alert-danger {background:var(--ew-danger-bg);border-color:var(--ew-danger-border);color:var(--ew-danger-fg)}
html .ew-alert.alert-info {background:var(--ew-info-bg);border-color:var(--ew-info-border);color:var(--ew-info-fg)}
html .ew-alert-icon {flex:0 0 28px;width:28px;height:28px;border-radius:50%;display:grid;place-items:center;font-weight:800;font-size:17px;border:1px solid currentColor;line-height:1}
html .alert-success .ew-alert-icon {color:var(--ew-success-icon)}
html .alert-warning .ew-alert-icon {color:var(--ew-warning-icon)}
html .alert-danger .ew-alert-icon {color:var(--ew-danger-icon)}
html .alert-info .ew-alert-icon {color:var(--ew-info-icon)}
html .ew-alert-body {flex:1;min-width:0}
html .ew-alert-title {display:block;font-size:.88rem;margin-bottom:2px}
html .ew-alert-message {font-size:.88rem;line-height:1.5;overflow-wrap:anywhere}
html .ew-alert.alert-dismissible {padding-right:3.25rem}
html[data-theme="dark"] .ew-alert .btn-close {filter:invert(1) grayscale(1);opacity:.75}
html .ew-secret-box {border:1px solid var(--ew-info-border);background:var(--ew-info-bg);color:var(--ew-info-fg);border-radius:10px;padding:12px;text-align:center;overflow-wrap:anywhere}
html .ew-secret-box code {color:inherit}


/* v2 — surfaces harmonisées : fond principal, sidebar, topbar et composants.
   Le choix d'accent est la seule entrée couleur ; color-mix conserve des surfaces neutres. */
html {
 --ew-layout-main:color-mix(in srgb,#f5f7fb 96%,var(--ew-accent) 4%);
 --ew-layout-topbar:color-mix(in srgb,#ffffff 95%,var(--ew-accent) 5%);
 --ew-layout-sidebar:color-mix(in srgb,#222e3c 88%,var(--ew-accent) 12%);
 --ew-layout-card:#ffffff;
 --ew-layout-border:color-mix(in srgb,#dfe5ed 93%,var(--ew-accent) 7%);
 --ew-layout-sidebar-hover:color-mix(in srgb,var(--ew-layout-sidebar) 88%,#ffffff 12%);
 --ew-layout-sidebar-active:color-mix(in srgb,var(--ew-layout-sidebar) 88%,var(--ew-accent) 12%);
}
html[data-theme="dark"] {
 --ew-layout-main:color-mix(in srgb,#171b26 94%,var(--ew-accent) 6%);
 --ew-layout-topbar:color-mix(in srgb,#232938 92%,var(--ew-accent) 8%);
 --ew-layout-sidebar:color-mix(in srgb,#141b2c 90%,var(--ew-accent) 10%);
 --ew-layout-card:color-mix(in srgb,#232938 96%,var(--ew-accent) 4%);
 --ew-layout-border:color-mix(in srgb,#3a4354 90%,var(--ew-accent) 10%);
 --ew-layout-sidebar-hover:color-mix(in srgb,var(--ew-layout-sidebar) 90%,#ffffff 10%);
 --ew-layout-sidebar-active:color-mix(in srgb,var(--ew-layout-sidebar) 86%,var(--ew-accent) 14%);
 --ew-bg:var(--ew-layout-main); --ew-card:var(--ew-layout-card); --ew-border:var(--ew-layout-border);
}
html body,html .main,html .content { background-color:var(--ew-layout-main)!important; }
html .navbar-bg,html .navbar.navbar-bg,html .navbar { background-color:var(--ew-layout-topbar)!important; }
html .sidebar,html .sidebar-content,html .sidebar-nav,html .sidebar-brand,html .sidebar-header,html .sidebar-item,html .sidebar-link { background-color:var(--ew-layout-sidebar)!important; }
html .sidebar-link:hover,html .sidebar-item:hover > .sidebar-link { background-color:var(--ew-layout-sidebar-hover)!important; }
html .sidebar-item.active > .sidebar-link,html .sidebar-item.active > .sidebar-link:hover {
 background-color:var(--ew-layout-sidebar-active)!important; border-left:3px solid var(--ew-accent)!important;
}
html[data-theme="dark"] .sidebar-link,html[data-theme="dark"] .sidebar-header,html[data-theme="dark"] .sidebar-brand { color:#c6cedd!important; }
html[data-theme="dark"] .sidebar-item.active > .sidebar-link { color:#ffffff!important; }
html[data-theme="dark"] .navbar-bg,html[data-theme="dark"] .navbar { border-color:var(--ew-layout-border)!important; }
html[data-theme="dark"] .card,html[data-theme="dark"] .card > .card-header,html[data-theme="dark"] .card > .card-body,html[data-theme="dark"] .card > .card-footer {
 background-color:var(--ew-layout-card)!important; border-color:var(--ew-layout-border)!important;
}
html[data-theme="dark"] .footer { background-color:var(--ew-layout-main)!important; }
html .ew-theme-toggle,html .ew-color-trigger { border-color:var(--ew-layout-border); }
html[data-theme="dark"] .ew-theme-toggle,html[data-theme="dark"] .ew-color-trigger { background:var(--ew-layout-card); }

/* Illustration de connexion et outil de cadrage */
.ew-login-illustration { width:100%; margin:0 auto 1.25rem; overflow:hidden; border-radius:12px; aspect-ratio:2/1; }
.ew-login-illustration img { width:100%; height:100%; object-fit:cover; display:block; }
.ew-crop-stage { max-width:600px; }
.ew-crop-stage canvas { width:100%; aspect-ratio:2/1; height:auto; display:block; border-radius:10px; cursor:grab; touch-action:none; border:1px solid var(--ew-accent); }
.ew-crop-stage canvas:active { cursor:grabbing; }

/* Logo optionnel de la sidebar */
.sidebar-brand { display:flex; align-items:center; gap:10px; min-width:0; }
.sidebar-brand .align-middle { min-width:0; overflow-wrap:anywhere; }
.ew-sidebar-logo { display:block; max-width:52px; max-height:46px; width:auto; height:auto; object-fit:contain; flex-shrink:0; }
.ew-logo-preview { display:flex; align-items:center; min-height:82px; padding:12px; background:var(--ew-sidebar-bg,#222e3c); border-radius:10px; }
.ew-logo-preview img { max-width:160px; max-height:72px; object-fit:contain; }

/* Correctif anti-débordement logo — sidebar + administration */
html .sidebar .sidebar-brand {
  display:flex;
  align-items:center;
  gap:10px;
  width:100%;
  max-width:100%;
  min-width:0;
  box-sizing:border-box;
  overflow:hidden;
}
html .sidebar .sidebar-brand .ew-sidebar-logo {
  display:block;
  flex:0 0 auto;
  width:auto !important;
  height:auto !important;
  max-width:44px !important;
  max-height:44px !important;
  object-fit:contain;
}
html .sidebar .sidebar-brand > .align-middle {
  display:block;
  flex:1 1 0;
  min-width:0;
  overflow:hidden;
  text-overflow:ellipsis;
  overflow-wrap:normal;
  white-space:nowrap;
}
html .ew-logo-preview {
  display:flex;
  align-items:center;
  justify-content:center;
  width:100%;
  max-width:100%;
  min-width:0;
  height:120px;
  padding:12px;
  overflow:hidden;
  box-sizing:border-box;
}
html .ew-logo-preview img {
  display:block;
  width:auto !important;
  height:auto !important;
  max-width:100% !important;
  max-height:96px !important;
  object-fit:contain;
}

/* Couleurs contextuelles Bootstrap en mode sombre */
html[data-theme="dark"] .text-primary { color: var(--ew-accent) !important; }
html[data-theme="dark"] .text-secondary { color: #b4becd !important; }
html[data-theme="dark"] .text-success { color: #67d8a0 !important; }
html[data-theme="dark"] .text-danger { color: #ff8b92 !important; }
html[data-theme="dark"] .text-warning { color: #ffd074 !important; }
html[data-theme="dark"] .text-info { color: #8ac8ff !important; }


/* Profil > Skills : lisibilité des badges cliquables en clair et en sombre.
   La règle générique des liens ne doit pas remplacer la couleur du texte des badges. */
html[data-theme="light"] a.badge.bg-primary,
html:not([data-theme="dark"]) a.badge.bg-primary {
    color: #ffffff !important;
}

html[data-theme="dark"] a.badge.bg-primary {
    color: #101827 !important;
}

html a.badge.bg-primary:hover,
html a.badge.bg-primary:focus-visible {
    text-decoration: none;
    filter: brightness(0.94);
}
