/* CSS Variables */
:root {
    --primary-color: #667eea;
    --primary-dark: #5a67d8;
    --secondary-color: #764ba2;
    --accent-color: #f093fb;
    --success-color: #48bb78;
    --danger-color: #f56565;
    --warning-color: #ed8936;
    
    --bg-color: #f7fafc;
    --card-bg: #ffffff;
    --text-color: #2d3748;
    --text-muted: #718096;
    --border-color: #e2e8f0;
    
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.15);
    
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    
    --transition: all 0.3s ease;
}

/* Dark Mode */
[data-theme="dark"] {
    --bg-color: #1a202c;
    --card-bg: #2d3748;
    --text-color: #f7fafc;
    --text-muted: #a0aec0;
    --border-color: #4a5568;
    
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.4);
    --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.5);
}

/* Reset */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* Base */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    min-height: 100vh;
    transition: var(--transition);
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 2rem;
}

header h1 {
    font-size: 2.5rem;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.5rem;
}

.subtitle {
    color: var(--text-muted);
    font-size: 1.1rem;
}

/* Stopwatch Card */
.stopwatch-card {
    background: var(--card-bg);
    border-radius: var(--radius-xl);
    padding: 2.5rem;
    box-shadow: var(--shadow-lg);
    text-align: center;
    margin-bottom: 2rem;
}

.time-display {
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 4rem;
    font-weight: 700;
    color: var(--text-color);
    margin-bottom: 2rem;
    letter-spacing: 2px;
    user-select: none;
}

.time-display .milliseconds {
    font-size: 2.5rem;
    color: var(--text-muted);
}

@media (max-width: 600px) {
    .time-display {
        font-size: 2.5rem;
    }
    .time-display .milliseconds {
        font-size: 1.5rem;
    }
}

/* Controls */
.controls {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: var(--transition);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-large {
    padding: 1rem 2.5rem;
    font-size: 1.25rem;
}

.btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: var(--card-bg);
    color: var(--text-color);
    border: 2px solid var(--border-color);
}

.btn-secondary:hover:not(:disabled) {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.btn-danger {
    background: var(--danger-color);
    color: white;
}

.btn-danger:hover:not(:disabled) {
    background: #e53e3e;
}

.btn.running {
    background: var(--warning-color);
}

.extra-controls {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
}

.extra-controls .btn {
    background: var(--bg-color);
    color: var(--text-muted);
    border: 1px solid var(--border-color);
}

.extra-controls .btn:hover {
    color: var(--primary-color);
    border-color: var(--primary-color);
}

/* Laps Section */
.laps-section {
    background: var(--card-bg);
    border-radius: var(--radius-xl);
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
    margin-bottom: 2rem;
}

.laps-section h2 {
    font-size: 1.25rem;
    margin-bottom: 1rem;
    color: var(--text-color);
}

.laps-header {
    display: grid;
    grid-template-columns: 1fr 2fr 2fr;
    padding: 0.75rem 1rem;
    background: var(--bg-color);
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.laps-list {
    max-height: 300px;
    overflow-y: auto;
}

.lap-item {
    display: grid;
    grid-template-columns: 1fr 2fr 2fr;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 0.95rem;
}

.lap-item:last-child {
    border-bottom: none;
}

.lap-item.fastest {
    color: var(--success-color);
}

.lap-item.slowest {
    color: var(--danger-color);
}

.laps-stats {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 2px solid var(--border-color);
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    text-align: center;
}

.stat-item {
    padding: 0.75rem;
    background: var(--bg-color);
    border-radius: var(--radius-md);
}

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

.stat-value {
    font-family: 'SF Mono', monospace;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-color);
}

/* Quick Timers */
.quick-timers {
    background: var(--card-bg);
    border-radius: var(--radius-xl);
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
    margin-bottom: 2rem;
    text-align: center;
}

.quick-timers h2 {
    font-size: 1.25rem;
    margin-bottom: 1rem;
}

.timer-buttons {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    flex-wrap: wrap;
}

.quick-timer-btn {
    padding: 0.75rem 1.25rem;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    border: none;
    border-radius: var(--radius-lg);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.quick-timer-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* Trust Badges */
.trust-badges {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    flex-wrap: wrap;
    margin-bottom: 3rem;
}

.badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.badge-icon {
    font-size: 1.25rem;
}

.badge-text {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
}

/* Features */
.features {
    margin-bottom: 3rem;
}

.features h2 {
    text-align: center;
    font-size: 1.75rem;
    margin-bottom: 1.5rem;
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
}

.feature-card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    text-align: center;
    transition: var(--transition);
}

.feature-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
}

.feature-icon {
    font-size: 2.5rem;
    margin-bottom: 1rem;
}

.feature-card h3 {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
}

.feature-card p {
    font-size: 0.9rem;
    color: var(--text-muted);
}

/* How to Use */
.how-to-use {
    margin-bottom: 3rem;
}

.how-to-use h2 {
    text-align: center;
    font-size: 1.75rem;
    margin-bottom: 1.5rem;
}

.steps {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.step {
    display: flex;
    gap: 1rem;
    background: var(--card-bg);
    padding: 1.25rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.step-number {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    flex-shrink: 0;
}

.step-content h3 {
    font-size: 1.1rem;
    margin-bottom: 0.25rem;
}

.step-content p {
    color: var(--text-muted);
    font-size: 0.95rem;
}

kbd {
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.15rem 0.4rem;
    font-family: 'SF Mono', monospace;
    font-size: 0.85rem;
}

/* FAQ */
.faq-section {
    margin-bottom: 3rem;
}

.faq-section h2 {
    text-align: center;
    font-size: 1.75rem;
    margin-bottom: 1.5rem;
}

.faq-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.faq-item {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.faq-question {
    width: 100%;
    padding: 1rem 1.25rem;
    text-align: left;
    background: none;
    border: none;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-color);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: var(--transition);
}

.faq-question::after {
    content: '+';
    font-size: 1.5rem;
    color: var(--primary-color);
    transition: var(--transition);
}

.faq-item.active .faq-question::after {
    transform: rotate(45deg);
}

.faq-question:hover {
    color: var(--primary-color);
}

.faq-answer {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.faq-item.active .faq-answer {
    max-height: 500px;
}

.faq-answer p {
    padding: 0 1.25rem 1rem;
    color: var(--text-muted);
    line-height: 1.7;
}

/* Footer */
footer {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

footer p {
    margin-bottom: 0.5rem;
}

/* Theme Toggle */
.theme-toggle {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--card-bg);
    border: 2px solid var(--border-color);
    box-shadow: var(--shadow-lg);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    z-index: 1000;
}

.theme-toggle:hover {
    transform: scale(1.1);
    border-color: var(--primary-color);
}

.theme-icon {
    font-size: 1.5rem;
}

/* Fullscreen Mode */
.fullscreen-mode {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: var(--bg-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.fullscreen-mode .time-display {
    font-size: 12vw;
    margin-bottom: 3rem;
}

.fullscreen-mode .controls {
    margin-bottom: 2rem;
}

.fullscreen-mode .exit-fullscreen {
    position: absolute;
    top: 2rem;
    right: 2rem;
}

/* Countdown Mode Styles */
.countdown-mode .time-display {
    color: var(--warning-color);
}

.countdown-mode.finished .time-display {
    color: var(--success-color);
    animation: pulse 0.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    .stopwatch-card {
        padding: 1.5rem;
    }
    
    .controls {
        gap: 0.75rem;
    }
    
    .btn-large {
        padding: 0.875rem 1.75rem;
        font-size: 1.1rem;
    }
    
    .trust-badges {
        gap: 0.75rem;
    }
    
    .badge {
        padding: 0.4rem 0.75rem;
    }
    
    .laps-stats {
        grid-template-columns: 1fr;
    }
}
