/* --- VARIABLES ET RESET --- */
:root {
    --bg: #0f172a;
    --card: #1e293b;
    --primary: #3b82f6;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --text: #f8fafc;
    --text-dim: #94a3b8;
    --prestige: #f43f5e;
    --border: rgba(255, 255, 255, 0.08);
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Inter', -apple-system, system-ui, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    margin: 0;
    padding: 15px;
    line-height: 1.5;
    display: flex;
    justify-content: center;
}

/* --- LAYOUT --- */
.container {
    width: 100%;
    max-width: 1100px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-top: env(safe-area-inset-top);
}

@media (min-width: 850px) {
    .container { flex-direction: row; align-items: flex-start; }
    .sidebar { width: 350px; position: sticky; top: 20px; flex-shrink: 0; }
    .main-content { flex-grow: 1; }
}

/* --- CARTES --- */
.card {
    background: var(--card);
    border-radius: 24px;
    padding: 24px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border);
    margin-bottom: 20px;
}

/* --- RANG ET PROGRESSION --- */
.rank-header { text-align: center; }

#rank-medal { 
    font-size: 5rem; 
    display: block; 
    margin: 10px 0;
    filter: drop-shadow(0 0 15px rgba(255, 255, 255, 0.1));
}

#rank-name { 
    font-weight: 800; 
    font-size: 1.6rem; 
    text-transform: uppercase; 
    letter-spacing: 1px;
    margin-bottom: 5px;
}

.lp-display { 
    font-size: 1.3rem; 
    font-weight: 700; 
    color: var(--primary); 
    background: rgba(59, 130, 246, 0.1);
    display: inline-block;
    padding: 4px 16px;
    border-radius: 20px;
    margin-bottom: 20px;
}

.prestige-badge {
    display: inline-block;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-dim);
    padding: 4px 14px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: bold;
    border: 1px solid var(--border);
    margin-bottom: 10px;
}

.prestige-active {
    background: linear-gradient(45deg, #f43f5e, #fb923c);
    color: white;
    border: none;
    box-shadow: 0 4px 12px rgba(244, 63, 94, 0.3);
}

.progress-container { 
    background: rgba(0, 0, 0, 0.2); 
    border-radius: 10px; 
    height: 10px; 
    margin: 15px 0; 
    overflow: hidden;
    border: 1px solid rgba(255,255,255,0.05);
}

#progress-bar { 
    background: linear-gradient(90deg, var(--primary), var(--success)); 
    height: 100%; 
    width: 0%; 
    transition: width 0.8s cubic-bezier(0.34, 1.56, 0.64, 1); 
}

/* --- LISTE EXERCICES --- */
.exo-list { display: flex; flex-direction: column; gap: 12px; }

.exo-item {
    background: rgba(255, 255, 255, 0.03);
    padding: 14px 18px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    border: 1px solid var(--border);
    transition: all 0.2s ease;
}

.exo-item.checked { 
    border-color: var(--success); 
    background: rgba(34, 197, 94, 0.08); 
}

.exo-content { display: flex; align-items: center; flex-grow: 1; overflow: hidden; }

.exo-content input[type="checkbox"] { 
    width: 22px; 
    height: 22px; 
    margin-right: 15px; 
    accent-color: var(--success); 
    cursor: pointer;
    flex-shrink: 0;
}

.exo-text { 
    flex-grow: 1; 
    font-size: 0.95rem;
    color: var(--text);
    outline: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.exo-text[contenteditable="true"] { 
    background: rgba(255, 255, 255, 0.1); 
    padding: 2px 8px;
    border-radius: 4px;
    white-space: normal;
}

.btn-edit { 
    background: transparent; 
    border: none; 
    font-size: 1.2rem; 
    cursor: pointer; 
    opacity: 0.3; 
    transition: 0.2s;
    padding: 5px;
}

.exo-item:hover .btn-edit { opacity: 1; }

/* --- CALENDRIER --- */
.cal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.cal-nav-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    cursor: pointer;
    transition: 0.2s;
}

.cal-nav-btn:hover { background: rgba(255, 255, 255, 0.1); }

.cal-grid { 
    display: grid; 
    grid-template-columns: repeat(7, 1fr); 
    gap: 8px; 
    width: 100%;
}

.day { 
    aspect-ratio: 1 / 1; 
    background: rgba(255, 255, 255, 0.03); 
    border-radius: 10px; 
    font-size: 0.85rem; 
    font-weight: 600;
    display: flex; 
    align-items: center; 
    justify-content: center; 
    border: 1px solid transparent;
    color: var(--text-dim);
    position: relative;
}

.day.green { 
    background: var(--success) !important; 
    color: white; 
    box-shadow: 0 4px 12px rgba(34, 197, 94, 0.2);
}

.day.orange { 
    background: var(--warning) !important; 
    color: white; 
}

.day.today { 
    border: 2px solid var(--primary); 
    color: var(--primary);
    background: rgba(59, 130, 246, 0.05);
}

/* Style spécifique pour le RESET de saison */
.day-reset {
    border: 1px dashed var(--danger) !important;
    background: rgba(239, 68, 68, 0.05) !important;
}

.reset-warning {
    position: absolute;
    top: -5px;
    right: -2px;
    font-size: 0.7rem;
    filter: drop-shadow(0 0 2px rgba(0,0,0,0.5));
    z-index: 2;
}

/* --- BOUTONS --- */
.btn { 
    padding: 14px; 
    border-radius: 16px; 
    border: none; 
    cursor: pointer; 
    font-weight: 700; 
    font-size: 0.9rem; 
    transition: transform 0.2s, filter 0.2s;
    width: 100%;
}

.btn:active { transform: scale(0.98); }

.btn-danger { 
    background: rgba(239, 68, 68, 0.1); 
    color: var(--danger); 
    border: 1px solid rgba(239, 68, 68, 0.2); 
}

.btn-danger:hover { background: rgba(239, 68, 68, 0.15); }

.btn-prestige { 
    background: linear-gradient(45deg, var(--prestige), #fb7185); 
    color: white; 
    margin-bottom: 15px;
    box-shadow: 0 4px 15px rgba(244, 63, 94, 0.4);
    display: none; /* Géré par JS */
}

.save-controls { 
    display: grid; 
    grid-template-columns: 1fr 1fr; 
    gap: 12px; 
    margin-top: 20px; 
}

.btn-save { 
    background: rgba(255, 255, 255, 0.05); 
    color: var(--text); 
    border: 1px solid var(--border); 
}

/* --- TIMER & INFOS --- */
.timer-box { 
    background: rgba(0, 0, 0, 0.2); 
    border-radius: 20px; 
    padding: 20px; 
    margin: 25px 0; 
    border: 1px solid var(--border);
    text-align: center;
}

#timer { 
    font-variant-numeric: tabular-nums; 
    font-size: 1.5rem; 
    letter-spacing: -1px; 
    font-weight: 700;
}

.reset-info { 
    font-size: 0.7rem; 
    color: var(--text-dim); 
    margin-top: 15px; 
    text-align: center; 
    line-height: 1.4;
}

/* --- RESPONSIVE MOBILE --- */
@media (max-width: 480px) {
    body { padding: 10px; }
    .card { padding: 18px; border-radius: 20px; }
    .cal-grid { gap: 4px; }
    .day { font-size: 0.75rem; border-radius: 6px; }
    #rank-medal { font-size: 4rem; }
}