﻿* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-gradient-start: #667eea;
    --bg-gradient-end: #764ba2;
    --container-bg: #ffffff;
    --left-panel-bg: #2c3e50;
    --right-panel-bg: #ecf0f1;
    --center-bg: #f8f9fa;
    --text-main: #2c3e50;
    --text-muted: #7f8c8d;
    --accent: #3498db;
    --history-item-bg: #ffffff;
    --input-bg: #ffffff;
    --input-border: #dee2e6;
}

body[data-theme="dark"] {
    --bg-gradient-start: #232a4d;
    --bg-gradient-end: #3b2a5c;
    --container-bg: #1b2333;
    --left-panel-bg: #10151f;
    --right-panel-bg: #171f2e;
    --center-bg: #1b2333;
    --text-main: #e5e7eb;
    --text-muted: #9aa5b1;
    --accent: #5dade2;
    --history-item-bg: #232c3f;
    --input-bg: #232c3f;
    --input-border: #374357;
}

body {
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    background: linear-gradient(135deg, var(--bg-gradient-start) 0%, var(--bg-gradient-end) 100%);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 20px;
    transition: background 0.3s ease;
}

/* Program Title Header */
.program-header {
    padding: 10px 20px;
    margin-bottom: 10px;
    border-radius: 10px;
    background: #382F73;
    width: 100%;
    max-width: 1400px;
}

.program-title {
    font-size: 25px;
    font-weight: bold;
    color: white;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    letter-spacing: 2px;
}

.program-subtitle {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 300;
    letter-spacing: 1px;
}

.container {
    background: var(--container-bg);
    border-radius: 15px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    width: 100%;
    max-width: 1400px;
    height: 85vh;
    display: flex;
    overflow: hidden;
    transition: background 0.3s ease;
}

/* Left Panel - Controls */
.left-panel {
    width: 250px;
    background: var(--left-panel-bg);
    padding: 30px 20px;
    color: white;
    display: flex;
    flex-direction: column;
    gap: 25px;
    overflow-y: auto;
    max-height: 100%;
    transition: background 0.3s ease;
}

    .left-panel::-webkit-scrollbar {
        width: 8px;
    }

    .left-panel::-webkit-scrollbar-track {
        background: #34495e;
        border-radius: 4px;
    }

    .left-panel::-webkit-scrollbar-thumb {
        background: #3498db;
        border-radius: 4px;
    }

        .left-panel::-webkit-scrollbar-thumb:hover {
            background: #2980b9;
        }

    .left-panel h3 {
        color: #3498db;
        margin-bottom: 10px;
        font-size: 14px;
        text-transform: uppercase;
        letter-spacing: 1px;
    }

.control-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.btn {
    background: #3498db;
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s ease;
    font-family: inherit;
}

    .btn:hover {
        background: #2980b9;
        transform: translateY(-2px);
    }

    .btn.restart {
        background: #e74c3c;
    }

        .btn.restart:hover {
            background: #c0392b;
        }

.time-selector {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.time-btn {
    background: #34495e;
    color: white;
    border: none;
    padding: 10px;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
}

    .time-btn:hover {
        background: #2c3e50;
    }

    .time-btn.active {
        background: #3498db;
    }

/* Center Panel - Main Typing Area */
.center-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--center-bg);
    transition: background 0.3s ease;
}

/* Speedometer */
.speedometer-container {
    padding: 20px;
    background: var(--container-bg);
    border-bottom: 1px solid var(--input-border);
    display: flex;
    justify-content: space-around;
    align-items: center;
    transition: background 0.3s ease;
}

.speed-display {
    text-align: center;
}

.speed-value {
    font-size: 48px;
    font-weight: bold;
    color: var(--accent);
}

.streak-value {
    font-size: 34px;
}

#streakStat.streak-hot .streak-value {
    color: #e67e22;
    animation: streakPulse 0.6s ease infinite;
}

@keyframes streakPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.12); }
}

.speed-label {
    font-size: 14px;
    color: var(--text-muted);
    margin-top: 5px;
}

.timer-display {
    font-size: 36px;
    font-weight: bold;
    color: var(--text-main);
}

/* Code Display Area */
.code-display {
    flex: 1;
    padding: 30px;
    background: #1e1e1e;
    color: #d4d4d4;
    font-size: 18px;
    line-height: 1.8;
    overflow-x: auto;
    overflow-y: hidden;
    position: relative;
}

.code-line {
    padding: 5px 10px;
    margin: 2px 0;
    border-radius: 3px;
    transition: all 0.3s ease;
    white-space: pre-wrap;
    word-wrap: break-word;
    word-break: break-all;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    max-width: 100%;
}

    .code-line.active {
        background: rgba(52, 152, 219, 0.2);
        border-left: 3px solid #3498db;
        padding-left: 20px;
    }

    .code-line .char {
        position: relative;
        display: inline-block;
    }

        .code-line .char.correct {
            color: #27ae60;
        }

        .code-line .char.incorrect {
            color: #e74c3c;
            background: rgba(231, 76, 60, 0.2);
        }

    .code-line .word-error {
        color: #e74c3c;
        background: rgba(231, 76, 60, 0.2);
        padding: 2px 4px;
        border-radius: 2px;
    }

/* Input Area */
.input-container {
    padding: 30px;
    background: var(--container-bg);
    border-top: 2px solid var(--accent);
    transition: background 0.3s ease;
}

.typing-input {
    width: 100%;
    padding: 15px 20px;
    font-size: 18px;
    border: 2px solid var(--input-border);
    border-radius: 5px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    transition: border-color 0.3s ease, background 0.3s ease, color 0.3s ease;
    word-wrap: break-word;
    word-break: break-all;
    white-space: pre-wrap;
    overflow-wrap: break-word;
    resize: vertical;
    min-height: 60px;
    background: var(--input-bg);
    color: var(--text-main);
}

    .typing-input:focus {
        outline: none;
        border-color: var(--accent);
    }

    .typing-input.error {
        border-color: #e74c3c;
        background: rgba(231, 76, 60, 0.05);
    }

/* Right Panel - History */
.right-panel {
    width: 300px;
    background: var(--right-panel-bg);
    padding: 20px;
    overflow-y: auto;
    transition: background 0.3s ease;
}

.history-title {
    font-size: 18px;
    font-weight: bold;
    color: var(--text-main);
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--accent);
}

.history-graph {
    display: block;
    width: 100%;
    height: 120px;
    margin-bottom: 20px;
    background: var(--history-item-bg);
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.history-item {
    background: var(--history-item-bg);
    color: var(--text-main);
    padding: 15px;
    margin-bottom: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, background 0.3s ease;
}

    .history-item:hover {
        transform: translateX(-5px);
    }

.history-wpm {
    font-size: 24px;
    font-weight: bold;
    color: #3498db;
}

.history-accuracy {
    font-size: 14px;
    color: #27ae60;
    margin-top: 5px;
}

.history-time {
    font-size: 12px;
    color: #95a5a6;
    margin-top: 5px;
}

/* Results Modal */
.results-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

    .results-modal.active {
        display: flex;
    }

.results-content {
    background: var(--container-bg);
    color: var(--text-main);
    padding: 40px;
    border-radius: 15px;
    text-align: center;
    max-width: 500px;
    animation: slideIn 0.3s ease;
}

.new-record-banner {
    background: linear-gradient(90deg, #f1c40f, #f39c12);
    color: #3a2a00;
    font-weight: bold;
    padding: 10px 16px;
    border-radius: 8px;
    margin-bottom: 20px;
    animation: recordGlow 1.2s ease infinite;
}

@keyframes recordGlow {
    0%, 100% { box-shadow: 0 0 6px rgba(241, 196, 15, 0.4); }
    50% { box-shadow: 0 0 18px rgba(241, 196, 15, 0.9); }
}

.share-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin: 20px 0;
}

.share-btn {
    background: #9b59b6;
}

    .share-btn:hover {
        background: #8e44ad;
    }

@keyframes slideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.results-title {
    font-size: 28px;
    color: #2c3e50;
    margin-bottom: 30px;
}

.result-stat {
    margin: 20px 0;
}

.result-label {
    font-size: 14px;
    color: #7f8c8d;
    margin-bottom: 5px;
}

.result-value {
    font-size: 36px;
    font-weight: bold;
    color: #3498db;
}

/* File Input */
.file-input-wrapper {
    position: relative;
    overflow: hidden;
    display: inline-block;
    width: 100%;
}

    .file-input-wrapper input[type=file] {
        position: absolute;
        left: -9999px;
    }

.file-input-label {
    background: #27ae60;
    color: white;
    padding: 12px 20px;
    border-radius: 5px;
    cursor: pointer;
    display: block;
    text-align: center;
    transition: all 0.3s ease;
}

    .file-input-label:hover {
        background: #229954;
    }

/* Custom Text Buttons */
.custom-text-btn {
    background: #9b59b6;
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

    .custom-text-btn:hover {
        background: #8e44ad;
    }

.custom-text-name {
    flex: 1;
    text-align: left;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.delete-custom-btn {
    background: #e74c3c;
    color: white;
    border: none;
    padding: 4px 8px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 12px;
    margin-left: 10px;
    transition: all 0.3s ease;
}

    .delete-custom-btn:hover {
        background: #c0392b;
        transform: scale(1.1);
    }

.custom-texts-container {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-bottom: 10px;
}

/* Default Text Buttons */
.default-texts-container {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-bottom: 10px;
}

.default-text-btn {
    background: #3498db;
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
    width: 100%;
    text-align: center;
}

    .default-text-btn:hover {
        background: #2980b9;
        transform: translateY(-2px);
    }

/* ========================================
   MOBILE RESPONSIVE STYLES
   ======================================== */

/* Mobile Toggle Buttons (hidden on desktop) */
.mobile-toggles {
    display: none;
}

.mobile-close-btn {
    display: none;
}

.mobile-overlay {
    display: none;
}

.center-panel .button-block {
    display: none;
}

/* Mobile Styles (max-width: 768px) */
@media (max-width: 768px) {
    /* Show mobile toggle buttons */
    .mobile-toggles {
        display: flex;
        justify-content: space-between;
        padding: 15px;
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        position: sticky;
        top: 0;
        z-index: 100;
        gap: 10px;
    }

    .mobile-toggle-btn {
        flex: 1;
        background: white;
        color: #2c3e50;
        border: none;
        padding: 14px 20px;
        border-radius: 8px;
        font-size: 16px;
        font-weight: bold;
        cursor: pointer;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
        transition: all 0.2s ease;
        font-family: inherit;
    }

        .mobile-toggle-btn:active {
            transform: scale(0.95);
            box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
        }

    /* Program header adjustments */
    .program-header {
        padding: 15px;
        margin-bottom: 0;
    }

    .program-title {
        font-size: 22px;
    }

    .program-subtitle {
        font-size: 12px;
    }

    /* Container becomes single column */
    .container {
        flex-direction: column;
        height: auto;
        min-height: 100vh;
    }

    /* Center panel takes full width */
    .center-panel {
        width: 100%;
        flex: 1;
        order: 2;
        display: flex;
        flex-direction: column;
        max-height: 100vh; /* Prevent overflow */
    }

    /* Speedometer adjustments */
    .speedometer-container {
        padding: 15px 10px;
        flex-wrap: wrap;
        gap: 10px;
    }

    .speed-value {
        font-size: 36px;
    }

    .timer-display {
        font-size: 28px;
    }

    /* Code display adjustments */
    .code-display {
        font-size: 14px;
        padding: 20px 15px;
        line-height: 1.6;
        max-height: 35vh; /* Limit height to show input below */
        overflow-y: auto;
    }

    /* Input area adjustments */
    .input-container {
        padding: 15px; /* Reduced from 30px */
    }

    .typing-input {
        font-size: 16px; /* Prevent iOS zoom */
        padding: 12px 15px;
        min-height: 60px; /* Reduced from 80px */
    }

    /* Hide side panels by default (slide off-screen) */
    .left-panel,
    .right-panel {
        position: fixed;
        top: 0;
        width: 100%;
        height: 100vh;
        z-index: 1001;
        transition: transform 0.4s ease;
        overflow-y: auto;
        padding-top: 60px; /* Space for close button */
    }

    .left-panel {
        left: 0;
        transform: translateX(-100%); /* Hidden to the left */
        order: 1;
    }

    .right-panel {
        right: 0;
        transform: translateX(100%); /* Hidden to the right */
        order: 3;
    }

    /* Show panels when active */
    .left-panel.active {
        transform: translateX(0); /* Slide in */
    }

    .right-panel.active {
        transform: translateX(0); /* Slide in */
    }

    /* Close button inside panels */
    .mobile-close-btn {
        display: block;
        position: fixed;
        width: 50px;
        height: 50px;
        background: #e74c3c;
        color: white;
        border: none;
        border-radius: 50%;
        font-size: 28px;
        font-weight: bold;
        cursor: pointer;
        z-index: 1002;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
        transition: all 0.2s ease;
        line-height: 1;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Left panel close button - top left */
    .left-panel .mobile-close-btn {
        top: 15px;
        left: 15px;
    }

    /* Right panel close button - top right */
    .right-panel .mobile-close-btn {
        top: 15px;
        right: 15px;
    }

    .mobile-close-btn:active {
        transform: scale(0.9);
    }

    /* Overlay background when panel is open */
    .mobile-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.7);
        z-index: 1000;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.4s ease;
    }

        .mobile-overlay.active {
            opacity: 1;
            pointer-events: all;
        }

    /* Left panel adjustments */
    .left-panel {
        padding: 70px 20px 30px 20px;
        gap: 20px;
    }

        .left-panel .btn {
            font-size: 16px;
            padding: 14px 20px;
        }

        .left-panel .time-btn {
            font-size: 15px;
            padding: 12px;
        }

    /* Right panel adjustments */
    .right-panel {
        padding: 70px 20px 30px 20px;
    }

    .history-title {
        font-size: 20px;
        margin-bottom: 15px;
    }

    .history-item {
        margin-bottom: 12px;
        padding: 12px;
    }

    /* Results modal adjustments */
    .results-modal {
        padding: 10px;
    }

    .results-content {
        padding: 30px 20px;
        max-width: 100%;
    }

    .results-title {
        font-size: 24px;
    }

    .result-value {
        font-size: 32px;
    }

    .center-panel .button-block {
        display: block;
        margin-bottom: 10px;
    }

    .center-panel .buttonblock .btn {
        display: inline-block;
    }
}

/* Tablet/Small Desktop (768px - 1024px) */
@media (min-width: 769px) and (max-width: 1024px) {
    .left-panel {
        width: 200px;
        padding: 20px 15px;
    }

    .right-panel {
        width: 250px;
        padding: 15px;
    }

    .program-title {
        font-size: 24px;
    }

    .speedometer-container {
        padding: 15px;
    }
}
