/* Theme variables — dark (default) and light modes */

:root,
[data-theme="dark"] {
    --bg-primary: #111827;
    --bg-secondary: #1f2937;
    --bg-tertiary: #374151;
    --bg-hover: rgba(31, 41, 55, 0.5);
    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    --border-color: #374151;
    --table-header-bg: #1f2937;
    --card-bg: #1f2937;
    --input-bg: #374151;
    --input-border: #4b5563;
    color-scheme: dark;
}

[data-theme="light"] {
    --bg-primary: #ffffff;
    --bg-secondary: #f9fafb;
    --bg-tertiary: #f3f4f6;
    --bg-hover: rgba(243, 244, 246, 0.5);
    --text-primary: #111827;
    --text-secondary: #4b5563;
    --text-muted: #9ca3af;
    --border-color: #e5e7eb;
    --table-header-bg: #f3f4f6;
    --card-bg: #ffffff;
    --input-bg: #ffffff;
    --input-border: #d1d5db;
    color-scheme: light;
}

/* ===== LIGHT MODE OVERRIDES ===== */

/* Body */
body {
    background-color: var(--bg-primary) !important;
    color: var(--text-primary) !important;
}

/* Backgrounds */
[data-theme="light"] .bg-gray-900 { background-color: var(--bg-primary) !important; }
[data-theme="light"] .bg-gray-800 { background-color: var(--bg-secondary) !important; }
[data-theme="light"] .bg-gray-700 { background-color: var(--bg-tertiary) !important; }
[data-theme="light"] .bg-gray-800\/50 { background-color: var(--bg-hover) !important; }

/* Gray text → dark text */
[data-theme="light"] .text-gray-100 { color: var(--text-primary) !important; }
[data-theme="light"] .text-gray-200 { color: var(--text-primary) !important; }
[data-theme="light"] .text-gray-300 { color: var(--text-secondary) !important; }
[data-theme="light"] .text-gray-400 { color: var(--text-secondary) !important; }
[data-theme="light"] .text-gray-500 { color: var(--text-muted) !important; }

/* White text → dark text, EXCEPT inside colored elements */
[data-theme="light"] .text-white { color: var(--text-primary) !important; }
/* Restore white text inside colored badges/severity/buttons */
[data-theme="light"] .severity-critical .text-white,
[data-theme="light"] .severity-high .text-white,
[data-theme="light"] .severity-medium .text-white,
[data-theme="light"] .severity-low .text-white,
[data-theme="light"] .bg-green-600 .text-white,
[data-theme="light"] .bg-green-500 .text-white,
[data-theme="light"] .bg-red-600 .text-white,
[data-theme="light"] .bg-red-500 .text-white,
[data-theme="light"] .bg-blue-600 .text-white,
[data-theme="light"] .bg-blue-500 .text-white,
[data-theme="light"] .bg-yellow-600 .text-white,
[data-theme="light"] .bg-orange-600 .text-white,
[data-theme="light"] .bg-gray-600 .text-white,
[data-theme="light"] .bg-gray-500 .text-white,
[data-theme="light"] span.text-white[class*="severity-"],
[data-theme="light"] span.text-white[class*="bg-green"],
[data-theme="light"] span.text-white[class*="bg-red"],
[data-theme="light"] span.text-white[class*="bg-blue"],
[data-theme="light"] span.text-white[class*="bg-gray-5"],
[data-theme="light"] span.text-white[class*="bg-gray-6"] { color: #ffffff !important; }

/* Borders */
[data-theme="light"] .border-gray-700 { border-color: var(--border-color) !important; }
[data-theme="light"] .border-gray-600 { border-color: var(--border-color) !important; }
[data-theme="light"] .divide-gray-700 > * + * { border-color: var(--border-color) !important; }

/* Tables */
[data-theme="light"] thead.bg-gray-800 { background-color: var(--table-header-bg) !important; }
[data-theme="light"] thead .text-gray-300 { color: var(--text-secondary) !important; }

/* Cards */
[data-theme="light"] .rounded-lg.border.border-gray-700 {
    border-color: var(--border-color) !important;
    background-color: var(--card-bg) !important;
}

/* Inputs */
[data-theme="light"] input,
[data-theme="light"] select,
[data-theme="light"] textarea {
    background-color: var(--input-bg) !important;
    border-color: var(--input-border) !important;
    color: var(--text-primary) !important;
}

/* Preserve white text on colored buttons and badges */
[data-theme="light"] button .text-white,
[data-theme="light"] button.text-white,
[data-theme="light"] a.text-white[class*="bg-"],
[data-theme="light"] [class*="bg-blue"] .text-white,
[data-theme="light"] [class*="bg-blue"].text-white,
[data-theme="light"] [class*="bg-green"] .text-white,
[data-theme="light"] [class*="bg-green"].text-white,
[data-theme="light"] [class*="bg-red"] .text-white,
[data-theme="light"] [class*="bg-red"].text-white,
[data-theme="light"] [class*="bg-indigo"] .text-white,
[data-theme="light"] [class*="bg-indigo"].text-white { color: #ffffff !important; }

/* Colored text that's too bright on light backgrounds */
[data-theme="light"] .text-yellow-400 { color: #a16207 !important; }
[data-theme="light"] .text-yellow-300 { color: #a16207 !important; }
[data-theme="light"] .text-green-400 { color: #15803d !important; }
[data-theme="light"] .text-green-300 { color: #166534 !important; }
[data-theme="light"] .text-red-400 { color: #dc2626 !important; }
[data-theme="light"] .text-red-300 { color: #991b1b !important; }

/* Status badges — dark mode uses bg-green-900/text-green-300, too dark in light mode */
[data-theme="light"] .bg-green-900 { background-color: #dcfce7 !important; }
[data-theme="light"] .text-green-300 { color: #166534 !important; }
[data-theme="light"] .bg-red-900 { background-color: #fee2e2 !important; }
[data-theme="light"] .text-red-300 { color: #991b1b !important; }
[data-theme="light"] .bg-yellow-900 { background-color: #fef9c3 !important; }
[data-theme="light"] .text-yellow-300 { color: #854d0e !important; }
[data-theme="light"] .bg-gray-700 { background-color: #f3f4f6 !important; }

/* Timeline / density bar */
[data-theme="light"] .timeline-bar { background: #e5e7eb !important; }

/* Hover states */
[data-theme="light"] .hover\:bg-gray-800:hover { background-color: #f3f4f6 !important; }
[data-theme="light"] .hover\:bg-gray-800\/50:hover { background-color: rgba(243, 244, 246, 0.5) !important; }

/* Scrollbar */
[data-theme="light"] .custom-scroll::-webkit-scrollbar-track { background: #f3f4f6; }
[data-theme="light"] .custom-scroll::-webkit-scrollbar-thumb { background: #d1d5db; }
[data-theme="light"] .custom-scroll::-webkit-scrollbar-thumb:hover { background: #9ca3af; }

/* ===== TOGGLE BUTTON ===== */
.theme-toggle {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 2px solid var(--border-color);
    background-color: var(--bg-secondary);
    cursor: pointer;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s;
}

.theme-toggle:hover {
    transform: scale(1.1);
}
