/* PointageEtu — feuille de style */
:root {
    --primary: #2f5bea;
    --primary-dark: #2346c0;
    --bg: #f3f5f9;
    --panel: #ffffff;
    --text: #1d2433;
    --muted: #6b7385;
    --border: #e1e5ee;
    --ok: #15803d;
    --ok-bg: #dcfce7;
    --late: #b45309;
    --late-bg: #fef3c7;
    --bad: #b91c1c;
    --bad-bg: #fee2e2;
    --info-bg: #e0e7ff;
    --side: #151b2e;
    --radius: 10px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body { font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif; background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.45; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; }
h2 { font-size: 1.1rem; }
code { background: #eef1f7; padding: 1px 6px; border-radius: 4px; font-size: .9em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

/* ---------- Mise en page ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar { width: 235px; background: var(--side); color: #cbd2e6; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; flex-shrink: 0; }
.brand { font-weight: 700; font-size: 1.2rem; color: #fff; padding: 20px 20px 14px; letter-spacing: .3px; }
.brand-mark { color: #7c9bff; margin-right: 4px; }
.sidebar nav { display: flex; flex-direction: column; padding: 6px 10px; gap: 2px; flex: 1; overflow-y: auto; }
.sidebar nav a { color: #cbd2e6; padding: 10px 12px; border-radius: 8px; }
.sidebar nav a:hover { background: rgba(255,255,255,.07); text-decoration: none; }
.sidebar nav a.active { background: var(--primary); color: #fff; }
.sidebar-foot { padding: 14px 20px 18px; border-top: 1px solid rgba(255,255,255,.1); display: flex; flex-direction: column; gap: 6px; font-size: .9rem; }
.sidebar-foot a { color: #9fb0d8; }
.who { color: #fff; font-weight: 600; display: flex; flex-direction: column; }
.who small { color: #8d99b8; font-weight: 400; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 18px 28px 6px; }
.topbar h1 { font-size: 1.5rem; }
.menu-btn { display: none; background: none; border: 0; font-size: 1.5rem; cursor: pointer; color: var(--text); }
.content { padding: 12px 28px 28px; flex: 1; }
.footer { padding: 14px 28px; color: var(--muted); font-size: .8rem; border-top: 1px solid var(--border); }

/* ---------- Blocs ---------- */
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 18px; }
.panel.narrow { max-width: 760px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.empty { color: var(--muted); padding: 10px 0; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 18px; }
.cards.small { margin-bottom: 14px; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }
.stat { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; display: flex; flex-direction: column; }
.stat-num { font-size: 1.9rem; font-weight: 700; color: var(--primary); line-height: 1.1; }
.stat-label { color: var(--muted); font-size: .85rem; margin-top: 4px; }

/* ---------- Tableaux ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); background: #f8f9fc; white-space: nowrap; }
tbody tr:hover { background: #fafbfe; }
td.actions { white-space: nowrap; text-align: right; }
td.actions form.inline { display: inline; }
tr.row-alert td { background: #fff5f5; }
.bar { height: 6px; background: #e8ebf3; border-radius: 4px; overflow: hidden; width: 90px; margin-bottom: 3px; }
.bar span { display: block; height: 100%; background: var(--primary); }
.row-alert .bar span { background: #dc2626; }

/* ---------- Formulaires ---------- */
label { display: flex; flex-direction: column; gap: 5px; font-size: .86rem; font-weight: 600; color: #384159; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=time], input[type=search], input[type=file], select, input:not([type]) {
    font: inherit; padding: 9px 11px; border: 1px solid #c9d0df; border-radius: 8px; background: #fff; color: var(--text); width: 100%;
}
input:focus, select:focus { outline: 2px solid rgba(47,91,234,.35); border-color: var(--primary); }
input:disabled { background: #f1f3f8; color: var(--muted); }
label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 500; }
label.check input { width: auto; }
.form-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.form-row label { min-width: 150px; }
.form-row label.grow { flex: 1; min-width: 220px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.filters select, .filters input { width: auto; min-width: 150px; }
.inline-filter select { width: auto; }
form.inline { display: inline; }

.btn { display: inline-block; font: inherit; font-weight: 600; font-size: .9rem; padding: 9px 15px; border-radius: 8px; border: 1px solid #c9d0df; background: #fff; color: var(--text); cursor: pointer; text-decoration: none; }
.btn:hover { background: #f1f4fb; text-decoration: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { color: var(--bad); border-color: #f0b4b4; }
.btn-danger:hover { background: var(--bad-bg); }
.btn-sm { padding: 5px 10px; font-size: .8rem; }
.btn-block { width: 100%; margin-top: 6px; padding: 11px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.alert { padding: 11px 14px; border-radius: 8px; margin-bottom: 14px; font-size: .92rem; }
.alert-success { background: var(--ok-bg); color: #14532d; }
.alert-error { background: var(--bad-bg); color: #7f1d1d; }
.alert-info { background: var(--info-bg); color: #1e3a8a; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .75rem; font-weight: 700; }
.badge-present { background: var(--ok-bg); color: var(--ok); }
.badge-retard { background: var(--late-bg); color: var(--late); }
.badge-justifie { background: var(--info-bg); color: #3730a3; }
.badge-absent { background: var(--bad-bg); color: var(--bad); }
select.sel-present { border-color: #86d9a3; background: #f0fdf4; }
select.sel-retard { border-color: #f3c97a; background: #fffbeb; }
select.sel-justifie { border-color: #a5b4fc; background: #eef2ff; }

.pagination { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 14px; }
.pagination a { padding: 5px 11px; border: 1px solid var(--border); border-radius: 6px; color: var(--text); }
.pagination a.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ---------- Connexion / installation ---------- */
.auth-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; background: linear-gradient(135deg, #151b2e, #2f5bea); }
.auth-card { background: #fff; border-radius: 14px; padding: 30px 30px 26px; width: 100%; max-width: 420px; box-shadow: 0 20px 50px rgba(0,0,0,.3); }
.auth-card form { display: flex; flex-direction: column; gap: 14px; margin-top: 14px; }
.auth-brand { color: var(--side); padding: 0 0 10px; }
.auth-card h2 { font-size: 1.3rem; margin-bottom: 4px; }

/* ---------- Scanner ---------- */
.scan-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 18px; margin-bottom: 18px; }
.scan-counter { font-size: 1.3rem; font-weight: 700; color: var(--primary); }
.scan-grid { display: grid; grid-template-columns: 1.1fr 1fr; gap: 18px; align-items: start; }
.video-box { position: relative; background: #0b1020; border-radius: var(--radius); overflow: hidden; aspect-ratio: 4 / 3; display: flex; align-items: center; justify-content: center; }
.video-box video { width: 100%; height: 100%; object-fit: cover; }
.video-frame { position: absolute; inset: 18% 18%; border: 3px solid rgba(255,255,255,.85); border-radius: 14px; pointer-events: none; box-shadow: 0 0 0 999px rgba(0,0,0,.25); display: none; }
.video-box.live .video-frame { display: block; }
.video-hint { position: absolute; color: #cbd2e6; text-align: center; padding: 20px; font-size: .95rem; }
.video-box.live .video-hint { display: none; }
.manual { display: flex; gap: 8px; align-items: flex-end; margin-top: 14px; }
.manual label { flex: 1; }
.result { border-radius: var(--radius); padding: 18px; font-size: 1.05rem; margin-bottom: 16px; text-align: center; font-weight: 600; transition: background .2s; }
.result .r-big { display: block; font-size: 1.35rem; }
.result .r-sub { display: block; font-size: .9rem; font-weight: 500; opacity: .85; margin-top: 3px; }
.result.idle { background: #eef1f7; color: var(--muted); }
.result.ok { background: var(--ok-bg); color: #14532d; }
.result.late { background: var(--late-bg); color: #78350f; }
.result.warn { background: var(--info-bg); color: #1e3a8a; }
.result.error { background: var(--bad-bg); color: #7f1d1d; }
.recent { list-style: none; margin: 0 0 14px; padding: 0; max-height: 380px; overflow-y: auto; }
.recent li { display: flex; align-items: center; gap: 10px; padding: 8px 4px; border-bottom: 1px solid var(--border); }
.recent .r-time { color: var(--muted); font-variant-numeric: tabular-nums; width: 46px; }
.recent .r-name { flex: 1; }
.recent .r-name small { color: var(--muted); margin-left: 4px; }

/* ---------- Cartes étudiants ---------- */
.cards-print { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 16px; }
.id-card { background: #fff; border: 2px solid var(--side); border-radius: 14px; overflow: hidden; break-inside: avoid; page-break-inside: avoid; }
.id-head { background: var(--side); color: #fff; padding: 8px 14px; font-weight: 700; }
.id-body { display: flex; gap: 14px; padding: 14px; align-items: center; }
.id-qr svg { display: block; border: 1px solid var(--border); }
.id-info { flex: 1; min-width: 0; }
.id-name { font-size: 1.15rem; margin-bottom: 8px; line-height: 1.25; }
.id-line { font-size: .9rem; color: #384159; }
.id-foot { background: #f3f5f9; text-align: center; font-size: .75rem; color: var(--muted); padding: 5px; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
    .sidebar { position: fixed; left: -260px; top: 0; z-index: 50; transition: left .2s; }
    .sidebar.open { left: 0; box-shadow: 0 0 40px rgba(0,0,0,.4); }
    .menu-btn { display: block; }
    .topbar, .content { padding-left: 16px; padding-right: 16px; }
    .scan-grid { grid-template-columns: 1fr; }
    .form-grid { grid-template-columns: 1fr; }
}

/* ---------- Impression ---------- */
@media print {
    body { background: #fff; }
    .sidebar, .topbar, .footer, .no-print, .menu-btn, .actions, .filters, .form-row { display: none !important; }
    .layout, .main { display: block; }
    .content { padding: 0; }
    .panel { border: 0; padding: 0; }
    .cards-print { grid-template-columns: 1fr 1fr; gap: 10px; }
    .id-card { border-color: #000; }
}
