:root {
    --primary: #5B4FCF;
    --primary-light: #EEF0FF;
    --surface: #F5F3FF;
    --bg: #FAFAFA;
    --text: #1A1A2E;
    --text-muted: #6B7280;
    --border: #E5E7EB;
    --error: #DC2626;
    --radius: 12px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
    --shadow: 0 4px 12px rgba(0,0,0,0.08);
}

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg);
    color: var(--text);
    margin: 0;
    padding-bottom: 80px;
}

header {
    background: linear-gradient(135deg, #5B4FCF 0%, #7C6BE0 100%);
    padding: 16px 20px;
    text-align: center;
    box-shadow: 0 2px 12px rgba(91,79,207,0.3);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

header h1 {
    color: white;
    letter-spacing: 0.3px;
}

h1, h2, h3 {
    font-weight: 600;
    margin: 0;
}

h2 {
    font-size: 1.3em;
    color: var(--text);
}

/* Views & Layout */
.view {
    display: none;
    padding: 20px 16px;
    max-width: 820px;
    margin: 0 auto;
}

.view.active {
    display: block;
}

.hidden {
    display: none !important;
}

.form-container {
    display: flex;
    flex-direction: column;
    gap: 14px;
    max-width: 480px;
    margin: 0 auto;
}

/* Form Elements */
input, select {
    padding: 11px 14px;
    border-radius: var(--radius);
    border: 1.5px solid var(--border);
    font-size: 16px;
    font-family: inherit;
    background: var(--surface);
    color: var(--text);
    transition: border-color 0.15s, box-shadow 0.15s;
    outline: none;
}

input:focus, select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(91,79,207,0.12);
}

button {
    padding: 11px 20px;
    border-radius: 100px;
    border: none;
    font-size: 15px;
    font-family: inherit;
    background: var(--primary);
    color: white;
    cursor: pointer;
    font-weight: 600;
    transition: transform 0.15s, box-shadow 0.15s, background 0.15s;
    box-shadow: 0 2px 8px rgba(91,79,207,0.25);
}

button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(91,79,207,0.35);
}

button:active {
    transform: translateY(0);
}

button.btn-danger {
    background: var(--error);
    box-shadow: 0 2px 8px rgba(220,38,38,0.25);
}

button.btn-danger:hover {
    box-shadow: 0 4px 14px rgba(220,38,38,0.35);
}

/* Admin Accordion */
.admin-accordion-header {
    background: var(--surface);
    color: var(--text);
    width: 100%;
    text-align: left;
    padding: 14px 18px;
    margin-top: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 0.95em;
    box-shadow: var(--shadow-sm);
    transition: background 0.15s, border-color 0.15s;
}

.admin-accordion-header:hover {
    background: var(--primary-light);
    border-color: var(--primary);
}

.admin-accordion-content {
    overflow: hidden;
    max-height: 0;
    transition: max-height 0.3s ease;
    border: 1.5px solid var(--border);
    border-top: none;
    padding: 0 16px;
    border-radius: 0 0 var(--radius) var(--radius);
    background: var(--surface);
}

.admin-section {
    padding: 16px 0;
}

/* List Items */
.list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 8px;
    border-bottom: 1px solid var(--border);
}

.list-item:last-child {
    border-bottom: none;
}

.btn-icon {
    background: none;
    color: var(--text-muted);
    padding: 8px;
    font-size: 20px;
    box-shadow: none;
    border-radius: 8px;
    min-width: 36px;
    min-height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    color: var(--primary);
    background: var(--primary-light);
    transform: none;
    box-shadow: none;
}

/* Calendar */
#calendar-salle-select {
    max-width: 200px;
}

.week-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    gap: 10px;
    flex-wrap: wrap;
}

.week-label {
    margin: 0 10px;
    font-weight: 600;
    color: var(--text);
    font-size: 0.95em;
}

.week-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
    margin-top: 12px;
}

.day-column {
    background: var(--surface);
    padding: 10px;
    border-radius: var(--radius);
    border: 1px solid transparent;
}

.day-column.today {
    border-color: var(--primary);
    background: var(--primary-light);
}

.day-column.today .day-col-header {
    color: var(--primary);
    font-weight: 700;
}

.slot-card {
    background: var(--surface);
    padding: 10px;
    border-radius: 10px;
    margin-bottom: 8px;
    box-shadow: var(--shadow-sm);
    border-left: 3px solid var(--primary);
    transition: box-shadow 0.15s;
}

.slot-card:hover {
    box-shadow: var(--shadow);
}

.slot-card.uncovered {
    border-left-color: #F59E0B;
    background: #FFFBEB;
}

.slot-header {
    font-size: 0.78em;
    color: var(--primary);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-bottom: 2px;
}

.slot-time {
    font-size: 1em;
    font-weight: 700;
    border-bottom: 1px solid var(--border);
    padding-bottom: 5px;
    margin-bottom: 5px;
}

.slot-user {
    margin-top: 5px;
    font-size: 0.9em;
}

.slot-presence {
    font-size: 0.82em;
    color: var(--text-muted);
    margin-top: 2px;
}

/* Navigation */
nav {
    position: fixed;
    bottom: 0;
    width: 100%;
    background: rgba(255,255,255,0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    justify-content: space-around;
    padding: 10px 0 12px;
    box-shadow: 0 -1px 0 var(--border), 0 -4px 16px rgba(0,0,0,0.06);
}

.nav-item {
    cursor: pointer;
    text-align: center;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 0.72em;
    font-weight: 500;
    gap: 2px;
    transition: color 0.15s;
}

.nav-item.active {
    color: var(--primary);
}

.nav-item .material-symbols-outlined {
    font-size: 24px;
}

/* Slot card internals */
.day-col-header {
    font-weight: 700;
    font-size: 0.88em;
    border-bottom: 1px solid var(--border);
    margin-bottom: 8px;
    padding-bottom: 6px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.slot-admin-del {
    cursor: pointer;
    float: right;
    color: var(--border);
    transition: color 0.15s;
}

.slot-admin-del:hover {
    color: var(--error);
}

.slot-user-club {
    color: var(--text-muted);
    font-size: 0.85em;
}

.slot-unregister-btn {
    color: var(--error);
    cursor: pointer;
    font-weight: bold;
    margin-left: 6px;
    opacity: 0.7;
    transition: opacity 0.15s;
}

.slot-unregister-btn:hover {
    opacity: 1;
}

.slot-empty {
    font-style: italic;
    color: var(--text-muted);
    font-size: 0.88em;
}

.slot-admin-add {
    margin-top: 8px;
    padding: 4px 8px;
    font-size: 0.8em;
    color: var(--primary);
    border: 1px dashed var(--primary);
    border-radius: 6px;
    text-align: center;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.slot-admin-add:hover {
    background: var(--primary);
    color: white;
}

/* Report table */
.report-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
    font-size: 0.9em;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.report-table th,
.report-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    text-align: left;
}

.report-table tbody tr:last-child td {
    border-bottom: none;
}

.report-table thead tr {
    background: var(--primary);
    color: white;
}

.report-table tbody tr:hover {
    background: var(--primary-light);
}

/* Toast */
.toast {
    position: fixed;
    bottom: 90px;
    left: 50%;
    transform: translateX(-50%);
    background: #1F2937;
    color: white;
    padding: 12px 22px;
    border-radius: 100px;
    font-size: 0.9em;
    font-weight: 500;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.25s, transform 0.25s;
    pointer-events: none;
    white-space: nowrap;
    box-shadow: var(--shadow);
}

.toast.show {
    opacity: 1;
}

.toast.success {
    background: #166534;
}

.toast.error {
    background: var(--error);
}

/* Confirm dialog */
.dialog-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.dialog-box {
    background: var(--surface);
    border-radius: 16px;
    padding: 28px;
    max-width: 320px;
    width: 90%;
    box-shadow: 0 8px 32px rgba(0,0,0,0.18);
}

.dialog-message {
    margin-bottom: 24px;
    line-height: 1.6;
    font-size: 0.97em;
}

.dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.btn-secondary {
    background: var(--bg);
    color: var(--text);
    border: 1.5px solid var(--border);
    box-shadow: none;
}

.btn-secondary:hover {
    background: var(--border);
    box-shadow: none;
}

/* Uncovered slots */
.uncovered-badge {
    font-size: 0.75em;
    background: #FEF3C7;
    color: #92400E;
    padding: 3px 10px;
    border-radius: 100px;
    font-weight: 600;
    white-space: nowrap;
}

.uncovered-time {
    font-size: 0.85em;
    color: var(--text-muted);
    margin-left: 4px;
}

.report-actions {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.action-group {
    display: flex;
    gap: 6px;
    align-items: center;
}

.section-hint {
    font-size: 0.88em;
    color: var(--text-muted);
    margin: 0 0 12px;
}

/* History form */
.history-form {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: flex-end;
}

.history-range {
    display: flex;
    align-items: center;
    gap: 6px;
}

.history-range label {
    font-size: 0.85em;
    color: var(--text-muted);
    font-weight: 600;
    white-space: nowrap;
}

.year-input {
    width: 88px;
}

.history-container {
    overflow-x: auto;
    margin-top: 16px;
}

/* Responsive mobile */
@media (max-width: 480px) {
    /* Calendrier : colonnes plus petites pour voir plus de jours */
    .week-grid {
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    }

    /* Barre semaine : nav centrée si le select prend toute la largeur */
    .week-controls select {
        width: 100%;
        max-width: 100%;
    }

    /* Rapport : boutons en colonne */
    .report-actions {
        flex-direction: column;
    }

    .action-group {
        width: 100%;
    }

    .action-group button {
        flex: 1;
    }

    /* Historique : empiler les plages de dates */
    .history-form {
        flex-direction: column;
        align-items: stretch;
    }

    .history-range {
        flex-wrap: wrap;
    }

    .history-range select {
        flex: 1;
    }

    .year-input {
        width: 80px;
    }

    /* Navigation : texte légèrement plus petit */
    .nav-item {
        font-size: 0.65em;
    }

    /* Formulaire créneau type : empilé */
    .admin-accordion-content form[id="add-creneau-form"] {
        flex-direction: column;
    }
}

/* ========== THEME SWITCHER ========== */
.theme-btn {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    background: white;
    border: none;
    border-radius: 100px;
    color: var(--primary);
    padding: 6px 13px 6px 9px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.18);
    font-size: 0.78em;
    font-weight: 700;
    font-family: inherit;
    white-space: nowrap;
}
.theme-btn:hover { background: #f0f0ff; transform: translateY(-50%); box-shadow: 0 4px 12px rgba(0,0,0,0.22); }
.theme-btn .material-symbols-outlined { font-size: 17px; }

.theme-picker {
    position: fixed;
    top: 58px;
    right: 10px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 6px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.14);
    display: flex;
    flex-direction: column;
    gap: 2px;
    z-index: 3000;
    min-width: 160px;
}
.theme-opt {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 8px;
    border: none;
    background: none;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.88em;
    font-weight: 500;
    color: var(--text);
    text-align: left;
    box-shadow: none;
    width: 100%;
    transition: background 0.12s;
}
.theme-opt:hover  { background: var(--bg); transform: none; box-shadow: none; }
.theme-opt.active { background: var(--primary-light); font-weight: 700; }
.theme-swatch {
    width: 14px; height: 14px;
    border-radius: 50%;
    flex-shrink: 0;
    border: 2px solid rgba(0,0,0,0.1);
}

/* ========== THEMES ========== */

/* --- Paper --- */
[data-theme="paper"] {
    --primary:       #2563EB;
    --primary-light: #EFF6FF;
    --surface:       #FFFFFF;
    --bg:            #FFFFFF;
    --shadow-sm:     0 1px 2px rgba(0,0,0,0.05);
    --shadow:        0 1px 4px rgba(0,0,0,0.08);
}
[data-theme="paper"] header {
    background: white;
    border-bottom: 1px solid var(--border);
    box-shadow: none;
}
[data-theme="paper"] header h1 { color: var(--text); }
[data-theme="paper"] .theme-btn { background: var(--primary); color: white; }
[data-theme="paper"] .theme-btn:hover { background: #1D4ED8; }
[data-theme="paper"] button { border-radius: 8px; box-shadow: none; }
[data-theme="paper"] button:hover { box-shadow: none; transform: none; }
[data-theme="paper"] .day-column { background: #F9FAFB; }

/* --- Sport --- */
[data-theme="sport"] {
    --primary:       #111827;
    --primary-light: #F3F4F6;
    --surface:       #FFFFFF;
    --bg:            #F3F4F6;
}
[data-theme="sport"] header {
    background: #111827;
    box-shadow: 0 1px 0 rgba(255,255,255,0.05);
}
[data-theme="sport"] .slot-card.uncovered {
    background: #FEF3C7;
    border-left-color: #D97706;
}
[data-theme="sport"] .day-column.today {
    background: #F9FAFB;
    border-color: #111827;
}
[data-theme="sport"] .day-column.today .day-col-header { color: #111827; }

/* --- Ardoise (dark) --- */
[data-theme="ardoise"] {
    --primary:       #4ADE80;
    --primary-light: #052e16;
    --surface:       #1C1C1C;
    --bg:            #111111;
    --text:          #F0F0F0;
    --text-muted:    #9CA3AF;
    --border:        rgba(255,255,255,0.09);
    --shadow-sm:     0 1px 3px rgba(0,0,0,0.4);
    --shadow:        0 4px 12px rgba(0,0,0,0.5);
    --error:         #F87171;
    color-scheme: dark;
}
[data-theme="ardoise"] header {
    background: #111111;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    box-shadow: none;
}
[data-theme="ardoise"] header h1 { color: #F0F0F0; }
[data-theme="ardoise"] .theme-btn { background: #4ADE80; color: #052e16; }
[data-theme="ardoise"] .theme-btn:hover { background: #86efac; }
[data-theme="ardoise"] input,
[data-theme="ardoise"] select { background: #111111; color-scheme: dark; }
[data-theme="ardoise"] button {
    background: #4ADE80; color: #052e16;
    box-shadow: 0 2px 8px rgba(74,222,128,0.2);
}
[data-theme="ardoise"] button:hover { box-shadow: 0 4px 14px rgba(74,222,128,0.35); }
[data-theme="ardoise"] button.btn-secondary { background: #1C1C1C; color: #F0F0F0; border-color: rgba(255,255,255,0.12); }
[data-theme="ardoise"] button.btn-secondary:hover { background: #242424; }
[data-theme="ardoise"] button.btn-danger { background: #F87171; color: white; }
[data-theme="ardoise"] .btn-icon { color: #9CA3AF; }
[data-theme="ardoise"] .btn-icon:hover { color: #4ADE80; background: rgba(74,222,128,0.1); }
[data-theme="ardoise"] .slot-card.uncovered { background: rgba(251,191,36,0.07); border-left-color: #FBBF24; }
[data-theme="ardoise"] .day-column.today { border-color: #4ADE80; background: rgba(74,222,128,0.04); }
[data-theme="ardoise"] .day-column.today .day-col-header { color: #4ADE80; }
[data-theme="ardoise"] .admin-accordion-header:hover { background: #242424; border-color: #4ADE80; }
[data-theme="ardoise"] nav { background: rgba(17,17,17,0.92); border-top-color: rgba(255,255,255,0.08); }
[data-theme="ardoise"] .toast { background: #1C1C1C; border: 1px solid rgba(74,222,128,0.3); color: #F0F0F0; }
[data-theme="ardoise"] .toast.success { background: #052e16; color: #4ADE80; border-color: #4ADE80; }
[data-theme="ardoise"] .toast.error { background: #450a0a; color: #F87171; border-color: #F87171; }
[data-theme="ardoise"] .report-table thead tr { background: #4ADE80; color: #052e16; }
[data-theme="ardoise"] .report-table tbody tr:hover { background: #242424; }
[data-theme="ardoise"] .uncovered-badge { background: rgba(251,191,36,0.12); color: #FBBF24; }
[data-theme="ardoise"] .dialog-box { border: 1px solid rgba(255,255,255,0.1); }
[data-theme="ardoise"] .theme-picker { background: #1C1C1C; border-color: rgba(255,255,255,0.1); }
[data-theme="ardoise"] .theme-opt { color: #F0F0F0; }
[data-theme="ardoise"] .theme-opt:hover { background: #242424; }
[data-theme="ardoise"] .theme-opt.active { background: #052e16; }
