/* Reset et configuration de base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

/* Thème par défaut : Océan Bleu */
:root {
    --bg-primary: #1a1a2e;
    --bg-secondary: #16213e;
    --bg-card: #0f3460;
    --accent: #00d9ff;
    --accent-glow: rgba(0, 217, 255, 0.3);
    --text-primary: #ffffff;
    --text-secondary: #b8c5d6;
    --success: #00ff88;
    --warning: #ffa500;
    --radius: 16px;
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

/* Thème Zen Vert */
[data-theme="zen"] {
    --bg-primary: #1a2e1a;
    --bg-secondary: #1e3821;
    --bg-card: #2d5a2d;
    --accent: #4ade80;
    --accent-glow: rgba(74, 222, 128, 0.3);
    --text-primary: #ffffff;
    --text-secondary: #c5d6c5;
}

/* Thème Relaxation Violet */
[data-theme="relaxation"] {
    --bg-primary: #1e1a2e;
    --bg-secondary: #2a1e3e;
    --bg-card: #3e2d5a;
    --accent: #a78bfa;
    --accent-glow: rgba(167, 139, 250, 0.3);
    --text-primary: #ffffff;
    --text-secondary: #d6c5e8;
}

/* Thème Énergie Orange */
[data-theme="energie"] {
    --bg-primary: #2e1e1a;
    --bg-secondary: #3e2516;
    --bg-card: #5a3d2d;
    --accent: #fb923c;
    --accent-glow: rgba(251, 146, 60, 0.3);
    --text-primary: #ffffff;
    --text-secondary: #d6c9b8;
}

/* Thème Rose Douceur */
[data-theme="douceur"] {
    --bg-primary: #2e1a24;
    --bg-secondary: #3e1e2e;
    --bg-card: #5a2d45;
    --accent: #f472b6;
    --accent-glow: rgba(244, 114, 182, 0.3);
    --text-primary: #ffffff;
    --text-secondary: #d6c5d0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
    color: var(--text-primary);
    min-height: 100vh;
    overflow: hidden;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
}

#app {
    width: 100%;
    height: 100vh;
    overflow: hidden;
}

/* Gestion des écrans */
.screen {
    display: none;
    width: 100%;
    height: 100vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.screen.active {
    display: flex;
    flex-direction: column;
}

/* En-têtes */
header {
    padding: 2rem 1.5rem 1rem;
    text-align: center;
}

h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, var(--accent) 0%, var(--success) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

h2 {
    font-size: 1.5rem;
    font-weight: 600;
}

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

/* Sélecteur de durée */
.duration-selector {
    padding: 0 1.5rem 1rem;
    text-align: center;
}

.duration-label {
    display: block;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 0.75rem;
}

.duration-buttons {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.duration-btn {
    background: var(--bg-card);
    border: 2px solid transparent;
    border-radius: 12px;
    padding: 0.6rem 1rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 60px;
}

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

.duration-btn:active {
    transform: scale(0.95);
}

/* Sélecteur de thème */
.theme-selector {
    padding: 0 1.5rem 1.5rem;
    text-align: center;
}

.theme-label {
    display: block;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 0.75rem;
}

.theme-buttons {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.theme-btn {
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.theme-btn.active .theme-color {
    box-shadow: 0 0 0 3px var(--accent), 0 0 20px var(--accent-glow);
    transform: scale(1.15);
}

.theme-btn:active .theme-color {
    transform: scale(0.9);
}

.theme-color {
    display: block;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

/* Liste des exercices */
.exercises-list {
    flex: 1;
    padding: 1rem 1.5rem;
    padding-bottom: 8rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.exercise-card {
    background: var(--bg-card);
    border: none;
    border-radius: var(--radius);
    padding: 1.5rem;
    text-align: left;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: var(--shadow);
    min-height: 90px;
}

.exercise-card:active {
    transform: scale(0.98);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.exercise-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.exercise-desc {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.exercise-info {
    color: var(--accent);
    font-size: 0.85rem;
    font-weight: 500;
}

/* Écran de configuration personnalisée */
.custom-config {
    flex: 1;
    padding: 2rem 1.5rem;
    padding-bottom: 8rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

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

/* Steppers */
.stepper {
    display: flex;
    align-items: center;
    background: var(--bg-card);
    border-radius: var(--radius);
    overflow: hidden;
}

.stepper-btn {
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 1.75rem;
    font-weight: 300;
    width: 60px;
    height: 60px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s ease;
}

.stepper-btn:active {
    background: rgba(255, 255, 255, 0.12);
}

.stepper-btn:disabled {
    opacity: 0.3;
    cursor: default;
}

.stepper-val {
    flex: 1;
    text-align: center;
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    pointer-events: none;
}

/* Boutons */
.back-btn,
.stop-btn {
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 1.1rem;
    padding: 0.5rem;
    cursor: pointer;
    transition: opacity 0.3s ease;
}

.back-btn:active,
.stop-btn:active {
    opacity: 0.7;
}

.start-btn {
    background: linear-gradient(135deg, var(--accent) 0%, var(--success) 100%);
    border: none;
    border-radius: var(--radius);
    padding: 1.25rem;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--bg-primary);
    cursor: pointer;
    margin-top: auto;
    box-shadow: 0 4px 20px var(--accent-glow);
    transition: all 0.3s ease;
}

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

/* Écran d'exercice */
#exercise-screen {
    justify-content: space-between;
}

.exercise-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem;
}

.current-exercise {
    flex: 1;
    text-align: center;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-secondary);
}

/* Conteneur de respiration */
.breathing-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}


.breathing-circle {
    width: 280px;
    height: 280px;
    border-radius: 50%;
    background: radial-gradient(circle, var(--accent) 0%, var(--bg-card) 70%);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 60px var(--accent-glow);
    will-change: transform;
}

.circle-content {
    text-align: center;
}

.phase-text {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.countdown {
    font-size: 3rem;
    font-weight: 700;
    color: var(--accent);
}

/* Informations de session */
.session-info {
    display: flex;
    justify-content: space-around;
    padding: 1rem 1.5rem 0.5rem;
}

.info-item {
    text-align: center;
}

.info-label {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
}

.info-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

/* Contrôles */
.controls {
    padding: 1rem 1.5rem 0.5rem;
    display: flex;
    justify-content: center;
    gap: 1rem;
}

/* Contrôle de volume */
.volume-control {
    padding: 0.5rem 1.5rem 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
}

.volume-icon {
    font-size: 1.5rem;
    min-width: 32px;
    text-align: center;
}

.volume-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 180px;
    height: 6px;
    background: var(--bg-card);
    border-radius: 3px;
    outline: none;
    transition: background 0.3s ease;
}

.volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: var(--accent);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 8px var(--accent-glow);
    transition: all 0.3s ease;
}

.volume-slider::-webkit-slider-thumb:active {
    transform: scale(1.2);
}

.volume-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: var(--accent);
    border-radius: 50%;
    border: none;
    cursor: pointer;
    box-shadow: 0 2px 8px var(--accent-glow);
    transition: all 0.3s ease;
}

.volume-slider::-moz-range-thumb:active {
    transform: scale(1.2);
}

.volume-value {
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 600;
    min-width: 42px;
    text-align: center;
}

.wake-lock-hint {
    padding: 0.5rem 1.5rem 6rem;
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-secondary);
    opacity: 0.7;
    line-height: 1.4;
}

.control-btn {
    background: var(--bg-card);
    border: 2px solid var(--accent);
    border-radius: var(--radius);
    padding: 1rem 2rem;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.3s ease;
}

.control-btn:active {
    transform: scale(0.95);
    background: var(--accent);
    color: var(--bg-primary);
}

.control-btn.muted {
    opacity: 0.5;
    border-color: var(--text-secondary);
}

/* Écran de résumé */
#summary-screen {
    align-items: center;
    justify-content: center;
}

.summary-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    padding: 2rem 1.5rem;
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.summary-icon {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent) 0%, var(--success) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--bg-primary);
    box-shadow: 0 0 40px var(--accent-glow);
}

.summary-title {
    font-size: 1.75rem;
    font-weight: 700;
}

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

.summary-stats {
    display: flex;
    gap: 3rem;
    justify-content: center;
}

.summary-stat-value {
    font-size: 2.25rem;
    font-weight: 700;
    color: var(--accent);
}

.summary-stat-label {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-top: 0.25rem;
}

.summary-buttons {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 100%;
}

.summary-buttons .control-btn {
    width: 100%;
}

/* Modal de confirmation */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.modal {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    padding: 2rem;
    width: 90%;
    max-width: 320px;
    box-shadow: var(--shadow);
    border: 1px solid rgba(255, 255, 255, 0.1);
    text-align: center;
}

.modal-text {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
}

.modal-buttons {
    display: flex;
    gap: 1rem;
}

.modal-buttons .control-btn {
    flex: 1;
    padding: 1rem;
}

.modal-stop-btn {
    flex: 1;
    background: #e53e3e;
    border: none;
    border-radius: var(--radius);
    padding: 1rem;
    font-size: 1rem;
    font-weight: 600;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
}

.modal-stop-btn:active {
    transform: scale(0.95);
    opacity: 0.85;
}

/* Responsive pour petits écrans */
@media (max-width: 360px) {
    .control-btn {
        padding: 0.8rem 1.2rem;
        font-size: 0.9rem;
    }

    .duration-btn {
        padding: 0.5rem 0.8rem;
        font-size: 0.85rem;
        min-width: 50px;
    }

    .volume-slider {
        width: 140px;
    }

    .volume-icon {
        font-size: 1.3rem;
        min-width: 28px;
    }

    .volume-value {
        font-size: 0.8rem;
        min-width: 38px;
    }

    .info-value {
        font-size: 1.2rem;
    }
}

/* Responsive pour tablettes */
@media (min-width: 768px) {
    .exercises-list {
        max-width: 600px;
        margin: 0 auto;
    }

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

/* Support du mode paysage */
@media (orientation: landscape) and (max-height: 500px) {
    .breathing-circle {
        width: 220px;
        height: 220px;
    }

    .phase-text {
        font-size: 1.2rem;
    }

    .countdown {
        font-size: 2rem;
    }
}
