/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #333;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    background-attachment: fixed;
    min-height: 100vh;
    padding-bottom: 80px;
}

/* Paper Texture Effect */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        radial-gradient(circle at 25px 25px, rgba(255,255,255,0.1) 2%, transparent 0%),
        radial-gradient(circle at 75px 75px, rgba(255,255,255,0.05) 2%, transparent 0%);
    background-size: 100px 100px;
    pointer-events: none;
    z-index: -1;
}

/* Color Palette Variables */
:root {
    --primary-blue: #2196F3;
    --success-green: #4CAF50;
    --warning-amber: #FFC107;
    --danger-red: #F44336;
    --accent-purple: #9C27B0;
    --bg-paper: rgba(255, 255, 255, 0.95);
    --text-primary: #333;
    --text-secondary: #666;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    --border-radius: 12px;
}

/* Header */
.app-header {
    background: var(--bg-paper);
    backdrop-filter: blur(10px);
    padding: 1rem;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.app-header h1 {
    color: var(--primary-blue);
    font-size: 1.5rem;
    font-weight: 700;
}

.voice-btn {
    background: var(--accent-purple);
    color: white;
    border: none;
    padding: 0.75rem;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: var(--shadow);
}

.voice-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2);
}

.voice-btn.active {
    background: var(--success-green);
}

/* Main Content */
.app-main {
    padding: 1rem;
    max-width: 1200px;
    margin: 0 auto;
}

.section {
    display: none;
    background: var(--bg-paper);
    border-radius: var(--border-radius);
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow);
    backdrop-filter: blur(10px);
}

.section.active {
    display: block;
}

/* Timer Display */
.timer-display {
    text-align: center;
    margin-bottom: 2rem;
}

.current-phase {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--primary-blue);
    margin-bottom: 1rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.timer-circle {
    position: relative;
    display: inline-block;
    margin-bottom: 2rem;
}

.time-display {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 3rem;
    font-weight: 700;
    color: var(--text-primary);
    font-family: 'Courier New', monospace;
}

.progress-ring {
    position: relative;
}

.progress-svg {
    transform: rotate(-90deg);
}

.progress-bg {
    fill: none;
    stroke: #e0e0e0;
    stroke-width: 8;
}

.progress-bar {
    fill: none;
    stroke: var(--primary-blue);
    stroke-width: 8;
    stroke-linecap: round;
    stroke-dasharray: 565.48;
    stroke-dashoffset: 565.48;
    transition: stroke-dashoffset 1s ease, stroke 0.3s ease;
}

.progress-bar.work {
    stroke: var(--success-green);
}

.progress-bar.rest {
    stroke: var(--warning-amber);
}

.progress-bar.prep {
    stroke: var(--primary-blue);
}

/* Timer Controls */
.timer-controls {
    display: flex;
    gap: 1rem;
    justify-content: center;
    align-items: center;
}

.control-btn {
    background: var(--primary-blue);
    color: white;
    border: none;
    padding: 1rem;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.5rem;
    transition: all 0.3s ease;
    box-shadow: var(--shadow);
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.control-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2);
}

.control-btn.primary {
    background: var(--success-green);
    width: 80px;
    height: 80px;
    font-size: 2rem;
}

.control-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

/* Quick Presets */
.quick-presets h3 {
    color: var(--text-primary);
    margin-bottom: 1rem;
    font-size: 1.25rem;
}

.preset-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.preset-btn {
    background: linear-gradient(135deg, var(--primary-blue), var(--accent-purple));
    color: white;
    border: none;
    padding: 1.5rem 1rem;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: var(--shadow);
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.preset-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
}

.preset-btn i {
    font-size: 2rem;
}

.preset-btn span {
    font-weight: 600;
    font-size: 1rem;
}

.preset-btn small {
    opacity: 0.8;
    font-size: 0.8rem;
}

/* Workout Suggestions */
.workout-suggestions h3 {
    color: var(--text-primary);
    margin-bottom: 1rem;
    font-size: 1.25rem;
}

.exercises-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.exercise-card {
    background: linear-gradient(135deg, var(--success-green), var(--primary-blue));
    color: white;
    padding: 1rem;
    border-radius: var(--border-radius);
    text-align: center;
    box-shadow: var(--shadow);
    transition: transform 0.3s ease;
}

.exercise-card:hover {
    transform: translateY(-2px);
}

.exercise-card h4 {
    margin-bottom: 0.5rem;
    font-size: 1.1rem;
}

.exercise-card p {
    font-size: 0.9rem;
    opacity: 0.9;
}

/* Forms */
.config-form, .audio-settings {
    margin-bottom: 2rem;
}

.form-group {
    margin-bottom: 1rem;
}

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

.form-group input,
.form-group select {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid #e0e0e0;
    border-radius: var(--border-radius);
    font-size: 1rem;
    transition: border-color 0.3s ease;
    background: white;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.1);
}

.form-group small {
    display: block;
    margin-top: 0.25rem;
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.form-group input[type="range"] {
    padding: 0;
}

/* Buttons */
.btn {
    background: var(--primary-blue);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: var(--shadow);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2);
}

.btn.primary {
    background: var(--success-green);
}

.btn.secondary {
    background: var(--text-secondary);
}

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

.form-actions {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

/* Saved Timers */
.saved-timers h3 {
    color: var(--text-primary);
    margin-bottom: 1rem;
}

.timers-list {
    display: grid;
    gap: 1rem;
}

.timer-item {
    background: white;
    padding: 1rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-left: 4px solid var(--primary-blue);
}

.timer-info h4 {
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.timer-info p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.timer-actions {
    display: flex;
    gap: 0.5rem;
}

.timer-actions button {
    background: transparent;
    border: 1px solid #ddd;
    padding: 0.5rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.timer-actions button:hover {
    background: var(--primary-blue);
    color: white;
    border-color: var(--primary-blue);
}

/* History Section */
.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.history-header h2 {
    color: var(--text-primary);
}

.stats-overview {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: white;
    padding: 1.5rem;
    border-radius: var(--border-radius);
    text-align: center;
    box-shadow: var(--shadow);
    border-top: 4px solid var(--primary-blue);
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-blue);
    margin-bottom: 0.5rem;
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.history-filters {
    margin-bottom: 2rem;
}

.history-filters select {
    padding: 0.5rem;
    border-radius: var(--border-radius);
    border: 2px solid #e0e0e0;
    background: white;
}

.history-list {
    display: grid;
    gap: 1rem;
}

.history-item {
    background: white;
    padding: 1rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    border-left: 4px solid var(--success-green);
}

.history-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.history-item h4 {
    color: var(--text-primary);
}

.history-date {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.history-details {
    color: var(--text-secondary);
    font-size: 0.9rem;
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

/* Settings */
.settings-group {
    margin-bottom: 2rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid #e0e0e0;
}

.settings-group:last-child {
    border-bottom: none;
}

.settings-group h3 {
    color: var(--text-primary);
    margin-bottom: 1rem;
    font-size: 1.2rem;
}

.setting-item {
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.setting-item label {
    flex: 1;
    font-weight: 600;
    color: var(--text-primary);
}

.setting-item input[type="range"],
.setting-item select {
    flex: 2;
}

.setting-item input[type="checkbox"] {
    width: auto;
    margin-right: 0.5rem;
}

.voice-commands-help {
    background: #f5f5f5;
    padding: 1rem;
    border-radius: var(--border-radius);
    margin-top: 1rem;
}

.voice-commands-help h4 {
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.voice-commands-help ul {
    list-style: none;
    padding: 0;
}

.voice-commands-help li {
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
    padding-left: 1rem;
    position: relative;
}

.voice-commands-help li::before {
    content: '🎤';
    position: absolute;
    left: 0;
}

/* FAQ Section */
.faq-section {
    background: var(--bg-paper);
    border-radius: var(--border-radius);
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow);
    backdrop-filter: blur(10px);
}

.faq-section h2 {
    color: var(--text-primary);
    margin-bottom: 2rem;
    text-align: center;
}

.faq-container {
    max-width: 800px;
    margin: 0 auto;
}

.faq-item {
    border-bottom: 1px solid #e0e0e0;
    margin-bottom: 1rem;
}

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

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

.faq-icon {
    font-size: 1.5rem;
    color: var(--primary-blue);
    transition: transform 0.3s ease;
}

.faq-question[aria-expanded="true"] .faq-icon {
    transform: rotate(45deg);
}

.faq-answer {
    padding: 0 0 1rem 0;
    color: var(--text-secondary);
    line-height: 1.6;
    overflow: hidden;
    transition: all 0.3s ease;
}

.faq-answer[hidden] {
    display: none;
}

.faq-answer p {
    margin-bottom: 1rem;
}

.faq-answer strong {
    color: var(--text-primary);
}

/* Bottom Navigation */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-paper);
    backdrop-filter: blur(10px);
    display: flex;
    justify-content: space-around;
    padding: 0.5rem;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    z-index: 1000;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.5rem;
    text-decoration: none;
    color: var(--text-secondary);
    transition: all 0.3s ease;
    border-radius: var(--border-radius);
    min-width: 60px;
}

.nav-item:hover,
.nav-item.active {
    color: var(--primary-blue);
    background: rgba(33, 150, 243, 0.1);
}

.nav-item i {
    font-size: 1.5rem;
    margin-bottom: 0.25rem;
}

.nav-item span {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Footer */
footer {
    background: var(--bg-paper);
    text-align: center;
    padding: 1rem;
    color: var(--text-secondary);
    font-size: 0.8rem;
    margin-top: 2rem;
    backdrop-filter: blur(10px);
}

/* Responsive Design */
@media (max-width: 768px) {
    .app-header {
        padding: 0.75rem;
    }
    
    .app-header h1 {
        font-size: 1.25rem;
    }
    
    .app-main {
        padding: 0.5rem;
    }
    
    .section {
        padding: 1rem;
    }
    
    .time-display {
        font-size: 2.5rem;
    }
    
    .preset-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .form-actions {
        flex-direction: column;
    }
    
    .timer-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    
    .history-header {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }
    
    .stats-overview {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .setting-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .setting-item label {
        flex: none;
    }
    
    .setting-item input[type="range"],
    .setting-item select {
        width: 100%;
        flex: none;
    }
}

@media (max-width: 480px) {
    .time-display {
        font-size: 2rem;
    }
    
    .preset-grid {
        grid-template-columns: 1fr;
    }
    
    .stats-overview {
        grid-template-columns: 1fr;
    }
    
    .control-btn {
        width: 50px;
        height: 50px;
        font-size: 1.25rem;
    }
    
    .control-btn.primary {
        width: 70px;
        height: 70px;
        font-size: 1.75rem;
    }
}

/* Dark Theme Support */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-paper: rgba(30, 30, 30, 0.95);
        --text-primary: #fff;
        --text-secondary: #ccc;
    }
    
    body {
        background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    }
    
    .form-group input,
    .form-group select {
        background: #333;
        color: white;
        border-color: #555;
    }
    
    .timer-item,
    .history-item,
    .stat-card {
        background: #333;
    }
    
    .voice-commands-help {
        background: #333;
    }
    
    .faq-item {
        border-bottom-color: #555;
    }
}

/* Animations */
@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.timer-circle.active {
    animation: pulse 1s infinite;
}

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

.section.active {
    animation: fadeIn 0.3s ease;
}

/* Utility Classes */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }
.mt-1 { margin-top: 1rem; }
.mb-1 { margin-bottom: 1rem; }
.p-1 { padding: 1rem; }
.hidden { display: none !important; }
.visible { display: block !important; }

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    }
    
    .btn,
    .control-btn,
    .preset-btn {
        border: 2px solid currentColor;
    }
}

/* 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;
    }
}
