/* Theme System - CSS Variables for Dark/Light modes */

:root {
	/* Default Dark Blue Theme */
	--bg-primary: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
	--bg-secondary: rgba(30, 41, 59, 0.6);
	--bg-card: rgba(30, 38, 54, 0.6);
	--bg-header: linear-gradient(90deg, #1e293b 0%, #0ea5e9 100%);
	--bg-input: rgba(30, 41, 59, 0.6);
	--bg-button: linear-gradient(135deg, #0ea5e9 0%, #0284c7 100%);
	--bg-hover: rgba(14, 165, 233, 0.15);

	--text-primary: #f1f5f9;
	--text-secondary: #94a3b8;
	--text-muted: #64748b;
	--text-link: #7dd3fc;

	--border-color: rgba(125, 211, 252, 0.1);
	--border-accent: rgba(14, 165, 233, 0.3);

	--accent-primary: #0ea5e9;
	--accent-secondary: #0284c7;
	--accent-light: #7dd3fc;

	--shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
	--shadow-md: 0 4px 16px rgba(14, 165, 233, 0.3);
	--shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.3);

	--scrollbar-track: rgba(30, 38, 54, 0.4);
	--scrollbar-thumb: linear-gradient(135deg, rgba(125, 211, 252, 0.3), rgba(14, 165, 233, 0.3));
}

/* Pure Dark Mode (OLED-friendly) */
[data-theme="dark"] {
	--bg-primary: linear-gradient(135deg, #000000 0%, #0a0a0a 100%);
	--bg-secondary: rgba(18, 18, 18, 0.95);
	--bg-card: rgba(28, 28, 28, 0.95);
	--bg-header: linear-gradient(90deg, #0a0a0a 0%, #1a1a1a 100%);
	--bg-input: rgba(28, 28, 28, 0.9);
	--bg-button: linear-gradient(135deg, #1e40af 0%, #1e3a8a 100%);
	--bg-hover: rgba(59, 130, 246, 0.15);

	--text-primary: #e5e7eb;
	--text-secondary: #9ca3af;
	--text-muted: #6b7280;
	--text-link: #60a5fa;

	--border-color: rgba(75, 85, 99, 0.3);
	--border-accent: rgba(59, 130, 246, 0.4);

	--accent-primary: #3b82f6;
	--accent-secondary: #2563eb;
	--accent-light: #60a5fa;

	--shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.5);
	--shadow-md: 0 4px 16px rgba(59, 130, 246, 0.2);
	--shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.6);

	--scrollbar-track: rgba(28, 28, 28, 0.6);
	--scrollbar-thumb: linear-gradient(135deg, rgba(75, 85, 99, 0.5), rgba(59, 130, 246, 0.5));
}

/* Light Mode */
[data-theme="light"] {
	--bg-primary: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
	--bg-secondary: rgba(255, 255, 255, 0.9);
	--bg-card: rgba(255, 255, 255, 0.95);
	--bg-header: linear-gradient(90deg, #0ea5e9 0%, #0284c7 100%);
	--bg-input: rgba(241, 245, 249, 0.9);
	--bg-button: linear-gradient(135deg, #0ea5e9 0%, #0284c7 100%);
	--bg-hover: rgba(14, 165, 233, 0.1);

	--text-primary: #0f172a;
	--text-secondary: #475569;
	--text-muted: #64748b;
	--text-link: #0284c7;

	--border-color: rgba(203, 213, 225, 0.8);
	--border-accent: rgba(14, 165, 233, 0.4);

	--accent-primary: #0ea5e9;
	--accent-secondary: #0284c7;
	--accent-light: #38bdf8;

	--shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.1);
	--shadow-md: 0 4px 16px rgba(14, 165, 233, 0.15);
	--shadow-lg: 0 8px 32px rgba(15, 23, 42, 0.15);

	--scrollbar-track: rgba(241, 245, 249, 0.6);
	--scrollbar-thumb: linear-gradient(135deg, rgba(203, 213, 225, 0.8), rgba(14, 165, 233, 0.6));
}

/* Apply theme variables */
html, body {
	background: var(--bg-primary) !important;
	color: var(--text-primary);
	transition: background 0.3s ease, color 0.3s ease;
}

/* Theme Toggle Button */
.theme-toggle {
	position: relative;
	display: flex;
	align-items: center;
	gap: 8px;
	background: var(--bg-secondary);
	border: 1px solid var(--border-color);
	border-radius: 24px;
	padding: 6px;
	cursor: pointer;
	transition: all 0.3s ease;
}

.theme-toggle:hover {
	border-color: var(--border-accent);
	transform: translateY(-1px);
}

.theme-option {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	border-radius: 50%;
	background: transparent;
	border: none;
	cursor: pointer;
	transition: all 0.2s ease;
	font-size: 1.2em;
	position: relative;
}

.theme-option.active {
	background: var(--accent-primary);
	box-shadow: 0 2px 8px rgba(14, 165, 233, 0.4);
}

.theme-option:hover:not(.active) {
	background: var(--bg-hover);
}

.theme-option::after {
	content: attr(title);
	position: absolute;
	bottom: -30px;
	left: 50%;
	transform: translateX(-50%);
	background: var(--bg-card);
	color: var(--text-secondary);
	padding: 4px 8px;
	border-radius: 4px;
	font-size: 0.7em;
	white-space: nowrap;
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.2s;
	border: 1px solid var(--border-color);
}

.theme-option:hover::after {
	opacity: 1;
}

/* Theme-specific overrides for existing styles */
[data-theme="light"] .pretty-table {
	background: var(--bg-card);
	border: 1px solid var(--border-color);
}

[data-theme="light"] .pretty-table tr:nth-child(even) td {
	background: rgba(241, 245, 249, 0.5);
}

[data-theme="light"] .pretty-table tr:nth-child(odd) td {
	background: rgba(248, 250, 252, 0.5);
}

[data-theme="light"] .pretty-table tbody tr:hover td {
	background: var(--bg-hover) !important;
}

[data-theme="light"] .swap-candidate {
	background: linear-gradient(90deg, rgba(34, 197, 94, 0.15) 0%, rgba(22, 163, 74, 0.1) 100%) !important;
	color: #15803d !important;
	border-left-color: #22c55e;
}

[data-theme="light"] .tier-worse {
	background: linear-gradient(90deg, rgba(239, 68, 68, 0.15) 0%, rgba(220, 38, 38, 0.1) 100%) !important;
	color: #dc2626 !important;
	border-left-color: #ef4444;
}

[data-theme="light"] .tier1 {
	background: linear-gradient(90deg, rgba(250, 204, 21, 0.2) 0%, rgba(234, 179, 8, 0.15) 100%) !important;
	color: #ca8a04 !important;
	border-left-color: #facc15;
}

/* Dark mode specific adjustments */
[data-theme="dark"] .winprob-row {
	background: linear-gradient(135deg, rgba(0, 0, 0, 0.95) 0%, rgba(10, 10, 10, 0.95) 100%);
	border-color: rgba(59, 130, 246, 0.3);
}

[data-theme="dark"] .league-tab {
	background: rgba(28, 28, 28, 0.8);
	border-color: rgba(75, 85, 99, 0.3);
}

[data-theme="dark"] .league-tab.active {
	background: linear-gradient(135deg, #1e40af 0%, #1e3a8a 100%);
}

/* Mobile responsive for theme toggle */
@media (max-width: 768px) {
	.theme-toggle {
		padding: 4px;
		gap: 4px;
	}

	.theme-option {
		width: 28px;
		height: 28px;
		font-size: 1em;
	}
}
