/* CSS Custom Properties for theming */
:root {
    --color-bg: #1a1a2e;
    --color-bg-secondary: #16213e;
    --color-text: #eaeaea;
    --color-text-muted: #a0a0a0;
    --color-primary: #00ff88;
    --color-warning: #ffcc00;
    --color-error: #ff4444;
    --color-success: #00ff88;
    --font-mono: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace;
    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s ease;
}

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

html, body {
    min-height: 100%;
    width: 100%;
    overflow-x: hidden;
    overflow-y: auto;
}

body {
    font-family: var(--font-sans);
    background: var(--color-bg);
    color: var(--color-text);
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
}

#app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    height: auto;
}

/* Timer Display - Main area */
.timer-display {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    background: var(--color-bg);
    transition: background-color var(--transition-fast);
    outline: none;
    position: relative;
    min-height: 70vh;
    padding: 2rem 1.25rem;
}

.timer-display:focus {
    outline: 4px solid var(--color-primary);
    outline-offset: -4px;
}

.timer-display.warning {
    background: linear-gradient(135deg, var(--color-bg) 0%, rgba(255, 204, 0, 0.2) 100%);
}

.timer-display.expired {
    background: linear-gradient(135deg, var(--color-bg) 0%, rgba(255, 68, 68, 0.3) 100%);
    animation: pulse-red 0.5s ease-in-out infinite;
}

@keyframes pulse-red {
    0%, 100% { background-color: rgba(255, 68, 68, 0.3); }
    50% { background-color: rgba(255, 68, 68, 0.5); }
}

.timer-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

/* Countdown display - Large and readable from distance */
.countdown {
    font-family: var(--font-mono);
    font-size: clamp(6rem, 25vw, 20rem);
    font-weight: 700;
    color: var(--color-primary);
    text-shadow: 0 0 30px rgba(0, 255, 136, 0.5);
    line-height: 1;
    transition: color var(--transition-fast), text-shadow var(--transition-fast);
}

.countdown.warning {
    color: var(--color-warning);
    text-shadow: 0 0 30px rgba(255, 204, 0, 0.5);
}

.countdown.expired {
    color: var(--color-error);
    text-shadow: 0 0 40px rgba(255, 68, 68, 0.7);
}

.status-text {
    font-size: clamp(1rem, 4vw, 2rem);
    font-weight: 500;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.2em;
}

/* Reset Button - Touch-friendly, min 80px */
.reset-btn {
    width: 100%;
    min-height: 80px;
    padding: 1.5rem 2rem;
    font-size: clamp(1.5rem, 5vw, 2rem);
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    background: var(--color-primary);
    color: var(--color-bg);
    border: none;
    cursor: pointer;
    transition: all var(--transition-fast);
    touch-action: manipulation;
}

.reset-btn:hover,
.reset-btn:focus {
    background: #00dd77;
    transform: scale(1.02);
}

.reset-btn:active {
    transform: scale(0.98);
    background: #00bb66;
}

.primary-actions {
    display: flex;
    gap: 0.75rem;
    padding: 0.75rem;
    background: var(--color-bg-secondary);
    flex-wrap: wrap;
}

.primary-actions .reset-btn {
    flex: 1 1 220px;
    width: auto;
}

.ghost-btn {
    background: transparent;
    color: var(--color-primary);
    border: 2px solid rgba(0, 255, 136, 0.4);
}

.ghost-btn:hover,
.ghost-btn:focus {
    background: rgba(0, 255, 136, 0.15);
}

/* Controls Bar */
.controls-bar {
    display: flex;
    justify-content: center;
    gap: 1rem;
    padding: 0.75rem;
    background: var(--color-bg-secondary);
}

.control-btn {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: 2px solid var(--color-text-muted);
    background: transparent;
    color: var(--color-text);
    font-size: 1.25rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
}

.control-btn:hover,
.control-btn:focus {
    border-color: var(--color-primary);
    color: var(--color-primary);
    background: rgba(0, 255, 136, 0.1);
}

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

/* Session List */
.session-list {
    padding: 1rem;
    background: var(--color-bg-secondary);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    overflow-y: visible;
    flex: 1 1 auto;
}

.session-card {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 0.75rem;
    padding: 0.75rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.session-card.current {
    border-color: rgba(0, 255, 136, 0.4);
    box-shadow: 0 0 20px rgba(0, 255, 136, 0.1);
}

.session-card.pending-delete {
    border-color: rgba(255, 68, 68, 0.6);
    box-shadow: 0 0 16px rgba(255, 68, 68, 0.2);
}

.session-card-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.5rem;
}

.session-title {
    font-size: 1rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--color-text);
}

.session-meta {
    font-size: 0.85rem;
    color: var(--color-text-muted);
    white-space: nowrap;
}

.session-metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(70px, 1fr));
    gap: 0.5rem;
}

.session-metric {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    text-align: center;
}

.session-metric label {
    font-size: 0.7rem;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.session-metric span {
    font-family: var(--font-mono);
    font-size: 1.1rem;
    font-weight: 600;
}

.session-metric.success span {
    color: var(--color-success);
}

.session-metric.error span {
    color: var(--color-error);
}

/* Settings Modal */
.settings-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
    animation: fadeIn 0.2s ease;
}

.settings-modal.hidden {
    display: none;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.settings-content {
    background: var(--color-bg-secondary);
    border-radius: 1rem;
    padding: 2rem;
    max-width: 400px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.settings-content h2 {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    color: var(--color-primary);
    text-align: center;
}

.setting-group {
    margin-bottom: 1.5rem;
}

.setting-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--color-text);
}

.range-container {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.range-container input[type="range"] {
    flex: 1;
    height: 8px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.2);
    -webkit-appearance: none;
    appearance: none;
}

.range-container input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--color-primary);
    cursor: pointer;
    transition: transform var(--transition-fast);
}

.range-container input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.range-container input[type="range"]::-moz-range-thumb {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--color-primary);
    cursor: pointer;
    border: none;
}

.range-value {
    min-width: 50px;
    text-align: right;
    font-family: var(--font-mono);
    color: var(--color-primary);
}

select {
    width: 100%;
    padding: 0.75rem;
    font-size: 1rem;
    border-radius: 0.5rem;
    border: 2px solid rgba(255, 255, 255, 0.2);
    background: var(--color-bg);
    color: var(--color-text);
    cursor: pointer;
}

select:focus {
    outline: none;
    border-color: var(--color-primary);
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: 20px;
    height: 20px;
    accent-color: var(--color-primary);
    cursor: pointer;
}

.settings-actions {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 2rem;
}

.settings-actions-row {
    display: flex;
    gap: 1rem;
}

.settings-link-block a {
    width: 100%;
    display: inline-block;
    text-align: center;
}

.primary-btn,
.secondary-btn {
    flex: 1;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.primary-btn {
    background: var(--color-primary);
    color: var(--color-bg);
    border: none;
}

.primary-btn:hover {
    background: #00dd77;
}

.secondary-btn {
    background: transparent;
    color: var(--color-text);
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.secondary-btn:hover {
    border-color: var(--color-error);
    color: var(--color-error);
}

/* Audio Prompt */
.audio-prompt {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    cursor: pointer;
}

.audio-prompt.hidden {
    display: none;
}

/* About page layout */
.about-page {
    max-width: 800px;
    margin: 0 auto;
    padding: 2.5rem 1.5rem 3rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    line-height: 1.6;
}

.about-header {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.about-header .eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.2em;
    font-weight: 700;
    color: var(--color-primary);
    font-size: 0.9rem;
}

.about-header h1 {
    font-size: clamp(1.75rem, 4vw, 2.4rem);
    line-height: 1.2;
}

.about-header .lede {
    color: var(--color-text-muted);
    font-size: 1.05rem;
}

.about-section {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 0.75rem;
    padding: 1.25rem 1.1rem;
}

.about-section h2 {
    font-size: 1.2rem;
    margin-bottom: 0.75rem;
    color: var(--color-primary);
}

.about-section ul {
    list-style: disc;
    padding-left: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.about-section strong {
    color: var(--color-text);
}

.about-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.about-actions .primary-btn,
.about-actions .secondary-btn {
    flex: 1 1 220px;
    text-align: center;
}

.audio-prompt-content {
    text-align: center;
    padding: 2rem;
}

.audio-prompt-content p {
    font-size: 1.5rem;
    color: var(--color-primary);
    animation: pulse 1.5s ease-in-out infinite;
}

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

/* Responsive adjustments */
@media (min-width: 768px) {
    .primary-actions {
        padding: 1rem 2rem;
        justify-content: center;
    }

    .primary-actions .reset-btn {
        border-radius: 0.5rem;
    }

    .session-list {
        max-width: 700px;
        margin: 0 auto 1rem;
        width: 100%;
        border-radius: 0.5rem;
    }
    
    .controls-bar {
        justify-content: center;
    }
}

/* Landscape mode optimizations */
@media (orientation: landscape) and (max-height: 500px) {
    .countdown {
        font-size: clamp(4rem, 20vh, 8rem);
    }
    
    .session-list {
        padding: 0.5rem;
        max-height: 50vh;
    }
    
    .reset-btn {
        min-height: 60px;
        padding: 1rem;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --color-primary: #00ff00;
        --color-warning: #ffff00;
        --color-error: #ff0000;
    }
    
    .countdown {
        text-shadow: none;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
