/* Dark Mode CSS Variables and Styles */

:root {
    /* Light mode colors (default) */
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-tertiary: #e9ecef;
    --text-primary: #333333;
    --text-secondary: #666666;
    --text-tertiary: #999999;
    --border-color: #e0e0e0;
    --header-bg: #ffffff;
    --nav-bg: #ffffff;
    --card-bg: #ffffff;
    --card-shadow: 0 2px 10px rgba(0,0,0,0.1);
    --link-color: #38003c;
    --link-hover: #4a0e4e;
    --search-bg: rgba(255,255,255,0.95);
    --dropdown-bg: linear-gradient(135deg, rgba(255,255,255,0.98) 0%, rgba(250,250,250,0.98) 100%);
    --code-bg: #f6f8fa;
    --footer-bg: #262627;
    --footer-text: #ffffff;
}

[data-theme="dark"] {
    /* Dark mode colors - True dark theme with no white */
    --bg-primary: #0a0a0a;
    --bg-secondary: #121212;
    --bg-tertiary: #1a1a1a;
    --text-primary: #f0f0f0;
    --text-secondary: #d0d0d0;
    --text-tertiary: #a0a0a0;
    --border-color: #2a2a2a;
    --header-bg: #0f0f0f;
    --nav-bg: #0f0f0f;
    --card-bg: #111111;
    --card-shadow: 0 2px 20px rgba(0,0,0,0.8);
    --link-color: #bb86fc;
    --link-hover: #d1a7ff;
    --search-bg: rgba(15,15,15,0.98);
    --dropdown-bg: linear-gradient(135deg, rgba(17,17,17,0.98) 0%, rgba(15,15,15,0.98) 100%);
    --code-bg: #151515;
    --footer-bg: #0a0a0a;
    --footer-text: #f0f0f0;
}

/* Theme Toggle Button Styles */
.theme-toggle {
    background: linear-gradient(135deg, #38003c, #00ff87);
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(56,0,60,0.2);
}

.theme-toggle:hover {
    transform: scale(1.1) rotate(180deg);
    box-shadow: 0 4px 15px rgba(56,0,60,0.3);
}

.theme-toggle:active {
    transform: scale(0.95);
}

.theme-icon-light,
.theme-icon-dark {
    position: absolute;
    font-size: 1.2rem;
    transition: all 0.3s ease;
}

/* Light mode - show sun */
[data-theme="light"] .theme-icon-light,
:root:not([data-theme]) .theme-icon-light {
    opacity: 1;
    transform: scale(1) rotate(0deg);
}

[data-theme="light"] .theme-icon-dark,
:root:not([data-theme]) .theme-icon-dark {
    opacity: 0;
    transform: scale(0) rotate(180deg);
}

/* Dark mode - show moon */
[data-theme="dark"] .theme-icon-light {
    opacity: 0;
    transform: scale(0) rotate(180deg);
}

[data-theme="dark"] .theme-icon-dark {
    opacity: 1;
    transform: scale(1) rotate(0deg);
}

/* Apply dark mode to main elements */
[data-theme="dark"] body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
}

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

[data-theme="dark"] .header-top {
    background: transparent !important;
}

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

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

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

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

[data-theme="dark"] .nav-links a:hover {
    color: var(--link-color) !important;
    background: rgba(56,0,60,0.1) !important;
}

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

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

[data-theme="dark"] #search-input::placeholder {
    color: var(--text-tertiary) !important;
}

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

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

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

[data-theme="dark"] .search-results-header {
    background: linear-gradient(135deg, #38003c, #4a0e4e) !important;
}

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

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

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

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

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

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

[data-theme="dark"] .dropdown-item:hover {
    background: rgba(56,0,60,0.1) !important;
    color: var(--link-color) !important;
}

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

[data-theme="dark"] .mobile-nav-links a {
    color: var(--text-primary) !important;
}

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

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

/* Article content dark mode */
[data-theme="dark"] .article-content,
[data-theme="dark"] .nyt-article {
    background: var(--card-bg);
    color: var(--text-primary);
}

[data-theme="dark"] .article-content h1,
[data-theme="dark"] .article-content h2,
[data-theme="dark"] .article-content h3,
[data-theme="dark"] .nyt-article h1,
[data-theme="dark"] .nyt-article h2,
[data-theme="dark"] .nyt-article h3 {
    color: var(--text-primary);
}

[data-theme="dark"] .article-content p,
[data-theme="dark"] .nyt-article p {
    color: var(--text-secondary);
}

[data-theme="dark"] .article-content a,
[data-theme="dark"] .nyt-article a {
    color: var(--link-color);
}

[data-theme="dark"] .article-content a:hover,
[data-theme="dark"] .nyt-article a:hover {
    color: var(--link-hover);
}

/* Cards and content sections */
[data-theme="dark"] .card,
[data-theme="dark"] .content-card,
[data-theme="dark"] .article-card {
    background: var(--card-bg);
    border-color: var(--border-color);
    box-shadow: var(--card-shadow);
}

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

[data-theme="dark"] .card-text,
[data-theme="dark"] .card-body {
    color: var(--text-secondary);
}

/* Forms and inputs */
[data-theme="dark"] input,
[data-theme="dark"] textarea,
[data-theme="dark"] select {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-color: var(--border-color);
}

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

[data-theme="dark"] input:focus,
[data-theme="dark"] textarea:focus,
[data-theme="dark"] select:focus {
    border-color: var(--link-color);
    background: var(--bg-secondary);
}

/* Buttons */
[data-theme="dark"] .btn,
[data-theme="dark"] button {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-color: var(--border-color);
}

[data-theme="dark"] .btn:hover,
[data-theme="dark"] button:hover {
    background: var(--link-color);
    color: var(--bg-primary);
}

/* Tables */
[data-theme="dark"] table {
    background: var(--card-bg);
    color: var(--text-primary);
}

[data-theme="dark"] th {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-color: var(--border-color);
}

[data-theme="dark"] td {
    border-color: var(--border-color);
}

[data-theme="dark"] tr:hover {
    background: var(--bg-tertiary);
}

/* Code blocks */
[data-theme="dark"] code,
[data-theme="dark"] pre {
    background: var(--code-bg);
    color: var(--text-primary);
    border-color: var(--border-color);
}

/* Transitions for smooth theme switching */
body,
.site-header,
.main-nav,
.card,
.article-content,
.nyt-article,
input,
textarea,
select,
button,
.btn,
table,
th,
td,
code,
pre {
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

/* Mobile responsiveness for theme toggle */
@media (max-width: 768px) {
    .theme-toggle {
        width: 35px;
        height: 35px;
    }
    
    .theme-icon-light,
    .theme-icon-dark {
        font-size: 1rem;
    }
}

/* Ensure theme toggle is visible in both modes */
[data-theme="dark"] .theme-toggle {
    background: linear-gradient(135deg, #bb86fc, #d1a7ff);
    box-shadow: 0 2px 15px rgba(187, 134, 252, 0.3);
}

/* Animation for theme transition */
@keyframes themeTransition {
    0% {
        opacity: 0.8;
    }
    50% {
        opacity: 0.9;
    }
    100% {
        opacity: 1;
    }
}

body.theme-transitioning {
    animation: themeTransition 0.3s ease;
}

/* Preserve brand colors in dark mode */
[data-theme="dark"] .fpl-premium-nav {
    color: var(--text-primary) !important;
}

[data-theme="dark"] .fpl-premium-nav:hover {
    color: var(--link-color) !important;
}

[data-theme="dark"] .premium-icon {
    color: #ffd700 !important;
}

/* Auth buttons in dark mode */
[data-theme="dark"] .auth-link.signin {
    border-color: var(--link-color) !important;
    color: var(--link-color) !important;
}

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

[data-theme="dark"] .auth-link.create-account {
    background: var(--link-color) !important;
    color: var(--text-primary) !important;
}

[data-theme="dark"] .auth-link.create-account:hover {
    background: var(--link-hover) !important;
}

/* Premium and account buttons */
[data-theme="dark"] .account-nav-btn {
    background: linear-gradient(135deg, #6f42c1, #9b59b6) !important;
}

[data-theme="dark"] .premium-nav-btn {
    background: linear-gradient(135deg, #ffd700, #ffed4e) !important;
    color: #38003c !important;
}

/* Additional comprehensive dark mode styles - No white backgrounds */

/* Ensure body and html are completely dark */
[data-theme="dark"] html,
[data-theme="dark"] body {
    background-color: var(--bg-primary) !important;
    color: var(--text-primary) !important;
}

/* All containers and wrappers */
[data-theme="dark"] .container,
[data-theme="dark"] .wrapper,
[data-theme="dark"] .content-wrapper,
[data-theme="dark"] .main-content,
[data-theme="dark"] .page-content {
    background-color: var(--bg-primary) !important;
    color: var(--text-primary) !important;
}

/* Headlines and main content areas - Ultra dark */
[data-theme="dark"] .main_headline,
[data-theme="dark"] .main_subheadline,
[data-theme="dark"] .main_subheadline2,
[data-theme="dark"] .main_subheadline3,
[data-theme="dark"] .main_subheadline4,
[data-theme="dark"] .main_subheadline5 {
    background: var(--bg-primary) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}

/* Additional stories and sections - Ultra dark */
[data-theme="dark"] .additional-stories,
[data-theme="dark"] .trending-section,
[data-theme="dark"] .news-section,
[data-theme="dark"] .content-section {
    background: var(--bg-primary) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}

/* All divs that might have white backgrounds */
[data-theme="dark"] div:not(.fpl-tools-banner):not(.theme-toggle):not(.search-btn):not(.menu-btn) {
    background-color: transparent !important;
}

/* Specifically target common white background classes */
[data-theme="dark"] .white-bg,
[data-theme="dark"] .bg-white,
[data-theme="dark"] .background-white {
    background-color: var(--bg-primary) !important;
}

/* Modal and popup backgrounds */
[data-theme="dark"] .modal,
[data-theme="dark"] .popup,
[data-theme="dark"] .overlay,
[data-theme="dark"] .dialog {
    background: var(--card-bg) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}

/* All text elements */
[data-theme="dark"] h1,
[data-theme="dark"] h2,
[data-theme="dark"] h3,
[data-theme="dark"] h4,
[data-theme="dark"] h5,
[data-theme="dark"] h6,
[data-theme="dark"] p,
[data-theme="dark"] span,
[data-theme="dark"] div,
[data-theme="dark"] li,
[data-theme="dark"] td,
[data-theme="dark"] th {
    color: var(--text-primary) !important;
}

/* Links with better contrast */
[data-theme="dark"] a {
    color: var(--link-color) !important;
}

[data-theme="dark"] a:hover {
    color: var(--link-hover) !important;
}

/* Bylines and meta text */
[data-theme="dark"] .byline,
[data-theme="dark"] .meta,
[data-theme="dark"] .date,
[data-theme="dark"] .author {
    color: var(--text-secondary) !important;
}

/* Remove any remaining white or light backgrounds */
[data-theme="dark"] .white,
[data-theme="dark"] .light,
[data-theme="dark"] .bright {
    background-color: var(--bg-primary) !important;
    color: var(--text-primary) !important;
}

/* Ensure all sections are dark */
[data-theme="dark"] section,
[data-theme="dark"] article,
[data-theme="dark"] aside,
[data-theme="dark"] main,
[data-theme="dark"] header:not(.site-header),
[data-theme="dark"] footer:not(.site-footer) {
    background-color: var(--bg-primary) !important;
    color: var(--text-primary) !important;
}

/* Images and media containers */
[data-theme="dark"] .image-container,
[data-theme="dark"] .media-container,
[data-theme="dark"] .video-container {
    background-color: var(--bg-secondary) !important;
}

/* Sidebar and widget areas - Ultra dark */
[data-theme="dark"] .sidebar,
[data-theme="dark"] .widget,
[data-theme="dark"] .sidebar-section {
    background: var(--bg-primary) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}

/* Comments and social sections - Ultra dark */
[data-theme="dark"] .comments,
[data-theme="dark"] .social-links,
[data-theme="dark"] .share-buttons {
    background: var(--bg-primary) !important;
    color: var(--text-primary) !important;
}

/* FPL and fantasy sections - Ultra dark */
[data-theme="dark"] .fpl-section,
[data-theme="dark"] .fantasy-section,
[data-theme="dark"] .stats-section {
    background: var(--bg-primary) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}

/* Newsletter and subscription forms - Ultra dark */
[data-theme="dark"] .newsletter,
[data-theme="dark"] .subscription,
[data-theme="dark"] .signup-form {
    background: var(--bg-primary) !important;
    color: var(--text-primary) !important;
}

/* Ensure proper scrollbar styling in dark mode */
[data-theme="dark"] ::-webkit-scrollbar {
    width: 12px;
    background: var(--bg-secondary);
}

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

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

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

/* Selection styling for dark mode */
[data-theme="dark"] ::selection {
    background: var(--link-color);
    color: var(--bg-primary);
}

[data-theme="dark"] ::-moz-selection {
    background: var(--link-color);
    color: var(--bg-primary);
}

/* High specificity overrides for any white backgrounds */
html[data-theme="dark"] body,
html[data-theme="dark"] body *,
html[data-theme="dark"] .container,
html[data-theme="dark"] .wrapper,
html[data-theme="dark"] .content {
    background-color: var(--bg-primary) !important;
}

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

/* Force ultra dark theme on common problematic selectors */
[data-theme="dark"] .main_headline,
[data-theme="dark"] .main_subheadline,
[data-theme="dark"] .main_subheadline2,
[data-theme="dark"] .main_subheadline3,
[data-theme="dark"] .main_subheadline4,
[data-theme="dark"] .main_subheadline5,
[data-theme="dark"] .additional-stories {
    background: var(--bg-primary) !important;
    color: var(--text-primary) !important;
    border: 1px solid var(--border-color) !important;
}

/* Ensure all content areas are properly themed */
[data-theme="dark"] * {
    border-color: var(--border-color) !important;
}

/* Override any remaining white/light colors */
[data-theme="dark"] *:not(img):not(video):not(iframe):not(.theme-toggle):not(.search-btn):not(.menu-btn) {
    background-color: transparent !important;
}