/* Palette et contrastes du panel nocturne. Chargé après les styles des écrans. */
:root {
  --danger-text: #C0392B;
  --warning-text: #A85A00;
}

body.dark-mode {
  color-scheme: dark;
  --sage: #A8CDB2;
  --sage-light: #91B69B;
  --sage-pale: #2E4035;
  --terracotta-light: #493929;
  --text: #F0F3F0;
  --text-light: #BCC7BF;
  --danger-text: #FFB4B4;
  --warning-text: #F3C77E;
  --night-border: #526157;
  --night-action: #365C45;
}

/* Formulaires, navigation clavier et boutons communs. */
body.dark-mode :is(input, select, textarea) {
  background: #1F2422;
  color: var(--text);
  border-color: var(--night-border);
}
body.dark-mode :is(input, textarea)::placeholder { color: #ADB9B0; opacity: 1; }
body.dark-mode :is(button, a, input, select, textarea, [tabindex]):focus-visible {
  outline: 2px solid #D2E8A9;
  outline-offset: 3px;
}
body.dark-mode :is(.btn-secondary, .pagination button, .cal-nav button, .fiche-add-btn) {
  background: var(--white);
  color: var(--text);
  border-color: var(--night-border);
}
body.dark-mode :is(.btn-secondary, .pagination button, .cal-nav button):hover { background: #354139; }
body.dark-mode :is(.btn-primary, .modal-submit, .postsave-actions button, .fab, .btn-icon-square, .fiche-save-fab, .fiche-field-add button, .login-box button, .btn-faite, .toast) {
  background: var(--night-action);
  color: #fff;
}
body.dark-mode :is(.btn-primary, .modal-submit, .postsave-actions button, .fab, .fiche-save-fab, .login-box button):hover { background: #426E53; }
body.dark-mode .pagination button.active { background: #A8CDB2; color: #17251B; border-color: #A8CDB2; }
body.dark-mode :is(.login-error, .modal-delete, .action-btn:hover, .fiche-trash:hover, .note-actions button.note-del:hover, .charge-fixe-delete) { color: var(--danger-text); }
body.dark-mode .fb-arch { background: #724522; color: #fff; }
body.dark-mode :is(.fiche-field-clear button, .fl-del) { background: #492D2D; color: var(--danger-text); }

/* Tableau de bord : objectif, périodes, cartes et graphiques. */
body.dark-mode .dashboard-settings { opacity: 1; }
body.dark-mode .dashboard-settings .dashboard-goal { color: #fff; }
body.dark-mode .dashboard-settings .dashboard-goal input {
  background: #1F2923;
  color: #F0F3F0;
  border-color: #9FB4A5;
}
body.dark-mode .dashboard-settings .dashboard-period { background: #202C25; border-color: #788E7F; }
body.dark-mode .dashboard-period button { color: #DAE4DD; }
body.dark-mode .dashboard-period button.active { background: #A8CDB2; color: #17251B; }
body.dark-mode .dashboard-period button:hover:not(.active) { background: #354A3C; }
body.dark-mode .dashboard-new-rdv { background: #E9F2EB; color: #203E2D; }
body.dark-mode .dashboard-new-rdv:hover { background: #fff; }
body.dark-mode .dashboard-planning-link { color: #fff; }
body.dark-mode :is(.dashboard-kpi, .dashboard-panel, .compta-chart-card, .dashboard-goal) { border-color: var(--night-border); }
body.dark-mode .dashboard-kpi-icon.gold { background: #493B20; color: #F3CF80; }
body.dark-mode .dashboard-kpi-icon.peach { background: #493929; color: #F5C49D; }
body.dark-mode .dashboard-today-progress { background: linear-gradient(135deg,#2E4035,#263128); border-color: var(--night-border); }
body.dark-mode .dashboard-today-progress-goal strong { color: #F3CF80; }
body.dark-mode :is(.dashboard-today-progress-track, .panel-loader-track) { background: #435047; box-shadow: none; }
body.dark-mode .dashboard-today-icon { background: var(--night-action); }
body.dark-mode :is(.annual-chart-axis, .annual-chart-month) { fill: var(--text-light); }
body.dark-mode :is(.annual-chart-grid, .dashboard-chart-grid) { stroke: #48554C; }
body.dark-mode .charge-fixe-auto-label { background: var(--sage-pale); color: var(--sage); }

/* Tableaux, listes et séparateurs. */
body.dark-mode :is(thead th, tbody td, .week-toprow, .cal-legend, .week-header-row, .week-daycol-header, .week-timecol, .week-daycol, .gsr-item, .fiche-owner, .modal-footer-bar, .rdvd-tabs, .fact-total-grand, .dashboard-rdv, .dashboard-task, .dashboard-bars, .dashboard-new-columns > div:first-child, .race-search-results, .race-search-results button) { border-color: var(--night-border); }
body.dark-mode :is(.animaux-subtab:hover, .race-search-results button:hover, .race-search-results button:focus) { background: #354139; }
body.dark-mode :is(.nav-badge, .animaux-subtab .nav-badge, .presta-badge.done) { background: #3C4840; color: #DAE4DD; }
body.dark-mode :is(.nav-item.active .nav-badge, .animaux-subtab.active .nav-badge) { background: var(--night-action); color: #fff; }
body.dark-mode .client-refuse-row { background: #303431 !important; color: #BCC7BF; opacity: 1; }
body.dark-mode .client-refuse-row:hover { background: #3B413D !important; opacity: 1; }
body.dark-mode .client-refuse-row .client-avatar { background: #485149 !important; }
body.dark-mode .client-refuse-row .client-name { color: #BCC7BF; }
body.dark-mode .animal-client-refuse-row td:first-child a { color: #BCC7BF !important; }
body.dark-mode .cat-chip button { background: #25332A; color: var(--text); }
body.dark-mode .cat-chip button:hover { background: #492D2D; color: var(--danger-text); }
body.dark-mode .switch-slider { background: #58675D; }
body.dark-mode .switch input:checked + .switch-slider { background: #A8CDB2; }
body.dark-mode .switch input:checked + .switch-slider:before { background: #17251B; }
body.dark-mode .switch input:focus-visible + .switch-slider { outline: 2px solid #D2E8A9; outline-offset: 3px; }
body.dark-mode .fiche-tabs { background: #304E3B; }
body.dark-mode .fiche-tab { opacity: 1; color: #D7E4DA; }
body.dark-mode .fiche-tab.active { background: #42634D; color: #fff; }
body.dark-mode .fiche-tab .tab-badge { background: #213427; color: #D7E4DA; }

/* Notifications et fenêtres : éviter le texte clair sur un fond blanc. */
body.dark-mode :is(.demande-banner:not(.ovh-credits-alert), .tache-banner) { background: #302B29; color: var(--text); }
body.dark-mode .demande-banner:not(.ovh-credits-alert) .demande-banner-title { color: #FFB4B4; }
body.dark-mode .tache-banner-title { color: #F3C77E; }
body.dark-mode :is(.demande-banner-close, .tache-banner-close) { color: #F0F3F0; }
body.dark-mode .tache-jour-badge { background: #493929; color: #F3C77E; }
body.dark-mode :is(.demande-card.traitee, .tache-card.faite, .tache-card.inactive) { opacity: 1; }
body.dark-mode :is(.modal-header-bar, .rdvd-header, .modal-box:has(> .modal-title) > .modal-title) { background: linear-gradient(135deg,#304E3B,#42634D) !important; color: #fff; }
body.dark-mode .rdvd-avatar-orange { background: #493929; }
body.dark-mode .rdvd-badge { background: #3E5729; color: #fff; }
body.dark-mode .rdvd-badge.termine { background: #48544C; }
body.dark-mode .rdvd-badge.annule { background: #922D27; }
body.dark-mode .rdvd-badge.absent { background: #814315; }
body.dark-mode .rdvd-btn-menu { background: #814315; }
body.dark-mode .rdvd-btn-debut { background: #276442; }

/* Calendrier : les hachures restent distinctes et les motifs lisibles. */
body.dark-mode :is(.week-blocage, .cal-blocage) { color: #DAE4DD; background: repeating-linear-gradient(45deg,#38443B,#38443B 8px,#465249 8px,#465249 16px); border-color: #9AA99E; }
body.dark-mode :is(.cal-day.is-journee-bloquee, .cal-day.is-journee-bloquee .cal-daynum, .cal-journee-bloquee-reason) { color: #DAE4DD; }

/* L'alerte SMS conserve son fond rouge et son texte blanc. */
body.dark-mode .dashboard-sms-credits.is-low { background: #B91C1C; border-color: #F08080; }
body.dark-mode .dashboard-sms-credits.is-low :is(.dashboard-kpi-icon, .dashboard-kpi-label, strong, small) { color: #fff; }
body.dark-mode .dashboard-sms-credits.is-low .dashboard-kpi-icon { background: #ffffff26; }
