/* Dark Mode Universal Overrides
 * This file fixes all pure white elements across the entire application
 * to use dark-friendly alternatives when dark theme is active
 */

/* Universal dark background fixes */
body.dark-theme {
  background: linear-gradient(135deg, #0f172a 0%, #1a1a2e 50%, #16213e 100%) !important;
}

/* Fix all pure white backgrounds */
body.dark-theme [style*="background: #ffffff"],
body.dark-theme [style*="background: white"],
body.dark-theme [style*="background-color: #ffffff"],
body.dark-theme [style*="background-color: white"],
body.dark-theme .bg-white {
  background: rgba(30, 41, 59, 0.8) !important;
  backdrop-filter: blur(10px);
}

/* Fix white text that should stay white or become light gray */
body.dark-theme [style*="color: white"]:not(.text-accent):not(.btn) {
  color: #f1f5f9 !important;
}

/* Fix white borders and outlines */
body.dark-theme [style*="border: .*white"],
body.dark-theme [style*="border-color: white"],
body.dark-theme [style*="outline: .*white"],
body.dark-theme [style*="outline-color: white"],
body.dark-theme .border-white {
  border-color: rgba(203, 213, 225, 0.3) !important;
}

/* Fix white card backgrounds */
body.dark-theme .card,
body.dark-theme .grid > .card,
body.dark-theme section > .card {
  background: rgba(30, 41, 59, 0.8) !important;
  border: 1px solid rgba(71, 85, 105, 0.3) !important;
}

/* Fix navigation elements */
body.dark-theme nav,
body.dark-theme .nav {
  background: rgba(15, 15, 35, 0.9) !important;
  border-bottom: 1px solid rgba(71, 85, 105, 0.3) !important;
}

body.dark-theme .nav-logo h1 {
  color: #f1f5f9 !important;
}

/* Fix modal backgrounds */
body.dark-theme [class*="modal"] {
  background: rgba(15, 15, 35, 0.95) !important;
}

body.dark-theme .modal-content,
body.dark-theme [class*="modal-content"] {
  background: rgba(30, 41, 59, 0.95) !important;
  border: 1px solid rgba(71, 85, 105, 0.3) !important;
}

/* Fix form inputs */
body.dark-theme input,
body.dark-theme textarea,
body.dark-theme select {
  background: rgba(51, 65, 85, 0.6) !important;
  border: 1px solid rgba(71, 85, 105, 0.4) !important;
  color: #f1f5f9 !important;
}

body.dark-theme input:focus,
body.dark-theme textarea:focus,
body.dark-theme select:focus {
  border-color: #dc2626 !important;
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.2) !important;
}

/* Fix buttons */
body.dark-theme button:not(.btn-primary):not([class*="bg-"]) {
  background: rgba(51, 65, 85, 0.6) !important;
  border: 1px solid rgba(71, 85, 105, 0.4) !important;
  color: #f1f5f9 !important;
}

body.dark-theme button:hover:not(.btn-primary):not([class*="bg-"]) {
  background: rgba(71, 85, 105, 0.8) !important;
}

/* Fix table backgrounds */
body.dark-theme table {
  background: rgba(30, 41, 59, 0.8) !important;
  border: 1px solid rgba(71, 85, 105, 0.3) !important;
}

body.dark-theme th {
  background: rgba(51, 65, 85, 0.6) !important;
  color: #f1f5f9 !important;
  border-bottom: 1px solid rgba(71, 85, 105, 0.3) !important;
}

body.dark-theme td {
  color: #cbd5e1 !important;
  border-bottom: 1px solid rgba(71, 85, 105, 0.2) !important;
}

/* Fix feature cards and sections */
body.dark-theme .feature-card,
body.dark-theme .hero-modern,
body.dark-theme section {
  background: rgba(30, 41, 59, 0.8) !important;
}

body.dark-theme .hero-modern {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #334155 100%) !important;
}

/* Fix text colors */
body.dark-theme h1,
body.dark-theme h2,
body.dark-theme h3,
body.dark-theme h4,
body.dark-theme h5,
body.dark-theme h6 {
  color: #f1f5f9 !important;
}

body.dark-theme p,
body.dark-theme span,
body.dark-theme div,
body.dark-theme li {
  color: #cbd5e1 !important;
}

body.dark-theme a {
  color: #60a5fa !important;
}

body.dark-theme a:hover {
  color: #93c5fd !important;
}

/* Fix Tailwind-style classes */
body.dark-theme .text-gray-900 { color: #f1f5f9 !important; }
body.dark-theme .text-gray-800 { color: #f1f5f9 !important; }
body.dark-theme .text-gray-700 { color: #f1f5f9 !important; }
body.dark-theme .text-gray-600 { color: #cbd5e1 !important; }
body.dark-theme .text-gray-500 { color: #94a3b8 !important; }
body.dark-theme .text-gray-400 { color: #94a3b8 !important; }

/* Near-white light backgrounds */
body.dark-theme [style*="background: #f8fafc"],
body.dark-theme [style*="background:#f8fafc"],
body.dark-theme [style*="background: #f9fafb"],
body.dark-theme [style*="background:#f9fafb"],
body.dark-theme [style*="background: #f1f5f9"],
body.dark-theme [style*="background:#f1f5f9"],
body.dark-theme [style*="background: #f7fafc"],
body.dark-theme [style*="background:#f7fafc"],
body.dark-theme [style*="background: #fafafa"],
body.dark-theme [style*="background:#fafafa"],
body.dark-theme [style*="background: #fbfbfb"],
body.dark-theme [style*="background:#fbfbfb"] {
  background: rgba(30, 41, 59, 0.8) !important;
  border: 1px solid rgba(71, 85, 105, 0.3) !important;
}

/* Tailwind light backgrounds */
body.dark-theme .bg-gray-50 { background: rgba(51, 65, 85, 0.6) !important; }
body.dark-theme .bg-gray-100 { background: rgba(51, 65, 85, 0.8) !important; }
body.dark-theme .bg-gray-200 { background: rgba(71, 85, 105, 0.8) !important; }
body.dark-theme .bg-slate-50 { background: rgba(51, 65, 85, 0.6) !important; }
body.dark-theme .bg-zinc-50 { background: rgba(51, 65, 85, 0.6) !important; }
body.dark-theme .bg-stone-50 { background: rgba(51, 65, 85, 0.6) !important; }
body.dark-theme .bg-neutral-50 { background: rgba(51, 65, 85, 0.6) !important; }

/* Light RGBA backgrounds */
body.dark-theme [style*="background: rgba(240"],
body.dark-theme [style*="background:rgba(240"],
body.dark-theme [style*="background: rgba(245"],
body.dark-theme [style*="background:rgba(245"],
body.dark-theme [style*="background: rgba(250"],
body.dark-theme [style*="background:rgba(250"],
body.dark-theme [style*="background: rgba(255, 255, 255, 0.9"],
body.dark-theme [style*="background:rgba(255, 255, 255, 0.9"] {
  background: rgba(30, 41, 59, 0.8) !important;
}

body.dark-theme .border-gray-100 { border-color: rgba(71, 85, 105, 0.3) !important; }
body.dark-theme .border-gray-200 { border-color: rgba(71, 85, 105, 0.4) !important; }
body.dark-theme .border-gray-300 { border-color: rgba(71, 85, 105, 0.5) !important; }

/* Fix specific page elements */
body.dark-theme .container main,
body.dark-theme main {
  background: linear-gradient(135deg, #0f172a 0%, #1a1a2e 50%, #16213e 100%) !important;
}

/* Fix dropdown menus */
body.dark-theme .dropdown-menu,
body.dark-theme .nav-dropdown-menu {
  background: rgba(30, 41, 59, 0.95) !important;
  border: 1px solid rgba(71, 85, 105, 0.3) !important;
}

/* Fix pagination controls */
body.dark-theme .pagination-controls,
body.dark-theme [id*="pagination"] {
  background: rgba(30, 41, 59, 0.8) !important;
  border: 1px solid rgba(71, 85, 105, 0.3) !important;
}

/* Keep accent colors (red buttons) working */
body.dark-theme .btn-primary,
body.dark-theme [style*="background: #dc2626"],
body.dark-theme [style*="background: linear-gradient(135deg, #dc2626"] {
  background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%) !important;
  color: #ffffff !important;
}

body.dark-theme .btn-primary:hover,
body.dark-theme [style*="background: #dc2626"]:hover {
  background: linear-gradient(135deg, #b91c1c 0%, #991b1b 100%) !important;
}

/* Fix chart backgrounds */
body.dark-theme canvas {
  background: rgba(30, 41, 59, 0.8) !important;
}

/* Fix loading states */
body.dark-theme .loading,
body.dark-theme .spinner {
  border-color: rgba(71, 85, 105, 0.3) !important;
  border-top-color: #dc2626 !important;
}

/* Ensure compatibility with existing dark mode class names */
body.dark-theme,
body[data-theme="dark"],
.dark-theme {
  background: linear-gradient(135deg, #0f172a 0%, #1a1a2e 50%, #16213e 100%) !important;
}
