/* ============================================================
   ZenTeach Léger — Feuille de style
   Couleurs reprises du logo et des captures d'écran fournies.
   ============================================================ */

:root {
    --yellow: #FFD232;
    --blue: #7F96FF;
    --blue-dark: #5F78E8;
    --navy: #101C4E;
    --navy-light: #1B2A6B;
    --bg: #F4F4F8;
    --card-bg: #E1E6FF;
    --border-blue: #C4CDFB;
    --orange: #FF9153;
    --green: #3FCF6E;
    --gray-text: #6B7280;
    --white: #FFFFFF;
    --radius: 14px;
    --radius-lg: 20px;
    --shadow: 0 4px 14px rgba(16, 28, 78, 0.08);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    font-family: 'Poppins', 'Segoe UI', Arial, sans-serif;
    background: var(--bg);
    color: var(--navy);
}

a { color: inherit; text-decoration: none; }
h1, h2 { margin: 0; color: var(--navy); }
p { line-height: 1.5; }

/* ---------- Layout général (pages protégées) ---------- */

body.app { display: block; }

.sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 230px;
    background: var(--bg);
    border-right: 1px solid #e4e4ee;
    padding: 24px 18px;
    display: flex;
    flex-direction: column;
    z-index: 60;
    transition: transform 0.25s ease;
}

.sidebar-logo { padding: 4px 6px 24px; }
.sidebar-logo img { width: 150px; display: block; }

.sidebar-nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 15px;
    color: var(--navy);
}

.nav-item svg { width: 20px; height: 20px; flex-shrink: 0; color: var(--blue); }

.nav-item:hover { background: #eceffe; }

.nav-item.active {
    background: var(--navy);
    color: var(--white);
}
.nav-item.active svg { color: var(--white); }

.sidebar-footer {
    border-top: 1px solid #e0e0ee;
    padding-top: 16px;
    margin-top: 12px;
}
.account-name { font-weight: 700; font-size: 14px; margin-bottom: 4px; }
.account-logout { font-size: 13px; color: var(--gray-text); }
.account-logout:hover { color: var(--navy); text-decoration: underline; }

.main {
    margin-left: 230px;
    padding: 36px 44px 60px;
    min-height: 100vh;
}

.topbar {
    display: none;
    align-items: center;
    justify-content: center;
    position: sticky;
    top: 0;
    padding: 14px 18px;
    padding-top: calc(14px + env(safe-area-inset-top));
    background: var(--white);
    border-bottom: 1px solid #eee;
    z-index: 40;
}
.topbar-logo { height: 30px; }
.topbar-logout {
    position: absolute;
    right: 18px;
    top: 50%;
    transform: translateY(-50%);
    width: 34px; height: 34px;
    display: flex; align-items: center; justify-content: center;
    color: var(--navy-light);
    border-radius: 8px;
}
.topbar-logout svg { width: 20px; height: 20px; }
.topbar-logout:hover { background: #eceffe; }

/* ---------- Barre de navigation basse (mobile uniquement) ---------- */

.bottom-nav {
    display: none;
    position: fixed;
    left: 0; right: 0; bottom: 0;
    background: var(--white);
    border-top: 1px solid #e4e4ee;
    box-shadow: 0 -2px 12px rgba(16, 28, 78, 0.08);
    padding-bottom: env(safe-area-inset-bottom);
    z-index: 60;
}
.bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 8px 4px 10px;
    font-size: 11px;
    font-weight: 600;
    color: var(--gray-text);
}
.bottom-nav-item svg { width: 22px; height: 22px; color: var(--gray-text); }
.bottom-nav-item.active { color: var(--navy); }
.bottom-nav-item.active svg { color: var(--blue); }

/* ---------- En-tête de page ---------- */

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    padding-bottom: 18px;
    border-bottom: 3px solid var(--navy);
    margin-bottom: 22px;
}
.page-header h1 { font-size: 26px; font-weight: 800; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: none;
    border-radius: 10px;
    padding: 12px 20px;
    font-family: inherit;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    transition: transform 0.1s ease, opacity 0.15s ease;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--navy); color: var(--white); }
.btn-primary:hover { background: var(--navy-light); }
.btn-dark { background: var(--navy); color: var(--white); }
.btn-block { width: 100%; margin-top: 6px; }
.btn-icon {
    background: var(--navy); color: var(--white);
    width: 40px; height: 40px; border-radius: 10px;
    font-size: 18px; padding: 0;
}

/* ---------- Onglets ---------- */

.tabs { display: flex; gap: 10px; margin-bottom: 26px; flex-wrap: wrap; }
.tab {
    padding: 10px 18px;
    border-radius: 20px;
    background: #dcdcec;
    color: var(--navy);
    font-weight: 600;
    font-size: 14px;
}
.tab.active { background: var(--blue); color: var(--white); }
.tab:hover:not(.active) { background: #cfcfe6; }

.empty-state { color: var(--gray-text); font-size: 15px; margin-top: 20px; }

/* ---------- Comptabilité ---------- */

.filters-bar {
    display: flex;
    gap: 14px;
    align-items: flex-end;
    flex-wrap: wrap;
    margin-bottom: 16px;
    background: var(--white);
    padding: 16px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.filters-bar .field { min-width: 160px; }

.period-presets { display: flex; gap: 10px; margin-bottom: 24px; flex-wrap: wrap; }

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}
.stat-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 18px;
    text-align: center;
    box-shadow: var(--shadow);
}
.stat-value { font-size: 24px; font-weight: 800; color: var(--navy); }
.stat-label { font-size: 12px; color: var(--gray-text); margin-top: 4px; text-transform: uppercase; letter-spacing: 0.02em; }
.stat-card.stat-green .stat-value { color: #1f9d4c; }
.stat-card.stat-orange .stat-value { color: #c96a2e; }

/* ---------- Cartes élèves ---------- */

.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 20px;
}

.student-card {
    background: var(--card-bg);
    border-top: 5px solid var(--blue);
    border-radius: var(--radius);
    padding: 18px 20px;
    box-shadow: var(--shadow);
}

.student-card-top { display: flex; align-items: center; gap: 14px; }

.avatar {
    width: 52px; height: 52px;
    border-radius: 50%;
    background: var(--blue);
    color: var(--card-bg);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.avatar svg { width: 30px; height: 30px; }

.student-name { font-weight: 700; font-size: 16px; }
.student-meta { font-size: 13px; color: #4b5372; margin-top: 2px; }
.student-objectif {
    margin-top: 12px;
    font-size: 13px;
    color: var(--navy-light);
    background: rgba(255,255,255,0.55);
    border-radius: 8px;
    padding: 8px 10px;
}

.student-card-actions { margin-top: 14px; text-align: right; }
.link-action {
    background: none; border: none; cursor: pointer;
    font-family: inherit; font-weight: 600; font-size: 13px;
    color: var(--navy-light); text-decoration: underline;
    padding: 0;
}
.link-action:hover { color: var(--navy); }

/* ---------- Tableau des cours ---------- */

.table-wrap { overflow-x: auto; border-radius: var(--radius); box-shadow: var(--shadow); }

.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--card-bg);
    min-width: 780px;
}

.data-table thead th {
    text-align: left;
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    padding: 14px 16px;
    border-bottom: 3px solid var(--navy);
    background: #dfe5ff;
}

.data-table tbody td {
    padding: 14px 16px;
    font-size: 14px;
    border-bottom: 1px solid #cfd6fb;
}
.data-table tbody tr:hover { background: #d7ddfc; }
.data-table tbody tr.clickable-row { cursor: pointer; }

.pill {
    display: inline-block;
    background: var(--blue);
    color: var(--white);
    font-weight: 700;
    font-size: 13px;
    padding: 6px 14px;
    border-radius: 20px;
}

.badge {
    display: inline-block;
    border: none;
    cursor: pointer;
    font-family: inherit;
    font-weight: 700;
    font-size: 13px;
    padding: 8px 14px;
    border-radius: 20px;
    color: var(--white);
}
.badge-nonpaye { background: var(--orange); }
.badge-paye { background: var(--green); }
.badge-autre { background: #9599b8; }
.badge:hover { filter: brightness(1.05); }

.icon-btn {
    background: none; border: none; cursor: pointer;
    color: var(--navy-light); padding: 6px; border-radius: 8px;
}
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn:hover { background: #d0d6f8; color: #c0392b; }

/* ---------- Calendrier ---------- */

.calendar-toolbar {
    display: flex; align-items: center; gap: 10px;
    margin-bottom: 20px; flex-wrap: wrap;
}
.calendar-range { font-weight: 700; font-size: 16px; margin-left: 10px; }

.calendar-scroll { overflow-x: auto; }

.calendar { min-width: 760px; background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }

.calendar-header-row, .calendar-body {
    display: grid;
    grid-template-columns: 60px repeat(7, 1fr);
}

.calendar-header-row {
    border-bottom: 2px solid var(--navy);
}

.calendar-day-head {
    text-align: center;
    font-weight: 700;
    font-size: 13px;
    padding: 12px 4px;
    color: var(--navy);
    border-left: 1px solid #eef0fa;
}
.calendar-day-head.is-today { color: var(--blue-dark); background: #eef1ff; }

.calendar-time-col { border-left: none; }

.calendar-hour-label {
    font-size: 12px;
    color: var(--gray-text);
    text-align: right;
    padding-right: 8px;
    border-top: 1px solid #f0f1f8;
    transform: translateY(-7px);
}

.calendar-day-col {
    position: relative;
    border-left: 1px solid #eef0fa;
}

.calendar-hour-line { border-top: 1px solid #f0f1f8; }

.calendar-event {
    position: absolute;
    left: 4px; right: 4px;
    background: var(--blue);
    color: var(--white);
    border-radius: 8px;
    padding: 6px 8px;
    font-size: 12px;
    overflow: hidden;
    box-shadow: 0 2px 6px rgba(16,28,78,0.25);
    display: flex;
    flex-direction: column;
    gap: 2px;
    cursor: pointer;
}
.calendar-event:hover { filter: brightness(1.08); }
.ce-time { font-weight: 700; font-size: 11px; opacity: 0.9; }
.ce-name { font-weight: 600; }

/* ---------- Modales ---------- */

.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(16, 28, 78, 0.45);
    display: flex; align-items: center; justify-content: center;
    z-index: 100;
    padding: 20px;
}
.modal-overlay.hidden { display: none; }

.modal {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 30px;
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 24px 60px rgba(16,28,78,0.3);
}

.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 18px;
}
.modal-header h2 { font-size: 20px; }
.modal-close {
    background: none; border: none; font-size: 26px; line-height: 1;
    cursor: pointer; color: var(--gray-text);
}
.modal-close:hover { color: var(--navy); }

/* ---------- Formulaires ---------- */

.form-grid { display: flex; flex-direction: column; gap: 14px; }
.field-row { display: flex; gap: 14px; }
.field-row .field { flex: 1; min-width: 0; }

.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--navy); }

input, select, textarea {
    font-family: inherit;
    font-size: 14px;
    padding: 11px 12px;
    border-radius: 10px;
    border: 1.5px solid #d7dbf5;
    background: #fbfbfe;
    color: var(--navy);
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--blue);
    background: var(--white);
}
textarea { resize: vertical; }

/* ---------- Pages de connexion / inscription ---------- */

body.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(160deg, #eef1ff 0%, var(--bg) 60%);
    padding: 20px;
}

.auth-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 40px 36px;
    width: 100%;
    max-width: 420px;
    text-align: center;
}
.auth-logo { width: 170px; margin-bottom: 18px; }
.auth-card h1 { font-size: 22px; margin-bottom: 20px; }
.auth-card .form-grid { text-align: left; }
.auth-switch { margin-top: 18px; font-size: 14px; color: var(--gray-text); }
.auth-switch a { color: var(--blue-dark); font-weight: 700; }

.alert-error {
    background: #ffe3e3;
    color: #c0392b;
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 13px;
    margin-bottom: 16px;
}

/* ---------- Responsive ---------- */

@media (max-width: 900px) {
    .topbar { display: flex; }
    .bottom-nav { display: flex; }

    .sidebar { display: none; }

    .main {
        margin-left: 0;
        padding: 20px;
        padding-bottom: calc(90px + env(safe-area-inset-bottom));
    }

    .page-header h1 { font-size: 21px; }

    .field-row { flex-direction: column; }
}
