/* Critical: Prevent flash by setting initial theme */
html[data-theme="dark"] {
    background-color: #1a202c !important;
    color: #f7fafc !important;
}

html[data-theme="light"] {
    background-color: #f7fafc !important;
    color: #2d3748 !important;
}

:root {
    /* Light mode variables */
    --bg-primary: #f7fafc;
    --bg-secondary: #edf2f7;
    --bg-nav: rgba(255, 255, 255, 0.95);
    --bg-nav-scroll: rgba(255, 255, 255, 0.95);
    --text-primary: #2d3748;
    --text-secondary: #4a5568;
    --text-nav: #2d3748;
    --border-color: rgba(0, 0, 0, 0.1);
    --shadow-color: rgba(0, 0, 0, 0.1);
    --shadow-hover: rgba(0, 0, 0, 0.2);
    --cta-bg: rgba(255, 255, 255, 0.95);
    --cta-text: #2d3748;
    --footer-bg: #2d3748;
    --footer-text: white;
    --link-hover: #667eea;
    --overlay-bg: rgba(45, 55, 72, 0.4);
    --overlay-secondary: rgba(74, 85, 104, 0.2);
    --code-bg: #f8f9fa;
    --code-color: #e74c3c;
    --pre-bg: #1a1a1a;
    --pre-color: #ffffff;
}

[data-theme="dark"] {
    /* Dark mode variables */
    --bg-primary: #1a202c;
    --bg-secondary: #2d3748;
    --bg-nav: rgba(26, 32, 44, 0.95);
    --bg-nav-scroll: rgba(26, 32, 44, 0.95);
    --text-primary: #f7fafc;
    --text-secondary: #e2e8f0;
    --text-nav: #f7fafc;
    --border-color: rgba(255, 255, 255, 0.1);
    --shadow-color: rgba(0, 0, 0, 0.3);
    --shadow-hover: rgba(0, 0, 0, 0.5);
    --cta-bg: rgba(45, 55, 72, 0.95);
    --cta-text: #f7fafc;
    --footer-bg: #1a202c;
    --footer-text: #e2e8f0;
    --link-hover: #90cdf4;
    --overlay-bg: rgba(0, 0, 0, 0.6);
    --overlay-secondary: rgba(0, 0, 0, 0.4);
    --code-bg: #2d3748;
    --code-color: #f56565;
    --pre-bg: #2d3748;
    --pre-color: #e2e8f0;
}

/* Theme transition */
* {
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

/* Prevent flash by setting initial theme state */
html {
    background-color: var(--bg-primary);
    color: var(--text-primary);
}

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
}

/* Dark mode toggle button */
.theme-toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-nav);
    transition: all 0.3s ease;
    margin-left: 1rem;
    line-height: 1;
    height: 2.5rem;
    width: 2.5rem;
}

.theme-toggle:hover {
    background: var(--border-color);
    transform: scale(1.1);
}

.theme-toggle svg {
    width: 1.2rem;
    height: 1.2rem;
    fill: currentColor;
}

/* Hide/show icons based on theme */
[data-theme="light"] .moon-icon,
[data-theme="dark"] .sun-icon {
    display: none;
}

[data-theme="light"] .sun-icon,
[data-theme="dark"] .moon-icon {
    display: block;
}

/* Ensure perfect alignment */
.nav-content {
    align-items: center;
}

.nav-links a {
    display: flex;
    align-items: center;
    height: 2.5rem;
}

.theme-toggle svg {
    width: 1.2rem;
    height: 1.2rem;
    fill: currentColor;
    display: block;
} 