/* CarSchool : theme clair unique, pas de mode sombre. */
:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e3e8f0;
  --primary: #2f6fed;
  --primary-soft: #e8f0fe;
  --primary-text: #ffffff;
  --success-bg: #e6f6ec;
  --success-text: #1b6b3a;
  --warn-bg: #fff4d6;
  --warn-text: #8a5a00;
  --error-bg: #fde8e8;
  --error-text: #a12626;
  --field-bg: #ffffff;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  padding-bottom: env(safe-area-inset-bottom);
}

h1 { font-size: 1.35rem; margin: 0 0 .75rem; }
h2 { font-size: 1.1rem; margin: 1rem 0 .5rem; }
h3 { font-size: 1rem; margin: 1rem 0 .5rem; }
p { margin: 0 0 .75rem; }
a { color: var(--primary); }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
small { font-weight: 400; }
ul.plain { margin: 0; padding-left: 1.1rem; }

/* --- En-tete --- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  padding: .65rem 1rem;
  padding-top: calc(.65rem + env(safe-area-inset-top));
  background: var(--card);
  border-bottom: 1px solid var(--border);
}
.brand { color: var(--primary); text-decoration: none; font-weight: 800; font-size: 1.1rem; letter-spacing: -.01em; }
.topbar-user { color: var(--text); text-decoration: none; font-size: .92rem; font-weight: 600; }
form.inline { display: inline; margin: 0; }
button.link {
  background: none; border: 0; padding: 0; color: inherit;
  font: inherit; cursor: pointer;
}
button.link:hover { text-decoration: underline; }

/* --- Navigation basse --- */
body.has-nav { padding-bottom: calc(66px + env(safe-area-inset-bottom)); }
.bottomnav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: flex;
  background: var(--card);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 10;
}
.bottomnav a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: .5rem 0 .45rem;
  font-size: .72rem;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
}
.bottomnav a.active { color: var(--primary); }
.bottomnav .ico { font-size: 1.25rem; line-height: 1; }

/* --- Mise en page --- */
.container {
  max-width: 640px;
  margin: 0 auto;
  padding: 1rem .9rem 2rem;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}
.auth-card { margin-top: 1.5rem; }
.auth-card h1 { text-align: center; }
.auth-card .muted { text-align: center; }
.card-danger { border-color: #f3c2c2; }

.page-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .75rem; }
.page-head h1 { margin: 0; }

/* --- Formulaires --- */
.stack { display: flex; flex-direction: column; gap: .85rem; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
label { display: flex; flex-direction: column; gap: .3rem; font-weight: 600; font-size: .92rem; }
input[type="text"], input[type="password"], input[type="number"], input[type="time"],
input[type="date"], select, textarea {
  width: 100%;
  font: inherit;
  padding: .65rem .75rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--field-bg);
  color: var(--text);
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
  border-color: var(--primary);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: .6rem 1rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  box-shadow: var(--shadow);
}
.btn:hover { border-color: #c9d3e3; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.btn-primary:hover { background: #2559c9; border-color: #2559c9; }
.btn-sm { min-height: 36px; padding: .35rem .7rem; font-size: .88rem; }
.btn-danger { background: var(--error-bg); color: var(--error-text); border-color: transparent; }
.actions { display: flex; gap: .6rem; justify-content: flex-end; flex-wrap: wrap; }
.actions-start { justify-content: flex-start; }
.stack > .btn { width: 100%; }

.choice-group { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: .5rem; }
.choice-group legend { font-weight: 600; font-size: .92rem; margin-bottom: .35rem; padding: 0; width: 100%; }
.choice {
  flex-direction: row; align-items: center; gap: .45rem;
  padding: .5rem .8rem; border: 1px solid var(--border); border-radius: 10px;
  font-weight: 500; cursor: pointer; background: var(--field-bg);
}
.choice:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.choice input { margin: 0; accent-color: var(--primary); }

/* --- Messages --- */
.flash {
  padding: .7rem .9rem;
  border-radius: 10px;
  margin-bottom: 1rem;
  font-size: .95rem;
}
.flash-success { background: var(--success-bg); color: var(--success-text); }
.flash-error { background: var(--error-bg); color: var(--error-text); }

/* --- Listes --- */
.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .5rem; }
.list-item {
  display: flex; align-items: center; gap: .6rem;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: .75rem .9rem;
  box-shadow: var(--shadow);
}
.list-main { flex: 1; min-width: 0; }
.list-title { font-weight: 600; display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.list-sub { font-size: .88rem; color: var(--muted); margin-top: .15rem; }

.badge {
  display: inline-block; font-size: .7rem; font-weight: 700; text-transform: uppercase;
  padding: .1rem .5rem; border-radius: 999px; background: #eef1f6; color: var(--muted);
  letter-spacing: .02em;
}
.badge-admin, .badge-week { background: var(--primary); color: var(--primary-text); }
.badge-college { background: #fff0d6; color: #8a5a00; }
.badge-lycee { background: #e3edff; color: #1e4bb8; }
.badge-warn, .badge-exc { background: var(--warn-bg); color: var(--warn-text); }
.badge-today { background: var(--success-bg); color: var(--success-text); }

/* --- Grille horaire --- */
.week-block { margin-bottom: .5rem; }
.week-block-head { display: flex; align-items: center; justify-content: space-between; }
.week-block-head h2 { margin: .5rem 0; }
table.grid { width: 100%; border-collapse: collapse; }
table.grid th { text-align: left; font-size: .88rem; font-weight: 600; padding: .3rem .25rem; }
table.grid td { padding: .2rem .25rem; }
table.grid input[type="time"] { padding: .45rem .5rem; }

/* --- Planning --- */
.week-nav { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .5rem; }
.week-title { text-align: center; font-weight: 700; line-height: 1.3; }
.week-title > div:last-child { margin-top: .2rem; display: flex; gap: .3rem; justify-content: center; flex-wrap: wrap; }
.week-actions { display: flex; gap: .4rem; flex-wrap: wrap; justify-content: center; margin-bottom: 1rem; }

.day { padding: .9rem; }
.day-today { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.day-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .5rem; }
.day-head h2 { margin: 0; display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }

.trip {
  border: 1px solid var(--border);
  border-left: 4px solid var(--muted);
  border-radius: 10px;
  padding: .6rem .7rem;
  margin-bottom: .55rem;
  background: #fbfcfe;
}
.trip-ok { border-left-color: #22a35a; }
.trip-missing { border-left-color: #e04848; }
.trip-short { border-left-color: #e9a10a; }
.trip-orphan { border-left-color: #b8c0cc; }
.trip-head { display: flex; align-items: center; justify-content: space-between; gap: .4rem; flex-wrap: wrap; }
.trip-time { font-size: 1.02rem; }
.pill { font-size: .75rem; font-weight: 700; padding: .15rem .55rem; border-radius: 999px; white-space: nowrap; }
.pill-ok { background: var(--success-bg); color: var(--success-text); }
.pill-missing { background: var(--error-bg); color: var(--error-text); }
.pill-short { background: var(--warn-bg); color: var(--warn-text); }
.pill-orphan { background: #eef1f6; color: var(--muted); }

.chips { display: flex; flex-wrap: wrap; gap: .3rem; align-items: center; margin: .45rem 0; }
.chip { font-size: .85rem; font-weight: 600; padding: .15rem .55rem; border-radius: 999px; }
.chip-college { background: #fff0d6; color: #8a5a00; }
.chip-lycee { background: #e3edff; color: #1e4bb8; }

.drivers { display: flex; flex-direction: column; gap: .25rem; margin: .3rem 0 .5rem; font-size: .95rem; }
.driver { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin: 0; }
.driver button.link { color: var(--muted); font-size: 1rem; padding: .2rem .4rem; }
.trip-actions { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; }
.trip-actions select { width: auto; min-height: 36px; padding: .3rem .5rem; font-size: .88rem; }
.skipped { font-size: .9rem; margin-top: .4rem; display: flex; flex-direction: column; gap: .2rem; }

/* --- Calendrier --- */
.cal-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: .6rem;
}
table.cal { border-collapse: separate; border-spacing: 0; min-width: 100%; font-size: .82rem; }
table.cal th, table.cal td { padding: .45rem .4rem; border-bottom: 1px solid var(--border); text-align: center; vertical-align: top; }
table.cal thead th { font-weight: 700; background: #f8fafd; position: sticky; top: 0; }
table.cal tbody tr:last-child th, table.cal tbody tr:last-child td { border-bottom: 0; }
table.cal .cal-name {
  text-align: left;
  position: sticky;
  left: 0;
  background: var(--card);
  z-index: 1;
  font-weight: 700;
  white-space: nowrap;
  border-right: 1px solid var(--border);
}
table.cal .cal-name a { color: var(--text); text-decoration: none; }
table.cal .cal-name .badge { display: block; width: max-content; margin-top: .15rem; }
table.cal thead .cal-name { z-index: 2; background: #f8fafd; }
table.cal .cal-today { background: var(--primary-soft); }
.cal-cell { min-width: 64px; position: relative; }
.cal-time { white-space: nowrap; line-height: 1.35; }
.cal-exc { background: var(--warn-bg); }
.cal-off { background: #f1f3f7; color: var(--muted); }
.cal-off-label { font-size: .72rem; font-weight: 600; }
.cal-exc-mark { font-size: .7rem; line-height: 1; margin-top: .15rem; }
