/* CSS Variables for Themes */
:root {
    /* Light Theme (default) */
    --bg-primary: #ffffff;
    --bg-secondary: #f5f5f5;
    --bg-tertiary: #e8e8e8;
    --text-primary: #333333;
    --text-secondary: #666666;
    --text-muted: #999999;
    --accent: #4a90d9;
    --accent-hover: #357abd;
    --correct: #4caf50;
    --incorrect: #f44336;
    --current-bg: rgba(74, 144, 217, 0.2);
    --border: #dddddd;
    --shadow: rgba(0, 0, 0, 0.1);
}

body.theme-dark {
    --bg-primary: #1a1a2e;
    --bg-secondary: #16213e;
    --bg-tertiary: #0f3460;
    --text-primary: #e8e8e8;
    --text-secondary: #b8b8b8;
    --text-muted: #888888;
    --accent: #e94560;
    --accent-hover: #ff6b6b;
    --correct: #00d9a5;
    --incorrect: #ff6b6b;
    --current-bg: rgba(233, 69, 96, 0.2);
    --border: #2a2a4a;
    --shadow: rgba(0, 0, 0, 0.3);
}

body.theme-ocean {
    --bg-primary: #0a1628;
    --bg-secondary: #0d2137;
    --bg-tertiary: #1a3a5c;
    --text-primary: #e0f7fa;
    --text-secondary: #80deea;
    --text-muted: #4dd0e1;
    --accent: #00bcd4;
    --accent-hover: #26c6da;
    --correct: #64ffda;
    --incorrect: #ff8a80;
    --current-bg: rgba(0, 188, 212, 0.2);
    --border: #1a3a5c;
    --shadow: rgba(0, 0, 0, 0.4);
}

body.theme-forest {
    --bg-primary: #1a2f1a;
    --bg-secondary: #2d4a2d;
    --bg-tertiary: #3d6b3d;
    --text-primary: #e8f5e9;
    --text-secondary: #a5d6a7;
    --text-muted: #81c784;
    --accent: #8bc34a;
    --accent-hover: #9ccc65;
    --correct: #aed581;
    --incorrect: #ef9a9a;
    --current-bg: rgba(139, 195, 74, 0.2);
    --border: #3d6b3d;
    --shadow: rgba(0, 0, 0, 0.3);
}

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 20px;
}

.logo {
    font-size: 1.8rem;
    font-weight: 700;
    letter-spacing: -1px;
}

.logo-typing {
    color: #e53935;
}

.logo-aced {
    color: #000000;
}

.header-controls {
    display: flex;
    gap: 10px;
}

/* Theme Selector */
.theme-selector {
    position: relative;
}

.theme-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.theme-btn:hover {
    background-color: var(--bg-tertiary);
}

.theme-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 8px;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s ease;
    z-index: 100;
    min-width: 120px;
}

.theme-dropdown.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.theme-option {
    display: block;
    width: 100%;
    padding: 10px 16px;
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    text-align: left;
    font-size: 0.9rem;
    transition: background-color 0.2s ease;
}

.theme-option:hover {
    background-color: var(--bg-tertiary);
}

.theme-option.active {
    color: var(--accent);
    font-weight: 600;
}

/* Mode Selector */
.mode-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    padding: 20px;
    background-color: var(--bg-secondary);
    border-radius: 12px;
    margin-bottom: 20px;
}

.mode-group {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.mode-label {
    color: var(--text-muted);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.mode-btn {
    padding: 8px 16px;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.mode-btn:hover {
    background-color: var(--accent);
    color: var(--bg-primary);
    border-color: var(--accent);
}

.mode-btn.active {
    background-color: var(--accent);
    color: var(--bg-primary);
    border-color: var(--accent);
}

/* Typing Area */
.typing-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    margin-bottom: 20px;
}

.text-display {
    background-color: var(--bg-secondary);
    border-radius: 12px;
    padding: 40px;
    min-height: 200px;
    cursor: text;
    overflow: hidden;
    position: relative;
}

.quote-textarea {
    width: 100%;
    min-height: 120px;
    font-size: 1.4rem;
    line-height: 2;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    text-align: left;
    background-color: transparent;
    border: none;
    color: transparent;
    caret-color: transparent;
    outline: none;
    resize: none;
    position: absolute;
    top: 40px;
    left: 40px;
    right: 40px;
    z-index: 1;
    padding: 0;
}

.quote-overlay {
    width: 100%;
    min-height: 120px;
    font-size: 1.4rem;
    line-height: 2;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    text-align: left;
    white-space: pre-wrap;
    word-break: break-word;
    overflow-wrap: break-word;
}

.input-container {
    background-color: var(--bg-secondary);
    border-radius: 12px;
    padding: 40px;
    margin-top: 10px;
    min-height: 200px;
}

.typing-input {
    width: 100%;
    min-height: 120px;
    font-size: 1.4rem;
    line-height: 2;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    text-align: left;
    word-wrap: break-word;
    background-color: transparent;
    border: none;
    color: var(--text-secondary);
    outline: none;
    resize: none;
}

.typing-input::placeholder {
    color: var(--text-muted);
}

/* Character States */
.char {
    transition: color 0.1s ease;
}

.char.pending {
    color: var(--text-primary);
}

.char.correct {
    color: var(--correct);
}

.char.incorrect {
    color: var(--incorrect);
    text-decoration: underline;
}

.char.current {
    background-color: var(--current-bg);
    border-radius: 2px;
}

/* Cursor */
.cursor {
    display: inline-block;
    width: 2px;
    height: 1.2em;
    background-color: var(--accent);
    animation: blink 1s infinite;
    vertical-align: middle;
    margin-left: -1px;
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

/* Stats Bar */
.stats-bar {
    display: flex;
    justify-content: center;
    gap: 60px;
    padding: 20px;
    background-color: var(--bg-secondary);
    border-radius: 12px;
    margin-bottom: 20px;
}

.stat {
    text-align: center;
}

.stat-value {
    display: block;
    font-size: 2rem;
    font-weight: 700;
    color: #2e7d32;
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Controls */
.controls {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin: 15px 0;
}

.control-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 32px;
    background-color: #2e7d32;
    border: none;
    border-radius: 8px;
    color: #ffffff;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.control-btn:hover {
    background-color: #1b5e20;
    transform: translateY(-2px);
}

.btn-icon {
    font-size: 1.2rem;
}

/* Results Modal */
.results-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 1000;
}

.results-modal.active {
    opacity: 1;
    visibility: visible;
}

.results-content {
    background-color: var(--bg-secondary);
    padding: 40px;
    border-radius: 16px;
    text-align: center;
    max-width: 400px;
    width: 90%;
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.results-modal.active .results-content {
    transform: scale(1);
}

.results-content h2 {
    color: var(--accent);
    margin-bottom: 30px;
    font-size: 1.8rem;
}

.results-stats {
    display: flex;
    justify-content: space-around;
    margin-bottom: 30px;
}

.result-stat {
    text-align: center;
}

.result-value {
    display: block;
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
}

.result-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Focus States */
.text-display:focus-within,
.text-display.focused {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }

    .header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }

    .mode-selector {
        flex-direction: column;
        gap: 15px;
        padding: 15px;
    }

    .mode-group {
        justify-content: center;
    }

    .text-display {
        padding: 25px;
        min-height: 150px;
    }

    .quote-text {
        font-size: 1.1rem;
        line-height: 1.8;
    }

    .stats-bar {
        gap: 30px;
        padding: 15px;
    }

    .stat-value {
        font-size: 1.5rem;
    }

    .results-stats {
        flex-direction: column;
        gap: 20px;
    }
}

@media (max-width: 480px) {
    .logo {
        font-size: 1.5rem;
    }

    .mode-btn {
        padding: 6px 12px;
        font-size: 0.8rem;
    }

    .quote-text {
        font-size: 1rem;
    }

    .stats-bar {
        gap: 20px;
    }

    .stat-value {
        font-size: 1.3rem;
    }
}
