/* ===== Chrono conduite — feuille de style ===== */
:root {
  --bg: #f3f5f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e3e8ef;
  --text: #0f172a;
  --muted: #64748b;
  --primary: #2563eb;
  --primary-soft: #e8efff;
  --success: #16a34a;
  --success-soft: #dcfce7;
  --success-text: #166534;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 4px 16px rgba(15, 23, 42, .06);
  --radius: 14px;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "Segoe UI Mono", Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1018; --surface: #131a25; --surface-2: #18212e; --border: #243041;
    --text: #e6ebf2; --muted: #8b98ab; --primary: #4f8cff; --primary-soft: #1a2a48;
    --success: #22c55e; --success-soft: #11331f; --success-text: #6ee7a0;
    --danger: #ef4444; --danger-soft: #3a1518;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
  }
}

* { box-sizing: border-box; }
body {
  margin: 0; background: transparent; color: var(--text); min-height: 100vh;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif; font-size: 15px; line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }

/* ----- Fond d'écran (fixe, aussi sur mobile) ----- */
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1;
  background:
    linear-gradient(var(--veil), var(--veil)),
    url("fondchronoconduite.jpg") center bottom / cover no-repeat;
}
:root { --veil: rgba(243, 245, 249, .25); }
@media (prefers-color-scheme: dark) { :root { --veil: rgba(11, 16, 24, .55); } }

/* Textes posés directement sur le fond : panneau translucide pour la lisibilité */
.page-head, .legend, .msg:not(:empty) {
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  border: 1px solid var(--border); border-radius: var(--radius);
}
.page-head { padding: 14px 18px; }
.legend { padding: 8px 14px; width: fit-content; margin-left: auto; margin-right: auto; }
.msg:not(:empty) { padding: 10px 14px; }
.page-head .legend { background: none; border: 0; padding: 0; backdrop-filter: none; margin: 0; }
.empty { background: var(--surface); border-radius: var(--radius); border: 1px solid var(--border); }
html { background: var(--bg); }
.muted { color: var(--muted); }

/* ----- Barre du haut ----- */
.appbar { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; }
.appbar-in { max-width: 820px; margin: 0 auto; padding: 0 16px; height: 58px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.wide .appbar-in, .wide main { max-width: 1120px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.05rem; letter-spacing: -.01em; }
.brand svg { width: 28px; height: 28px; color: var(--primary); }
.nav-right { display: flex; align-items: center; gap: 8px; }
.logout { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 9px; color: var(--muted); border: 1px solid var(--border); }
.logout:hover { color: var(--danger); }
.logout svg { width: 18px; height: 18px; }
.tabs { display: flex; gap: 4px; background: var(--surface-2); border: 1px solid var(--border); padding: 3px; border-radius: 10px; }
.tabs a { padding: 6px 14px; border-radius: 7px; color: var(--muted); text-decoration: none; font-weight: 600; font-size: .9rem; }
.tabs a.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.08); }

main { max-width: 820px; margin: 0 auto; padding: 22px 16px 48px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 1.45rem; letter-spacing: -.02em; }
.page-head .sub { color: var(--muted); text-transform: capitalize; margin-top: 2px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 20px; }

/* ----- Boutons ----- */
button, .btn {
  font: inherit; font-weight: 600; border: 1px solid transparent; border-radius: 10px; cursor: pointer;
  padding: 10px 16px; color: #fff; background: var(--primary); text-decoration: none; display: inline-flex;
  align-items: center; justify-content: center; gap: 6px; transition: filter .15s, opacity .15s, transform .05s;
}
button:hover:not(:disabled), .btn:hover { filter: brightness(1.08); }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: .3; cursor: default; }
.go { background: var(--success); }
.stop { background: var(--danger); }
.ghost, .secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.danger-ghost { background: var(--surface); color: var(--danger); border-color: var(--border); }
.primary { width: 100%; margin-top: 22px; font-size: 1.05rem; padding: 13px; }

/* ----- Page de départ ----- */
.setup { max-width: 480px; margin: 8px auto 0; }
.setup-card { overflow: hidden; }
.setup-hero {
  position: relative; text-align: center; color: #fff; padding: 30px 24px 28px;
  background:
    radial-gradient(circle at 85% 0%, rgba(255,255,255,.18), transparent 45%),
    linear-gradient(135deg, #1d4ed8 0%, #4f46e5 60%, #7c3aed 100%);
}
.hero-icon {
  width: 60px; height: 60px; margin: 0 auto 14px; border-radius: 18px; display: grid; place-items: center;
  background: rgba(255,255,255,.16); border: 1px solid rgba(255,255,255,.28); backdrop-filter: blur(4px);
}
.hero-icon svg { width: 34px; height: 34px; }
.setup-hero h2 { margin: 0; font-size: 1.5rem; letter-spacing: -.02em; }
.setup-hero p { margin: 6px 0 0; opacity: .85; font-size: .95rem; }
.setup-form { padding: 8px 24px 24px; }
.field { margin-top: 18px; }
.field label { margin: 0 0 8px; text-transform: uppercase; letter-spacing: .06em; font-size: .72rem; font-weight: 700; }
.input-icon { position: relative; }
.input-icon svg { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--muted); pointer-events: none; }
.setup-form .input-icon input { padding-left: 42px; }
/* Pastille numérotée à côté du champ (et non dessus) */
.student-input { display: flex; align-items: center; gap: 12px; }
.student-input + .student-input { margin-top: 10px; }
.student-input .num { width: 32px; height: 32px; font-size: .9rem; }
.student-input input { flex: 1; min-width: 0; }
.setup-form .primary { margin-top: 24px; padding: 14px; font-size: 1.05rem; border-radius: 12px;
  background: linear-gradient(135deg, #1d4ed8, #4f46e5); box-shadow: 0 6px 18px rgba(37, 99, 235, .3); }
.setup-note { display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 14px; color: var(--muted); font-size: .85rem; }
label { display: block; font-weight: 600; font-size: .85rem; margin: 16px 0 6px; color: var(--muted); }
input[type=text], input[type=date], input[type=password] {
  width: 100%; font: inherit; font-size: 1rem; padding: 11px 12px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text); outline: none;
}
input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }

/* ----- Numéro d'élève ----- */
.num {
  flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  background: var(--primary-soft); color: var(--primary); font-weight: 700; font-size: .85rem;
}
.done .num { background: var(--success); color: #fff; }

/* ----- Barre de progression vers 1h45 ----- */
.bar { height: 4px; border-radius: 4px; background: var(--border); overflow: hidden; margin-top: 6px; }
.bar span { display: block; height: 100%; width: 0; background: var(--primary); border-radius: 4px; transition: width .3s; }
.done .bar span { background: var(--success); }

/* ----- Lignes élèves (chrono) ----- */
.students { padding: 6px; }
.srow {
  display: grid; grid-template-columns: minmax(0, 1fr) auto auto auto; gap: 14px; align-items: center;
  padding: 12px 14px; border-radius: 10px; transition: background .3s;
}
.srow + .srow { margin-top: 2px; }
.srow.done { background: var(--success-soft); }
.srow.active { box-shadow: inset 3px 0 0 var(--success); }
.who { display: flex; align-items: center; gap: 12px; min-width: 0; }
.info { min-width: 0; flex: 1; }
.nm { font-weight: 650; font-size: 1.02rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.live { display: none; font-size: .7rem; font-weight: 700; color: var(--success); text-transform: uppercase; letter-spacing: .05em; margin-left: 6px; }
.active .live { display: inline; }
.stat { text-align: right; }
.k { display: block; font-size: .68rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.v { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 1.15rem; }
.cum .v { font-weight: 700; }
.done .cum .v { color: var(--success-text); }
.btns { display: flex; gap: 6px; }
.btns button { min-width: 62px; }

/* ----- Totaux ----- */
.totals { margin-top: 14px; display: grid; grid-template-columns: 1.4fr 1fr 1fr; }
.totals > div { padding: 16px 20px; }
.totals > div + div { border-left: 1px solid var(--border); }
.totals .v { font-size: 1.2rem; }
.totals .main .v { font-size: 1.9rem; font-weight: 700; color: var(--primary); }

.actions { margin-top: 14px; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.actions button { font-size: 1.05rem; padding: 14px; }
.footer { margin-top: 14px; display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.footer .secondary { font-size: .9rem; padding: 8px 14px; }
.legend { display: flex; align-items: center; gap: 8px; justify-content: center; color: var(--muted); font-size: .85rem; margin-top: 16px; }
.legend i { width: 14px; height: 14px; border-radius: 4px; background: var(--success-soft); border: 1px solid var(--success); display: inline-block; }

.msg { margin-top: 12px; font-weight: 600; text-align: center; }
.msg:empty { display: none; }
.msg.err { color: var(--danger); }
.msg.ok { color: var(--success); }

/* ----- Archives ----- */
.arch-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 18px; }
.acard { display: flex; flex-direction: column; overflow: hidden; }
.acard.editing { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft), var(--shadow); }
.ahead { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 16px 18px 12px; }
.adate { font-weight: 700; font-size: 1.05rem; text-transform: capitalize; }
.ahours { text-align: right; font-family: var(--mono); font-size: .95rem; white-space: nowrap; }
.ahours small { display: block; color: var(--muted); font-size: .78rem; margin-top: 2px; }
.alist { list-style: none; margin: 0; padding: 0 8px; }
.alist li { display: flex; align-items: center; gap: 12px; padding: 10px 10px; border-radius: 10px; }
.alist li + li { margin-top: 2px; }
.alist li.done { background: var(--success-soft); }
.alist .info { min-width: 0; }
.alist .v { font-size: 1.05rem; margin-left: auto; }
.alist .done .v { color: var(--success-text); font-weight: 700; }
.alist li.edit { display: grid; grid-template-columns: 28px 1fr 120px; }
.alist li.edit input { padding: 8px 10px; font-size: .95rem; }
.atotal {
  display: flex; justify-content: space-between; align-items: center; margin: 10px 18px 0; padding: 12px 0;
  border-top: 1px solid var(--border);
}
.atotal span { font-weight: 600; color: var(--muted); }
.atotal strong { font-family: var(--mono); font-size: 1.25rem; color: var(--primary); }
.afoot { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 12px 18px 18px; margin-top: auto; }
.afoot button { padding: 9px; font-size: .92rem; }
.acard.editing .ahead input { max-width: 190px; padding: 8px 10px; }
.ehours { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 0 18px 12px; }
input[type=time] {
  width: 100%; font: inherit; font-size: .95rem; padding: 8px 10px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text); outline: none;
}
.empty { grid-column: 1 / -1; text-align: center; color: var(--muted); padding: 48px 20px; }

/* ----- Mobile ----- */
@media (max-width: 600px) {
  body { font-size: 14px; }
  main { padding: 14px 10px 36px; }
  .appbar-in { padding: 0 10px; height: 52px; }
  .brand span { display: none; }
  .students { padding: 4px; }
  /* Ligne 1 : numéro + nom + progression ; ligne 2 : en cours | Go Stop | cumul */
  .srow { grid-template-columns: auto 1fr auto; gap: 8px 10px; padding: 10px 8px; }
  .srow .who { grid-column: 1 / -1; }
  .srow .stat:not(.cum) { text-align: left; }
  .srow .btns { justify-self: center; }
  .who { gap: 8px; }
  .num { width: 22px; height: 22px; font-size: .72rem; }
  .nm { font-size: 1rem; white-space: normal; overflow-wrap: anywhere; }
  .k { font-size: .58rem; }
  .v { font-size: .92rem; }
  .btns { gap: 4px; }
  .btns button { min-width: 0; padding: 9px 9px; font-size: .85rem; }
  .totals { grid-template-columns: 1fr 1fr; }
  .totals .main { grid-column: 1 / -1; border-bottom: 1px solid var(--border); }
  .totals > div { padding: 12px 14px; }
  .totals > div + div { border-left: 0; }
  .totals > div:last-child { border-left: 1px solid var(--border); }
  .totals .main .v { font-size: 1.6rem; }
  .arch-list { grid-template-columns: 1fr; }
}
