/* CSS Variables for Theme Management */
:root {
    --primary-bg: #fafafa;
    --secondary-bg: #ffffff;
    --text-primary: #2c3e50;
    --text-secondary: #7f8c8d;
    --accent-color: #6c5ce7;
    --success-color: #00b894;
    --error-color: #e17055;
    --border-color: #e9ecef;
    --shadow: 0 4px 20px rgba(0,0,0,0.08);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dark Theme Variables */
[data-theme="dark"] {
    --primary-bg: #1a1a1a;
    --secondary-bg: #2d2d2d;
    --text-primary: #e0e0e0;
    --text-secondary: #b0b0b0;
    --accent-color: #a29bfe;
    --success-color: #00b894;
    --error-color: #e17055;
    --border-color: #404040;
    --shadow: 0 4px 20px rgba(0,0,0,0.3);
}

/* Global Styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    background: var(--primary-bg);
    color: var(--text-primary);
    line-height: 1.6;
    transition: var(--transition);
    min-height: 100vh;
}

/* Main Container */
.main-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 2rem 0;
}

/* Header Styles */
.app-header {
    text-align: center;
    margin-bottom: 3rem;
    animation: fadeInUp 0.8s ease-out;
}

.app-title {
    font-size: 2.5rem;
    font-weight: 600;
    background: linear-gradient(135deg, var(--accent-color), #fd79a8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.5rem;
}

.app-subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
    font-weight: 300;
}

/* Typing Card */
.typing-card {
    background: var(--secondary-bg);
    border-radius: 20px;
    padding: 2.5rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
    transition: var(--transition);
    animation: fadeInUp 0.8s ease-out 0.2s both;
}

/* Controls Section */
.controls-section {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.timer-options {
    display: flex;
    gap: 0.5rem;
}

.timer-btn {
    padding: 0.5rem 1rem;
    border: 2px solid var(--border-color);
    background: transparent;
    color: var(--text-primary);
    border-radius: 25px;
    font-weight: 500;
    transition: var(--transition);
    cursor: pointer;
}

.timer-btn:hover {
    border-color: var(--accent-color);
    transform: translateY(-2px);
}

.timer-btn.active {
    background: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
}

.theme-toggle {
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.5rem;
    cursor: pointer;
    transition: var(--transition);
    padding: 0.5rem;
    border-radius: 50%;
}

.theme-toggle:hover {
    background: var(--border-color);
    transform: rotate(180deg);
}

/* Stats Section */
.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    text-align: center;
    padding: 1rem;
    background: var(--primary-bg);
    border-radius: 15px;
    border: 1px solid var(--border-color);
    transition: var(--transition);
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 600;
    color: var(--accent-color);
    display: block;
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

/* Typing Area */
.typing-area {
    position: relative;
    margin-bottom: 2rem;
}

.text-display {
    background: var(--primary-bg);
    border: 2px solid var(--border-color);
    border-radius: 15px;
    padding: 2rem;
    font-size: 1.2rem;
    line-height: 1.8;
    font-family: 'SF Mono', 'Monaco', monospace;
    min-height: 200px;
    position: relative;
    transition: var(--transition);
}

.text-display:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.1);
}

/* Character Styling */
.char {
    position: relative;
    transition: var(--transition);
}

.char.correct {
    background-color: var(--success-color);
    color: white;
    border-radius: 3px;
}

.char.incorrect {
    background-color: var(--error-color);
    color: white;
    border-radius: 3px;
}

.char.current {
    background-color: var(--accent-color);
    animation: blink 1s infinite;
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0.3; }
}

/* Action Buttons */
.action-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-bottom: 2rem;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-color), #a29bfe);
    border: none;
    border-radius: 25px;
    padding: 0.75rem 2rem;
    font-weight: 500;
    font-size: 1.1rem;
    transition: var(--transition);
    box-shadow: 0 4px 15px rgba(108, 92, 231, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(108, 92, 231, 0.4);
}

.btn-secondary {
    background: transparent;
    border: 2px solid var(--border-color);
    color: var(--text-primary);
    border-radius: 25px;
    padding: 0.75rem 2rem;
    font-weight: 500;
    transition: var(--transition);
}

.btn-secondary:hover {
    border-color: var(--accent-color);
    transform: translateY(-2px);
}

/* Modal Styles */
.modal-content {
    border-radius: 20px;
    border: none;
    background: var(--secondary-bg);
    box-shadow: var(--shadow);
}

.modal-header {
    border-bottom: 1px solid var(--border-color);
    padding: 1.5rem 2rem 1rem;
}

.modal-body {
    padding: 2rem;
}

.result-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.result-item {
    text-align: center;
    padding: 1.5rem;
    background: var(--primary-bg);
    border-radius: 15px;
    border: 1px solid var(--border-color);
}

.result-value {
    font-size: 2rem;
    font-weight: 600;
    color: var(--accent-color);
}

.result-label {
    color: var(--text-secondary);
    margin-top: 0.5rem;
}

/* Progress Bar */
.progress-bar {
    height: 8px;
    border-radius: 4px;
    background: var(--border-color);
    overflow: hidden;
    margin: 1rem 0;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--success-color), var(--accent-color));
    border-radius: 4px;
    transition: width 0.3s ease;
}

/* Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

/* Active State */
.typing-active .text-display {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.1);
}

/* Utility Classes */
.disabled {
    pointer-events: none;
    opacity: 0.6;
}

/* Mobile Responsive Design */
@media (max-width: 768px) {
    .controls-section {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
    }

    .timer-options {
        justify-content: center;
    }

    .typing-card {
        padding: 1.5rem;
        margin: 1rem;
    }

    .app-title {
        font-size: 2rem;
    }

    .text-display {
        padding: 1.5rem;
        font-size: 1.1rem;
    }

    .result-grid {
        grid-template-columns: 1fr;
    }

    .stats-row {
        grid-template-columns: repeat(2, 1fr);
    }
}