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

:root {
    --primary: #6366f1;
    --primary-light: #818cf8;
    --primary-dark: #4f46e5;
    --secondary: #0ea5e9;
    --success: #10b981;
    --warning: #f59e0b;
    --bg-dark: #0f172a;
    --bg-card: #1e293b;
    --bg-hover: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border: #334155;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
    --transition: all 0.3s ease;
    --radius: 12px;
    --radius-lg: 20px;
}

/* Base Styles */
html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: linear-gradient(135deg, var(--bg-dark) 0%, #1a1a2e 100%);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

.app-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
header {
    text-align: center;
    padding: 30px 0;
}

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

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

/* Main Content */
main {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 30px;
}

section h2 {
    font-size: 1rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 15px;
    text-align: center;
}

/* Pattern Selection */
.pattern-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.pattern-btn {
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 15px 10px;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.pattern-btn:hover {
    background: var(--bg-hover);
    border-color: var(--primary);
    transform: translateY(-2px);
}

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

.pattern-name {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.pattern-timing {
    font-size: 0.85rem;
    color: var(--secondary);
    font-weight: 500;
}

.pattern-btn.active .pattern-timing {
    color: var(--text-primary);
}

.pattern-desc {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.pattern-btn.active .pattern-desc {
    color: var(--text-secondary);
}

/* Custom Section */
.custom-section {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 20px;
    border: 1px solid var(--border);
}

.custom-section.hidden {
    display: none;
}

.custom-inputs {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
}

.input-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.input-group label {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.input-group input {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-dark);
    color: var(--text-primary);
    font-size: 1.2rem;
    text-align: center;
    transition: var(--transition);
}

.input-group input:focus {
    outline: none;
    border-color: var(--primary);
}

/* Timer Options */
.timer-options {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
}

.timer-btn {
    padding: 10px 20px;
    border: 2px solid var(--border);
    border-radius: 50px;
    background: var(--bg-card);
    color: var(--text-primary);
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.9rem;
    font-weight: 500;
}

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

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

/* Audio Toggle */
.audio-section {
    display: flex;
    justify-content: center;
}

.toggle-container {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
}

.toggle-container input {
    display: none;
}

.toggle-slider {
    width: 50px;
    height: 26px;
    background: var(--bg-hover);
    border-radius: 50px;
    position: relative;
    transition: var(--transition);
}

.toggle-slider::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    background: var(--text-primary);
    border-radius: 50%;
    top: 3px;
    left: 3px;
    transition: var(--transition);
}

.toggle-container input:checked + .toggle-slider {
    background: var(--primary);
}

.toggle-container input:checked + .toggle-slider::after {
    left: 27px;
}

.toggle-label {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

/* Breathing Animation */
.breathing-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    padding: 20px 0;
}

.breathing-container {
    position: relative;
    width: 250px;
    height: 250px;
}

.breathing-circle {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 120px;
    height: 120px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.5s ease-out;
    box-shadow: 0 0 60px rgba(99, 102, 241, 0.4);
}

.breathing-circle.inhale {
    width: 200px;
    height: 200px;
    box-shadow: 0 0 80px rgba(99, 102, 241, 0.6);
}

.breathing-circle.exhale {
    width: 100px;
    height: 100px;
    box-shadow: 0 0 40px rgba(99, 102, 241, 0.3);
}

.breathing-circle.hold {
    box-shadow: 0 0 60px rgba(16, 185, 129, 0.5);
}

.inner-circle {
    background: var(--bg-dark);
    border-radius: 50%;
    width: 70%;
    height: 70%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

.instruction {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.countdown {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-light);
}

/* Progress Ring */
.progress-ring {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.progress-ring svg {
    width: 100%;
    height: 100%;
}

.progress-bg {
    fill: none;
    stroke: var(--bg-hover);
    stroke-width: 4;
}

.progress-bar {
    fill: none;
    stroke: var(--primary);
    stroke-width: 4;
    stroke-linecap: round;
    stroke-dasharray: 597;
    stroke-dashoffset: 597;
    transition: stroke-dashoffset 1s linear;
}

/* Session Timer & Cycle Counter */
.session-timer {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

.cycle-counter {
    font-size: 1rem;
    color: var(--text-secondary);
}

/* Controls */
.controls-section {
    display: flex;
    justify-content: center;
    gap: 15px;
    padding: 20px 0;
}

.control-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 15px 30px;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    font-size: 1.1rem;
    font-weight: 600;
    transition: var(--transition);
    box-shadow: var(--shadow);
}

.control-btn.hidden {
    display: none;
}

.control-btn .icon {
    width: 24px;
    height: 24px;
    fill: currentColor;
}

.start-btn {
    background: linear-gradient(135deg, var(--success), #059669);
    color: white;
}

.start-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.pause-btn {
    background: linear-gradient(135deg, var(--warning), #d97706);
    color: white;
}

.pause-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.stop-btn {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
}

.stop-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

/* Footer */
footer {
    text-align: center;
    padding: 30px 0;
    margin-top: auto;
    border-top: 1px solid var(--border);
}

footer a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    transition: var(--transition);
}

footer a:hover {
    color: var(--primary-light);
}

/* Responsive Design */
@media (max-width: 600px) {
    .app-container {
        padding: 15px;
    }

    header h1 {
        font-size: 1.8rem;
    }

    .subtitle {
        font-size: 0.95rem;
    }

    .pattern-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .pattern-btn {
        padding: 12px 8px;
    }

    .pattern-name {
        font-size: 0.9rem;
    }

    .custom-inputs {
        grid-template-columns: repeat(2, 1fr);
    }

    .timer-options {
        gap: 8px;
    }

    .timer-btn {
        padding: 8px 15px;
        font-size: 0.85rem;
    }

    .breathing-container {
        width: 200px;
        height: 200px;
    }

    .breathing-circle {
        width: 100px;
        height: 100px;
    }

    .breathing-circle.inhale {
        width: 160px;
        height: 160px;
    }

    .breathing-circle.exhale {
        width: 80px;
        height: 80px;
    }

    .instruction {
        font-size: 0.85rem;
    }

    .countdown {
        font-size: 1.5rem;
    }

    .session-timer {
        font-size: 2rem;
    }

    .control-btn {
        padding: 12px 25px;
        font-size: 1rem;
    }

    .control-btn .icon {
        width: 20px;
        height: 20px;
    }
}

@media (max-width: 380px) {
    .pattern-grid {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .custom-inputs {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .controls-section {
        flex-wrap: wrap;
    }
}

/* Animation Keyframes */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

.breathing-circle.active {
    animation: pulse 2s ease-in-out infinite;
}

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

/* Focus States */
button:focus-visible,
input:focus-visible {
    outline: 2px solid var(--primary-light);
    outline-offset: 2px;
}

/* Selection */
::selection {
    background: var(--primary);
    color: white;
}
