:root {
    --blue: #334ef9;
    --purple: #6200e9;
    --lime: #b4ec39;
    --red: #d30201;
    --grey-bg: #eeeef4;
    --lavender: #8984d2;
    --peach: #fb9a7f;
    --mint: #65fcd7;
    --maroon: #751413;

    --bg: var(--grey-bg);
    --card-bg: #ffffff;
    --text: #1a1a2e;
    --text-light: #6b6b80;
    --primary: var(--blue);
    --primary-dark: var(--purple);
    --vide: #e1e1ec;
    --border: #e1e1ec;
    --radius: 14px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    padding: 14px 24px;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--text);
}

.brand img {
    height: 34px;
    width: auto;
}

.brand-name {
    font-weight: 700;
    font-size: 1.15rem;
    letter-spacing: 0.01em;
    color: var(--text);
}

.topbar nav {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.topbar nav a {
    text-decoration: none;
    color: var(--text-light);
    font-weight: 500;
    padding: 6px 10px;
    border-radius: 8px;
    transition: background 0.15s, color 0.15s;
}

.topbar nav a:hover {
    background: var(--bg);
}

.topbar nav a.active {
    color: var(--primary);
    background: rgba(51, 78, 249, 0.1);
}

.container {
    max-width: 680px;
    margin: 0 auto;
    padding: 24px 16px 80px;
}

.date-du-jour {
    text-align: center;
    color: var(--text-light);
    font-size: 1.05rem;
    margin-bottom: 20px;
}

/* --- Login --- */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(160deg, var(--grey-bg) 0%, #e3e1fb 100%);
}

.login-box {
    background: var(--card-bg);
    padding: 40px 32px;
    border-radius: var(--radius);
    box-shadow: 0 10px 30px rgba(98, 0, 233, 0.12);
    text-align: center;
    width: 100%;
    max-width: 340px;
}

.login-box .brand {
    justify-content: center;
    margin-bottom: 4px;
}

.login-box img.login-logo {
    height: 64px;
    width: auto;
    margin-bottom: 8px;
}

.login-box h1 {
    margin: 0 0 4px;
    font-size: 1.3rem;
}

.login-box .subtitle { color: var(--text-light); margin-bottom: 24px; }

.login-box form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.login-box input[type="password"] {
    padding: 12px 14px;
    border-radius: 10px;
    border: 1px solid var(--border);
    font-size: 1rem;
}

.login-box input[type="password"]:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(51, 78, 249, 0.15);
}

.error {
    color: var(--red);
    font-size: 0.9rem;
    margin-bottom: 12px;
}

/* --- Boutons --- */
.btn {
    display: inline-block;
    background: var(--primary);
    color: #fff;
    border: none;
    padding: 12px 18px;
    border-radius: 10px;
    font-size: 1rem;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    transition: background 0.15s, transform 0.1s;
}
.btn:hover { background: var(--primary-dark); }
.btn:active { transform: scale(0.98); }

.btn-small {
    background: var(--bg);
    border: 1px solid var(--border);
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text);
}
.btn-small:hover { background: var(--border); }

.btn-danger {
    color: var(--red);
    border-color: var(--red);
}
.btn-danger:hover { background: rgba(211, 2, 1, 0.08); }

/* --- Progress bar --- */
.progress-bar {
    background: var(--vide);
    border-radius: 999px;
    height: 12px;
    overflow: hidden;
    margin-bottom: 8px;
}
.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--blue), var(--lime));
    transition: width 0.4s ease;
}
.progress-text {
    text-align: center;
    color: var(--text-light);
    font-size: 0.9rem;
    margin-bottom: 24px;
}

/* --- Liste d'actions --- */
.actions-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.action-item {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    transition: background 0.2s, border-color 0.2s, transform 0.15s;
}

.action-item.done {
    background: rgba(180, 236, 57, 0.18);
    border-color: var(--lime);
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    font-size: 1rem;
}

.checkbox-label input[type="checkbox"] {
    display: none;
}

.checkbox-custom {
    width: 24px;
    height: 24px;
    border-radius: 7px;
    border: 2px solid var(--border);
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, border-color 0.15s, transform 0.15s;
}

.checkbox-label input[type="checkbox"]:checked + .checkbox-custom {
    background: var(--lime);
    border-color: var(--lime);
    transform: scale(1.05);
}

.checkbox-label input[type="checkbox"]:checked + .checkbox-custom::after {
    content: "✓";
    color: #2d3d05;
    font-size: 14px;
    font-weight: bold;
}

.action-name {
    flex: 1;
}

.action-item.done .action-name {
    color: var(--text-light);
    text-decoration: line-through;
}

/* --- Bandeau de succès --- */
.success-banner {
    margin-top: 24px;
    text-align: center;
    background: linear-gradient(90deg, var(--purple), var(--blue));
    color: #fff;
    padding: 16px;
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 1.05rem;
    opacity: 0;
    transform: scale(0.9);
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.success-banner.show {
    opacity: 1;
    transform: scale(1);
}

/* --- Confettis --- */
#confetti-container {
    position: fixed;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
    z-index: 999;
}

.confetti-piece {
    position: absolute;
    top: -10px;
    width: 8px;
    height: 14px;
    opacity: 0.9;
    animation: fall linear forwards;
}

@keyframes fall {
    to {
        transform: translateY(110vh) rotate(360deg);
        opacity: 0.3;
    }
}

/* --- État vide --- */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-light);
}
.empty-state .btn { margin-top: 16px; }

/* --- Calendrier --- */
.calendar-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    margin-bottom: 16px;
}
.calendar-header h2 { margin: 0; min-width: 200px; text-align: center; color: var(--purple); }

.nav-arrow {
    text-decoration: none;
    font-size: 1.3rem;
    color: var(--text);
    background: var(--card-bg);
    border: 1px solid var(--border);
    width: 38px;
    height: 38px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}
.nav-arrow:hover { background: var(--border); }

.legend {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 14px;
    font-size: 0.82rem;
    color: var(--text-light);
    margin-bottom: 18px;
}
.legend span { display: flex; align-items: center; gap: 6px; }

.dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}
.dot.reussi { background: var(--lime); }
.dot.partiel { background: var(--peach); }
.dot.rate { background: var(--red); }
.dot.vide { background: var(--vide); }

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 6px;
}

.calendar-day-label {
    text-align: center;
    font-size: 0.78rem;
    color: var(--text-light);
    font-weight: 600;
    padding-bottom: 4px;
}

.calendar-cell {
    aspect-ratio: 1;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 600;
    background: var(--vide);
    color: var(--text-light);
}

.calendar-cell.empty { background: transparent; }

.calendar-cell.reussi { background: var(--lime); color: #2d3d05; }
.calendar-cell.partiel { background: var(--peach); color: #5c2410; }
.calendar-cell.rate { background: var(--red); color: #fff; }
.calendar-cell.vide { background: var(--vide); color: var(--text-light); }
.calendar-cell.futur { background: transparent; color: var(--text-light); border: 1px dashed var(--border); }
.calendar-cell.aujourdhui-vide {
    background: var(--card-bg);
    border: 2px solid var(--blue);
    color: var(--blue);
}

/* --- Gestion des actions --- */
.add-action-form {
    display: flex;
    gap: 10px;
    margin-bottom: 24px;
}
.add-action-form input[type="text"] {
    flex: 1;
    padding: 12px 14px;
    border-radius: 10px;
    border: 1px solid var(--border);
    font-size: 1rem;
}
.add-action-form input[type="text"]:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(51, 78, 249, 0.15);
}

.manage-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.manage-item {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.manage-item.inactif { opacity: 0.5; }

.inline-form { display: inline-flex; margin: 0; }
.rename-form { flex: 1; min-width: 180px; gap: 8px; }
.rename-form input[type="text"] {
    flex: 1;
    border: 1px solid transparent;
    background: transparent;
    font-size: 1rem;
    padding: 6px 8px;
    border-radius: 6px;
}
.rename-form input[type="text"]:focus {
    border-color: var(--border);
    background: var(--bg);
    outline: none;
}

.manage-actions { display: flex; gap: 8px; }

.info-message {
    background: rgba(101, 252, 215, 0.25);
    color: #0a5c4a;
    padding: 10px 14px;
    border-radius: 10px;
    margin-bottom: 16px;
    font-size: 0.9rem;
}

h2 { color: var(--purple); }

@media (max-width: 480px) {
    .topbar { flex-direction: column; align-items: flex-start; }
    .calendar-header h2 { min-width: auto; font-size: 1.1rem; }
}
