/**
 * Descansar - Main Styles
 * Modular CSS with CSS Custom Properties
 */

/* ========================================
   CSS Custom Properties (Theme Variables)
   ======================================== */

:root {
    /* Colors - Light Theme */
    --color-primary: #6366f1;
    --color-primary-dark: #4f46e5;
    --color-primary-light: #818cf8;

    --color-success: #10b981;
    --color-warning: #f59e0b;
    --color-danger: #ef4444;

    --color-bg: #f8fafc;
    --color-bg-secondary: #ffffff;
    --color-bg-tertiary: #f1f5f9;

    --color-text: #1e293b;
    --color-text-secondary: #64748b;
    --color-text-muted: #94a3b8;

    --color-border: #e2e8f0;
    --color-border-focus: #6366f1;

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);

    /* Border Radius */
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --radius-full: 9999px;

    /* Typography */
    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --font-family-mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;

    --font-size-xs: 0.75rem;
    --font-size-sm: 0.875rem;
    --font-size-base: 1rem;
    --font-size-lg: 1.125rem;
    --font-size-xl: 1.25rem;
    --font-size-2xl: 1.5rem;
    --font-size-3xl: 1.875rem;
    --font-size-4xl: 2.25rem;
    --font-size-5xl: 3rem;

    /* Spacing */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --space-10: 2.5rem;
    --space-12: 3rem;

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-base: 200ms ease;
    --transition-slow: 300ms ease;

    /* Z-index */
    --z-dropdown: 100;
    --z-modal: 200;
    --z-tooltip: 300;
}

/* Dark Theme */
[data-theme="dark"] {
    --color-primary: #818cf8;
    --color-primary-dark: #6366f1;
    --color-primary-light: #a5b4fc;

    --color-bg: #0f172a;
    --color-bg-secondary: #1e293b;
    --color-bg-tertiary: #334155;

    --color-text: #f1f5f9;
    --color-text-secondary: #cbd5e1;
    --color-text-muted: #94a3b8;

    --color-border: #334155;
    --color-border-focus: #818cf8;

    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.3);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.4), 0 2px 4px -2px rgb(0 0 0 / 0.3);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.4), 0 4px 6px -4px rgb(0 0 0 / 0.3);
}

/* ========================================
   Reset & Base
   ======================================== */

*,
*::before,
*::after {
    box-sizing: border-box;
}

* {
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    line-height: 1.5;
    color: var(--color-text);
    background-color: var(--color-bg);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ========================================
   Accessibility
   ======================================== */

.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--color-primary);
    color: white;
    padding: var(--space-2) var(--space-4);
    z-index: var(--z-tooltip);
    transition: top var(--transition-fast);
}

.skip-link:focus {
    top: 0;
}

/* Focus styles */
:focus-visible {
    outline: 2px solid var(--color-border-focus);
    outline-offset: 2px;
}

/* Screen reader only helper */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ========================================
   Layout
   ======================================== */

.app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    max-width: 480px;
    margin: 0 auto;
    padding: var(--space-4);
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-4) 0;
    margin-bottom: var(--space-4);
}

.header__brand {
    display: flex;
    flex-direction: column;
}

.header__title {
    font-size: var(--font-size-2xl);
    font-weight: 700;
    color: var(--color-primary);
    letter-spacing: -0.025em;
}

.header__tagline {
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
}

.header__nav {
    display: flex;
    gap: var(--space-2);
}

.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: var(--space-6);
}

.footer {
    padding: var(--space-6) 0 var(--space-4);
    text-align: center;
    margin-top: auto;
}

.footer__text {
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
}

.footer__copyright {
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
    margin-top: var(--space-1);
}

.footer__link {
    display: inline-block;
    font-size: var(--font-size-sm);
    color: var(--color-primary);
    text-decoration: none;
    margin-top: var(--space-3);
    padding: var(--space-2) var(--space-4);
    border: 1px solid var(--color-primary);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.footer__link:hover {
    background: var(--color-primary);
    color: white;
}

/* ========================================
   Mode Selector (Tabs)
   ======================================== */

.mode-selector {
    display: flex;
    justify-content: center;
}

.mode-selector__tabs {
    display: flex;
    background: var(--color-bg-tertiary);
    padding: var(--space-1);
    border-radius: var(--radius-lg);
    gap: var(--space-1);
}

.mode-selector__tab {
    padding: var(--space-2) var(--space-5);
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--color-text-secondary);
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.mode-selector__tab:hover {
    color: var(--color-text);
}

.mode-selector__tab--active {
    background: var(--color-bg-secondary);
    color: var(--color-primary);
    box-shadow: var(--shadow-sm);
}

/* ========================================
   Timer Display
   ======================================== */

.timer {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-6);
    position: relative;
}

/* Celebration Lottie animation */
.timer__celebration {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 300px;
    height: 300px;
    z-index: 10;
    pointer-events: none;
}

.timer__progress {
    position: relative;
    width: 220px;
    height: 220px;
}

.progress-ring {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.progress-ring__background {
    fill: none;
    stroke: var(--color-bg-tertiary);
    stroke-width: 8;
}

.progress-ring__progress {
    fill: none;
    stroke: var(--color-primary);
    stroke-width: 8;
    stroke-linecap: round;
    transition: stroke-dashoffset var(--transition-slow);
}

.timer__display {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}

.timer__time {
    display: block;
    font-size: var(--font-size-5xl);
    font-weight: 700;
    font-family: var(--font-family-mono);
    color: var(--color-text);
    letter-spacing: -0.02em;
}

.timer__label {
    display: block;
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
    margin-top: var(--space-1);
}

.timer__info {
    display: flex;
    gap: var(--space-8);
    justify-content: center;
}

.timer__info-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-1);
}

.timer__info-label {
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.timer__info-value {
    font-size: var(--font-size-lg);
    font-weight: 600;
    font-family: var(--font-family-mono);
    color: var(--color-text);
}

/* ========================================
   Panels
   ======================================== */

.panel {
    background: var(--color-bg-secondary);
    border-radius: var(--radius-xl);
    padding: var(--space-6);
    box-shadow: var(--shadow-md);
}

.panel--hidden {
    display: none;
}

/* ========================================
   Input Group
   ======================================== */

.input-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.input-group__label {
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--color-text);
}

.input-group__control {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.input-group__suffix {
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
}

.input-group__hint {
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
}

.input {
    flex: 1;
    padding: var(--space-3) var(--space-4);
    font-size: var(--font-size-lg);
    font-family: var(--font-family-mono);
    text-align: center;
    color: var(--color-text);
    background: var(--color-bg);
    border: 2px solid var(--color-border);
    border-radius: var(--radius-md);
    transition: border-color var(--transition-fast);
    max-width: 100px;
}

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

.input:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ========================================
   Presets
   ======================================== */

.presets {
    display: flex;
    gap: var(--space-2);
    justify-content: center;
    margin-top: var(--space-4);
    flex-wrap: wrap;
}

/* ========================================
   Techniques (Advanced Mode)
   ======================================== */

.techniques {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.technique-card {
    padding: var(--space-4);
    background: var(--color-bg);
    border: 2px solid var(--color-border);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.technique-card:hover {
    border-color: var(--color-primary-light);
}

.technique-card--active {
    border-color: var(--color-primary);
    background: linear-gradient(135deg, var(--color-bg) 0%, rgba(99, 102, 241, 0.05) 100%);
}

.technique-card__title {
    font-size: var(--font-size-lg);
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: var(--space-1);
}

.technique-card__description {
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
}

.technique-card__meta {
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
    margin-top: var(--space-2);
}

/* Custom Settings */
.custom-settings {
    margin-top: var(--space-4);
    padding-top: var(--space-4);
    border-top: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

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

/* ========================================
   Controls
   ======================================== */

.controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-4);
}

.controls__secondary {
    display: flex;
    gap: var(--space-3);
}

.controls__secondary--hidden {
    display: none;
}

/* ========================================
   Buttons
   ======================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-5);
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--color-text);
    background: var(--color-bg-secondary);
    border: 2px solid var(--color-border);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

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

.btn:active {
    transform: scale(0.98);
}

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

.btn--primary:hover {
    background: var(--color-primary-dark);
    border-color: var(--color-primary-dark);
    color: white;
}

.btn--secondary {
    background: transparent;
}

.btn--large {
    padding: var(--space-4) var(--space-8);
    font-size: var(--font-size-base);
    border-radius: var(--radius-lg);
}

.btn--icon {
    padding: var(--space-2);
    border-radius: var(--radius-md);
    background: transparent;
    border: none;
}

.btn--icon:hover {
    background: var(--color-bg-tertiary);
}

.btn--adjust {
    padding: var(--space-2) var(--space-3);
    font-size: var(--font-size-sm);
    font-weight: 600;
    min-width: 44px;
}

.btn--preset {
    padding: var(--space-2) var(--space-4);
    font-size: var(--font-size-sm);
    background: var(--color-bg);
}

.btn--preset:hover {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: white;
}

.btn--hidden {
    display: none;
}

.btn__icon {
    font-size: var(--font-size-base);
}

/* ========================================
   Icons
   ======================================== */

.icon {
    display: inline-block;
    width: 20px;
    height: 20px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

.icon--theme::before {
    content: "🌙";
    font-size: 18px;
}

[data-theme="dark"] .icon--theme::before {
    content: "☀️";
}

.icon--settings::before {
    content: "⚙️";
    font-size: 18px;
}

.icon--close::before {
    content: "✕";
    font-size: 16px;
}

/* ========================================
   Stats
   ======================================== */

.stats {
    display: flex;
    justify-content: center;
    gap: var(--space-8);
    padding: var(--space-4);
    background: var(--color-bg-secondary);
    border-radius: var(--radius-lg);
}

.stats--hidden {
    display: none;
}

.stats__item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-1);
}

.stats__value {
    font-size: var(--font-size-2xl);
    font-weight: 700;
    font-family: var(--font-family-mono);
    color: var(--color-primary);
}

.stats__label {
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
}

/* ========================================
   Modal
   ======================================== */

.modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: calc(100% - var(--space-8));
    max-width: 400px;
    max-height: calc(100vh - var(--space-8));
    background: var(--color-bg-secondary);
    border: none;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    padding: 0;
    overflow: hidden;
}

.modal::backdrop {
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.modal__content {
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - var(--space-8));
}

.modal__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-4) var(--space-6);
    border-bottom: 1px solid var(--color-border);
}

.modal__title {
    font-size: var(--font-size-lg);
    font-weight: 600;
}

.modal__close {
    margin-right: calc(var(--space-2) * -1);
}

.modal__body {
    padding: var(--space-6);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: var(--space-6);
}

/* ========================================
   Settings
   ======================================== */

.settings-group {
    border: none;
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

.settings-group__title {
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: var(--space-2);
}

/* Toggle Switch */
.toggle {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    cursor: pointer;
}

.toggle input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle__slider {
    position: relative;
    width: 44px;
    height: 24px;
    background: var(--color-bg-tertiary);
    border-radius: var(--radius-full);
    transition: background var(--transition-fast);
}

.toggle__slider::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background: white;
    border-radius: 50%;
    transition: transform var(--transition-fast);
    box-shadow: var(--shadow-sm);
}

.toggle input:checked + .toggle__slider {
    background: var(--color-primary);
}

.toggle input:checked + .toggle__slider::after {
    transform: translateX(20px);
}

.toggle input:focus-visible + .toggle__slider {
    outline: 2px solid var(--color-border-focus);
    outline-offset: 2px;
}

.toggle__label {
    font-size: var(--font-size-sm);
    color: var(--color-text);
}

/* ========================================
   Responsive
   ======================================== */

@media (max-width: 480px) {
    .app {
        padding: var(--space-3);
    }

    .timer__time {
        font-size: var(--font-size-4xl);
    }

    .timer__progress {
        width: 180px;
        height: 180px;
    }

    .panel {
        padding: var(--space-4);
    }

    .btn--large {
        width: 100%;
    }
}

/* ========================================
   Animations
   ======================================== */

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

.timer--running .timer__time {
    animation: pulse 2s ease-in-out infinite;
}

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

/* ========================================
   Print
   ======================================== */

@media print {
    .header__nav,
    .controls,
    .mode-selector {
        display: none;
    }
}
