/* ── Reset ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Segoe UI', Arial, sans-serif;
    background: #f0f2f5;
    color: #333;
    min-height: 100vh;
}

a { color: #007bff; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Navbar ────────────────────────────────────────────────────── */
.navbar {
    background: #1a1a2e;
    color: #fff;
    padding: 0 2rem;
    height: 60px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 8px rgba(0,0,0,.3);
    position: sticky;
    top: 0;
    z-index: 100;
}

.navbar-brand {
    font-size: 1.1rem;
    font-weight: 700;
    color: #a0c4ff;
}
.navbar-brand:hover { color: #fff; text-decoration: none; }

.navbar-links {
    display: flex;
    align-items: center;
    gap: 1.4rem;
    font-size: .9rem;
}
.navbar-links span  { color: #aaa; }
.navbar-links strong { color: #e0e0ff; }
.navbar-links a     { color: #ccc; }
.navbar-links a:hover { color: #fff; text-decoration: none; }

.btn-logout {
    background: #e74c3c;
    color: #fff !important;
    padding: .35rem .9rem;
    border-radius: 5px;
    font-weight: 700;
}
.btn-logout:hover { background: #c0392b !important; }

/* ── Container ─────────────────────────────────────────────────── */
.container {
    max-width: 1100px;
    margin: 2rem auto;
    padding: 0 1.5rem;
}

/* ── Auth pages ────────────────────────────────────────────────── */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 2rem;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
}

.auth-card {
    background: #fff;
    padding: 2.5rem;
    border-radius: 16px;
    box-shadow: 0 12px 40px rgba(0,0,0,.3);
    width: 100%;
    max-width: 460px;
}
.auth-card--wide { max-width: 720px; }

.auth-logo {
    font-size: 2.5rem;
    text-align: center;
    margin-bottom: .6rem;
}

.auth-card h2 {
    text-align: center;
    font-size: 1.5rem;
    color: #1a1a2e;
    margin-bottom: .3rem;
}

.auth-subtitle {
    text-align: center;
    color: #888;
    font-size: .88rem;
    margin-bottom: 1.8rem;
}

/* ── Formulaires ───────────────────────────────────────────────── */
.form-group { margin-bottom: 1.1rem; }

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    font-size: .875rem;
    color: #444;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"],
input[type="date"],
select {
    width: 100%;
    padding: 11px 13px;
    border: 1.5px solid #ddd;
    border-radius: 8px;
    font-size: .95rem;
    background: #fafafa;
    color: #333;
    transition: border-color .2s, box-shadow .2s;
}

input:focus, select:focus {
    border-color: #007bff;
    background: #fff;
    outline: none;
    box-shadow: 0 0 0 3px rgba(0,123,255,.12);
}

/* Wrapper pour input + bouton œil */
.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}
.input-wrapper input { padding-right: 2.8rem; }

.toggle-pwd {
    position: absolute;
    right: 10px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    padding: 0;
    line-height: 1;
    color: #888;
}
.toggle-pwd:hover { color: #333; }

.required     { color: #e74c3c; }
.required-note { font-size: .8rem; color: #888; margin-bottom: 1rem; }

/* ── Boutons ────────────────────────────────────────────────────── */
.btn {
    display: inline-block;
    padding: 11px 22px;
    border: none;
    border-radius: 8px;
    font-size: .95rem;
    font-weight: 700;
    cursor: pointer;
    transition: background .2s, transform .1s;
    text-align: center;
}
.btn:active { transform: scale(.98); }

.btn-primary {
    background: #007bff;
    color: #fff;
    width: 100%;
    padding: 13px;
    font-size: 1rem;
    margin-top: .6rem;
}
.btn-primary:hover { background: #0056b3; color: #fff; text-decoration: none; }

.btn-secondary { background: #6c757d; color: #fff; }
.btn-secondary:hover { background: #545b62; color: #fff; text-decoration: none; }

.btn-danger { background: #e74c3c; color: #fff; }
.btn-danger:hover { background: #c0392b; color: #fff; text-decoration: none; }

/* ── Alertes ────────────────────────────────────────────────────── */
.alert {
    padding: .9rem 1.1rem;
    border-radius: 8px;
    margin-bottom: 1.3rem;
    font-size: .9rem;
}
.alert-success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.alert-error   { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
.alert ul      { padding-left: 1.3rem; margin: 0; }
.alert ul li   { margin-bottom: .25rem; }

.auth-link {
    text-align: center;
    margin-top: 1.3rem;
    font-size: .9rem;
    color: #666;
}

/* ── Dashboard ──────────────────────────────────────────────────── */
.dashboard-card {
    background: #fff;
    padding: 2rem 2.5rem;
    border-radius: 14px;
    box-shadow: 0 2px 16px rgba(0,0,0,.08);
}

.dashboard-header { margin-bottom: 1.5rem; }
.dashboard-header h1 { font-size: 1.7rem; color: #1a1a2e; margin-bottom: .3rem; }
.dashboard-header p  { color: #555; }

.user-info h3 {
    font-size: 1rem;
    color: #1a1a2e;
    margin-bottom: 1rem;
    padding-bottom: .5rem;
    border-bottom: 2px solid #f0f2f5;
}

.info-table { width: 100%; border-collapse: collapse; margin-bottom: 2rem; }
.info-table th,
.info-table td {
    padding: .75rem 1rem;
    text-align: left;
    border-bottom: 1px solid #f0f2f5;
    font-size: .93rem;
}
.info-table th { background: #f8f9fa; color: #555; font-weight: 600; width: 200px; }
.info-table tr:last-child th,
.info-table tr:last-child td { border-bottom: none; }

.dashboard-actions {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    padding-top: 1rem;
    border-top: 2px solid #f0f2f5;
}

/* ── Page header ────────────────────────────────────────────────── */
.page-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.page-header h1 { font-size: 1.6rem; color: #1a1a2e; }

.badge {
    background: #007bff;
    color: #fff;
    padding: .3rem .8rem;
    border-radius: 20px;
    font-size: .82rem;
    font-weight: 700;
}

/* ── Table ──────────────────────────────────────────────────────── */
.table-wrapper {
    overflow-x: auto;
    border-radius: 10px;
    box-shadow: 0 2px 12px rgba(0,0,0,.07);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    font-size: .9rem;
}
.data-table thead   { background: #1a1a2e; color: #fff; }
.data-table th      { padding: .9rem 1rem; font-size: .85rem; text-align: left; white-space: nowrap; }
.data-table td      { padding: .8rem 1rem; border-bottom: 1px solid #f0f2f5; color: #444; }
.data-table tbody tr:hover { background: #f0f5ff; }
.data-table tbody tr:last-child td { border-bottom: none; }

.empty-state {
    text-align: center;
    padding: 3rem;
    color: #888;
    background: #fff;
    border-radius: 10px;
    font-style: italic;
}

.back-link { margin-top: 1.5rem; }

/* ── Footer ─────────────────────────────────────────────────────── */
.footer {
    text-align: center;
    padding: 1.5rem;
    color: #aaa;
    font-size: .82rem;
    margin-top: 3rem;
    border-top: 1px solid #e0e0e0;
}

/* ── Responsive ─────────────────────────────────────────────────── */
@media (max-width: 640px) {
    .form-row        { grid-template-columns: 1fr; }
    .auth-card       { padding: 1.8rem 1.2rem; }
    .dashboard-card  { padding: 1.5rem 1rem; }
    .dashboard-actions { flex-direction: column; }
    .navbar {
        height: auto;
        flex-direction: column;
        padding: .8rem 1rem;
        gap: .6rem;
    }
    .navbar-links { flex-wrap: wrap; justify-content: center; gap: .8rem; }
    .container    { padding: 0 1rem; }
}

/* ── Role badges ─────────────────────────────────────────────── */
.role-badge {
    display: inline-block;
    padding: .2rem .6rem;
    border-radius: 12px;
    font-size: .78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .4px;
}
.role-admin { background: #fff3cd; color: #856404; border: 1px solid #ffc107; }
.role-user  { background: #d1ecf1; color: #0c5460; border: 1px solid #bee5eb; }

/* ── Élèves ──────────────────────────────────────────────────── */
.eleve-thumb {
    width: 44px;
    height: 44px;
    object-fit: cover;
    border-radius: 50%;
    border: 2px solid #e0e0e0;
}

.eleve-thumb-placeholder {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #e9ecef;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

/* Badges sexe */
.sexe-badge {
    display: inline-block;
    padding: .2rem .6rem;
    border-radius: 12px;
    font-size: .78rem;
    font-weight: 700;
}
.sexe-m { background: #cfe2ff; color: #084298; border: 1px solid #b6d4fe; }
.sexe-f { background: #f8d7da; color: #842029; border: 1px solid #f5c2c7; }

/* Boutons d'action dans les tableaux */
.actions { white-space: nowrap; }

.btn-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-size: .95rem;
    text-decoration: none;
    transition: background .15s;
    background: transparent;
}
.btn-view:hover  { background: #e3f0ff; }
.btn-edit:hover  { background: #fff3cd; }
.btn-delete:hover { background: #f8d7da; }

/* ── Form card (formulaires hors auth) ───────────────────────── */
.form-card {
    background: #fff;
    padding: 2rem 2.5rem;
    border-radius: 14px;
    box-shadow: 0 2px 16px rgba(0,0,0,.08);
    max-width: 800px;
    margin: 0 auto;
}

.form-card-header { margin-bottom: 1.8rem; }
.form-card-header h1 { font-size: 1.5rem; color: #1a1a2e; }
.form-subtitle { color: #666; font-size: .9rem; margin-top: .3rem; }

.form-actions {
    display: flex;
    gap: 1rem;
    align-items: center;
    margin-top: 1.5rem;
    padding-top: 1.2rem;
    border-top: 2px solid #f0f2f5;
}

input[type="file"] {
    width: 100%;
    padding: 8px;
    border: 1.5px dashed #ccc;
    border-radius: 8px;
    font-size: .9rem;
    background: #fafafa;
    cursor: pointer;
}
input[type="file"]:hover { border-color: #007bff; }

.field-hint {
    display: block;
    color: #888;
    font-size: .78rem;
    margin-top: .3rem;
}

.photo-preview {
    display: block;
    max-width: 120px;
    max-height: 120px;
    object-fit: cover;
    border-radius: 8px;
    margin-top: .5rem;
    border: 2px solid #dee2e6;
}

.photo-preview-existing {
    margin-bottom: .5rem;
}
.photo-preview-existing small { display: block; color: #888; font-size: .78rem; margin-top: .3rem; }

/* ── Fiche détail élève ──────────────────────────────────────── */
.detail-card {
    background: #fff;
    padding: 2rem 2.5rem;
    border-radius: 14px;
    box-shadow: 0 2px 16px rgba(0,0,0,.08);
}

.detail-header {
    display: flex;
    gap: 2rem;
    align-items: flex-start;
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 2px solid #f0f2f5;
}

.photo-large {
    width: 120px;
    height: 120px;
    object-fit: cover;
    border-radius: 12px;
    border: 3px solid #e0e0e0;
    flex-shrink: 0;
}

.photo-placeholder-large {
    width: 120px;
    height: 120px;
    border-radius: 12px;
    background: #e9ecef;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    flex-shrink: 0;
}

.detail-identity h1 { font-size: 1.6rem; color: #1a1a2e; margin-bottom: .4rem; }
.detail-class  { color: #555; font-size: .95rem; margin-bottom: .3rem; }
.detail-matricule { color: #666; font-size: .9rem; }
.detail-matricule code {
    background: #f0f2f5;
    padding: .1rem .4rem;
    border-radius: 4px;
    font-family: monospace;
}

@media (max-width: 640px) {
    .detail-header { flex-direction: column; gap: 1rem; }
    .form-card { padding: 1.5rem 1rem; }
    .form-actions { flex-direction: column; }
}

/* ── Classes ─────────────────────────────────────────────────── */
.annee-badge {
    display: inline-block;
    background: #e8f4fd;
    color: #0c63e4;
    border: 1px solid #b6d4fe;
    padding: .2rem .6rem;
    border-radius: 12px;
    font-size: .82rem;
    font-weight: 600;
    white-space: nowrap;
}

.classe-icon {
    font-size: 3rem;
    flex-shrink: 0;
    width: 80px;
    text-align: center;
}

/* ── Établissements ──────────────────────────────────────────── */
.statut-badge {
    display: inline-block;
    padding: .2rem .7rem;
    border-radius: 12px;
    font-size: .78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .4px;
}
.statut-actif   { background: #d1e7dd; color: #0a3622; border: 1px solid #a3cfbb; }
.statut-inactif { background: #f8d7da; color: #58151c; border: 1px solid #f1aeb5; }

/* ── Photo téléchargement ────────────────────────────────────── */
.detail-photo-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .6rem;
    flex-shrink: 0;
}

.btn-download-photo {
    display: inline-block;
    background: #e8f4fd;
    color: #0c63e4;
    border: 1px solid #b6d4fe;
    padding: .35rem .9rem;
    border-radius: 8px;
    font-size: .82rem;
    font-weight: 600;
    text-decoration: none;
    transition: background .15s;
    white-space: nowrap;
}
.btn-download-photo:hover {
    background: #cfe2ff;
    text-decoration: none;
}

.no-photo-hint {
    font-size: .8rem;
    color: #aaa;
    font-style: italic;
}

/* ── Section photo (onglets fichier / webcam) ────────────────── */
.photo-section {
    border: 1.5px solid #ddd;
    border-radius: 10px;
    padding: 1.2rem;
    margin-bottom: 1.1rem;
    background: #fafafa;
}

.photo-section-label {
    display: block;
    font-weight: 700;
    font-size: .9rem;
    color: #1a1a2e;
    margin-bottom: .8rem;
}

/* Onglets */
.photo-tabs {
    display: flex;
    gap: .5rem;
    margin-bottom: 1rem;
}

.photo-tab {
    padding: .45rem 1.1rem;
    border: 1.5px solid #ddd;
    border-radius: 8px;
    background: #fff;
    font-size: .88rem;
    font-weight: 600;
    cursor: pointer;
    color: #555;
    transition: all .15s;
}

.photo-tab:hover  { border-color: #007bff; color: #007bff; }
.photo-tab.active { background: #007bff; color: #fff; border-color: #007bff; }

.photo-tab-content { /* visible par défaut */ }

/* Webcam */
.webcam-container { display: flex; flex-direction: column; gap: .8rem; }

.webcam-video-wrap,
.webcam-capture-wrap {
    position: relative;
    width: 100%;
    max-width: 480px;
    border-radius: 10px;
    overflow: hidden;
    background: #000;
    aspect-ratio: 4/3;
}

#webcam-video,
#webcam-canvas {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Cadre de visée */
.webcam-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.webcam-frame {
    width: 60%;
    aspect-ratio: 3/4;
    border: 2.5px solid rgba(255,255,255,.75);
    border-radius: 8px;
    box-shadow: 0 0 0 2000px rgba(0,0,0,.25);
}

.webcam-capture-label {
    position: absolute;
    bottom: .5rem;
    left: 0; right: 0;
    text-align: center;
    color: #fff;
    font-size: .8rem;
    font-weight: 600;
    background: rgba(0,0,0,.45);
    padding: .3rem;
}

.webcam-controls {
    display: flex;
    gap: .6rem;
    flex-wrap: wrap;
    align-items: center;
}

.webcam-status {
    font-size: .85rem;
    color: #555;
    min-height: 1.2rem;
}

@media (max-width: 640px) {
    .webcam-video-wrap,
    .webcam-capture-wrap { max-width: 100%; }
    .webcam-controls { flex-direction: column; align-items: stretch; }
}
