/* TYPING SPEED TEST STYLING */

/* Stats Display */
.stats-display {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-box {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 1.5rem;
    border-radius: 10px;
    text-align: center;
    box-shadow: 0 4px 6px rgba(37, 99, 235, 0.2);
    transition: transform 0.2s ease;
}

.stat-box:hover {
    transform: translateY(-2px);
}

.stat-label {
    font-size: 0.9rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.95;
    display: block;
    margin-bottom: 0.5rem;
}

.stat-value {
    font-size: 2rem;
    font-weight: 800;
    display: block;
    font-family: 'Courier New', monospace;
}

/* Sample Text Section */
.text-section {
    margin-bottom: 2rem;
}

.sample-text {
    background: #f0f6ff;
    border: 2px solid var(--border);
    border-radius: 8px;
    padding: 1.5rem;
    line-height: 1.8;
    color: var(--dark);
    font-size: 1.1rem;
    min-height: 100px;
    word-wrap: break-word;
    transition: all 0.3s ease;
}

.sample-text.active {
    background: #e0f0ff;
    border-color: var(--primary);
}

.sample-text .typed {
    background: var(--success);
    color: white;
    padding: 0 2px;
    border-radius: 2px;
}

.sample-text .current {
    background: var(--primary);
    color: white;
    padding: 0 2px;
    border-radius: 2px;
    animation: blink 0.6s infinite;
}

.sample-text .error {
    background: var(--error);
    color: white;
    padding: 0 2px;
    border-radius: 2px;
}

@keyframes blink {
    0%, 49% {
        opacity: 1;
    }
    50%, 100% {
        opacity: 0.3;
    }
}

/* Input Section */
.input-section {
    margin-bottom: 2rem;
}

.input-section textarea {
    width: 100%;
    min-height: 120px;
    padding: 1rem;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    font-family: 'Courier New', monospace;
    resize: vertical;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    color: var(--dark);
    /* Mobile improvements */
    -webkit-appearance: none;
    -webkit-user-select: text;
    user-select: text;
    /* Ensure keyboard appears on iOS */
    font-size: 16px;
}

.input-section textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.input-section textarea:disabled {
    background-color: #f5f5f5;
    color: var(--gray);
    cursor: not-allowed;
}

/* Controls */
.controls {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 2rem;
}

.btn-primary {
    padding: 0.8rem 2rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1rem;
    /* Mobile improvements */
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    /* Ensure button is easily tappable on mobile */
    min-height: 44px;
    min-width: 44px;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.btn-primary:active:not(:disabled) {
    transform: translateY(0);
}

.btn-primary:disabled {
    background: #d1d5db;
    cursor: not-allowed;
    opacity: 0.7;
}

.btn-secondary {
    padding: 0.8rem 2rem;
    background: white;
    color: var(--primary);
    border: 2px solid var(--primary);
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1rem;
    /* Mobile improvements */
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    /* Ensure button is easily tappable on mobile */
    min-height: 44px;
    min-width: 44px;
}

.btn-secondary:hover {
    background: #f0f6ff;
    transform: translateY(-2px);
}

.btn-secondary:active {
    transform: translateY(0);
}

/* Results Section */
.results-section {
    background: linear-gradient(135deg, #f0f6ff 0%, #e8f1ff 100%);
    border: 2px solid var(--primary);
    border-radius: 8px;
    padding: 2rem;
    margin-top: 2rem;
    animation: slideIn 0.4s ease;
}

.results-section h2 {
    color: var(--primary);
    margin-bottom: 1.5rem;
    text-align: center;
    font-size: 1.5rem;
}

.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1.5rem;
}

.result-item {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    text-align: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.result-label {
    display: block;
    font-size: 0.9rem;
    color: var(--gray);
    font-weight: 500;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.result-value {
    display: block;
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--primary);
    font-family: 'Courier New', monospace;
}

/* Responsive Design */
@media (max-width: 768px) {
    .stats-display {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }

    .stat-box {
        padding: 1rem;
    }

    .stat-value {
        font-size: 1.5rem;
    }

    .sample-text {
        font-size: 1rem;
        padding: 1rem;
    }

    .input-section textarea {
        min-height: 100px;
        font-size: 16px;
    }

    .controls {
        gap: 0.75rem;
        padding-bottom: 1rem;
    }

    .btn-primary,
    .btn-secondary {
        padding: 0.7rem 1.5rem;
        font-size: 0.95rem;
        min-height: 44px;
    }

    .results-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }

    .result-item {
        padding: 1rem;
    }

    .result-value {
        font-size: 1.3rem;
    }
}

@media (max-width: 480px) {
    .stats-display {
        grid-template-columns: 1fr;
    }

    .controls {
        flex-direction: column;
        padding-bottom: 1.5rem;
    }

    .btn-primary,
    .btn-secondary {
        width: 100%;
        min-height: 48px;
        font-size: 1rem;
    }

    .input-section textarea {
        font-size: 16px;
        min-height: 120px;
        padding: 0.75rem;
    }

    .results-grid {
        grid-template-columns: 1fr;
    }

    /* Add safe area for devices with notches */
    @supports (padding: max(0px)) {
        body {
            padding-left: max(0px, env(safe-area-inset-left));
            padding-right: max(0px, env(safe-area-inset-right));
        }
    }
}
