/*
 * E-JAR 2.0 — Correctif final de contraste + menu de gestion.
 * Règle métier permanente : fond foncé = écriture claire ; fond clair = écriture foncée.
 * Cette feuille est chargée en dernier afin de neutraliser les anciennes surcharges EDARA/E-Jar.
 */
:root {
    --ejar-contrast-dark: #070707;
    --ejar-contrast-dark-2: #17130b;
    --ejar-contrast-blue: #d4af37;
    --ejar-contrast-mid: #92701b;
    --ejar-contrast-light: #fbf8f0;
    --ejar-contrast-soft: #f4ecd9;
    --ejar-contrast-text: #17140e;
    --ejar-contrast-muted: #746e62;
    --ejar-contrast-white: #ffffff;
    --ejar-contrast-border: rgba(146, 112, 27, .24);
    --ejar-contrast-dark-gradient: radial-gradient(circle at 12% 0%, rgba(212, 175, 55, .20), transparent 34%), linear-gradient(135deg, #050505 0%, #17130b 62%, #2a210e 100%);
    --ejar-contrast-primary-gradient: linear-gradient(135deg, #070707 0%, #59430f 58%, #d4af37 100%);
    --ejar-contrast-light-gradient: linear-gradient(180deg, #ffffff 0%, #fbf8f0 100%);
}

/* Socle clair : toutes les interfaces E-Jar partent d'un texte foncé lisible. */
html body :where(.ejar-dashboard, .ejar-admin-page-shell, .ejar-agence-page-shell, .ejar-client-page-shell, .ejar-registration-page, .ejar-public, .ejar-fixed-user-menu) {
    color: var(--ejar-contrast-text) !important;
    -webkit-text-fill-color: var(--ejar-contrast-text) !important;
}

/* Panneaux et cartes sur fond clair. */
html body :where(.ejar-dashboard, .ejar-admin-page-shell, .ejar-agence-page-shell, .ejar-client-page-shell, .ejar-registration-page, .ejar-public) :where(
    .ejar-card,
    .ejar-panel,
    .ejar-light-panel,
    .ejar-form,
    .ejar-modal-content,
    .ejar-stat-card:not(.is-dark),
    .ejar-table,
    table,
    tbody,
    tfoot,
    tr,
    td,
    .ejar-admin-nav-pill,
    .ejar-admin-nav-drawer,
    .ejar-admin-nav-group,
    .ejar-admin-nav-group-links,
    .ejar-public-hero-card,
    .ejar-public-feature-card,
    .ejar-public-search,
    .ejar-public-info,
    .ejar-public-empty,
    .ejar-public-vehicle-card,
    .ejar-public-details,
    .ejar-public-booking,
    .ejar-public-specs span,
    .ejar-public-estimate,
    .ejar-subtabs-card,
    .ejar-edit-panel-card,
    .ejar-smart-filter-panel,
    .ejar-table-toolbar,
    .ejar-control-center,
    .ejar-diagnostic-check,
    .ejar-diagnostic-action-form
) {
    color: var(--ejar-contrast-text) !important;
    -webkit-text-fill-color: var(--ejar-contrast-text) !important;
}

html body :where(.ejar-dashboard, .ejar-admin-page-shell, .ejar-agence-page-shell, .ejar-client-page-shell, .ejar-registration-page, .ejar-public) :where(
    .ejar-card,
    .ejar-panel,
    .ejar-light-panel,
    .ejar-form,
    .ejar-modal-content,
    .ejar-stat-card:not(.is-dark),
    .ejar-table,
    table,
    td,
    .ejar-admin-nav-pill,
    .ejar-admin-nav-drawer,
    .ejar-admin-nav-group,
    .ejar-public-hero-card,
    .ejar-public-feature-card,
    .ejar-public-search,
    .ejar-public-info,
    .ejar-public-empty,
    .ejar-public-vehicle-card,
    .ejar-public-details,
    .ejar-public-booking,
    .ejar-subtabs-card,
    .ejar-edit-panel-card,
    .ejar-smart-filter-panel,
    .ejar-table-toolbar,
    .ejar-control-center
) :where(h1, h2, h3, h4, h5, h6, p, span, strong, small, label, li, dt, dd, em, b, td, th) {
    color: var(--ejar-contrast-text) !important;
    -webkit-text-fill-color: var(--ejar-contrast-text) !important;
}

/* Textes secondaires sur fond clair : foncés mais légèrement adoucis. */
html body :where(.ejar-dashboard, .ejar-public, .ejar-admin-page-shell, .ejar-agence-page-shell, .ejar-client-page-shell) :where(
    .ejar-muted,
    .ejar-public-muted,
    .ejar-public-form-note,
    .ejar-public-vehicle-summary,
    .ejar-admin-help-text,
    .ejar-diagnostic-action-desc,
    .ejar-diagnostic-actions-intro,
    .ejar-card small,
    .ejar-tool-card small:not(:hover)
) {
    color: var(--ejar-contrast-muted) !important;
    -webkit-text-fill-color: var(--ejar-contrast-muted) !important;
}

/* Fonds foncés identifiés : texte clair obligatoire. */
html body :where(
    .ejar-dashboard-header,
    .ejar-ui-admin-header,
    .ejar-page-hero,
    .ejar-admin-hero,
    .ejar-control-hero,
    .ejar-dark-panel,
    .ejar-panel-dark,
    .ejar-card-dark,
    .ejar-stat-card.is-dark,
    .ejar-public .ejar-on-dark-panel,
    .ejar-public-hero,
    .ejar-public-catalog-hero,
    .ejar-public-process,
    .ejar-public-vehicle-media,
    .ejar-admin-nav-brand,
    .ejar-user-menu-avatar,
    .ejar-user-menu-chevron,
    .ejar-button-dark,
    .ejar-btn-primary,
    .ejar-button-primary,
    .ejar-admin-button-primary,
    .ejar-status-available,
    .ejar-status-unavailable,
    .ejar-public-status,
    .ejar-money-card.is-dark,
    .ejar-alert-dark,
    .ejar-table thead th,
    .ejar-dashboard table thead th
) {
    background-color: var(--ejar-contrast-dark) !important;
    color: var(--ejar-contrast-white) !important;
    -webkit-text-fill-color: var(--ejar-contrast-white) !important;
}

html body :where(
    .ejar-dashboard-header,
    .ejar-ui-admin-header,
    .ejar-page-hero,
    .ejar-admin-hero,
    .ejar-control-hero,
    .ejar-dark-panel,
    .ejar-panel-dark,
    .ejar-card-dark,
    .ejar-stat-card.is-dark,
    .ejar-public .ejar-on-dark-panel,
    .ejar-public-hero,
    .ejar-public-catalog-hero,
    .ejar-public-process,
    .ejar-public-vehicle-media,
    .ejar-admin-nav-brand,
    .ejar-button-dark,
    .ejar-btn-primary,
    .ejar-button-primary,
    .ejar-admin-button-primary,
    .ejar-status-available,
    .ejar-status-unavailable,
    .ejar-public-status,
    .ejar-money-card.is-dark,
    .ejar-alert-dark,
    .ejar-table thead th,
    .ejar-dashboard table thead th
) :where(*:not(input):not(textarea):not(select):not(option)) {
    color: var(--ejar-contrast-white) !important;
    -webkit-text-fill-color: var(--ejar-contrast-white) !important;
}

/* Harmonisation E-Jar : les grands blocs foncés reprennent les couleurs du logo. */
html body :where(.ejar-dashboard-header, .ejar-ui-admin-header, .ejar-page-hero, .ejar-admin-hero, .ejar-control-hero, .ejar-public-hero, .ejar-public-catalog-hero, .ejar-public-process) {
    background: var(--ejar-contrast-dark-gradient) !important;
    border-color: rgba(212, 175, 55, .30) !important;
}

/* Icônes ou pastilles posées sur un fond clair à l'intérieur d'un bloc foncé. */
html body :where(.ejar-page-hero-icon, .ejar-public-feature-card > span, .ejar-public-vehicle-topline > span, .ejar-badge-soft, .ejar-button-light, .ejar-btn-light) {
    background: var(--ejar-contrast-soft) !important;
    color: var(--ejar-contrast-dark) !important;
    -webkit-text-fill-color: var(--ejar-contrast-dark) !important;
}
html body :where(.ejar-page-hero-icon, .ejar-public-feature-card > span, .ejar-public-vehicle-topline > span, .ejar-badge-soft, .ejar-button-light, .ejar-btn-light) * {
    color: var(--ejar-contrast-dark) !important;
    -webkit-text-fill-color: var(--ejar-contrast-dark) !important;
}

/* Boutons principaux : fond foncé/or, texte clair. */
html body :where(.ejar-public-btn-primary, .ejar-public-submit, .ejar-public-search button, .ejar-admin-nav-toggle, .ejar-reset-button, button.ejar-reset-button, a.ejar-reset-button) {
    background: var(--ejar-contrast-primary-gradient) !important;
    color: var(--ejar-contrast-white) !important;
    -webkit-text-fill-color: var(--ejar-contrast-white) !important;
    border-color: rgba(212, 175, 55, .42) !important;
}
html body :where(.ejar-public-btn-primary, .ejar-public-submit, .ejar-public-search button, .ejar-admin-nav-toggle, .ejar-reset-button, button.ejar-reset-button, a.ejar-reset-button) * {
    color: var(--ejar-contrast-white) !important;
    -webkit-text-fill-color: var(--ejar-contrast-white) !important;
}
html body .ejar-admin-nav-toggle-icon i {
    background: var(--ejar-contrast-white) !important;
}

/* Formulaires : champs blancs = texte foncé. */
html body :where(.ejar-dashboard, .ejar-admin-page-shell, .ejar-agence-page-shell, .ejar-client-page-shell, .ejar-registration-page, .ejar-public) :where(input, textarea, select, option) {
    background-color: #ffffff !important;
    color: var(--ejar-contrast-text) !important;
    -webkit-text-fill-color: var(--ejar-contrast-text) !important;
    border-color: var(--ejar-contrast-border) !important;
}
html body :where(.ejar-dashboard, .ejar-public) :where(input::placeholder, textarea::placeholder) {
    color: var(--ejar-contrast-muted) !important;
    -webkit-text-fill-color: var(--ejar-contrast-muted) !important;
    opacity: .92 !important;
}

/* Tableaux : en-tête foncé lisible, corps clair lisible. */
html body :where(.ejar-dashboard, .ejar-admin-page-shell, .ejar-agence-page-shell, .ejar-client-page-shell) :where(table thead, table thead tr, table thead th, .ejar-table thead th) {
    background: var(--ejar-contrast-dark-2) !important;
    color: var(--ejar-contrast-white) !important;
    -webkit-text-fill-color: var(--ejar-contrast-white) !important;
}
html body :where(.ejar-dashboard, .ejar-admin-page-shell, .ejar-agence-page-shell, .ejar-client-page-shell) :where(table tbody, table tbody tr, table tbody td, .ejar-table tbody td) {
    background-color: #ffffff;
    color: var(--ejar-contrast-text) !important;
    -webkit-text-fill-color: var(--ejar-contrast-text) !important;
}

/* Menu de gestion : drawer clair, liens lisibles, lien actif foncé. */
html body .ejar-admin-nav-offcanvas-mode .ejar-admin-nav-pill,
html body .ejar-admin-nav-drawer,
html body .ejar-admin-nav-drawer[data-ejar-nav-portal="drawer"] {
    background: rgba(255,255,255,.98) !important;
    color: var(--ejar-contrast-text) !important;
    -webkit-text-fill-color: var(--ejar-contrast-text) !important;
    border-color: var(--ejar-contrast-border) !important;
}
html body .ejar-admin-nav-current strong,
html body .ejar-admin-nav-drawer-head strong,
html body .ejar-admin-nav-close,
html body .ejar-admin-nav-group-title {
    color: var(--ejar-contrast-text) !important;
    -webkit-text-fill-color: var(--ejar-contrast-text) !important;
}
html body .ejar-admin-nav-current-kicker,
html body .ejar-admin-nav-drawer-kicker {
    color: var(--ejar-contrast-muted) !important;
    -webkit-text-fill-color: var(--ejar-contrast-muted) !important;
}
html body .ejar-admin-nav-offcanvas-mode .ejar-admin-nav-group {
    background: var(--ejar-contrast-light-gradient) !important;
    color: var(--ejar-contrast-text) !important;
    -webkit-text-fill-color: var(--ejar-contrast-text) !important;
    border-color: var(--ejar-contrast-border) !important;
}
html body .ejar-admin-nav-offcanvas-mode a.ejar-admin-nav-link:not(.ejar-admin-nav-link-relances) {
    background: #ffffff !important;
    color: var(--ejar-contrast-text) !important;
    -webkit-text-fill-color: var(--ejar-contrast-text) !important;
    border-color: rgba(64, 113, 152, .16) !important;
}
html body .ejar-admin-nav-offcanvas-mode a.ejar-admin-nav-link:not(.ejar-admin-nav-link-relances) * {
    color: var(--ejar-contrast-text) !important;
    -webkit-text-fill-color: var(--ejar-contrast-text) !important;
}
html body .ejar-admin-nav-offcanvas-mode a.ejar-admin-nav-link:hover,
html body .ejar-admin-nav-offcanvas-mode a.ejar-admin-nav-link:focus-visible,
html body .ejar-admin-nav-offcanvas-mode a.ejar-admin-nav-link.active,
html body .ejar-admin-nav-offcanvas-mode a.ejar-admin-nav-link.is-active {
    background: var(--ejar-contrast-primary-gradient) !important;
    color: var(--ejar-contrast-white) !important;
    -webkit-text-fill-color: var(--ejar-contrast-white) !important;
    border-color: rgba(212, 175, 55, .34) !important;
}
html body .ejar-admin-nav-offcanvas-mode a.ejar-admin-nav-link:hover *,
html body .ejar-admin-nav-offcanvas-mode a.ejar-admin-nav-link:focus-visible *,
html body .ejar-admin-nav-offcanvas-mode a.ejar-admin-nav-link.active *,
html body .ejar-admin-nav-offcanvas-mode a.ejar-admin-nav-link.is-active * {
    color: var(--ejar-contrast-white) !important;
    -webkit-text-fill-color: var(--ejar-contrast-white) !important;
}
html body .ejar-admin-nav-offcanvas-mode a.ejar-admin-nav-link-relances,
html body .ejar-admin-nav-offcanvas-mode a[href*="relance"] {
    background: linear-gradient(135deg, #991b1b 0%, #dc2626 100%) !important;
    color: var(--ejar-contrast-white) !important;
    -webkit-text-fill-color: var(--ejar-contrast-white) !important;
}
html body .ejar-admin-nav-offcanvas-mode a.ejar-admin-nav-link-relances *,
html body .ejar-admin-nav-offcanvas-mode a[href*="relance"] * {
    color: var(--ejar-contrast-white) !important;
    -webkit-text-fill-color: var(--ejar-contrast-white) !important;
}

/* Menu utilisateur fixe : fond clair lisible, hover foncé lisible. */
html body .ejar-fixed-user-menu,
html body .ejar-fixed-user-menu .ejar-user-menu-pill,
html body .ejar-fixed-user-menu .ejar-user-menu-dropdown {
    background: rgba(255,255,255,.98) !important;
    color: var(--ejar-contrast-text) !important;
    -webkit-text-fill-color: var(--ejar-contrast-text) !important;
    border-color: var(--ejar-contrast-border) !important;
}
html body .ejar-fixed-user-menu :where(.ejar-user-menu-welcome, .ejar-user-menu-name, .ejar-user-menu-role, .ejar-user-menu-link) {
    color: var(--ejar-contrast-text) !important;
    -webkit-text-fill-color: var(--ejar-contrast-text) !important;
}
html body .ejar-fixed-user-menu .ejar-user-menu-link:hover {
    background: var(--ejar-contrast-primary-gradient) !important;
    color: var(--ejar-contrast-white) !important;
    -webkit-text-fill-color: var(--ejar-contrast-white) !important;
}
html body .ejar-fixed-user-menu .ejar-user-menu-link:hover * {
    color: var(--ejar-contrast-white) !important;
    -webkit-text-fill-color: var(--ejar-contrast-white) !important;
}

/* Alertes et badges doux : fonds clairs, textes foncés adaptés. */
html body :where(.ejar-alert, .ejar-public-notice, .ejar-public-unavailable-message, .ejar-parc-badge-success, .ejar-parc-badge-warning, .ejar-parc-badge-danger, .ejar-parc-badge-neutral) {
    -webkit-text-fill-color: currentColor !important;
}
html body :where(.ejar-public-notice-success, .ejar-parc-badge-success, .ejar-money-positive) { color: #166534 !important; -webkit-text-fill-color: #166534 !important; }
html body :where(.ejar-public-notice-warning, .ejar-parc-badge-warning) { color: #78350f !important; -webkit-text-fill-color: #78350f !important; }
html body :where(.ejar-public-notice-danger, .ejar-public-unavailable-message, .ejar-parc-badge-danger, .ejar-money-negative) { color: #991b1b !important; -webkit-text-fill-color: #991b1b !important; }

/* Éléments désactivés : toujours lisibles même sans action possible. */
html body :where(.ejar-public-card-unavailable, .ejar-is-disabled, .is-disabled, [aria-disabled="true"], button:disabled) {
    opacity: 1 !important;
}
html body :where(button:disabled, .ejar-public-card-unavailable .ejar-public-submit) {
    background: #e5edf5 !important;
    color: #49657b !important;
    -webkit-text-fill-color: #49657b !important;
    border-color: #c6ddec !important;
    cursor: not-allowed !important;
}

/* E-JAR 2.0.4 — toute action noire/or conserve un libellé blanc lisible. */
html body :is(
    .ejar-button:not(.ejar-button-light):not(:disabled):not([aria-disabled="true"]),
    .ejar-btn-primary:not(:disabled),
    .ejar-button-primary:not(:disabled),
    .ejar-admin-button-primary:not(:disabled),
    .ejar-form button[type="submit"]:not(.ejar-button-light):not(:disabled),
    .ejar-sorties-button.gold,
    .ejar-client-action-card:hover,
    .ejar-agence-account-card.is-selected .ejar-button,
    .ejar-subtab.is-active,
    .ejar-subtab.active,
    .ejar-edit-tab.is-active,
    .ejar-edit-tab.active,
    .ejar-parc-tab.is-active,
    .ejar-parc-tab.active,
    .ejar-selected,
    [aria-selected="true"]
) {
    color: #ffffff !important;
    -webkit-text-fill-color: #ffffff !important;
    text-shadow: 0 1px 8px rgba(0,0,0,.72) !important;
}
html body :is(
    .ejar-button:not(.ejar-button-light):not(:disabled):not([aria-disabled="true"]),
    .ejar-btn-primary:not(:disabled),
    .ejar-button-primary:not(:disabled),
    .ejar-admin-button-primary:not(:disabled),
    .ejar-form button[type="submit"]:not(.ejar-button-light):not(:disabled),
    .ejar-sorties-button.gold,
    .ejar-client-action-card:hover,
    .ejar-agence-account-card.is-selected .ejar-button,
    .ejar-subtab.is-active,
    .ejar-subtab.active,
    .ejar-edit-tab.is-active,
    .ejar-edit-tab.active,
    .ejar-parc-tab.is-active,
    .ejar-parc-tab.active,
    .ejar-selected,
    [aria-selected="true"]
) * {
    color: #ffffff !important;
    -webkit-text-fill-color: #ffffff !important;
}
html body .ejar-sorties-months label:has(input:checked) {
    color: #ffffff !important;
    -webkit-text-fill-color: #ffffff !important;
    text-shadow: 0 1px 8px rgba(0,0,0,.72) !important;
}

/* Sur les surfaces sombres, le noir du fichier JPG devient visuellement transparent. */
html body :is(.ejar-admin-nav-brand, .ejar-dashboard-header, .ejar-ui-admin-header, .ejar-page-hero, .ejar-admin-hero, .ejar-control-hero, .ejar-dark-panel, .ejar-panel-dark) img[src*="ejar-logo-officiel"] {
    mix-blend-mode: lighten;
}
html body :is(.ejar-admin-nav-brand, .ejar-dashboard-header, .ejar-ui-admin-header, .ejar-page-hero, .ejar-admin-hero, .ejar-control-hero, .ejar-dark-panel, .ejar-panel-dark) {
    isolation: isolate;
}
html body .ejar-admin-nav-brand {
    background: #000000 !important;
}
