/* ===== THEME SYSTEM ===== */
/* Light and Dark mode color schemes */

/* ===== LIGHT MODE (DEFAULT) ===== */
:root,
[data-theme="light"] {
    /* Backgrounds */
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-tertiary: #e9ecef;

    /* Text */
    --text-primary: #212529;
    --text-secondary: #6c757d;
    --text-tertiary: #adb5bd;

    /* Accent */
    --accent: #0066cc;
    --accent-hover: #0052a3;

    /* Borders & Shadows */
    --border: #dee2e6;
    --shadow: rgba(0, 0, 0, 0.1);

    /* Status Colors */
    --success: #28a745;
    --warning: #ffc107;
    --danger: #dc3545;
    --info: #17a2b8;
}

/* ===== DARK MODE ===== */
[data-theme="dark"] {
    /* Backgrounds */
    --bg-primary: #1a1a1a;
    --bg-secondary: #2d2d2d;
    --bg-tertiary: #3d3d3d;

    /* Text */
    --text-primary: #e0e0e0;
    --text-secondary: #a0a0a0;
    --text-tertiary: #707070;

    /* Accent */
    --accent: #4da6ff;
    --accent-hover: #66b3ff;

    /* Borders & Shadows */
    --border: #404040;
    --shadow: rgba(0, 0, 0, 0.3);

    /* Status Colors */
    --success: #4caf50;
    --warning: #ff9800;
    --danger: #f44336;
    --info: #2196f3;
}

/* ===== SMOOTH TRANSITIONS ===== */
body,
.header,
.sidebar,
.content,
.right-panel,
.search-input,
.icon-button,
.nav-link,
.feature-card,
.screenplay,
.markdown-content {
    transition:
        background-color var(--transition-normal),
        color var(--transition-normal),
        border-color var(--transition-normal);
}

/* ===== THEME TOGGLE BUTTON ===== */
.theme-icon {
    transition: transform var(--transition-fast);
}

#themeToggle:hover .theme-icon {
    transform: scale(1.1) rotate(15deg);
}

/* Icon changes based on theme */
[data-theme="light"] .theme-icon::before {
    content: "🌙";
}

[data-theme="dark"] .theme-icon::before {
    content: "☀️";
}

/* ===== DARK MODE SPECIFIC ADJUSTMENTS ===== */

/* Improve contrast for dark mode */
[data-theme="dark"] .search-input {
    background: var(--bg-secondary);
}

[data-theme="dark"] .search-input:focus {
    box-shadow: 0 0 0 3px rgba(77, 166, 255, 0.2);
}

[data-theme="dark"] .nav-link.active {
    background: var(--accent);
    color: var(--bg-primary);
}

[data-theme="dark"] kbd {
    background: var(--bg-secondary);
    border-color: var(--border);
}

/* Scrollbar styling (webkit browsers) */
[data-theme="dark"] ::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}

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

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

[data-theme="dark"] ::-webkit-scrollbar-thumb:hover {
    background: #4d4d4d;
}

/* ===== AUTO DARK MODE (based on system preference) ===== */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        /* Apply dark mode colors if no theme is explicitly set */
        --bg-primary: #1a1a1a;
        --bg-secondary: #2d2d2d;
        --bg-tertiary: #3d3d3d;
        --text-primary: #e0e0e0;
        --text-secondary: #a0a0a0;
        --text-tertiary: #707070;
        --accent: #4da6ff;
        --accent-hover: #66b3ff;
        --border: #404040;
        --shadow: rgba(0, 0, 0, 0.3);
    }
}

/* ===== HIGH CONTRAST MODE ===== */
@media (prefers-contrast: high) {
    :root {
        --border: #000000;
    }

    [data-theme="dark"] {
        --border: #ffffff;
    }

    .nav-link.active {
        border: 2px solid currentColor;
    }
}

/* ===== REDUCED MOTION ===== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ===== PRINT MODE (always light) ===== */
@media print {
    :root {
        --bg-primary: #ffffff;
        --bg-secondary: #ffffff;
        --bg-tertiary: #f5f5f5;
        --text-primary: #000000;
        --text-secondary: #333333;
        --text-tertiary: #666666;
        --accent: #000000;
        --border: #000000;
        --shadow: transparent;
    }

    /* Hide theme toggle in print */
    #themeToggle {
        display: none;
    }
}

/* ===== CUSTOM THEME SUPPORT (for future expansion) ===== */
[data-theme="high-contrast-light"] {
    --bg-primary: #ffffff;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f0f0f0;
    --text-primary: #000000;
    --text-secondary: #000000;
    --text-tertiary: #333333;
    --accent: #0000ff;
    --accent-hover: #0000cc;
    --border: #000000;
    --shadow: rgba(0, 0, 0, 0.2);
}

[data-theme="high-contrast-dark"] {
    --bg-primary: #000000;
    --bg-secondary: #000000;
    --bg-tertiary: #1a1a1a;
    --text-primary: #ffffff;
    --text-secondary: #ffffff;
    --text-tertiary: #cccccc;
    --accent: #ffff00;
    --accent-hover: #ffff66;
    --border: #ffffff;
    --shadow: rgba(255, 255, 255, 0.2);
}

/* Sepia theme (easy on the eyes for long reading) */
[data-theme="sepia"] {
    --bg-primary: #f4ecd8;
    --bg-secondary: #e8dcc4;
    --bg-tertiary: #d9ccb0;
    --text-primary: #5b4636;
    --text-secondary: #8b7355;
    --text-tertiary: #a68f72;
    --accent: #8b4513;
    --accent-hover: #a0522d;
    --border: #c9b896;
    --shadow: rgba(91, 70, 54, 0.1);
}
