/* ============================================================
   SANCTIO – Feuille de style principale
   Palette : bleu marine / blanc / gris clair
   ============================================================ */

:root {
    --primary:      #1e3a5f;
    --primary-light:#2d5282;
    --primary-dark: #0f1f35;
    --accent:       #3b82f6;
    --accent-hover: #2563eb;
    --success:      #16a34a;
    --warning:      #d97706;
    --danger:       #dc2626;
    --bg:           #f0f4f8;
    --surface:      #ffffff;
    --border:       #e2e8f0;
    --text:         #1a202c;
    --text-muted:   #64748b;
    --sidebar-w:    260px;
    --radius:       8px;
    --shadow:       0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
    --shadow-md:    0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
}

/* ----- Reset & base ----- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body { font-family: 'Inter', sans-serif; background: var(--bg); color: var(--text); line-height: 1.6; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }

/* ============================================================
   LAYOUT
   ============================================================ */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* ----- Sidebar ----- */
.sidebar {
    width: var(--sidebar-w);
    background: var(--primary);
    color: #e2e8f0;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: 1.4rem 1.2rem;
    border-bottom: 1px solid rgba(255,255,255,.1);
}
.brand-icon { font-size: 1.5rem; }
.brand-name { font-size: 1.25rem; font-weight: 700; color: #fff; letter-spacing: .5px; }

.sidebar-year {
    margin: .8rem 1rem;
    padding: .5rem .8rem;
    background: rgba(255,255,255,.08);
    border-radius: var(--radius);
    font-size: .78rem;
}
.sidebar-year--warn { background: rgba(217,119,6,.25); color: #fcd34d; }
.year-label { display: block; opacity: .7; font-size: .7rem; text-transform: uppercase; letter-spacing: .5px; }
.year-value { font-weight: 600; color: #fff; }

.sidebar-nav { flex: 1; padding: .5rem 0; }
.nav-section { margin-bottom: 1rem; }
.nav-section-label {
    display: block;
    padding: .4rem 1.2rem;
    font-size: .68rem;
    text-transform: uppercase;
    letter-spacing: .8px;
    color: rgba(255,255,255,.4);
    font-weight: 600;
}
.nav-item {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .55rem 1.2rem;
    color: rgba(255,255,255,.8);
    font-size: .875rem;
    border-left: 3px solid transparent;
    transition: all .15s;
}
.nav-item:hover { background: rgba(255,255,255,.1); color: #fff; text-decoration: none; }
.nav-item.active { background: rgba(255,255,255,.12); color: #fff; border-left-color: var(--accent); font-weight: 500; }
.nav-icon { width: 1.2rem; text-align: center; }

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid rgba(255,255,255,.1);
    display: flex;
    align-items: center;
    gap: .6rem;
}
.user-info { display: flex; align-items: center; gap: .6rem; flex: 1; min-width: 0; }
.user-avatar {
    width: 36px; height: 36px;
    background: var(--accent);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: .75rem; font-weight: 700; color: #fff; flex-shrink: 0;
}
.user-name { font-size: .82rem; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: .7rem; opacity: .6; }
.btn-logout {
    background: rgba(255,255,255,.1);
    border: none; border-radius: var(--radius);
    padding: .4rem .6rem;
    color: rgba(255,255,255,.8);
    cursor: pointer; font-size: 1rem;
    text-decoration: none;
    transition: background .15s;
}
.btn-logout:hover { background: rgba(220,38,38,.4); color: #fff; }

/* ----- Main content ----- */
.main-content { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: .9rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 10;
    box-shadow: var(--shadow);
}
.page-title { font-size: 1.1rem; font-weight: 600; color: var(--primary); }
.sidebar-toggle {
    display: none;
    background: none; border: none; font-size: 1.3rem; cursor: pointer; color: var(--primary);
}

.content-body { padding: 1.5rem; flex: 1; }

/* ============================================================
   COMPOSANTS
   ============================================================ */

/* ----- Alertes ----- */
.alert {
    padding: .8rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: .875rem;
    font-weight: 500;
}
.alert-success { background: #dcfce7; color: #166534; border: 1px solid #86efac; }
.alert-error   { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.alert-info    { background: #dbeafe; color: #1e40af; border: 1px solid #93c5fd; }
.alert-warning { background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; }

/* ----- Cards ----- */
.card {
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    margin-bottom: 1.25rem;
}
.card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
}
.card-title { font-size: 1rem; font-weight: 600; color: var(--primary); }
.card-body  { padding: 1.25rem; }

/* ----- Boutons ----- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .5rem 1rem;
    border-radius: var(--radius);
    border: none;
    font-family: inherit;
    font-size: .875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all .15s;
    text-decoration: none;
    line-height: 1.4;
}
.btn:hover { text-decoration: none; filter: brightness(.92); }
.btn-primary  { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); filter: none; }
.btn-secondary{ background: #e2e8f0; color: var(--text); }
.btn-success  { background: var(--success); color: #fff; }
.btn-danger   { background: var(--danger); color: #fff; }
.btn-warning  { background: var(--warning); color: #fff; }
.btn-outline  { background: transparent; border: 1px solid var(--border); color: var(--text-muted); }
.btn-sm       { padding: .3rem .7rem; font-size: .8rem; }
.btn-lg       { padding: .75rem 1.4rem; font-size: 1rem; }
.btn-block    { width: 100%; justify-content: center; }

/* ----- Formulaires ----- */
.form-group   { margin-bottom: 1rem; }
.form-row     { display: grid; gap: 1rem; }
.form-row-2   { grid-template-columns: 1fr 1fr; }
.form-row-3   { grid-template-columns: 1fr 1fr 1fr; }
label         { display: block; font-size: .85rem; font-weight: 500; margin-bottom: .35rem; color: var(--text); }
label .req    { color: var(--danger); margin-left: 2px; }

.form-control, select.form-control, textarea.form-control {
    width: 100%;
    padding: .55rem .8rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: .9rem;
    color: var(--text);
    background: #fff;
    transition: border-color .15s, box-shadow .15s;
    line-height: 1.5;
}
.form-control:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}
textarea.form-control { resize: vertical; min-height: 90px; }
.form-control[readonly] { background: #f8fafc; }

/* ----- Checkboxes ----- */
.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: .5rem;
    margin-top: .4rem;
}
.checkbox-item {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .45rem .7rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: border-color .15s, background .15s;
    font-size: .875rem;
}
.checkbox-item:hover { border-color: var(--accent); background: #eff6ff; }
.checkbox-item input[type="checkbox"] { cursor: pointer; accent-color: var(--accent); width: 1rem; height: 1rem; }
.checkbox-item.checked { border-color: var(--accent); background: #eff6ff; }

/* ----- Tables ----- */
.table-wrap { overflow-x: auto; }
table.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .875rem;
}
.data-table th, .data-table td {
    padding: .65rem .9rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}
.data-table th {
    background: #f8fafc;
    font-weight: 600;
    color: var(--text-muted);
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .4px;
    white-space: nowrap;
}
.data-table tr:hover td { background: #f8fafc; }
.data-table td .actions { display: flex; gap: .4rem; }

/* ----- Badges ----- */
.badge {
    display: inline-block;
    padding: .2rem .55rem;
    border-radius: 20px;
    font-size: .72rem;
    font-weight: 600;
    line-height: 1;
}
.badge-blue    { background: #dbeafe; color: #1e40af; }
.badge-green   { background: #dcfce7; color: #166534; }
.badge-red     { background: #fee2e2; color: #991b1b; }
.badge-orange  { background: #ffedd5; color: #9a3412; }
.badge-gray    { background: #f1f5f9; color: #475569; }

/* ----- Pagination ----- */
.pagination { display: flex; gap: .35rem; flex-wrap: wrap; margin-top: 1rem; }
.page-btn {
    padding: .35rem .7rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: .82rem;
    color: var(--text);
    background: var(--surface);
    text-decoration: none;
    transition: all .15s;
}
.page-btn:hover { background: #f1f5f9; text-decoration: none; }
.page-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ============================================================
   PAGE LOGIN
   ============================================================ */
.login-page {
    min-height: 100vh;
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 60%, var(--primary-light) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.login-card {
    background: var(--surface);
    border-radius: 12px;
    padding: 2.5rem 2rem;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.login-logo { text-align: center; margin-bottom: 2rem; }
.login-logo .logo-icon { font-size: 2.5rem; }
.login-logo h1 { font-size: 1.8rem; font-weight: 700; color: var(--primary); margin-top: .4rem; }
.login-logo p  { font-size: .85rem; color: var(--text-muted); }

/* ============================================================
   PAGE CONSEIL
   ============================================================ */
.conseil-zones { display: flex; flex-direction: column; gap: 1.25rem; }
.zone-header {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: 1rem 1.25rem;
    background: var(--primary);
    color: #fff;
    border-radius: var(--radius) var(--radius) 0 0;
}
.zone-number {
    width: 28px; height: 28px;
    background: rgba(255,255,255,.2);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: .85rem; font-weight: 700; flex-shrink: 0;
}
.zone-title { font-weight: 600; font-size: .95rem; }

.eleve-photo {
    width: 90px; height: 110px;
    object-fit: cover;
    border-radius: var(--radius);
    border: 2px solid var(--border);
}
.eleve-photo-placeholder {
    width: 90px; height: 110px;
    background: #f1f5f9;
    border-radius: var(--radius);
    border: 2px dashed var(--border);
    display: flex; align-items: center; justify-content: center;
    font-size: 2rem; color: var(--text-muted);
}

.titulaires-list {
    margin-top: .4rem;
    display: flex;
    flex-wrap: wrap;
    gap: .35rem;
}

/* Avis profs dynamiques */
.avis-prof-block {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: .9rem;
    margin-bottom: .75rem;
    background: #fafafa;
}
.avis-prof-label { font-size: .85rem; font-weight: 600; margin-bottom: .4rem; color: var(--primary); }

/* ----- Autocomplete ----- */
.autocomplete-wrap { position: relative; }
.autocomplete-list {
    position: absolute;
    top: 100%; left: 0; right: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 var(--radius) var(--radius);
    max-height: 250px;
    overflow-y: auto;
    z-index: 100;
    box-shadow: var(--shadow-md);
}
.autocomplete-item {
    padding: .55rem .8rem;
    cursor: pointer;
    font-size: .875rem;
    transition: background .1s;
}
.autocomplete-item:hover, .autocomplete-item.selected { background: #eff6ff; }
.autocomplete-item strong { color: var(--primary); }
.autocomplete-item small  { color: var(--text-muted); }

/* ----- Archives ----- */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: .75rem;
    align-items: flex-end;
    margin-bottom: 1.25rem;
}
.filter-bar .form-group { margin-bottom: 0; flex: 1; min-width: 150px; }

/* ----- Admin cards ----- */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.2rem;
    box-shadow: var(--shadow);
}
.stat-value { font-size: 2rem; font-weight: 700; color: var(--primary); }
.stat-label { font-size: .8rem; color: var(--text-muted); margin-top: .2rem; }

/* ----- Import CSV ----- */
.import-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}
.import-card { border: 2px dashed var(--border); border-radius: var(--radius); padding: 1.2rem; text-align: center; }
.import-card h3 { font-size: .95rem; margin-bottom: .5rem; }
.import-card p  { font-size: .8rem; color: var(--text-muted); margin-bottom: .75rem; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: -var(--sidebar-w);
        top: 0; bottom: 0;
        transform: translateX(-100%);
        transition: transform .25s;
        z-index: 200;
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar-toggle { display: block; }
    .form-row-2, .form-row-3 { grid-template-columns: 1fr; }
    .content-body { padding: 1rem; }
    .checkbox-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 480px) {
    .checkbox-grid { grid-template-columns: 1fr; }
    .filter-bar .form-group { min-width: 100%; }
}

/* ============================================================
   UTILITAIRES
   ============================================================ */
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: .5rem; }
.mb-2 { margin-bottom: 1rem; }
.d-flex         { display: flex; }
.align-center   { align-items: center; }
.justify-between{ justify-content: space-between; }
.gap-1          { gap: .5rem; }
.gap-2          { gap: 1rem; }
.text-muted     { color: var(--text-muted); }
.text-sm        { font-size: .8rem; }
.fw-600         { font-weight: 600; }
.w-100          { width: 100%; }
.text-center    { text-align: center; }
.text-danger    { color: var(--danger); }
.text-success   { color: var(--success); }

/* Modal confirm suppression */
.modal-backdrop {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 300;
}
.modal-backdrop.show { display: flex; }
.modal-box {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1.5rem;
    max-width: 380px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.modal-box h3 { margin-bottom: .5rem; }
.modal-box p  { font-size: .875rem; color: var(--text-muted); margin-bottom: 1rem; }
.modal-actions { display: flex; gap: .5rem; justify-content: flex-end; }

/* Textarea auto-resize */
textarea.auto-resize { overflow: hidden; }
