/* ========================================== */
/* RESET & BASE STYLES             */
/* ========================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    color: white;
    overflow-x: hidden;
    transition: background 0.5s ease;
}

body.work {
    background: linear-gradient(135deg, #0f0f1a 0%, #1c1c2e 100%);
}

body.pause {
    background: linear-gradient(135deg, #0f1c1a 0%, #1c2e1c 100%);
}

/* Fond animé */
body::before {
    content: '';
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.05) 1%, transparent 1%) repeat;
    background-size: 50px 50px;
    animation: moveBG 20s linear infinite;
    z-index: 0;
}

@keyframes moveBG {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ========================================== */
/* CONTAINER                    */
/* ========================================== */
.container {
    display: flex;
    justify-content: space-between;
    align-items: stretch;
    gap: 40px;
    background: rgba(15, 15, 25, 0.9);
    backdrop-filter: blur(10px);
    border-radius: 30px;
    padding: 40px;
    max-width: 1000px;
    width: 100%;
    z-index: 1;
    position: relative;
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
}

.left, .right {
    flex: 1;
    z-index: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

/* ========================================== */
/* TYPOGRAPHIE                 */
/* ========================================== */
h1 {
    font-size: 3rem;
    margin-bottom: 20px;
    font-weight: 800;
    letter-spacing: 2px;
    background: linear-gradient(135deg, #8e44ad, #ff6ec7);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-align: center;
}

h2#mode {
    font-size: 1.8rem;
    margin-bottom: 10px;
    text-align: center;
    opacity: 0.9;
}

h2#time {
    font-size: 6rem;
    font-weight: 900;
    margin: 20px 0;
    text-align: center;
    animation: pulseGlow 2s ease-in-out infinite;
}

@keyframes pulseGlow {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.03); opacity: 0.8; }
}

/* Couleurs dynamiques */
body.work #time {
    color: #ff6ec7;
    text-shadow: 0 0 20px rgba(255,105,180,0.6);
}

body.pause #time {
    color: #1abc9c;
    text-shadow: 0 0 20px rgba(26,188,156,0.6);
}

/* ========================================== */
/* BOUTONS                   */
/* ========================================== */
.buttons {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

button {
    padding: 15px 25px;
    border-radius: 50px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    text-transform: uppercase;
    border: none;
    transition: all 0.3s ease;
    background: linear-gradient(135deg, #8e44ad, #ff6ec7);
    color: white;
    touch-action: manipulation;
}

button:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 20px rgba(255, 105, 180, 0.3);
}

#updateTime {
    background: linear-gradient(135deg, #1abc9c, #2ecc71);
}

/* ========================================== */
/* RÉGLAGES & STATS            */
/* ========================================== */
.custom-time {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 20px;
}

.custom-time label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
}

.custom-time input {
    width: 80px;
    padding: 8px;
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.2);
    background: #1c1c2e;
    color: white;
    font-size: 16px; /* Important pour éviter le zoom iOS */
    text-align: center;
}

.right > p {
    text-align: center;
    font-size: 1.1rem;
    margin: 20px 0;
}

#sessions {
    color: #ff6ec7;
    font-weight: 800;
    font-size: 1.4rem;
}

#statsChart {
    background: rgba(0,0,0,0.2);
    border-radius: 15px;
    padding: 10px;
    width: 100% !important;
    height: auto !important;
}

/* ========================================== */
/* RESPONSIVE (CORRECTIF)         */
/* ========================================== */

/* Mode Tablette */
@media (max-width: 900px) {
    .container {
        flex-direction: column;
        padding: 30px;
        max-width: 500px;
    }
    h2#time { font-size: 5rem; }
}

/* Mode Mobile (Le plus important) */
@media (max-width: 500px) {
    body { padding: 10px; }

    .container {
        padding: 25px 15px;
        border-radius: 20px;
        gap: 20px;
    }

    h1 { font-size: 1.8rem; margin-bottom: 10px; }
    h2#mode { font-size: 1.2rem; }
    h2#time { font-size: 3.5rem; margin: 10px 0; }

    .buttons {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    #reset { grid-column: span 2; } /* Le bouton reset prend toute la largeur */

    button {
        padding: 12px 15px;
        font-size: 0.85rem;
    }

    /* Réorganisation des réglages sur une ligne */
    .custom-time {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .custom-time label {
        flex-direction: column;
        gap: 5px;
        text-align: center;
    }

    .custom-time input { width: 100%; }

    #updateTime {
        grid-column: span 2;
        margin-top: 5px;
    }

    .stats h2 { font-size: 1.3rem; }
}

/* Fix Landscape Mobile */
@media (max-height: 500px) and (orientation: landscape) {
    .container { flex-direction: row; padding: 15px; }
    h1 { font-size: 1.2rem; }
    h2#time { font-size: 2.5rem; }
    .right { display: none; } /* On cache les stats en paysage court pour voir le chrono */
}