:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --bg: #f8fafc;
    --sidebar-bg: #ffffff;
    --text: #1e293b;
    --border: #e2e8f0;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --pink: #ec4899;
    --blue: #0ea5e9;
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
body { background-color: var(--bg); color: var(--text); display: flex; height: 100vh; overflow: hidden; }

sidebar { width: 320px; background: var(--sidebar-bg); border-right: 1px solid var(--border); display: flex; flex-direction: column; height: 100%; z-index: 10; }
.sidebar-header { padding: 15px; border-bottom: 1px solid var(--border); background: linear-gradient(135deg, #1e3a8a, #2563eb); color: white; }
.usb-sync-box { padding: 12px 15px; background: #fffbeb; border-bottom: 1px solid #fef3c7; }
.usb-sync-box h4 { font-size: 11px; color: #b45309; text-transform: uppercase; margin-bottom: 6px; font-weight: bold; }
.sync-buttons { display: flex; gap: 6px; }
.btn-sync { flex: 1; padding: 6px; font-size: 11px; background: white; border: 1px solid #d97706; color: #b45309; font-weight: 600; border-radius: 4px; cursor: pointer; }
.btn-sync.btn-save { background: #d97706; color: white; }

.sidebar-selectors { padding: 10px 15px; display: flex; flex-direction: column; gap: 8px; background: #f1f5f9; border-bottom: 1px solid var(--border); }
.sidebar-selectors label { font-size: 10px; font-weight: 700; color: #475569; }
.sidebar-selectors select { width: 100%; padding: 6px; border-radius: 4px; border: 1px solid var(--border); font-size: 13px; background: white; margin-top: 2px; }

.eleve-list { flex: 1; overflow-y: auto; list-style: none; }
.eleve-item { padding: 10px 15px; border-bottom: 1px solid var(--border); cursor: pointer; display: flex; justify-content: space-between; align-items: center; font-size: 14px; }
.eleve-item:hover { background: #f1f5f9; }
.eleve-item.active { background: #e0f2fe; border-left: 4px solid var(--primary); font-weight: bold; }
.gender-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 6px; }
.gender-F { background-color: var(--pink); }
.gender-M { background-color: var(--blue); }

main { flex: 1; display: flex; flex-direction: column; height: 100%; overflow: hidden; }
header { background: #fff; padding: 15px 20px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.nav-tabs { display: flex; gap: 2px; background: #e2e8f0; padding: 5px 10px 0 10px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.tab-btn { padding: 8px 12px; border: none; background: #f1f5f9; cursor: pointer; font-size: 13px; border-radius: 6px 6px 0 0; color: #475569; font-weight: 500; white-space: nowrap; }
.tab-btn.active { background: #fff; color: var(--primary); font-weight: bold; border-bottom: 2px solid var(--primary); }

.content-view { flex: 1; padding: 20px; overflow-y: auto; display: none; }
.content-view.active { display: block; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }
.card { background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 20px; margin-bottom: 20px; box-shadow: 0 1px 3px rgba(0,0,0,0.05); }
.card h3 { margin-bottom: 15px; font-size: 15px; color: #0f172a; border-bottom: 1px solid #f1f5f9; padding-bottom: 6px; }

/* RECONSTRUCTION GRILLE DU DASHBOARD LIVE */
.student-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 15px; margin-top: 10px; }
.student-card { background: #ffffff; border: 2px solid #e2e8f0; border-radius: 8px; padding: 12px; display: flex; flex-direction: column; justify-content: space-between; min-height: 125px; cursor: pointer; transition: all 0.2s ease; position: relative; box-shadow: 0 2px 4px rgba(0,0,0,0.02); }
.student-card:hover { transform: translateY(-2px); box-shadow: 0 4px 6px rgba(0,0,0,0.06); }

/* Etats Couleur Dynamiques du Jour */
.card-green { border-color: #10b981; background: #f0fdf4; }
.card-orange { border-color: #f59e0b; background: #fffbeb; }
.card-red { border-color: #ef4444; background: #fef2f2; }
.card-absent { border-color: #94a3b8; background: #f1f5f9; opacity: 0.6; }

.card-presence-bar { display: flex; gap: 4px; margin-top: 8px; }
.btn-presence-toggle { flex:1; font-size: 10px; padding: 3px 5px; border-radius: 4px; border: 1px solid var(--border); cursor: pointer; text-align: center; font-weight: bold; background: white; }
.btn-presence-toggle.active-abs { background: #64748b; color: white; border-color: #475569; }
.btn-presence-toggle.active-ret { background: #d97706; color: white; border-color: #b45309; }

.indicators-badge-line { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; min-height: 18px; }
.mini-badge-ind { font-size: 11px; padding: 1px 4px; background: white; border: 1px solid var(--border); border-radius: 4px; }

/* MODALS DESIGN */
.modal { display: none; position: fixed; top:0; left:0; width:100%; height:100%; background: rgba(15,23,42,0.6); z-index: 1000; align-items:center; justify-content:center; }
.modal-content { background: white; padding: 25px; border-radius: 8px; max-height: 90vh; overflow-y:auto; box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1); }
.modal-split { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 15px; }

.btn-toggle-ind-modal { padding: 8px; border: 1px solid var(--border); border-radius: 6px; text-align: left; font-size: 12px; cursor: pointer; background: white; display: flex; justify-content: space-between; align-items: center; font-weight: 500; }
.btn-toggle-ind-modal.selected-neg { background: #fef2f2; border-color: #ef4444; color: #b91c1c; }
.btn-toggle-ind-modal.selected-pos { background: #f0fdf4; border-color: #10b981; color: #15803d; }

/* RESTES DES COMPOSANTS */
.counters-grid { display: grid; grid-template-columns: 1fr; gap: 8px; }
.counter-widget { display: flex; justify-content: space-between; align-items: center; background: #f8fafc; border: 1px solid var(--border); padding: 10px; border-radius: 6px; }
.counter-actions { display: flex; gap: 6px; align-items: center; }
.btn-counter { width: 28px; height: 28px; border: 1px solid var(--border); background: white; font-weight: bold; cursor: pointer; border-radius: 4px; }
.timeline { margin-top: 10px; max-height: 220px; overflow-y: auto; border-left: 2px solid var(--border); padding-left: 15px; }
.timeline-item { position: relative; margin-bottom: 10px; font-size: 12px; color: #334155; }
.flex-form { display: flex; gap: 8px; align-items: center; width: 100%; flex-wrap: wrap; }
input, select, textarea { padding: 8px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; background: white; }
.btn { padding: 8px 14px; border-radius: 6px; border: none; cursor: pointer; font-size: 13px; font-weight: 500; display: inline-flex; align-items: center; gap: 6px; }
.btn-primary { background: var(--primary); color: white; }
.btn-secondary { background: #f1f5f9; color: #475569; }
.btn-danger { background: var(--danger); color: white; }
.btn-success { background: var(--success); color: white; }
.badges-container { display: flex; flex-direction: column; gap: 6px; background: #f8fafc; padding: 10px; border-radius: 6px; border: 1px dashed var(--border); max-height: 300px; overflow-y: auto; }
.csv-badge { background: #e0f2fe; color: #0369a1; border: 1px solid #bae6fd; padding: 8px; border-radius: 4px; font-size: 12px; font-weight: 600; cursor: grab; }
.drop-target-area { background: #f1f5f9; border: 2px dashed #cbd5e1; border-radius: 6px; padding: 12px; min-height: 44px; display: flex; align-items: center; justify-content: center; font-size: 12px; color: #94a3b8; }
.drop-target-area.hover { background: #f0fdf4; border-color: var(--success); color: var(--success); }
tr.draggable-row { cursor: move; }
.drag-handle { color: #94a3b8; font-weight: bold; padding-right: 10px; cursor: move; }
.config-list { list-style: none; margin-top: 10px; max-height: 150px; overflow-y: auto; }
.config-list li { display: flex; justify-content: space-between; padding: 6px; border-bottom: 1px solid var(--border); font-size: 13px; align-items: center; }
.seating-area { position: relative; width: 100%; height: 480px; background: #cbd5e1; border-radius: 8px; overflow: hidden; background-image: radial-gradient(#94a3b8 1px, transparent 1px); background-size: 16px 16px; margin-top: 10px; }
.seating-desk {
    position: absolute !important; /* Force le navigateur à utiliser les coordonnées X et Y du script */
    width: 100px;
    height: 60px;
    border: 1px solid #94a3b8;
    border-radius: 6px;
    background-color: #ffffff;
    padding: 4px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    cursor: move;
    box-sizing: border-box;
    transition: background-color 0.2s;
}
.teacher-desk { background: #475569; color: white; text-align: center; padding: 6px; border-radius: 4px; font-weight: bold; font-size: 12px; }
.groups-wrapper { display: flex; flex-wrap: wrap; gap: 15px; margin-top: 15px; }
.group-card { background: white; border: 1px solid var(--border); border-radius: 6px; width: calc(25% - 12px); padding: 12px; }
.picker-box { background: linear-gradient(135deg, #f1f5f9, #e2e8f0); border: 1px solid var(--border); border-radius: 8px; padding: 25px; text-align: center; font-size: 24px; font-weight: bold; min-height: 90px; display: flex; justify-content: center; align-items: center; margin-bottom: 15px; }
.tbi-timer-box { background: #0f172a; color: #14b8a6; padding: 20px; border-radius: 8px; text-align: center; font-family: monospace; font-size: 48px; font-weight: bold; margin-bottom: 15px; border: 2px solid #14b8a6; }
table { width: 100%; border-collapse: collapse; margin-top: 10px; }
th, td { border: 1px solid var(--border); padding: 8px 10px; text-align: left; font-size: 12px; }
th { background-color: #f8fafc; color: #475569; }
/* --- GRADUATION DES COULEURS DU DASHBOARD --- */

/* 1 indicateur : Avertissement (Jaune / Ambre) */
.student-card.card-avertissement {
    background-color: #fef08a; /* Jaune clair */
    border-left: 6px solid #eab308;
    color: #854d0e;
}

/* 2 indicateurs : Observation Carnet (Orange) */
.student-card.card-observation {
    background-color: #fed7aa; /* Orange clair */
    border-left: 6px solid #f97316;
    color: #c2410c;
}

/* 3 indicateurs : Punition (Rouge clair / Rose) */
.student-card.card-punition {
    background-color: #fecdd3; /* Rose/Rouge très clair */
    border-left: 6px solid #f43f5e;
    color: #9f1239;
}

/* 4 indicateurs : Retenue (Rouge vif) */
.student-card.card-retenue {
    background-color: #fee2e2; /* Rouge alerte */
    border-left: 6px solid #dc2626;
    color: #991b1b;
    animation: pulse-border 2s infinite; /* Optionnel : fait clignoter légèrement la carte */
}

/* 5 indicateurs et plus : Exclusion (Violet foncé / Sombre) */
.student-card.card-exclusion {
    background-color: #f3e8ff; /* Violet */
    border-left: 6px solid #7c3aed;
    color: #6b21a8;
    font-weight: bold;
}

/* Style pour le petit texte de la sanction sur la carte */
.sanction-text-badge {
    font-size: 11px;
    font-weight: bold;
    margin-top: 5px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

@keyframes pulse-border {
    0% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.4); }
    70% { box-shadow: 0 0 0 6px rgba(220, 38, 38, 0); }
    100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0); }
}