/* =============================================
   DARK MODE — LensPro
   ============================================= */

/* ─── Light theme variables (defaults) ─── */
:root,
[data-theme="light"] {
  --bg-primary: #ffffff;
  --bg-secondary: #f8fafc;
  --bg-tertiary: #f1f5f9;
  --text-primary: #0f172a;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --border-color: #e2e8f0;
  --border-hover: #cbd5e1;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-light: #eff6ff;
  --danger: #dc2626;
  --danger-light: #fef2f2;
  --success: #16a34a;
  --success-light: #f0fdf4;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
}

/* ─── Dark theme variables (softer slate-blue) ─── */
[data-theme="dark"] {
  --bg-primary: #1a2236;
  --bg-secondary: #232e45;
  --bg-tertiary: #2d3a54;
  --text-primary: #e8edf5;
  --text-secondary: #a0aec0;
  --text-muted: #718096;
  --border-color: #364158;
  --border-hover: #4a5a75;
  --accent: #5b9cf6;
  --accent-hover: #7eb8ff;
  --accent-light: #253a5e;
  --danger: #f87171;
  --danger-light: #3a1e1e;
  --success: #4ade80;
  --success-light: #1c3326;
  --shadow: 0 1px 3px rgba(0,0,0,0.3);

  /* Override existing gray scale for dark */
  --gray-50: #232e45;
  --gray-100: #2d3a54;
  --gray-200: #364158;
  --gray-300: #4a5a75;
  --gray-400: #8896ab;
  --gray-500: #a0aec0;
  --gray-600: #cbd5e1;
  --gray-700: #e2e8f0;
  --gray-800: #e8edf5;
  --gray-900: #f1f5f9;

  /* Also override primary-color etc. for existing var usage */
  --primary-color: #5b9cf6;
  --primary-dark: #3b82f6;
  --secondary-color: #818cf8;
  --success-color: #4ade80;
  --warning-color: #fbbf24;
  --danger-color: #f87171;
}

/* ─── Body — force over styles.css ─── */
[data-theme="dark"] body {
  background: #141c2e !important;
  color: var(--text-primary) !important;
}

/* ─── Main container — force over styles.css ─── */
[data-theme="dark"] .main-container {
  background: var(--bg-primary) !important;
  box-shadow: var(--shadow) !important;
  border-color: var(--border-color) !important;
}

/* ─── Navbar — maximum specificity ─── */
html[data-theme="dark"] .navbar-container,
[data-theme="dark"] .navbar-container,
[data-theme="dark"] nav.navbar-container {
  background: #1e2a42 !important;
  border-bottom: 1px solid #364158 !important;
  color: #e8edf5 !important;
}

html[data-theme="dark"] .navbar-link,
[data-theme="dark"] .navbar-link,
[data-theme="dark"] a.navbar-link {
  color: #c5cdd9 !important;
}

html[data-theme="dark"] .navbar-link:hover,
html[data-theme="dark"] .navbar-link.active,
[data-theme="dark"] .navbar-link:hover,
[data-theme="dark"] .navbar-link.active {
  color: #ffffff !important;
  background: #2d3a54 !important;
}

html[data-theme="dark"] .navbar-action-icon,
[data-theme="dark"] .navbar-action-icon {
  color: #c5cdd9 !important;
}

html[data-theme="dark"] .navbar-action-icon:hover,
[data-theme="dark"] .navbar-action-icon:hover {
  background: #2d3a54 !important;
  color: #7eb8ff !important;
}

[data-theme="dark"] .navbar-actions-separator {
  background: #364158 !important;
}

/* Profile dropdown */
[data-theme="dark"] .navbar-profile-dropdown {
  background: var(--bg-secondary) !important;
  border-color: var(--border-color) !important;
  box-shadow: 0 10px 40px rgba(0,0,0,0.5) !important;
}

[data-theme="dark"] .navbar-profile-header {
  border-bottom-color: var(--border-color) !important;
  background: var(--bg-tertiary) !important;
}

[data-theme="dark"] .navbar-profile-name {
  color: var(--text-primary) !important;
}

[data-theme="dark"] .navbar-profile-role {
  color: var(--text-secondary) !important;
}

[data-theme="dark"] .navbar-profile-item {
  color: var(--text-secondary) !important;
}

[data-theme="dark"] .navbar-profile-footer {
  border-top-color: var(--border-color) !important;
  background: var(--bg-tertiary) !important;
}

[data-theme="dark"] .navbar-profile-logout {
  color: var(--text-secondary) !important;
}

[data-theme="dark"] .navbar-profile-logout:hover {
  color: var(--danger) !important;
  background: var(--danger-light) !important;
}

[data-theme="dark"] .navbar-profile-version {
  color: var(--text-muted) !important;
}

/* Mobile bottom nav */
[data-theme="dark"] .bottom-nav {
  background: var(--bg-secondary) !important;
  border-top-color: var(--border-color) !important;
}

[data-theme="dark"] .bottom-nav-item {
  color: var(--text-secondary) !important;
}

[data-theme="dark"] .bottom-nav-item.active,
[data-theme="dark"] .bottom-nav-item:hover {
  color: var(--accent) !important;
}

[data-theme="dark"] .bottom-nav-submenu {
  background: var(--bg-secondary) !important;
  border-color: var(--border-color) !important;
}

/* ─── Page header ─── */
[data-theme="dark"] .page-header-compact {
  background: var(--bg-primary) !important;
  border-bottom-color: var(--border-color) !important;
}

[data-theme="dark"] .page-header-compact h2 {
  color: var(--text-primary) !important;
}

[data-theme="dark"] .page-header-compact span[style*="color: #6b7280"],
[data-theme="dark"] .page-header-compact span[style*="color:#6b7280"] {
  color: var(--text-secondary) !important;
}

[data-theme="dark"] .page-header-compact span[style*="color: #d1d5db"],
[data-theme="dark"] .page-header-compact span[style*="color:#d1d5db"] {
  color: var(--border-color) !important;
}

/* ─── Buttons ─── */
[data-theme="dark"] .nav-button-compact {
  background: var(--bg-tertiary) !important;
  color: var(--text-primary) !important;
  box-shadow: var(--shadow) !important;
}

[data-theme="dark"] .nav-button-compact:hover {
  background: var(--border-hover) !important;
}

/* Primary button stays blue */
[data-theme="dark"] .nav-button-compact--primary {
  background: var(--accent) !important;
  color: #ffffff !important;
}

[data-theme="dark"] .nav-button-compact--primary:hover {
  background: var(--accent-hover) !important;
}

[data-theme="dark"] .btn-primary {
  background: linear-gradient(135deg, var(--accent) 0%, #1d4ed8 100%) !important;
}

[data-theme="dark"] .btn {
  color: var(--text-primary);
}

/* ─── Tables ─── */
[data-theme="dark"] #clientsList,
[data-theme="dark"] #framesList,
[data-theme="dark"] #doctorsList,
[data-theme="dark"] #monturesList,
[data-theme="dark"] #verresList,
[data-theme="dark"] #fournisseursList,
[data-theme="dark"] #storesList {
  background: var(--bg-primary) !important;
  border-color: var(--border-color) !important;
}

[data-theme="dark"] .table-section {
  background: var(--bg-primary) !important;
  border-color: var(--border-color) !important;
}

/* Table headers */
[data-theme="dark"] body #clientsList thead,
[data-theme="dark"] body #clientsList thead tr,
[data-theme="dark"] body #framesList thead,
[data-theme="dark"] body #framesList thead tr,
[data-theme="dark"] body #doctorsList thead,
[data-theme="dark"] body #doctorsList thead tr,
[data-theme="dark"] body #monturesList thead,
[data-theme="dark"] body #monturesList thead tr,
[data-theme="dark"] body #verresList thead,
[data-theme="dark"] body #verresList thead tr,
[data-theme="dark"] body #fournisseursList thead,
[data-theme="dark"] body #fournisseursList thead tr,
[data-theme="dark"] body #storesList thead,
[data-theme="dark"] body #storesList thead tr,
[data-theme="dark"] body #ordersTable thead,
[data-theme="dark"] body #ordersTable thead tr,
[data-theme="dark"] body .invoices-table thead,
[data-theme="dark"] body .invoices-table thead tr,
[data-theme="dark"] body .transactions-table thead,
[data-theme="dark"] body .transactions-table thead tr {
  background: var(--bg-secondary) !important;
}

/* Table header cells */
[data-theme="dark"] body #clientsList th,
[data-theme="dark"] body #clientsList th[style],
[data-theme="dark"] body #framesList th,
[data-theme="dark"] body #framesList th[style],
[data-theme="dark"] body #doctorsList th,
[data-theme="dark"] body #doctorsList th[style],
[data-theme="dark"] body #monturesList th,
[data-theme="dark"] body #monturesList th[style],
[data-theme="dark"] body #verresList th,
[data-theme="dark"] body #verresList th[style],
[data-theme="dark"] body #fournisseursList th,
[data-theme="dark"] body #fournisseursList th[style],
[data-theme="dark"] body #storesList th,
[data-theme="dark"] body #storesList th[style],
[data-theme="dark"] body #ordersTable th,
[data-theme="dark"] body #ordersTable th[style],
[data-theme="dark"] body .invoices-table th,
[data-theme="dark"] body .transactions-table th {
  color: var(--text-primary) !important;
  background: var(--bg-secondary) !important;
  border-bottom-color: var(--border-color) !important;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2) !important;
}

[data-theme="dark"] body #clientsList th:hover,
[data-theme="dark"] body #framesList th:hover,
[data-theme="dark"] body #doctorsList th:hover,
[data-theme="dark"] body #monturesList th:hover,
[data-theme="dark"] body #verresList th:hover,
[data-theme="dark"] body #fournisseursList th:hover,
[data-theme="dark"] body #storesList th:hover,
[data-theme="dark"] body #ordersTable th:hover,
[data-theme="dark"] body .invoices-table th:hover,
[data-theme="dark"] body .transactions-table th:hover {
  color: var(--text-primary) !important;
}

/* Table rows */
[data-theme="dark"] body #clientsList tbody tr,
[data-theme="dark"] body #clientsList tbody tr:nth-child(2n),
[data-theme="dark"] body #framesList tbody tr,
[data-theme="dark"] body #framesList tbody tr:nth-child(2n),
[data-theme="dark"] body #doctorsList tbody tr,
[data-theme="dark"] body #doctorsList tbody tr:nth-child(2n),
[data-theme="dark"] body #monturesList tbody tr,
[data-theme="dark"] body #monturesList tbody tr:nth-child(2n),
[data-theme="dark"] body #verresList tbody tr,
[data-theme="dark"] body #verresList tbody tr:nth-child(2n),
[data-theme="dark"] body #fournisseursList tbody tr,
[data-theme="dark"] body #fournisseursList tbody tr:nth-child(2n),
[data-theme="dark"] body #storesList tbody tr,
[data-theme="dark"] body #storesList tbody tr:nth-child(2n),
[data-theme="dark"] body #ordersTable tbody tr,
[data-theme="dark"] body #ordersTable tbody tr:nth-child(2n),
[data-theme="dark"] body .invoices-table tbody tr,
[data-theme="dark"] body .invoices-table tbody tr:nth-child(2n),
[data-theme="dark"] body .transactions-table tbody tr,
[data-theme="dark"] body .transactions-table tbody tr:nth-child(2n) {
  background: var(--bg-primary) !important;
  background-color: var(--bg-primary) !important;
  border-bottom-color: var(--border-color) !important;
}

/* Table row hover */
[data-theme="dark"] body #clientsList tbody tr:hover,
[data-theme="dark"] body #framesList tbody tr:hover,
[data-theme="dark"] body #doctorsList tbody tr:hover,
[data-theme="dark"] body #monturesList tbody tr:hover,
[data-theme="dark"] body #verresList tbody tr:hover,
[data-theme="dark"] body #fournisseursList tbody tr:hover,
[data-theme="dark"] body #storesList tbody tr:hover,
[data-theme="dark"] body #ordersTable tbody tr:hover,
[data-theme="dark"] body .invoices-table tbody tr:hover,
[data-theme="dark"] body .transactions-table tbody tr:hover {
  background: var(--bg-secondary) !important;
  background-color: var(--bg-secondary) !important;
}

/* Table cells */
[data-theme="dark"] body #clientsList td,
[data-theme="dark"] body #framesList td,
[data-theme="dark"] body #doctorsList td,
[data-theme="dark"] body #monturesList td,
[data-theme="dark"] body #verresList td,
[data-theme="dark"] body #fournisseursList td,
[data-theme="dark"] body #storesList td,
[data-theme="dark"] body #ordersTable td,
[data-theme="dark"] body .invoices-table td,
[data-theme="dark"] body .transactions-table td {
  color: var(--text-secondary) !important;
}

/* Order status rows in dark mode */
[data-theme="dark"] body #ordersTable tbody tr.status-en_commande,
[data-theme="dark"] body #ordersTable tbody tr.status-en_commande:nth-child(2n) {
  background: #422006 !important;
  background-color: #422006 !important;
}
[data-theme="dark"] body #ordersTable tbody tr.status-en_commande:hover {
  background: #4a2c0a !important;
  background-color: #4a2c0a !important;
}
[data-theme="dark"] body #ordersTable tbody tr.status-recu,
[data-theme="dark"] body #ordersTable tbody tr.status-recu:nth-child(2n) {
  background: #431407 !important;
  background-color: #431407 !important;
}
[data-theme="dark"] body #ordersTable tbody tr.status-recu:hover {
  background: #4d1a0b !important;
  background-color: #4d1a0b !important;
}

/* Invoices special rows */
[data-theme="dark"] body .invoices-table tbody tr.unpaid {
  background: var(--danger-light) !important;
  border-left-color: var(--danger) !important;
}
[data-theme="dark"] body .invoices-table tbody tr.unpaid:hover {
  background: #3d1919 !important;
}
[data-theme="dark"] body .transactions-table tbody tr.failed {
  background: var(--danger-light) !important;
  border-left-color: var(--danger) !important;
}
[data-theme="dark"] body .transactions-table tbody tr.refunded {
  background: #2d2006 !important;
  border-left-color: #f59e0b !important;
}

[data-theme="dark"] body .table-row-hover:hover {
  background: var(--bg-secondary) !important;
}

/* ─── Pagination ─── */
[data-theme="dark"] .pagination-btn {
  color: var(--text-primary) !important;
  border-color: var(--border-color) !important;
}

[data-theme="dark"] .pagination-btn:hover:not(:disabled) {
  background: var(--bg-tertiary) !important;
  border-color: var(--border-hover) !important;
}

[data-theme="dark"] .pagination-number {
  color: var(--text-secondary) !important;
}

[data-theme="dark"] .pagination-number:hover:not(:disabled):not(.pagination-number--active) {
  background: var(--bg-tertiary) !important;
  border-color: var(--border-color) !important;
}

[data-theme="dark"] .pagination-number--active {
  background: var(--accent) !important;
  color: #ffffff !important;
  border-color: var(--accent) !important;
}

[data-theme="dark"] .pagination-number--active:hover {
  background: var(--accent-hover) !important;
  border-color: var(--accent-hover) !important;
}

[data-theme="dark"] .pagination-ellipsis {
  color: var(--text-muted) !important;
}

/* ─── Modals — NUCLEAR OVERRIDE ─── */
[data-theme="dark"] .modal-overlay,
[data-theme="dark"] .equipment-overlay__backdrop {
  background: rgba(0,0,0,0.7) !important;
}

html[data-theme="dark"] .modal-content,
html[data-theme="dark"] .clean-modal,
html[data-theme="dark"] .clean-modal .modal-content,
html[data-theme="dark"] .client-modal,
html[data-theme="dark"] #clientModal .modal-content,
html[data-theme="dark"] #equipmentModal .modal-content,
html[data-theme="dark"] #equipmentDetailsModal .modal-content,
html[data-theme="dark"] #columnSelectModal .modal-content,
html[data-theme="dark"] #familyModal .modal-content,
html[data-theme="dark"] #addOrderModal .modal-content,
html[data-theme="dark"] [class*="modal"] > div[style*="background: white"],
html[data-theme="dark"] [class*="modal"] > div[style*="background:#fff"],
html[data-theme="dark"] [class*="modal"] > div[style*="background: #fff"],
html[data-theme="dark"] [class*="modal"] > div[style*="background: #ffffff"],
[data-theme="dark"] .modal-content,
[data-theme="dark"] .clean-modal {
  background: #1e2a42 !important;
  border-color: #364158 !important;
  color: #e8edf5 !important;
}

html[data-theme="dark"] .modal-header,
html[data-theme="dark"] .clean-modal-header,
html[data-theme="dark"] .client-modal__header,
[data-theme="dark"] .modal-header {
  border-bottom-color: #364158 !important;
  background: #232e45 !important;
  color: #e8edf5 !important;
}

html[data-theme="dark"] .modal-title,
html[data-theme="dark"] .clean-modal-title,
[data-theme="dark"] .modal-title {
  color: #e8edf5 !important;
}

html[data-theme="dark"] .modal-body,
html[data-theme="dark"] .clean-modal-body,
html[data-theme="dark"] .client-modal__body,
[data-theme="dark"] .modal-body {
  color: #e8edf5 !important;
  background: #1e2a42 !important;
}

html[data-theme="dark"] .modal-footer,
html[data-theme="dark"] .clean-modal-footer,
html[data-theme="dark"] .client-modal__footer,
[data-theme="dark"] .modal-footer {
  border-top-color: #364158 !important;
  background: #232e45 !important;
  color: #e8edf5 !important;
}

html[data-theme="dark"] .modal-close,
[data-theme="dark"] .modal-close {
  color: #a0aec0 !important;
}

html[data-theme="dark"] .modal-close:hover,
[data-theme="dark"] .modal-close:hover {
  background: #2d3a54 !important;
  color: #e8edf5 !important;
}

/* Equipment overlay */
[data-theme="dark"] .equipment-overlay__frame {
  background: var(--bg-primary) !important;
}

[data-theme="dark"] .equipment-overlay__loader {
  background: var(--bg-primary) !important;
}

[data-theme="dark"] .equipment-overlay__spinner {
  border-color: var(--border-color) !important;
  border-top-color: #60a5fa !important;
}

[data-theme="dark"] .equipment-overlay__close {
  background: var(--bg-secondary) !important;
  color: var(--text-primary) !important;
}

/* Share notifications modal */
[data-theme="dark"] .share-notifications-modal {
  background: var(--bg-primary) !important;
  border-color: var(--border-color) !important;
}

[data-theme="dark"] .share-notifications-header {
  border-bottom-color: var(--border-color) !important;
}

[data-theme="dark"] .share-notifications-title {
  color: var(--text-primary) !important;
}

[data-theme="dark"] .share-notifications-close {
  color: var(--text-secondary) !important;
}

[data-theme="dark"] .share-notifications-body {
  color: var(--text-secondary) !important;
}

[data-theme="dark"] .share-notifications-empty {
  color: var(--text-muted) !important;
}

/* ─── Inputs / Selects ─── */
[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: var(--bg-secondary) !important;
  border-color: var(--border-color) !important;
  color: var(--text-primary) !important;
}

[data-theme="dark"] input::placeholder,
[data-theme="dark"] textarea::placeholder {
  color: var(--text-muted) !important;
}

[data-theme="dark"] input:focus,
[data-theme="dark"] select:focus,
[data-theme="dark"] textarea:focus {
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 3px rgba(59,130,246,0.2) !important;
}

/* ─── Search ─── */
[data-theme="dark"] .search-info {
  background: linear-gradient(135deg, var(--accent-light), #1a2e4a) !important;
  border-color: var(--accent) !important;
}

[data-theme="dark"] .search-info__title {
  color: var(--accent-hover) !important;
}

[data-theme="dark"] .search-info__item-text {
  color: var(--text-secondary) !important;
}

[data-theme="dark"] .search-info__item-value {
  color: var(--accent-hover) !important;
}

/* Date selector */
[data-theme="dark"] .date-selector__trigger {
  background: var(--bg-secondary) !important;
  border-color: var(--border-color) !important;
  color: var(--text-secondary) !important;
}

[data-theme="dark"] .date-selector__trigger:hover:not(.date-selector__trigger--disabled) {
  background: var(--accent-light) !important;
  border-color: var(--accent) !important;
  color: var(--accent-hover) !important;
}

[data-theme="dark"] .date-selector__menu {
  background: var(--bg-secondary) !important;
  border-color: var(--border-color) !important;
  box-shadow: 0 20px 40px rgba(0,0,0,0.5) !important;
}

[data-theme="dark"] .date-selector__option {
  color: var(--text-secondary) !important;
}

[data-theme="dark"] .date-selector__option:hover {
  background: var(--accent-light) !important;
  color: var(--text-primary) !important;
}

[data-theme="dark"] .date-selector__option--active,
[data-theme="dark"] .date-selector__option--active:hover {
  background: rgba(59,130,246,0.2) !important;
  color: var(--accent-hover) !important;
}

/* ─── Badges / Pills ─── */
[data-theme="dark"] .code-badge {
  background: var(--bg-tertiary) !important;
  color: var(--text-secondary) !important;
}

[data-theme="dark"] .suggestion-item:hover {
  background: var(--accent-light) !important;
}

/* ─── Dashboard cards ─── */
[data-theme="dark"] .stat-card,
[data-theme="dark"] .dashboard-card {
  background: var(--bg-secondary) !important;
  border-color: var(--border-color) !important;
  box-shadow: var(--shadow) !important;
}

[data-theme="dark"] .dashboard-card-header {
  border-bottom-color: var(--border-color) !important;
}

[data-theme="dark"] .stat-card-header,
[data-theme="dark"] .stat-card-value,
[data-theme="dark"] .dashboard-card-title {
  color: var(--text-primary) !important;
}

[data-theme="dark"] .stat-card-label {
  color: var(--text-secondary) !important;
}

/* ─── Quick action buttons ─── */
[data-theme="dark"] .quick-action {
  background: var(--bg-secondary) !important;
  border-color: var(--border-color) !important;
  color: var(--text-primary) !important;
}

[data-theme="dark"] .quick-action:hover {
  background: var(--bg-tertiary) !important;
  border-color: var(--border-hover) !important;
}

/* ─── Header gradient override ─── */
[data-theme="dark"] .header {
  background: linear-gradient(135deg, #1e3a5f 0%, #312e81 100%) !important;
}

/* ─── Page section ─── */
[data-theme="dark"] .page-section {
  background: var(--bg-primary);
}

[data-theme="dark"] .page-section--light {
  background: var(--bg-secondary) !important;
  border-bottom-color: var(--border-color) !important;
}

/* ─── Scrollbar ─── */
[data-theme="dark"] ::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

[data-theme="dark"] ::-webkit-scrollbar-track {
  background: var(--bg-secondary);
}

[data-theme="dark"] ::-webkit-scrollbar-thumb {
  background: var(--bg-tertiary);
  border-radius: 4px;
}

[data-theme="dark"] ::-webkit-scrollbar-thumb:hover {
  background: var(--border-hover);
}

/* ─── Chat interface ─── */
[data-theme="dark"] .chat-container {
  background: var(--bg-primary) !important;
  border-color: var(--border-color) !important;
}

[data-theme="dark"] .chat-header {
  background: var(--bg-secondary) !important;
  border-bottom-color: var(--border-color) !important;
}

[data-theme="dark"] .chat-messages {
  background: var(--bg-primary) !important;
}

[data-theme="dark"] .chat-input-area {
  background: var(--bg-secondary) !important;
  border-top-color: var(--border-color) !important;
}

/* ─── Misc inline-style overrides ─── */
[data-theme="dark"] [style*="background: #fff"],
[data-theme="dark"] [style*="background:#fff"],
[data-theme="dark"] [style*="background: #ffffff"],
[data-theme="dark"] [style*="background:#ffffff"],
[data-theme="dark"] [style*="background: white"],
[data-theme="dark"] [style*="background:white"],
[data-theme="dark"] [style*="background-color: #fff"],
[data-theme="dark"] [style*="background-color:#fff"],
[data-theme="dark"] [style*="background-color: #ffffff"],
[data-theme="dark"] [style*="background-color:#ffffff"],
[data-theme="dark"] [style*="background-color: white"],
[data-theme="dark"] [style*="background-color:white"] {
  background: var(--bg-primary) !important;
  background-color: var(--bg-primary) !important;
}

[data-theme="dark"] [style*="color: #111827"],
[data-theme="dark"] [style*="color:#111827"],
[data-theme="dark"] [style*="color: #0f172a"],
[data-theme="dark"] [style*="color:#0f172a"] {
  color: var(--text-primary) !important;
}

[data-theme="dark"] [style*="color: #374151"],
[data-theme="dark"] [style*="color:#374151"],
[data-theme="dark"] [style*="color: #4b5563"],
[data-theme="dark"] [style*="color:#4b5563"] {
  color: var(--text-secondary) !important;
}

[data-theme="dark"] [style*="color: #6b7280"],
[data-theme="dark"] [style*="color:#6b7280"],
[data-theme="dark"] [style*="color: #9ca3af"],
[data-theme="dark"] [style*="color:#9ca3af"] {
  color: var(--text-muted) !important;
}

[data-theme="dark"] [style*="border-color: #e5e7eb"],
[data-theme="dark"] [style*="border-color:#e5e7eb"],
[data-theme="dark"] [style*="border: 1px solid #e5e7eb"],
[data-theme="dark"] [style*="border:1px solid #e5e7eb"] {
  border-color: var(--border-color) !important;
}

/* ─── Form hint & labels ─── */
[data-theme="dark"] .form-hint {
  color: var(--text-muted) !important;
}

[data-theme="dark"] label {
  color: var(--text-primary) !important;
}

/* ─── Loading states ─── */
[data-theme="dark"] .loading-text {
  color: var(--text-secondary) !important;
}

[data-theme="dark"] .empty-title {
  color: var(--text-primary) !important;
}

[data-theme="dark"] .empty-description {
  color: var(--text-muted) !important;
}

/* ─── Theme toggle button ─── */
.theme-toggle-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.15s ease;
  color: #6b7280;
  padding: 0;
}

.theme-toggle-btn:hover {
  background: #f1f5f9;
  color: #3b82f6;
}

[data-theme="dark"] .theme-toggle-btn {
  color: var(--text-secondary) !important;
}

[data-theme="dark"] .theme-toggle-btn:hover {
  background: var(--bg-tertiary) !important;
  color: #fbbf24 !important;
}

/* ─── Tabs / Filters (commandes etc.) ─── */
[data-theme="dark"] #tabContainer button,
[data-theme="dark"] #statusFilterContainer button {
  background: var(--bg-secondary) !important;
  color: var(--text-secondary) !important;
  border-color: var(--border-color) !important;
}

[data-theme="dark"] #tabContainer button.active,
[data-theme="dark"] #tabContainer button:hover,
[data-theme="dark"] #statusFilterContainer button.active,
[data-theme="dark"] #statusFilterContainer button:hover {
  background: var(--accent-light) !important;
  color: var(--accent-hover) !important;
  border-color: var(--accent) !important;
}

/* ─── Tooltip & Dropdown menus ─── */
[data-theme="dark"] .dropdown-menu,
[data-theme="dark"] [class*="dropdown"] > ul,
[data-theme="dark"] [class*="dropdown"] > div {
  background: var(--bg-secondary) !important;
  border-color: var(--border-color) !important;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5) !important;
}

/* ─── Postit (keep yellow in dark) ─── */
[data-theme="dark"] .postit-toggle {
  background: #b8860b !important;
  color: #fff !important;
  border-color: #8b6914 !important;
}

[data-theme="dark"] .postit-textarea {
  background: #3d3000 !important;
  border-color: #8b6914 !important;
  color: var(--text-primary) !important;
}

[data-theme="dark"] .postit-preview {
  background: #3d3000 !important;
  border-color: #8b6914 !important;
  color: var(--text-primary) !important;
}

[data-theme="dark"] .postit-modal {
  background: #3d3000 !important;
  border-color: #8b6914 !important;
}

[data-theme="dark"] .postit-modal__header {
  background: #8b6914 !important;
}

[data-theme="dark"] .postit-modal__title {
  color: #fff !important;
}

[data-theme="dark"] .postit-modal__textarea {
  background: #2d2300 !important;
  border-color: #8b6914 !important;
  color: var(--text-primary) !important;
}

[data-theme="dark"] .postit-modal__footer {
  background: #5a4510 !important;
  border-color: #8b6914 !important;
}

/* ─── Equipment section ─── */
[data-theme="dark"] .equipment-section {
  border-top-color: var(--border-color) !important;
}

[data-theme="dark"] .equipment-section__title {
  color: var(--text-primary) !important;
}

/* ─── Modal backdrop ─── */
html[data-theme="dark"] .modal,
[data-theme="dark"] .modal {
  background: rgba(0,0,0,0.65) !important;
}

/* Client modal specific */
[data-theme="dark"] .client-modal__header {
  border-bottom-color: var(--border-color) !important;
}

[data-theme="dark"] .client-code-chip {
  background: var(--bg-tertiary) !important;
  border-color: var(--border-color) !important;
}

[data-theme="dark"] .client-code-chip__label {
  color: var(--text-secondary) !important;
}

[data-theme="dark"] .form-input--code {
  background: var(--bg-tertiary) !important;
  color: var(--text-secondary) !important;
  border-color: var(--border-color) !important;
}

[data-theme="dark"] .client-actions-btn,
[data-theme="dark"] .duplicate-client-btn {
  color: var(--text-secondary) !important;
}

[data-theme="dark"] .client-actions-dropdown {
  background: var(--bg-secondary) !important;
  border-color: var(--border-color) !important;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5) !important;
}

[data-theme="dark"] .client-actions-item {
  color: var(--text-secondary) !important;
}

[data-theme="dark"] .client-actions-item:hover {
  background: var(--bg-tertiary) !important;
  color: var(--text-primary) !important;
}

/* ─── Form elements (complete) ─── */
[data-theme="dark"] .form-label {
  color: var(--text-secondary) !important;
}

[data-theme="dark"] .form-label--inline {
  color: var(--text-secondary) !important;
}

[data-theme="dark"] .form-input,
[data-theme="dark"] .form-input[type="text"],
[data-theme="dark"] .form-input[type="tel"],
[data-theme="dark"] .form-input[type="email"],
[data-theme="dark"] .form-input[type="date"],
[data-theme="dark"] .form-input[type="number"],
[data-theme="dark"] .form-input[type="password"] {
  background: var(--bg-secondary) !important;
  border-color: var(--border-color) !important;
  color: var(--text-primary) !important;
}

[data-theme="dark"] .form-input:focus {
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 3px rgba(59,130,246,0.2) !important;
}

[data-theme="dark"] .form-input::placeholder {
  color: var(--text-muted) !important;
}

/* ─── Equipment / SaaS footer (client modal) ─── */
[data-theme="dark"] #clientModal .equipment-saas-footer {
  background: var(--bg-secondary) !important;
  border-top-color: var(--border-color) !important;
}

[data-theme="dark"] #clientModal .equipment-saas-btn-cancel {
  color: var(--text-secondary) !important;
}

[data-theme="dark"] #clientModal .equipment-saas-btn-cancel:hover {
  color: var(--text-primary) !important;
}

[data-theme="dark"] .equipment-modal-footer {
  background: var(--bg-secondary) !important;
  border-top-color: var(--border-color) !important;
}

/* ─── History Modal ─── */
[data-theme="dark"] #historyModal .hm-content {
  background: var(--bg-primary) !important;
  box-shadow: 0 20px 50px rgba(0,0,0,0.5) !important;
}

[data-theme="dark"] #historyModal .hm-header h3 {
  color: var(--text-primary) !important;
}

[data-theme="dark"] #historyModal .hm-close {
  color: var(--text-muted) !important;
}

[data-theme="dark"] #historyModal .hm-close:hover {
  background: var(--bg-tertiary) !important;
  color: var(--text-primary) !important;
}

[data-theme="dark"] #historyModal .hm-search input {
  background: var(--bg-secondary) !important;
  border-color: var(--border-color) !important;
  color: var(--text-primary) !important;
}

[data-theme="dark"] #historyModal .hm-search input:focus {
  border-color: var(--accent) !important;
  background: var(--bg-primary) !important;
}

[data-theme="dark"] #historyModal .hm-search svg {
  color: var(--text-muted) !important;
}

[data-theme="dark"] #historyModal .hm-filter select {
  background: var(--bg-secondary) !important;
  border-color: var(--border-color) !important;
  color: var(--text-secondary) !important;
}

[data-theme="dark"] #historyModal .hm-body .history-item {
  border-bottom-color: var(--border-color) !important;
}

[data-theme="dark"] #historyModal .hm-body .history-item:hover {
  background: var(--bg-secondary) !important;
}

[data-theme="dark"] #historyModal .hm-footer {
  border-top-color: var(--border-color) !important;
}

[data-theme="dark"] #historyModal .hm-btn-ghost {
  background: var(--bg-tertiary) !important;
  color: var(--text-secondary) !important;
}

[data-theme="dark"] #historyModal .hm-btn-ghost:hover {
  background: var(--border-hover) !important;
}

[data-theme="dark"] #historyModal .hm-btn-danger {
  color: var(--text-muted) !important;
}

[data-theme="dark"] #historyModal .hm-btn-danger:hover {
  color: var(--danger) !important;
}

/* History item text colors */
[data-theme="dark"] .history-item-name,
[data-theme="dark"] .history-item {
  color: var(--text-primary) !important;
}

[data-theme="dark"] .history-item-code,
[data-theme="dark"] .history-item-time {
  color: var(--text-muted) !important;
}

[data-theme="dark"] .history-item-remove {
  color: var(--text-muted) !important;
}

/* ─── Duplicate Client Modal ─── */
[data-theme="dark"] .duplicate-client-modal-container {
  background: var(--bg-primary) !important;
  box-shadow: 0 20px 60px -12px rgba(0,0,0,0.6) !important;
}

[data-theme="dark"] .duplicate-client-modal-header {
  background: var(--bg-primary) !important;
  border-bottom-color: var(--border-color) !important;
}

[data-theme="dark"] .duplicate-client-modal-title {
  color: var(--text-primary) !important;
}

[data-theme="dark"] .duplicate-client-modal-subtitle {
  color: var(--text-secondary) !important;
}

[data-theme="dark"] .duplicate-client-modal-close {
  background: var(--bg-tertiary) !important;
  color: var(--text-muted) !important;
}

[data-theme="dark"] .duplicate-client-modal-close:hover {
  background: var(--border-hover) !important;
  color: var(--text-primary) !important;
}

[data-theme="dark"] .duplicate-client-modal-body {
  color: var(--text-primary) !important;
}

[data-theme="dark"] .duplicate-client-info {
  background: var(--bg-secondary) !important;
  border-color: var(--border-color) !important;
}

[data-theme="dark"] .duplicate-client-info-label {
  color: var(--text-muted) !important;
}

[data-theme="dark"] .duplicate-client-info-value {
  color: var(--text-primary) !important;
}

[data-theme="dark"] .duplicate-client-modal-footer {
  border-top-color: var(--border-color) !important;
}

[data-theme="dark"] .duplicate-client-btn-secondary {
  background: var(--bg-tertiary) !important;
  color: var(--text-secondary) !important;
  border-color: var(--border-color) !important;
}

[data-theme="dark"] .duplicate-client-btn-secondary:hover {
  background: var(--border-hover) !important;
}

/* ─── RA Modal (Renouvellement avec Adaptation) ─── */
[data-theme="dark"] .ra-modal__content {
  background: var(--bg-primary) !important;
  box-shadow: 0 24px 48px rgba(0,0,0,0.5) !important;
}

[data-theme="dark"] .ra-modal__header {
  background: var(--bg-secondary) !important;
  border-bottom-color: var(--border-color) !important;
}

[data-theme="dark"] .ra-modal__header h3 {
  color: var(--text-primary) !important;
}

[data-theme="dark"] .ra-modal__close {
  color: var(--text-muted) !important;
}

[data-theme="dark"] .ra-modal__close:hover {
  background: var(--bg-tertiary) !important;
  color: var(--text-primary) !important;
}

[data-theme="dark"] .ra-form-panel {
  border-right-color: var(--border-color) !important;
}

[data-theme="dark"] .ra-section-title {
  color: var(--text-muted) !important;
}

[data-theme="dark"] .ra-corr-block {
  background: var(--bg-secondary) !important;
  border-color: var(--border-color) !important;
}

[data-theme="dark"] .ra-corr-header {
  background: var(--bg-tertiary) !important;
  border-bottom-color: var(--border-color) !important;
}

[data-theme="dark"] .ra-corr-header span {
  color: var(--text-muted) !important;
}

[data-theme="dark"] .ra-corr-row + .ra-corr-row {
  border-top-color: var(--border-color) !important;
}

[data-theme="dark"] .ra-corr-row__label {
  color: var(--text-secondary) !important;
}

[data-theme="dark"] .ra-corr-input {
  background: var(--bg-primary) !important;
  border-color: var(--border-color) !important;
  color: var(--text-primary) !important;
}

[data-theme="dark"] .ra-corr-input:focus {
  border-color: var(--accent) !important;
}

[data-theme="dark"] .ra-text-toolbar {
  background: #2d2300 !important;
  border-bottom-color: #8b6914 !important;
}

[data-theme="dark"] .ra-text-toolbar__select {
  background: var(--bg-secondary) !important;
  border-color: var(--border-color) !important;
  color: var(--text-primary) !important;
}

/* ─── Correction tables (light blue headers → dark) ─── */
[data-theme="dark"] [style*="background: #f0f9ff"],
[data-theme="dark"] [style*="background:#f0f9ff"] {
  background: var(--bg-tertiary) !important;
}

[data-theme="dark"] [style*="background: #e0f2fe"],
[data-theme="dark"] [style*="background:#e0f2fe"] {
  background: var(--bg-secondary) !important;
}

[data-theme="dark"] [style*="background: linear-gradient(135deg, #f0f9ff"],
[data-theme="dark"] [style*="background:linear-gradient(135deg, #f0f9ff"],
[data-theme="dark"] [style*="background: linear-gradient(135deg,#f0f9ff"] {
  background: linear-gradient(135deg, var(--bg-secondary), var(--bg-tertiary)) !important;
}

[data-theme="dark"] [style*="border: 1px solid #0ea5e9"],
[data-theme="dark"] [style*="border:1px solid #0ea5e9"] {
  border-color: #1e5a8a !important;
}

[data-theme="dark"] [style*="border-bottom: 2px solid #0ea5e9"] {
  border-bottom-color: #1e5a8a !important;
}

/* ─── Inline backgrounds (more patterns) ─── */
[data-theme="dark"] [style*="background: #f8fafc"],
[data-theme="dark"] [style*="background:#f8fafc"] {
  background: var(--bg-secondary) !important;
}

[data-theme="dark"] [style*="background: #f9fafb"],
[data-theme="dark"] [style*="background:#f9fafb"] {
  background: var(--bg-secondary) !important;
}

[data-theme="dark"] [style*="background: #f3f4f6"],
[data-theme="dark"] [style*="background:#f3f4f6"] {
  background: var(--bg-tertiary) !important;
}

[data-theme="dark"] [style*="background: #f1f5f9"],
[data-theme="dark"] [style*="background:#f1f5f9"] {
  background: var(--bg-tertiary) !important;
}

[data-theme="dark"] [style*="background-color: #fafafa"],
[data-theme="dark"] [style*="background-color:#fafafa"] {
  background-color: var(--bg-secondary) !important;
}

[data-theme="dark"] [style*="background-color: #f0f9ff"],
[data-theme="dark"] [style*="background-color:#f0f9ff"] {
  background-color: var(--bg-secondary) !important;
}

/* ─── Inline border overrides ─── */
[data-theme="dark"] [style*="border: 1px solid #e2e8f0"],
[data-theme="dark"] [style*="border:1px solid #e2e8f0"],
[data-theme="dark"] [style*="border: 1.5px solid #e2e8f0"],
[data-theme="dark"] [style*="border:1.5px solid #e2e8f0"] {
  border-color: var(--border-color) !important;
}

[data-theme="dark"] [style*="border: 1px solid #d1d5db"],
[data-theme="dark"] [style*="border:1px solid #d1d5db"] {
  border-color: var(--border-color) !important;
}

[data-theme="dark"] [style*="border-bottom: 1px solid #f1f5f9"],
[data-theme="dark"] [style*="border-bottom:1px solid #f1f5f9"] {
  border-bottom-color: var(--border-color) !important;
}

[data-theme="dark"] [style*="border-top: 1px solid #f1f5f9"],
[data-theme="dark"] [style*="border-top:1px solid #f1f5f9"] {
  border-top-color: var(--border-color) !important;
}

[data-theme="dark"] [style*="border-bottom: 1px solid #f3f4f6"],
[data-theme="dark"] [style*="border-bottom:1px solid #f3f4f6"] {
  border-bottom-color: var(--border-color) !important;
}

[data-theme="dark"] [style*="border: 1px solid #e5e7eb"],
[data-theme="dark"] [style*="border:1px solid #e5e7eb"] {
  border-color: var(--border-color) !important;
}

/* ─── Inline color overrides (more patterns) ─── */
[data-theme="dark"] [style*="color: #1e293b"],
[data-theme="dark"] [style*="color:#1e293b"] {
  color: var(--text-primary) !important;
}

[data-theme="dark"] [style*="color: #334155"],
[data-theme="dark"] [style*="color:#334155"] {
  color: var(--text-secondary) !important;
}

[data-theme="dark"] [style*="color: #475569"],
[data-theme="dark"] [style*="color:#475569"] {
  color: var(--text-secondary) !important;
}

[data-theme="dark"] [style*="color: #64748b"],
[data-theme="dark"] [style*="color:#64748b"] {
  color: var(--text-muted) !important;
}

/* ─── Clean Modal (WhatsApp / Email) ─── */
[data-theme="dark"] .clean-modal .modal-content {
  background: var(--bg-primary) !important;
}

[data-theme="dark"] .clean-modal .cm-header {
  border-bottom-color: var(--border-color) !important;
}

[data-theme="dark"] .clean-modal .cm-header-left {
  color: var(--text-primary) !important;
}

[data-theme="dark"] .clean-modal .cm-close {
  color: var(--text-muted) !important;
}

[data-theme="dark"] .clean-modal .cm-close:hover {
  background: var(--bg-tertiary) !important;
  color: var(--text-primary) !important;
}

[data-theme="dark"] .clean-modal .cm-body {
  color: var(--text-primary) !important;
}

[data-theme="dark"] .clean-modal .cm-divider {
  background: var(--border-color) !important;
}

[data-theme="dark"] .clean-modal .cm-recipient-label {
  color: var(--text-muted) !important;
}

[data-theme="dark"] .clean-modal .cm-recipient-value {
  color: var(--text-primary) !important;
}

[data-theme="dark"] .clean-modal .cm-section-label {
  color: var(--text-secondary) !important;
}

[data-theme="dark"] .clean-modal .cm-small-btn {
  background: var(--bg-tertiary) !important;
  color: var(--text-secondary) !important;
}

[data-theme="dark"] .clean-modal .cm-textarea,
[data-theme="dark"] .clean-modal .cm-input {
  background: var(--bg-secondary) !important;
  border-color: var(--border-color) !important;
  color: var(--text-primary) !important;
}

[data-theme="dark"] .clean-modal .cm-pill {
  background: var(--accent-light) !important;
  color: var(--accent-hover) !important;
}

[data-theme="dark"] .clean-modal .cm-dropzone {
  background: var(--bg-secondary) !important;
  border-color: var(--border-color) !important;
}

[data-theme="dark"] .clean-modal .cm-dropzone-icon {
  color: var(--text-muted) !important;
}

[data-theme="dark"] .clean-modal .cm-footer {
  border-top-color: var(--border-color) !important;
  background: var(--bg-secondary) !important;
}

[data-theme="dark"] .clean-modal .cm-btn-cancel {
  background: var(--bg-tertiary) !important;
  color: var(--text-secondary) !important;
}

/* ─── Toggle switch ─── */
[data-theme="dark"] [style*="background: #e5e7eb"],
[data-theme="dark"] [style*="background:#e5e7eb"] {
  background: var(--bg-tertiary) !important;
}

/* ─── Observation textarea ─── */
[data-theme="dark"] textarea {
  background: var(--bg-secondary) !important;
  border-color: var(--border-color) !important;
  color: var(--text-primary) !important;
}

/* ─── Column select modal ─── */
[data-theme="dark"] .column-select-modal {
  background: var(--bg-primary) !important;
}

/* ─── Family modal ─── */
[data-theme="dark"] #familyModal .modal-content {
  background: var(--bg-primary) !important;
}

/* ─── Payment modal ─── */
[data-theme="dark"] .payment-modal {
  background: var(--bg-primary) !important;
}

/* ─── Inline style background overrides for JS-generated content ─── */
[data-theme="dark"] div[style*="background: rgb(249, 250, 251)"],
[data-theme="dark"] div[style*="background-color: rgb(249, 250, 251)"] {
  background: var(--bg-secondary) !important;
  background-color: var(--bg-secondary) !important;
}

[data-theme="dark"] div[style*="background: rgb(255, 255, 255)"],
[data-theme="dark"] div[style*="background-color: rgb(255, 255, 255)"] {
  background: var(--bg-primary) !important;
  background-color: var(--bg-primary) !important;
}

[data-theme="dark"] div[style*="background: rgb(243, 244, 246)"],
[data-theme="dark"] div[style*="background-color: rgb(243, 244, 246)"] {
  background: var(--bg-tertiary) !important;
  background-color: var(--bg-tertiary) !important;
}

/* ─── Clients table inline styles (iPad overrides) ─── */
[data-theme="dark"] #clientsList th {
  background: var(--bg-secondary) !important;
}

[data-theme="dark"] #clientsList tbody tr:nth-child(even) {
  background-color: var(--bg-secondary) !important;
}

[data-theme="dark"] #clientsList tbody tr:hover {
  background-color: var(--bg-tertiary) !important;
}

/* ─── General text inside dark modals ─── */
[data-theme="dark"] .modal h3,
[data-theme="dark"] .modal h4,
[data-theme="dark"] .modal h5,
[data-theme="dark"] .modal p,
[data-theme="dark"] .modal span:not(.material-symbols-outlined):not(.navbar-action-badge) {
  color: inherit;
}

/* ─── Select option dark mode ─── */
[data-theme="dark"] option {
  background: var(--bg-secondary) !important;
  color: var(--text-primary) !important;
}

/* ─── Autocomplete / suggestion dropdown ─── */
[data-theme="dark"] .autocomplete-items,
[data-theme="dark"] .suggestions-dropdown,
[data-theme="dark"] [class*="suggestion"] {
  background: var(--bg-secondary) !important;
  border-color: var(--border-color) !important;
}

[data-theme="dark"] .autocomplete-items div:hover,
[data-theme="dark"] .suggestions-dropdown div:hover {
  background: var(--bg-tertiary) !important;
}

/* ─── Search container global ─── */
[data-theme="dark"] .search-container input,
[data-theme="dark"] #headerSearchInput {
  background: var(--bg-secondary) !important;
  border-color: var(--border-color) !important;
  color: var(--text-primary) !important;
}

/* ─── Navbar link colors override for inline styles ─── */
[data-theme="dark"] .navbar-link[style] {
  color: var(--text-secondary) !important;
}

[data-theme="dark"] .navbar-link[style]:hover,
[data-theme="dark"] .navbar-link[style].active {
  color: var(--text-primary) !important;
}

/* =========================================================
   PAGE-SPECIFIC DARK MODE OVERRIDES
   ========================================================= */

/* ─── Agenda ─── */
[data-theme="dark"] .agenda-container {
  background: var(--bg-primary) !important;
}

[data-theme="dark"] .agenda-header {
  background: var(--bg-primary) !important;
  border-bottom-color: var(--border-color) !important;
}

[data-theme="dark"] .agenda-date-nav {
  background: var(--bg-secondary) !important;
  border-color: var(--border-color) !important;
}

[data-theme="dark"] .agenda-day-section {
  background: rgba(59,130,246,0.08) !important;
}

[data-theme="dark"] .agenda-task-item {
  background: var(--bg-secondary) !important;
  border-color: var(--border-color) !important;
}

[data-theme="dark"] .agenda-task-item:hover {
  background: var(--bg-tertiary) !important;
}

[data-theme="dark"] .agenda-no-store {
  background: #3d3000 !important;
  color: var(--text-primary) !important;
}

/* ─── Caisse ─── */
[data-theme="dark"] .encaissements-table {
  background: var(--bg-primary) !important;
}

[data-theme="dark"] .table-header {
  background: var(--bg-secondary) !important;
  border-bottom-color: var(--border-color) !important;
}

[data-theme="dark"] .export-dropdown-menu {
  background: var(--bg-secondary) !important;
  border-color: var(--border-color) !important;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5) !important;
}

[data-theme="dark"] .btn-icon {
  background: var(--bg-tertiary) !important;
  color: var(--text-secondary) !important;
}

[data-theme="dark"] .btn-icon:hover {
  background: var(--border-hover) !important;
}

[data-theme="dark"] .payment-stat-card {
  background: var(--bg-secondary) !important;
  border-color: var(--border-color) !important;
}

[data-theme="dark"] .payment-stats-container {
  color: var(--text-primary) !important;
}

/* ─── Renouvellement ─── */
[data-theme="dark"] .rv-card {
  background: var(--bg-secondary) !important;
  border-color: var(--border-color) !important;
}

[data-theme="dark"] .rv-table-wrap {
  background: var(--bg-primary) !important;
}

[data-theme="dark"] .rv-filters-line {
  background: var(--bg-secondary) !important;
}

[data-theme="dark"] .rv-search {
  background: var(--bg-secondary) !important;
  border-color: var(--border-color) !important;
  color: var(--text-primary) !important;
}

[data-theme="dark"] .rv-bar {
  background: var(--bg-secondary) !important;
  border-color: var(--border-color) !important;
}

[data-theme="dark"] .rv-modal {
  background: var(--bg-primary) !important;
}

/* ─── Commandes ─── */
[data-theme="dark"] .search-input {
  background: var(--bg-secondary) !important;
  border-color: var(--border-color) !important;
  color: var(--text-primary) !important;
}

[data-theme="dark"] .status-badge {
  background: var(--bg-tertiary) !important;
  color: var(--text-secondary) !important;
}

[data-theme="dark"] #dateFilterWrapper {
  background: var(--bg-secondary) !important;
  border-color: var(--border-color) !important;
}

[data-theme="dark"] #dateFilterWrapper input {
  background: var(--bg-secondary) !important;
  border-color: var(--border-color) !important;
  color: var(--text-primary) !important;
}

/* ─── Montures / Verres table overrides ─── */
[data-theme="dark"] #monturesList th {
  background: var(--bg-secondary) !important;
}

[data-theme="dark"] #monturesList tbody tr:nth-child(2n) {
  background-color: var(--bg-secondary) !important;
}

[data-theme="dark"] #monturesList tbody tr:hover {
  background-color: var(--bg-tertiary) !important;
}

[data-theme="dark"] #verresList tbody tr:nth-child(2n) {
  background-color: var(--bg-secondary) !important;
}

[data-theme="dark"] #doctorsList th {
  background: var(--bg-secondary) !important;
}

/* ─── Fournisseurs ─── */
[data-theme="dark"] #marquesContainer {
  background: var(--bg-secondary) !important;
  border-color: var(--border-color) !important;
}

[data-theme="dark"] .marque-tag {
  background: var(--accent-light) !important;
  color: var(--accent-hover) !important;
}

/* ─── Admin pages ─── */
[data-theme="dark"] .invoices-header {
  background: var(--bg-primary) !important;
}

[data-theme="dark"] .filters-section {
  background: var(--bg-primary) !important;
  border-color: var(--border-color) !important;
}

[data-theme="dark"] .quick-action-btn.secondary {
  background: var(--bg-secondary) !important;
  border-color: var(--border-color) !important;
  color: var(--text-primary) !important;
}

[data-theme="dark"] .quick-action-btn.secondary:hover {
  background: var(--bg-tertiary) !important;
}

/* ─── Editable inputs (verre etc.) ─── */
[data-theme="dark"] .editable-input {
  background: transparent !important;
  color: var(--text-primary) !important;
  border-color: transparent !important;
}

[data-theme="dark"] .editable-input:hover {
  border-color: var(--border-hover) !important;
}

[data-theme="dark"] .editable-input:focus {
  background: var(--bg-secondary) !important;
  border-color: var(--accent) !important;
}

/* ─── Renouvellement CSS vars override ─── */
[data-theme="dark"] {
  --g50: #232e45;
  --g100: #2d3a54;
  --g200: #364158;
  --g300: #4a5a75;
  --g400: #8896ab;
  --g500: #a0aec0;
  --g600: #cbd5e1;
  --g700: #e2e8f0;
  --g800: #e8edf5;
  --g900: #f1f5f9;
}

/* ─── Universal catch-all: JS-generated light backgrounds ─── */
[data-theme="dark"] [style*="background: #fafafa"],
[data-theme="dark"] [style*="background:#fafafa"] {
  background: var(--bg-secondary) !important;
}

[data-theme="dark"] [style*="background: #eff6ff"],
[data-theme="dark"] [style*="background:#eff6ff"] {
  background: var(--accent-light) !important;
}

[data-theme="dark"] [style*="background: #ecfdf5"],
[data-theme="dark"] [style*="background:#ecfdf5"] {
  background: var(--success-light) !important;
}

[data-theme="dark"] [style*="background: #fee2e2"],
[data-theme="dark"] [style*="background:#fee2e2"] {
  background: var(--danger-light) !important;
}

[data-theme="dark"] [style*="background: #fef3c7"],
[data-theme="dark"] [style*="background:#fef3c7"] {
  background: #3d3000 !important;
}

/* ─── Strong text color overrides for deeply nested spans ─── */
[data-theme="dark"] [style*="color: #0c4a6e"],
[data-theme="dark"] [style*="color:#0c4a6e"] {
  color: var(--accent-hover) !important;
}

[data-theme="dark"] [style*="color: #065f46"],
[data-theme="dark"] [style*="color:#065f46"] {
  color: var(--success) !important;
}

[data-theme="dark"] [style*="color: #5b21b6"],
[data-theme="dark"] [style*="color:#5b21b6"] {
  color: #a78bfa !important;
}

/* ─── Box shadow overrides for light mode shadows ─── */
[data-theme="dark"] [style*="box-shadow: 0 2px 8px rgba(0,0,0,.08)"],
[data-theme="dark"] [style*="box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08)"] {
  box-shadow: 0 2px 8px rgba(0,0,0,0.3) !important;
}

/* ─── HR and dividers ─── */
[data-theme="dark"] hr {
  border-color: var(--border-color) !important;
}

/* ─── Tab containers ─── */
[data-theme="dark"] #tabContainer {
  background: var(--bg-secondary) !important;
}

/* ─── Footer ─── */
[data-theme="dark"] #footerContainer,
[data-theme="dark"] .footer {
  background: var(--bg-secondary) !important;
  border-top-color: var(--border-color) !important;
  color: var(--text-muted) !important;
}

/* ─── Admin modals ─── */
[data-theme="dark"] #storeModal .modal-content,
[data-theme="dark"] #sellersListModal .modal-content,
[data-theme="dark"] #addOrderModal .modal-content,
[data-theme="dark"] #whatsappReceivedModal,
[data-theme="dark"] #whatsappTemplatesModal,
[data-theme="dark"] #editWhatsAppTemplateModal {
  background: var(--bg-primary) !important;
  color: var(--text-primary) !important;
}

/* ─── Catch-all: remaining white text containers ─── */
[data-theme="dark"] .clients-table {
  background: var(--bg-primary) !important;
}

[data-theme="dark"] .clients-container {
  background: var(--bg-primary) !important;
}

/* =========================================================
   WHATSAPP PAGE
   ========================================================= */
[data-theme="dark"] .ws-page {
  color: var(--text-primary);
}

[data-theme="dark"] .ws-header {
  background: var(--bg-secondary) !important;
  border-color: var(--border-color) !important;
}

[data-theme="dark"] .ws-header-content h1 {
  color: var(--text-primary) !important;
}

[data-theme="dark"] .ws-header-content p {
  color: var(--text-secondary) !important;
}

[data-theme="dark"] .ws-card {
  background: var(--bg-secondary) !important;
  border-color: var(--border-color) !important;
}

[data-theme="dark"] .ws-card-title {
  color: var(--text-primary) !important;
  border-bottom-color: var(--border-color) !important;
}

[data-theme="dark"] .ws-status {
  border-color: var(--border-color) !important;
}

[data-theme="dark"] .ws-status--connected {
  background: var(--success-light) !important;
  border-color: #166534 !important;
}

[data-theme="dark"] .ws-status--disconnected {
  background: var(--danger-light) !important;
  border-color: #7f1d1d !important;
}

[data-theme="dark"] .ws-status-label {
  color: var(--text-primary) !important;
}

[data-theme="dark"] .ws-status-details {
  color: var(--text-secondary) !important;
}

[data-theme="dark"] .ws-status-badge--connected {
  background: #14532d !important;
  color: var(--success) !important;
}

[data-theme="dark"] .ws-status-badge--disconnected {
  background: #450a0a !important;
  color: var(--danger) !important;
}

[data-theme="dark"] .ws-qr-container {
  background: var(--bg-tertiary) !important;
  border-color: var(--border-color) !important;
}

[data-theme="dark"] .ws-qr-wrapper {
  background: var(--bg-primary) !important;
}

[data-theme="dark"] .ws-qr-loading {
  color: var(--text-secondary) !important;
}

[data-theme="dark"] .ws-qr-spinner {
  border-color: var(--border-color) !important;
  border-top-color: var(--accent) !important;
}

[data-theme="dark"] .ws-logout-desc {
  color: var(--text-secondary) !important;
}

[data-theme="dark"] .ws-confirm-box {
  background: var(--bg-primary) !important;
  box-shadow: 0 20px 50px rgba(0,0,0,0.5) !important;
}

[data-theme="dark"] .ws-confirm-box h3 {
  color: var(--text-primary) !important;
}

[data-theme="dark"] .ws-confirm-box p {
  color: var(--text-secondary) !important;
}

[data-theme="dark"] .ws-confirm-icon {
  background: var(--danger-light) !important;
}

[data-theme="dark"] .ws-btn-ghost {
  background: var(--bg-tertiary) !important;
  color: var(--text-secondary) !important;
}

[data-theme="dark"] .ws-btn-ghost:hover {
  background: var(--border-hover) !important;
}

/* =========================================================
   STORE SETTINGS PAGE
   ========================================================= */
[data-theme="dark"] .store-page {
  color: var(--text-primary);
}

[data-theme="dark"] .store-sidebar {
  color: var(--text-primary);
}

[data-theme="dark"] .sidebar-header {
  border-bottom-color: var(--border-color) !important;
}

[data-theme="dark"] .sidebar-title {
  color: var(--text-primary) !important;
}

[data-theme="dark"] .sidebar-link {
  color: var(--text-secondary) !important;
}

[data-theme="dark"] .sidebar-link:hover {
  background: var(--bg-tertiary) !important;
  color: var(--text-primary) !important;
}

[data-theme="dark"] .sidebar-link.active {
  background: var(--accent-light) !important;
  color: var(--accent) !important;
}

[data-theme="dark"] .card {
  background: var(--bg-secondary) !important;
  border-color: var(--border-color) !important;
}

[data-theme="dark"] .card-title {
  color: var(--text-primary) !important;
  border-bottom-color: var(--border-color) !important;
}

[data-theme="dark"] .page-title {
  color: var(--text-primary) !important;
}

[data-theme="dark"] .page-subtitle {
  color: var(--text-secondary) !important;
}

[data-theme="dark"] .form-select {
  background: var(--bg-secondary) !important;
  border-color: var(--border-color) !important;
  color: var(--text-primary) !important;
}

[data-theme="dark"] .form-input:disabled,
[data-theme="dark"] .form-select:disabled {
  background: var(--bg-tertiary) !important;
}

[data-theme="dark"] .password-info {
  background: var(--accent-light) !important;
  border-color: var(--accent) !important;
  color: var(--text-secondary) !important;
}

[data-theme="dark"] .password-toggle-btn {
  color: var(--text-muted) !important;
}

/* =========================================================
   ADMIN BILLING PAGE
   ========================================================= */
[data-theme="dark"] .billing-section {
  background: var(--bg-secondary) !important;
  border-color: var(--border-color) !important;
}

[data-theme="dark"] .section-header {
  border-bottom-color: var(--border-color) !important;
  color: var(--text-primary) !important;
}

[data-theme="dark"] .preview-section {
  background: var(--bg-secondary) !important;
}

[data-theme="dark"] .preview-content {
  background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-tertiary) 100%) !important;
}

[data-theme="dark"] .preview-invoice {
  background: var(--bg-primary) !important;
  border-color: var(--border-color) !important;
}

[data-theme="dark"] .preview-details {
  color: var(--text-secondary) !important;
}

[data-theme="dark"] .form-help {
  color: var(--text-muted) !important;
}

[data-theme="dark"] .action-buttons {
  background: var(--bg-secondary) !important;
  border-top-color: var(--border-color) !important;
}

/* =========================================================
   ADMIN STRIPE PAGE
   ========================================================= */
[data-theme="dark"] .stripe-header {
  background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%) !important;
  border-color: var(--border-color) !important;
}

[data-theme="dark"] .stat-card {
  background: var(--bg-secondary) !important;
  border-color: var(--border-color) !important;
}

/* Stat card colored icons — dark variants */
[data-theme="dark"] .stat-card-icon.blue {
  background: linear-gradient(135deg, #1e3a5f 0%, #1e40af 100%) !important;
}

[data-theme="dark"] .stat-card-icon.green {
  background: linear-gradient(135deg, #14532d 0%, #166534 100%) !important;
}

[data-theme="dark"] .stat-card-icon.purple {
  background: linear-gradient(135deg, #3b0764 0%, #581c87 100%) !important;
}

[data-theme="dark"] .stat-card-icon.amber {
  background: linear-gradient(135deg, #451a03 0%, #78350f 100%) !important;
}

/* Status badges with gradients */
[data-theme="dark"] .status-badge.success {
  background: linear-gradient(135deg, #14532d 0%, #166534 100%) !important;
  color: var(--success) !important;
}

[data-theme="dark"] .status-badge.pending {
  background: linear-gradient(135deg, #451a03 0%, #78350f 100%) !important;
  color: #fbbf24 !important;
}

[data-theme="dark"] .status-badge.failed {
  background: linear-gradient(135deg, #450a0a 0%, #7f1d1d 100%) !important;
  color: var(--danger) !important;
}

/* =========================================================
   ADMIN WHATSAPP PAGE
   ========================================================= */
[data-theme="dark"] .whatsapp-card {
  background: var(--bg-secondary) !important;
  border-color: var(--border-color) !important;
}

[data-theme="dark"] .whatsapp-card__icon--status {
  background: linear-gradient(135deg, #1e3a5f 0%, #1e40af 100%) !important;
}

[data-theme="dark"] .whatsapp-card__icon--qr {
  background: linear-gradient(135deg, #451a03 0%, #78350f 100%) !important;
}

[data-theme="dark"] .whatsapp-card__icon--logout {
  background: linear-gradient(135deg, #450a0a 0%, #7f1d1d 100%) !important;
}

[data-theme="dark"] .status-container {
  background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-tertiary) 100%) !important;
  border-color: var(--border-color) !important;
}

[data-theme="dark"] .status-container.connected {
  background: linear-gradient(135deg, #14532d 0%, #166534 100%) !important;
  border-color: #166534 !important;
}

[data-theme="dark"] .qr-container {
  background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%) !important;
}

[data-theme="dark"] .qr-code-wrapper {
  background: var(--bg-primary) !important;
}

/* =========================================================
   ADMIN MAIL SETTINGS PAGE
   ========================================================= */
[data-theme="dark"] .info-badge {
  background: var(--accent-light) !important;
  color: var(--accent-hover) !important;
}

[data-theme="dark"] .checkbox-wrapper {
  background: var(--bg-secondary) !important;
  border-color: var(--border-color) !important;
}

[data-theme="dark"] .signature-editor-wrapper {
  background: var(--bg-secondary) !important;
  border-color: var(--border-color) !important;
}

/* Alert messages */
[data-theme="dark"] .alert-success {
  background: linear-gradient(135deg, #14532d 0%, #166534 100%) !important;
  color: var(--success) !important;
}

[data-theme="dark"] .alert-error {
  background: linear-gradient(135deg, #450a0a 0%, #7f1d1d 100%) !important;
  color: var(--danger) !important;
}

[data-theme="dark"] .alert {
  border-color: var(--border-color) !important;
}

/* =========================================================
   ADMIN INVOICES LIST PAGE
   ========================================================= */
[data-theme="dark"] .invoices-table thead {
  background: var(--bg-secondary) !important;
}

/* =========================================================
   ADMIN INVOICES PAGE
   ========================================================= */
[data-theme="dark"] .invoice-section {
  background: var(--bg-secondary) !important;
  border-color: var(--border-color) !important;
}

[data-theme="dark"] .items-table th {
  background: var(--bg-secondary) !important;
  color: var(--text-primary) !important;
}

[data-theme="dark"] .totals-table .total-row {
  background: var(--bg-secondary) !important;
}

[data-theme="dark"] .input-field {
  background: var(--bg-secondary) !important;
  border-color: var(--border-color) !important;
  color: var(--text-primary) !important;
}

/* =========================================================
   ADMIN SELLERS STATISTICS PAGE
   ========================================================= */
[data-theme="dark"] .stats-header {
  background: var(--bg-secondary) !important;
  border-color: var(--border-color) !important;
}

[data-theme="dark"] .stats-card {
  background: var(--bg-secondary) !important;
  border-color: var(--border-color) !important;
}

/* =========================================================
   BACKUPS PAGE
   ========================================================= */
[data-theme="dark"] .backup-card {
  background: var(--bg-secondary) !important;
  border-color: var(--border-color) !important;
}

/* =========================================================
   LABEL SETTINGS PAGE
   ========================================================= */
[data-theme="dark"] .ls-field input[readonly] {
  background: var(--bg-tertiary) !important;
  color: var(--text-secondary) !important;
}

[data-theme="dark"] .ls-checkbox {
  background: var(--bg-secondary) !important;
  border-color: var(--border-color) !important;
}

/* =========================================================
   MAIL SETTINGS PAGE
   ========================================================= */
[data-theme="dark"] .ms-field input {
  background: var(--bg-secondary) !important;
  border-color: var(--border-color) !important;
  color: var(--text-primary) !important;
}

[data-theme="dark"] .ms-checkbox {
  background: var(--bg-secondary) !important;
  border-color: var(--border-color) !important;
}

[data-theme="dark"] .signature-editor {
  background: var(--bg-secondary) !important;
  border-color: var(--border-color) !important;
  color: var(--text-primary) !important;
}

[data-theme="dark"] .help-example {
  background: var(--bg-secondary) !important;
  border-color: var(--border-color) !important;
}

/* =========================================================
   HELP PAGE
   ========================================================= */
[data-theme="dark"] .feature-card {
  background: var(--bg-secondary) !important;
  border-color: var(--border-color) !important;
}

[data-theme="dark"] .help-section {
  background: var(--bg-secondary) !important;
}

/* =========================================================
   RETROCESSION PAGE
   ========================================================= */
[data-theme="dark"] .panel {
  background: var(--bg-secondary) !important;
  border-color: var(--border-color) !important;
}

[data-theme="dark"] .retrocession-card {
  background: var(--bg-secondary) !important;
  border-color: var(--border-color) !important;
}

[data-theme="dark"] .retrocession-card--active {
  background: var(--accent-light) !important;
  border-color: var(--accent) !important;
}

/* =========================================================
   STORE FRIENDS PAGE
   ========================================================= */
[data-theme="dark"] .friend-card {
  background: var(--bg-secondary) !important;
  border-color: var(--border-color) !important;
}

/* =========================================================
   IMPORTS PAGE
   ========================================================= */
[data-theme="dark"] .import-card {
  background: var(--bg-secondary) !important;
  border-color: var(--border-color) !important;
}

[data-theme="dark"] .dropzone {
  background: var(--bg-secondary) !important;
  border-color: var(--border-color) !important;
}

[data-theme="dark"] .dropzone:hover {
  background: var(--bg-tertiary) !important;
}

/* =========================================================
   LOGIN PAGES
   ========================================================= */
[data-theme="dark"] .login-container,
[data-theme="dark"] .login-form-side,
[data-theme="dark"] .login-card {
  background: var(--bg-primary) !important;
  color: var(--text-primary) !important;
}

[data-theme="dark"] .login-form-side input,
[data-theme="dark"] .login-card input {
  background: var(--bg-secondary) !important;
  border-color: var(--border-color) !important;
  color: var(--text-primary) !important;
}

[data-theme="dark"] .login-form-side label,
[data-theme="dark"] .login-card label {
  color: var(--text-secondary) !important;
}

[data-theme="dark"] .login-footer {
  color: var(--text-muted) !important;
}

/* =========================================================
   LANDING / INDEX PAGE
   ========================================================= */
[data-theme="dark"] .landing-nav {
  background: var(--bg-primary) !important;
  border-bottom-color: var(--border-color) !important;
}

[data-theme="dark"] .hero {
  background: var(--bg-primary) !important;
}

[data-theme="dark"] .hero h1,
[data-theme="dark"] .hero h2 {
  color: var(--text-primary) !important;
}

[data-theme="dark"] .hero p {
  color: var(--text-secondary) !important;
}

[data-theme="dark"] .feature-section {
  background: var(--bg-primary) !important;
}

/* =========================================================
   GRADIENT BACKGROUNDS — UNIVERSAL DARK OVERRIDES
   ========================================================= */

/* Light blue gradients → dark blue */
[data-theme="dark"] [style*="linear-gradient(135deg, #f0f9ff"],
[data-theme="dark"] [style*="linear-gradient(135deg,#f0f9ff"],
[data-theme="dark"] [style*="linear-gradient(135deg, #fff"],
[data-theme="dark"] [style*="linear-gradient(135deg,#fff"],
[data-theme="dark"] [style*="linear-gradient(135deg, #ffffff"],
[data-theme="dark"] [style*="linear-gradient(135deg,#ffffff"],
[data-theme="dark"] [style*="linear-gradient(180deg,#fff"],
[data-theme="dark"] [style*="linear-gradient(180deg, #fff"] {
  background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%) !important;
}

/* Success/green gradients */
[data-theme="dark"] [style*="linear-gradient(135deg, #d1fae5"],
[data-theme="dark"] [style*="linear-gradient(135deg,#d1fae5"],
[data-theme="dark"] [style*="linear-gradient(135deg, #ecfdf5"],
[data-theme="dark"] [style*="linear-gradient(135deg,#ecfdf5"] {
  background: linear-gradient(135deg, #14532d 0%, #166534 100%) !important;
}

/* Danger/red gradients */
[data-theme="dark"] [style*="linear-gradient(135deg, #fee2e2"],
[data-theme="dark"] [style*="linear-gradient(135deg,#fee2e2"],
[data-theme="dark"] [style*="linear-gradient(135deg, #fef2f2"],
[data-theme="dark"] [style*="linear-gradient(135deg,#fef2f2"] {
  background: linear-gradient(135deg, #450a0a 0%, #7f1d1d 100%) !important;
}

/* Warning/amber gradients */
[data-theme="dark"] [style*="linear-gradient(135deg, #fef3c7"],
[data-theme="dark"] [style*="linear-gradient(135deg,#fef3c7"] {
  background: linear-gradient(135deg, #451a03 0%, #78350f 100%) !important;
}

/* Blue icon gradients */
[data-theme="dark"] [style*="linear-gradient(135deg, #dbeafe"],
[data-theme="dark"] [style*="linear-gradient(135deg,#dbeafe"] {
  background: linear-gradient(135deg, #1e3a5f 0%, #1e40af 100%) !important;
}

/* Purple icon gradients */
[data-theme="dark"] [style*="linear-gradient(135deg, #e9d5ff"],
[data-theme="dark"] [style*="linear-gradient(135deg,#e9d5ff"] {
  background: linear-gradient(135deg, #3b0764 0%, #581c87 100%) !important;
}

/* Gray gradients */
[data-theme="dark"] [style*="linear-gradient(135deg, #f9fafb"],
[data-theme="dark"] [style*="linear-gradient(135deg,#f9fafb"],
[data-theme="dark"] [style*="linear-gradient(135deg, #f8fafc"],
[data-theme="dark"] [style*="linear-gradient(135deg,#f8fafc"] {
  background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-tertiary) 100%) !important;
}

/* =========================================================
   ADDITIONAL INLINE STYLE CATCH-ALL
   ========================================================= */

/* f5f5f5 / f5f7fa — page body backgrounds */
[data-theme="dark"] [style*="background: #f5f5f5"],
[data-theme="dark"] [style*="background:#f5f5f5"] {
  background: var(--bg-primary) !important;
}

[data-theme="dark"] [style*="background: #f5f7fa"],
[data-theme="dark"] [style*="background:#f5f7fa"] {
  background: var(--bg-primary) !important;
}

/* f0f4f8 */
[data-theme="dark"] [style*="background: #f0f4f8"],
[data-theme="dark"] [style*="background:#f0f4f8"] {
  background: var(--bg-tertiary) !important;
}

/* f0f0f0 */
[data-theme="dark"] [style*="background: #f0f0f0"],
[data-theme="dark"] [style*="background:#f0f0f0"],
[data-theme="dark"] [style*="border-color: #f0f0f0"],
[data-theme="dark"] [style*="border-color:#f0f0f0"] {
  border-color: var(--border-color) !important;
}

/* d1fae5 — green status light */
[data-theme="dark"] [style*="background: #d1fae5"],
[data-theme="dark"] [style*="background:#d1fae5"] {
  background: #14532d !important;
}

/* dbeafe — blue light */
[data-theme="dark"] [style*="background: #dbeafe"],
[data-theme="dark"] [style*="background:#dbeafe"] {
  background: #1e3a5f !important;
}

/* d1d5db — border */
[data-theme="dark"] [style*="border-color: #d1d5db"],
[data-theme="dark"] [style*="border-color:#d1d5db"],
[data-theme="dark"] [style*="border: 1px solid #d1d5db"],
[data-theme="dark"] [style*="border:1px solid #d1d5db"] {
  border-color: var(--border-color) !important;
}

/* e9d5ff — purple */
[data-theme="dark"] [style*="background: #e9d5ff"],
[data-theme="dark"] [style*="background:#e9d5ff"] {
  background: #3b0764 !important;
}

/* fde68a — amber */
[data-theme="dark"] [style*="background: #fde68a"],
[data-theme="dark"] [style*="background:#fde68a"] {
  background: #78350f !important;
}

/* fecaca — red light */
[data-theme="dark"] [style*="background: #fecaca"],
[data-theme="dark"] [style*="background:#fecaca"],
[data-theme="dark"] [style*="border-color: #fecaca"],
[data-theme="dark"] [style*="border-color:#fecaca"] {
  border-color: #7f1d1d !important;
}

/* a7f3d0 — green border */
[data-theme="dark"] [style*="border-color: #a7f3d0"],
[data-theme="dark"] [style*="border-color:#a7f3d0"] {
  border-color: #166534 !important;
}

/* f0f7ff — blue tint */
[data-theme="dark"] [style*="background: #f0f7ff"],
[data-theme="dark"] [style*="background:#f0f7ff"] {
  background: var(--accent-light) !important;
}

/* Text colors in inline styles */
[data-theme="dark"] [style*="color: #1f2937"],
[data-theme="dark"] [style*="color:#1f2937"] {
  color: var(--text-primary) !important;
}

[data-theme="dark"] [style*="color: #991b1b"],
[data-theme="dark"] [style*="color:#991b1b"] {
  color: var(--danger) !important;
}

[data-theme="dark"] [style*="color: #065f46"],
[data-theme="dark"] [style*="color:#065f46"] {
  color: var(--success) !important;
}

/* =========================================================
   COMMON COMPONENTS (all pages)
   ========================================================= */

/* Notification toast */
[data-theme="dark"] .notification,
[data-theme="dark"] .toast {
  background: var(--bg-secondary) !important;
  border-color: var(--border-color) !important;
  color: var(--text-primary) !important;
}

/* Loading spinner */
[data-theme="dark"] .loading-spinner {
  border-color: var(--border-color) !important;
  border-top-color: var(--accent) !important;
}

/* Dividers */
[data-theme="dark"] [style*="border-bottom: 1px solid #e5e7eb"],
[data-theme="dark"] [style*="border-bottom:1px solid #e5e7eb"] {
  border-bottom-color: var(--border-color) !important;
}

[data-theme="dark"] [style*="border-top: 1px solid #e5e7eb"],
[data-theme="dark"] [style*="border-top:1px solid #e5e7eb"] {
  border-top-color: var(--border-color) !important;
}

[data-theme="dark"] [style*="border-bottom: 2px solid #f3f4f6"],
[data-theme="dark"] [style*="border-bottom:2px solid #f3f4f6"] {
  border-bottom-color: var(--border-color) !important;
}

[data-theme="dark"] [style*="border-top: 2px solid #f3f4f6"],
[data-theme="dark"] [style*="border-top:2px solid #f3f4f6"] {
  border-top-color: var(--border-color) !important;
}

/* =========================================================
   AGENDA — DETAILED
   ========================================================= */
[data-theme="dark"] .agenda-day-section.agenda-day-today-highlight {
  background: rgba(59,130,246,0.1) !important;
}

[data-theme="dark"] .agenda-task-list-wrapper::-webkit-scrollbar-track {
  background: var(--bg-secondary) !important;
}

[data-theme="dark"] .agenda-task-list-wrapper::-webkit-scrollbar-thumb {
  background: var(--bg-tertiary) !important;
}

/* =========================================================
   ARTICLES PAGE
   ========================================================= */
[data-theme="dark"] .articles-container {
  background: var(--bg-primary) !important;
}

/* =========================================================
   CLEAN MODAL — COMPLETE SUB-CLASSES
   ========================================================= */
[data-theme="dark"] .clean-modal .cm-icon-circle {
  background: var(--bg-tertiary) !important;
}

[data-theme="dark"] .clean-modal .cm-icon-circle.wa {
  background: #14532d !important;
}

[data-theme="dark"] .clean-modal .cm-icon-circle.email {
  background: var(--accent-light) !important;
}

[data-theme="dark"] .clean-modal .cm-recipient {
  border-color: var(--border-color) !important;
}

[data-theme="dark"] .clean-modal .cm-recipient-icon {
  color: var(--text-muted) !important;
}

[data-theme="dark"] .clean-modal .cm-small-btn.neutral {
  background: var(--bg-tertiary) !important;
  color: var(--text-secondary) !important;
}

[data-theme="dark"] .clean-modal .cm-small-btn.info {
  background: var(--accent-light) !important;
  color: var(--accent-hover) !important;
}

[data-theme="dark"] .clean-modal .cm-input-icon-circle {
  background: var(--bg-tertiary) !important;
}

/* =========================================================
   GLOBAL BODY BACKGROUND OVERRIDE
   ========================================================= */
[data-theme="dark"] body {
  background: #141c2e !important;
  color: var(--text-primary) !important;
}

/* Force override ALL form inputs/selects/textareas globally */
[data-theme="dark"] input,
[data-theme="dark"] select,
[data-theme="dark"] textarea {
  background: var(--bg-secondary) !important;
  border-color: var(--border-color) !important;
  color: var(--text-primary) !important;
}

[data-theme="dark"] input[type="checkbox"],
[data-theme="dark"] input[type="radio"],
[data-theme="dark"] input[type="range"],
[data-theme="dark"] input[type="color"],
[data-theme="dark"] input[type="submit"],
[data-theme="dark"] input[type="button"] {
  background: revert !important;
}

[data-theme="dark"] input::placeholder,
[data-theme="dark"] textarea::placeholder {
  color: var(--text-muted) !important;
}

[data-theme="dark"] input:focus,
[data-theme="dark"] select:focus,
[data-theme="dark"] textarea:focus {
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 3px rgba(91,156,246,0.2) !important;
}

[data-theme="dark"] input:disabled,
[data-theme="dark"] select:disabled,
[data-theme="dark"] textarea:disabled {
  background: var(--bg-tertiary) !important;
  opacity: 0.6;
}

/* Force override inline style="background: white" on ANY element */
[data-theme="dark"] [style*="background: white"],
[data-theme="dark"] [style*="background:white"],
[data-theme="dark"] [style*="background: #fff"],
[data-theme="dark"] [style*="background:#fff"],
[data-theme="dark"] [style*="background: #ffffff"],
[data-theme="dark"] [style*="background:#ffffff"],
[data-theme="dark"] [style*="background-color: white"],
[data-theme="dark"] [style*="background-color:white"],
[data-theme="dark"] [style*="background-color: #fff"],
[data-theme="dark"] [style*="background-color:#fff"],
[data-theme="dark"] [style*="background-color: #ffffff"],
[data-theme="dark"] [style*="background-color:#ffffff"] {
  background: var(--bg-primary) !important;
  background-color: var(--bg-primary) !important;
}

/* Force override inline style="color: #111827" etc. for text */
[data-theme="dark"] [style*="color: #111827"],
[data-theme="dark"] [style*="color:#111827"],
[data-theme="dark"] [style*="color: #0f172a"],
[data-theme="dark"] [style*="color:#0f172a"],
[data-theme="dark"] [style*="color: #1f2937"],
[data-theme="dark"] [style*="color:#1f2937"],
[data-theme="dark"] [style*="color: #1e293b"],
[data-theme="dark"] [style*="color:#1e293b"] {
  color: var(--text-primary) !important;
}

[data-theme="dark"] [style*="color: #374151"],
[data-theme="dark"] [style*="color:#374151"],
[data-theme="dark"] [style*="color: #4b5563"],
[data-theme="dark"] [style*="color:#4b5563"],
[data-theme="dark"] [style*="color: #334155"],
[data-theme="dark"] [style*="color:#334155"] {
  color: var(--text-secondary) !important;
}

[data-theme="dark"] [style*="color: #6b7280"],
[data-theme="dark"] [style*="color:#6b7280"],
[data-theme="dark"] [style*="color: #9ca3af"],
[data-theme="dark"] [style*="color:#9ca3af"],
[data-theme="dark"] [style*="color: #64748b"],
[data-theme="dark"] [style*="color:#64748b"] {
  color: var(--text-muted) !important;
}

/* Force override inline borders */
[data-theme="dark"] [style*="border: 1px solid #e5e7eb"],
[data-theme="dark"] [style*="border:1px solid #e5e7eb"],
[data-theme="dark"] [style*="border: 1px solid #e2e8f0"],
[data-theme="dark"] [style*="border:1px solid #e2e8f0"],
[data-theme="dark"] [style*="border: 1px solid #d1d5db"],
[data-theme="dark"] [style*="border:1px solid #d1d5db"],
[data-theme="dark"] [style*="border-color: #e5e7eb"],
[data-theme="dark"] [style*="border-color:#e5e7eb"],
[data-theme="dark"] [style*="border-color: #e2e8f0"],
[data-theme="dark"] [style*="border-color:#e2e8f0"] {
  border-color: var(--border-color) !important;
}

[data-theme="dark"] [style*="border-bottom: 1px solid #e5e7eb"],
[data-theme="dark"] [style*="border-bottom:1px solid #e5e7eb"],
[data-theme="dark"] [style*="border-bottom: 1px solid #f3f4f6"],
[data-theme="dark"] [style*="border-bottom:1px solid #f3f4f6"],
[data-theme="dark"] [style*="border-bottom: 1px solid #f1f5f9"],
[data-theme="dark"] [style*="border-bottom:1px solid #f1f5f9"],
[data-theme="dark"] [style*="border-top: 1px solid #e5e7eb"],
[data-theme="dark"] [style*="border-top:1px solid #e5e7eb"],
[data-theme="dark"] [style*="border-top: 1px solid #f1f5f9"],
[data-theme="dark"] [style*="border-top:1px solid #f1f5f9"] {
  border-color: var(--border-color) !important;
}

/* Force override light backgrounds in inline styles */
[data-theme="dark"] [style*="background: #f5f5f5"],
[data-theme="dark"] [style*="background:#f5f5f5"],
[data-theme="dark"] [style*="background: #f5f7fa"],
[data-theme="dark"] [style*="background:#f5f7fa"],
[data-theme="dark"] [style*="background: #f9fafb"],
[data-theme="dark"] [style*="background:#f9fafb"],
[data-theme="dark"] [style*="background: #f8fafc"],
[data-theme="dark"] [style*="background:#f8fafc"],
[data-theme="dark"] [style*="background: #f3f4f6"],
[data-theme="dark"] [style*="background:#f3f4f6"],
[data-theme="dark"] [style*="background: #f1f5f9"],
[data-theme="dark"] [style*="background:#f1f5f9"],
[data-theme="dark"] [style*="background: #fafafa"],
[data-theme="dark"] [style*="background:#fafafa"],
[data-theme="dark"] [style*="background: #f0f4f8"],
[data-theme="dark"] [style*="background:#f0f4f8"] {
  background: var(--bg-secondary) !important;
}

[data-theme="dark"] [style*="background: #e0f2fe"],
[data-theme="dark"] [style*="background:#e0f2fe"],
[data-theme="dark"] [style*="background: #f0f9ff"],
[data-theme="dark"] [style*="background:#f0f9ff"],
[data-theme="dark"] [style*="background: #eff6ff"],
[data-theme="dark"] [style*="background:#eff6ff"],
[data-theme="dark"] [style*="background: #f0f7ff"],
[data-theme="dark"] [style*="background:#f0f7ff"] {
  background: var(--accent-light) !important;
}

[data-theme="dark"] [style*="background: #e5e7eb"],
[data-theme="dark"] [style*="background:#e5e7eb"],
[data-theme="dark"] [style*="background: #e2e8f0"],
[data-theme="dark"] [style*="background:#e2e8f0"] {
  background: var(--bg-tertiary) !important;
}

/* =========================================================
   NUCLEAR OVERRIDES — Last rules win (highest cascade order)
   These catch EVERYTHING that still shows white/light in dark mode
   ========================================================= */

/* --- ALL modals, popups, overlays — background dark --- */
html[data-theme="dark"] .modal .modal-content,
html[data-theme="dark"] .modal > div,
html[data-theme="dark"] .modal > div > div,
html[data-theme="dark"] #clientModal .modal-content,
html[data-theme="dark"] #clientModal .client-modal,
html[data-theme="dark"] #clientModal .modal-body,
html[data-theme="dark"] #clientModal .client-modal__body,
html[data-theme="dark"] #clientModal .client-modal__left,
html[data-theme="dark"] #clientModal .client-modal__right,
html[data-theme="dark"] #clientModal .client-modal__layout,
html[data-theme="dark"] #historyModal .hm-content,
html[data-theme="dark"] #equipmentModal .modal-content,
html[data-theme="dark"] #equipmentDetailsModal .modal-content,
html[data-theme="dark"] #paymentModal .modal-content,
html[data-theme="dark"] .duplicate-client-modal-container,
html[data-theme="dark"] .ra-modal__content,
html[data-theme="dark"] .ws-confirm-box,
html[data-theme="dark"] .clean-modal .modal-content {
  background: #1e2a42 !important;
  color: #e8edf5 !important;
}

/* --- Fiche Atelier & JS-generated modals (SweetAlert-like) --- */
html[data-theme="dark"] div[style*="position: fixed"] > div[style*="background"],
html[data-theme="dark"] div[style*="z-index"] > div[style*="background: #fff"],
html[data-theme="dark"] div[style*="z-index"] > div[style*="background: white"],
html[data-theme="dark"] div[style*="z-index"] > div[style*="background:#fff"],
html[data-theme="dark"] div[style*="z-index"] > div[style*="background:white"] {
  background: #1e2a42 !important;
  color: #e8edf5 !important;
  border-color: #364158 !important;
}

/* --- ALL h1-h6 inside modals --- */
html[data-theme="dark"] .modal h1,
html[data-theme="dark"] .modal h2,
html[data-theme="dark"] .modal h3,
html[data-theme="dark"] .modal h4,
html[data-theme="dark"] .modal h5,
html[data-theme="dark"] .modal h6,
html[data-theme="dark"] .modal p,
html[data-theme="dark"] .modal label,
html[data-theme="dark"] .modal span,
html[data-theme="dark"] .modal div {
  color: inherit;
}

/* --- Equipment SaaS footer (Supprimer/Annuler/Enregistrer bar) --- */
html[data-theme="dark"] .equipment-saas-footer,
html[data-theme="dark"] #clientModal .equipment-saas-footer,
html[data-theme="dark"] .equipment-modal-footer {
  background: #232e45 !important;
  border-top: 1px solid #364158 !important;
}

html[data-theme="dark"] .equipment-saas-btn-cancel,
html[data-theme="dark"] #clientModal .equipment-saas-btn-cancel {
  color: #a0aec0 !important;
}

html[data-theme="dark"] .equipment-saas-btn-cancel:hover {
  color: #e8edf5 !important;
}

/* --- Correction table (OD/OG) in modals --- */
html[data-theme="dark"] table[style*="border-collapse"],
html[data-theme="dark"] .modal table {
  border-color: #364158 !important;
}

html[data-theme="dark"] .modal th,
html[data-theme="dark"] .modal table th,
html[data-theme="dark"] th[style*="background: #f0f9ff"],
html[data-theme="dark"] th[style*="background:#f0f9ff"],
html[data-theme="dark"] th[style*="background: #e0f2fe"],
html[data-theme="dark"] th[style*="background:#e0f2fe"],
html[data-theme="dark"] td[style*="background: #f0f9ff"],
html[data-theme="dark"] td[style*="background:#f0f9ff"] {
  background: #253a5e !important;
  color: #c5cdd9 !important;
  border-color: #364158 !important;
}

html[data-theme="dark"] .modal td,
html[data-theme="dark"] .modal table td {
  color: #e8edf5 !important;
  border-color: #364158 !important;
}

html[data-theme="dark"] .modal td input,
html[data-theme="dark"] .modal table td input {
  background: #232e45 !important;
  color: #e8edf5 !important;
  border-color: #364158 !important;
}

/* --- Correction table inline-styled borders --- */
html[data-theme="dark"] [style*="border: 1px solid #0ea5e9"],
html[data-theme="dark"] [style*="border:1px solid #0ea5e9"],
html[data-theme="dark"] [style*="border: 2px solid #0ea5e9"],
html[data-theme="dark"] [style*="border-bottom: 2px solid #0ea5e9"] {
  border-color: #2563eb !important;
}

/* --- Client form labels --- */
html[data-theme="dark"] .form-label,
html[data-theme="dark"] .form-label--inline,
html[data-theme="dark"] label.form-label {
  color: #c5cdd9 !important;
}

/* --- Client code chip --- */
html[data-theme="dark"] .client-code-chip {
  background: #2d3a54 !important;
  border-color: #364158 !important;
}

html[data-theme="dark"] .client-code-chip__label {
  color: #a0aec0 !important;
}

/* --- Form inputs — final nuclear override --- */
html[data-theme="dark"] input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="submit"]):not([type="button"]),
html[data-theme="dark"] select,
html[data-theme="dark"] textarea,
html[data-theme="dark"] .form-input,
html[data-theme="dark"] .form-select {
  background: #232e45 !important;
  border-color: #364158 !important;
  color: #e8edf5 !important;
}

html[data-theme="dark"] input::placeholder,
html[data-theme="dark"] textarea::placeholder {
  color: #718096 !important;
}

html[data-theme="dark"] .form-input--code {
  background: #2d3a54 !important;
  color: #a0aec0 !important;
}

/* --- Buttons inside modals (Annuler etc.) --- */
html[data-theme="dark"] .modal button:not(.btn-primary):not(.equipment-saas-btn-save):not(.nav-button-compact--primary) {
  color: #c5cdd9;
}

/* --- Suggestion/autocomplete dropdowns --- */
html[data-theme="dark"] .autocomplete-items,
html[data-theme="dark"] .suggestions-dropdown,
html[data-theme="dark"] [class*="suggestion"],
html[data-theme="dark"] [class*="autocomplete"],
html[data-theme="dark"] div[style*="position: absolute"][style*="background: white"],
html[data-theme="dark"] div[style*="position: absolute"][style*="background:#fff"],
html[data-theme="dark"] div[style*="position: absolute"][style*="background: #fff"] {
  background: #232e45 !important;
  border-color: #364158 !important;
  color: #e8edf5 !important;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5) !important;
}

/* --- Equipment items inside modals (verre droit/gauche, monture) --- */
html[data-theme="dark"] .equipment-item,
html[data-theme="dark"] [class*="equipment-row"],
html[data-theme="dark"] [class*="equipment-item"],
html[data-theme="dark"] .modal [style*="border: 1px solid #e2e8f0"],
html[data-theme="dark"] .modal [style*="border:1px solid #e2e8f0"],
html[data-theme="dark"] .modal [style*="border: 1.5px solid #e2e8f0"] {
  background: #232e45 !important;
  border-color: #364158 !important;
  color: #e8edf5 !important;
}

/* --- Navbar — brighter links in top bar --- */
html[data-theme="dark"] .navbar-container a,
html[data-theme="dark"] .navbar-container button,
html[data-theme="dark"] .navbar-container span:not(.navbar-action-badge):not(.wa-status-badge) {
  color: inherit;
}

html[data-theme="dark"] .navbar-avatar {
  border-color: #364158 !important;
}

html[data-theme="dark"] .navbar-avatar-initials {
  color: #e8edf5 !important;
}

/* --- Bottom nav (mobile) --- */
html[data-theme="dark"] .bottom-nav {
  background: #1e2a42 !important;
  border-top: 1px solid #364158 !important;
}

html[data-theme="dark"] .bottom-nav-item {
  color: #a0aec0 !important;
}

html[data-theme="dark"] .bottom-nav-item.active {
  color: #5b9cf6 !important;
}

/* --- iframe embedded equipment --- */
html[data-theme="dark"] body.embedded-equipment {
  background: #1e2a42 !important;
}

html[data-theme="dark"] body.embedded-equipment .modal-content {
  background: #1e2a42 !important;
}

/* --- Fiche Atelier & print modals (JS generated) --- */
html[data-theme="dark"] [id*="printModal"],
html[data-theme="dark"] [id*="ficheModal"],
html[data-theme="dark"] [id*="Print"] .modal-content,
html[data-theme="dark"] [id*="print"] .modal-content {
  background: #1e2a42 !important;
  color: #e8edf5 !important;
}

/* --- Tab VL/VP rows in correction table --- */
html[data-theme="dark"] td[style*="background: #eef"],
html[data-theme="dark"] td[style*="background:#eef"],
html[data-theme="dark"] tr[style*="background: #f0f9ff"],
html[data-theme="dark"] tr[style*="background:#f0f9ff"] {
  background: #253a5e !important;
}

/* --- Active tab (blue background) in correction table --- */
html[data-theme="dark"] td[style*="background: #3b82f6"],
html[data-theme="dark"] td[style*="background:#3b82f6"],
html[data-theme="dark"] td[style*="background: #2563eb"],
html[data-theme="dark"] td[style*="background:#2563eb"] {
  background: #3b82f6 !important;
  color: #fff !important;
}

/* --- WhatsApp toggle / switch --- */
html[data-theme="dark"] .toggle-container,
html[data-theme="dark"] [style*="background: #10b981"] {
  background: #10b981 !important;
}

/* --- All remaining white divs inside any dark context --- */
html[data-theme="dark"] .modal div[style*="background: white"],
html[data-theme="dark"] .modal div[style*="background:#fff"],
html[data-theme="dark"] .modal div[style*="background: #fff"],
html[data-theme="dark"] .modal div[style*="background: #ffffff"],
html[data-theme="dark"] .modal div[style*="background:#ffffff"] {
  background: #1e2a42 !important;
}

html[data-theme="dark"] .modal div[style*="background: #f8fafc"],
html[data-theme="dark"] .modal div[style*="background:#f8fafc"],
html[data-theme="dark"] .modal div[style*="background: #f9fafb"],
html[data-theme="dark"] .modal div[style*="background:#f9fafb"],
html[data-theme="dark"] .modal div[style*="background: #f3f4f6"],
html[data-theme="dark"] .modal div[style*="background:#f3f4f6"],
html[data-theme="dark"] .modal div[style*="background: #f1f5f9"],
html[data-theme="dark"] .modal div[style*="background:#f1f5f9"] {
  background: #232e45 !important;
}

/* --- Section titles (Corrections, Équipements, Autre) --- */
html[data-theme="dark"] .modal [style*="color: #64748b"],
html[data-theme="dark"] .modal [style*="color:#64748b"],
html[data-theme="dark"] .modal [style*="color: #94a3b8"],
html[data-theme="dark"] .modal [style*="color:#94a3b8"] {
  color: #718096 !important;
}

/* --- Price inputs --- */
html[data-theme="dark"] input[style*="text-align: right"],
html[data-theme="dark"] input[style*="text-align:right"] {
  background: #232e45 !important;
  color: #e8edf5 !important;
}

/* --- Verre droit/gauche, monture section borders --- */
html[data-theme="dark"] [style*="border-top: 1px solid #e2e8f0"],
html[data-theme="dark"] [style*="border-top: 1px solid #e5e7eb"],
html[data-theme="dark"] [style*="border-bottom: 1px solid #e2e8f0"],
html[data-theme="dark"] [style*="border-bottom: 1px solid #e5e7eb"] {
  border-color: #364158 !important;
}

/* --- Select dropdown options --- */
html[data-theme="dark"] option {
  background: #232e45 !important;
  color: #e8edf5 !important;
}

/* =========================================================
   EQUIPMENT MODAL (glasses.html) — Full dark mode
   ========================================================= */

/* --- Correction table: header cells (background: #f0f9ff) --- */
html[data-theme="dark"] th[style*="background: #f0f9ff"],
html[data-theme="dark"] th[style*="background:#f0f9ff"] {
  background: #1e2a42 !important;
  color: #e8edf5 !important;
  border-color: #2563eb !important;
}

/* --- Correction table: OD/OG/VL/VP label cells (background: #e0f2fe) --- */
html[data-theme="dark"] th[style*="background: #e0f2fe"],
html[data-theme="dark"] th[style*="background:#e0f2fe"],
html[data-theme="dark"] td[style*="background: #e0f2fe"],
html[data-theme="dark"] td[style*="background:#e0f2fe"] {
  background: #1e3a5f !important;
  color: #e8edf5 !important;
  border-color: #2563eb !important;
}

/* --- Correction table: separator column (background: #e2e8f0) --- */
html[data-theme="dark"] th[style*="background: #e2e8f0"],
html[data-theme="dark"] th[style*="background:#e2e8f0"],
html[data-theme="dark"] td[style*="background: #e2e8f0"],
html[data-theme="dark"] td[style*="background:#e2e8f0"] {
  background: #253550 !important;
  border-color: #364158 !important;
}

/* --- Correction table: data cells (background: #fff) --- */
html[data-theme="dark"] td[style*="background: #fff"],
html[data-theme="dark"] td[style*="background:#fff"] {
  background: #232e45 !important;
  border-color: #2563eb !important;
}

/* --- Correction table: all inputs inside table cells --- */
html[data-theme="dark"] table td input[type="text"] {
  background: transparent !important;
  color: #e8edf5 !important;
}

/* --- Correction table border --- */
html[data-theme="dark"] table[style*="border: 2px solid #0ea5e9"] {
  border-color: #2563eb !important;
}
html[data-theme="dark"] table[style*="border: 2px solid #0ea5e9"] td,
html[data-theme="dark"] table[style*="border: 2px solid #0ea5e9"] th {
  border-color: #2563eb !important;
}

/* --- Textarea (Observation) --- */
html[data-theme="dark"] .form-textarea,
html[data-theme="dark"] textarea.form-input {
  background: #232e45 !important;
  border-color: #364158 !important;
  color: #e8edf5 !important;
}

/* --- Écart/Hauteur inputs --- */
html[data-theme="dark"] input[style*="border: none"][style*="padding: 0.25rem"],
html[data-theme="dark"] input[id*="Ecart"],
html[data-theme="dark"] input[id*="ecart"],
html[data-theme="dark"] input[id*="Height"],
html[data-theme="dark"] input[id*="height"] {
  background: #232e45 !important;
  color: #e8edf5 !important;
}

/* --- Equipment items (Verre, Monture, Autre) inputs --- */
html[data-theme="dark"] input[id*="Name"],
html[data-theme="dark"] input[id*="Article"],
html[data-theme="dark"] input[id*="article"] {
  color: #e8edf5 !important;
}

/* --- General label colors --- */
html[data-theme="dark"] label[style*="color: var(--gray-700)"],
html[data-theme="dark"] label[style*="color: #374151"] {
  color: #a0aec0 !important;
}

/* --- Bottom footer bar of equipment modal --- */
html[data-theme="dark"] .equipment-modal-footer,
html[data-theme="dark"] div[style*="border-top"][style*="background: #f8f9fa"],
html[data-theme="dark"] div[style*="border-top"][style*="background:#f8f9fa"],
html[data-theme="dark"] div[style*="border-top"][style*="background: #f9fafb"],
html[data-theme="dark"] div[style*="border-top"][style*="background:#f9fafb"] {
  background: #1a2236 !important;
  border-color: #364158 !important;
}

/* --- Autocomplete dropdowns --- */
html[data-theme="dark"] .autocomplete-results,
html[data-theme="dark"] .autocomplete-dropdown,
html[data-theme="dark"] [class*="autocomplete"] ul,
html[data-theme="dark"] [class*="autocomplete"] li {
  background: #232e45 !important;
  color: #e8edf5 !important;
  border-color: #364158 !important;
}

/* --- Name/phone bar at top of embedded modal --- */
html[data-theme="dark"] #stickyClientBar {
  background: #1e2a42 !important;
  border-color: #364158 !important;
  color: #e8edf5 !important;
}

/* --- Section titles (Corrections, Équipements, Autre, Total) --- */
html[data-theme="dark"] h4[style*="color: #1e293b"],
html[data-theme="dark"] h4[style*="color:#1e293b"] {
  color: #e8edf5 !important;
}

/* --- Doctor/FINESS/Date fields at top --- */
html[data-theme="dark"] input[id="doctorName"],
html[data-theme="dark"] input[id="codeFiness"],
html[data-theme="dark"] input[id="detailsPrescriptionDate"],
html[data-theme="dark"] input[id="detailsPurchaseDate"] {
  background: #232e45 !important;
  color: #e8edf5 !important;
  border-color: #364158 !important;
}

/* --- Copy arrow buttons between OD/OG --- */
html[data-theme="dark"] button[style*="background: #3b82f6"],
html[data-theme="dark"] button[style*="background:#3b82f6"] {
  background: #2563eb !important;
}

/* --- Réglé checkbox area and Total --- */
html[data-theme="dark"] span[style*="color: #1e293b"],
html[data-theme="dark"] span[style*="color:#1e293b"] {
  color: #e8edf5 !important;
}

/* =========================================================
   FINAL FIXES — Mobile responsive, action buttons, toasts,
   context menus, bottom nav submenus
   ========================================================= */

/* --- Bottom nav (mobile) — ensure full dark --- */
html[data-theme="dark"] .bottom-nav {
  background: #1e2a42 !important;
  border-top: 1px solid #364158 !important;
}

html[data-theme="dark"] .bottom-nav-item {
  color: #718096 !important;
}

html[data-theme="dark"] .bottom-nav-item.active {
  color: #5b9cf6 !important;
}

html[data-theme="dark"] .bottom-nav-label {
  color: inherit !important;
}

html[data-theme="dark"] .bottom-nav-icon {
  color: inherit !important;
}

/* Bottom nav submenu popups */
html[data-theme="dark"] .bottom-nav-submenu {
  background: #1e2a42 !important;
  border: 1px solid #364158 !important;
  box-shadow: 0 -8px 30px rgba(0,0,0,0.5) !important;
}

html[data-theme="dark"] .bottom-nav-submenu-item {
  color: #c5cdd9 !important;
}

html[data-theme="dark"] .bottom-nav-submenu-item:hover,
html[data-theme="dark"] .bottom-nav-submenu-item.active {
  background: #253a5e !important;
  color: #7eb8ff !important;
}

html[data-theme="dark"] .bottom-nav-submenu-item .material-symbols-outlined {
  color: inherit !important;
}

/* --- Action buttons in tables (edit/delete) — make visible --- */
html[data-theme="dark"] .action-btn {
  box-shadow: 0 2px 6px rgba(0,0,0,0.3) !important;
}

html[data-theme="dark"] .action-btn-edit {
  background: #3b82f6 !important;
  color: #fff !important;
}

html[data-theme="dark"] .action-btn-delete {
  background: #ef4444 !important;
  color: #fff !important;
}

/* --- Context menu / row action popup --- */
html[data-theme="dark"] .row-actions-popup,
html[data-theme="dark"] .actions-popup,
html[data-theme="dark"] [class*="action-popup"],
html[data-theme="dark"] [class*="context-menu"],
html[data-theme="dark"] [class*="popover"] {
  background: #1e2a42 !important;
  border-color: #364158 !important;
  box-shadow: 0 8px 30px rgba(0,0,0,0.5) !important;
  color: #e8edf5 !important;
}

/* Generic popup/floating menus created by JS */
html[data-theme="dark"] div[style*="position: fixed"][style*="z-index"][style*="background: white"],
html[data-theme="dark"] div[style*="position: fixed"][style*="z-index"][style*="background:#fff"],
html[data-theme="dark"] div[style*="position: fixed"][style*="z-index"][style*="background: #fff"],
html[data-theme="dark"] div[style*="position: absolute"][style*="z-index"][style*="background: white"],
html[data-theme="dark"] div[style*="position: absolute"][style*="z-index"][style*="background:#fff"],
html[data-theme="dark"] div[style*="position: absolute"][style*="z-index"][style*="background: #fff"],
html[data-theme="dark"] div[style*="position: absolute"][style*="z-index"][style*="background: #ffffff"] {
  background: #1e2a42 !important;
  border-color: #364158 !important;
  color: #e8edf5 !important;
  box-shadow: 0 8px 30px rgba(0,0,0,0.5) !important;
}

/* --- Notifications / Toasts --- */
html[data-theme="dark"] .notification {
  box-shadow: 0 10px 25px rgba(0,0,0,0.5) !important;
}

html[data-theme="dark"] .notification-success {
  background: #059669 !important;
  color: #fff !important;
}

html[data-theme="dark"] .notification-error {
  background: #dc2626 !important;
  color: #fff !important;
}

html[data-theme="dark"] .notification-warning {
  background: #d97706 !important;
  color: #fff !important;
}

html[data-theme="dark"] .notification-info {
  background: #2563eb !important;
  color: #fff !important;
}

/* Toast variants */
html[data-theme="dark"] .toast-success,
html[data-theme="dark"] .ws-toast--success {
  background: #059669 !important;
}

html[data-theme="dark"] .toast-error,
html[data-theme="dark"] .ws-toast--error {
  background: #dc2626 !important;
}

/* --- Delete confirmation overlay --- */
html[data-theme="dark"] .delete-confirm-overlay {
  background: rgba(0,0,0,0.6) !important;
}

html[data-theme="dark"] .delete-confirm-box {
  background: #1e2a42 !important;
  border-color: #364158 !important;
  color: #e8edf5 !important;
}

html[data-theme="dark"] .delete-confirm-title {
  color: #e8edf5 !important;
}

html[data-theme="dark"] .delete-confirm-text {
  color: #a0aec0 !important;
}

html[data-theme="dark"] .delete-confirm-actions .btn-secondary {
  background: #232e45 !important;
  color: #a0aec0 !important;
  border-color: #364158 !important;
}

/* --- Mobile menu full dark --- */
html[data-theme="dark"] .mobile-menu-overlay {
  background: rgba(0,0,0,0.5) !important;
}

html[data-theme="dark"] .mobile-menu-panel {
  background: #1e2a42 !important;
  color: #e8edf5 !important;
}

html[data-theme="dark"] .mobile-menu-header {
  background: #232e45 !important;
  border-bottom-color: #364158 !important;
}

html[data-theme="dark"] .mobile-menu-item {
  color: #c5cdd9 !important;
  border-bottom-color: #364158 !important;
}

html[data-theme="dark"] .mobile-menu-item:hover {
  background: #2d3a54 !important;
  color: #fff !important;
}

html[data-theme="dark"] .mobile-menu-submenu-item {
  color: #a0aec0 !important;
}

html[data-theme="dark"] .mobile-menu-submenu-item:hover {
  background: #253a5e !important;
  color: #7eb8ff !important;
}

/* --- Template items (app.js generated) --- */
html[data-theme="dark"] .template-item {
  background: #232e45 !important;
  border-color: #364158 !important;
  color: #e8edf5 !important;
}

html[data-theme="dark"] .template-item:hover {
  background: #2d3a54 !important;
}

html[data-theme="dark"] .template-action-btn {
  color: #a0aec0 !important;
}

html[data-theme="dark"] .template-action-btn:hover {
  background: #2d3a54 !important;
}

/* --- Search dropdowns (suggestion lists) --- */
html[data-theme="dark"] .search-results-dropdown,
html[data-theme="dark"] .suggestion-list,
html[data-theme="dark"] [id*="suggestions"],
html[data-theme="dark"] [id*="Suggestions"],
html[data-theme="dark"] [class*="suggestion-list"],
html[data-theme="dark"] [class*="autocomplete-list"] {
  background: #1e2a42 !important;
  border-color: #364158 !important;
  box-shadow: 0 8px 30px rgba(0,0,0,0.5) !important;
}

html[data-theme="dark"] .suggestion-item,
html[data-theme="dark"] .autocomplete-item {
  color: #e8edf5 !important;
}

html[data-theme="dark"] .suggestion-item:hover,
html[data-theme="dark"] .autocomplete-item:hover {
  background: #253a5e !important;
}

/* --- Doctors page — action buttons specifically --- */
html[data-theme="dark"] #doctorsList .action-btn-edit {
  background: #3b82f6 !important;
  color: #fff !important;
  opacity: 1 !important;
}

html[data-theme="dark"] #doctorsList .action-btn-delete {
  background: #ef4444 !important;
  color: #fff !important;
  opacity: 1 !important;
}

/* --- All table action cells --- */
html[data-theme="dark"] .table-actions .action-btn {
  opacity: 1 !important;
}

/* --- Empty states --- */
html[data-theme="dark"] .empty-state {
  color: #a0aec0 !important;
}

html[data-theme="dark"] .empty-icon {
  color: #4a5a75 !important;
}

/* --- Loading spinner --- */
html[data-theme="dark"] .loading-spinner {
  border-color: #364158 !important;
  border-top-color: #5b9cf6 !important;
}

/* --- Responsive navbar media query overrides --- */
@media (max-width: 768px) {
  html[data-theme="dark"] .navbar-container {
    background: #1e2a42 !important;
    border-bottom-color: #364158 !important;
  }
}

@media (max-width: 1024px) {
  html[data-theme="dark"] .navbar-container {
    background: #1e2a42 !important;
    border-bottom-color: #364158 !important;
  }
}
