/* BusPlay by iiker — espace exploitant.
   Memes couleurs que l'interface embarquee, pour que l'exploitant retrouve ses
   reperes en passant du portail au vehicule. */

:root {
  --bg: #070a12;
  --surface: #0e1420;
  --surface-2: #141c2b;
  --line: #1f2a3d;
  --text: #f2f5fa;
  --muted: #8f9cb3;
  --accent: #ffa62b;
  --accent-ink: #1a1205;
  --ok: #3ecf8e;
  --warn: #ffb340;
  --bad: #ff5c5c;
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
}

[hidden] { display: none !important; }

a { color: var(--accent); }

/* ---------- amorçage ---------- */

.boot {
  min-height: 100vh;
  display: grid;
  place-items: center;
  gap: 18px;
  color: var(--muted);
}

/* La marque n'est jamais posee sur une pastille en degrade : une seule
   couleur, pour qu'elle survive a une photocopie et a une serigraphie. */
.brand-mark {
  color: var(--accent);
  display: inline-flex;
  line-height: 0;
}

/* Le titre porte deja 16 px de marge haute : en ajouter ici creuserait un trou. */
.login-card .brand-mark { margin-bottom: 2px; }

/* ---------- connexion ---------- */

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(100%, 380px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 30px 26px;
}

.login-card h1 {
  font-size: 20px;
  margin: 16px 0 4px;
  letter-spacing: -0.02em;
}

.login-card .sub {
  color: var(--muted);
  font-size: 14px;
  margin: 0 0 24px;
}

.field { margin-bottom: 14px; }

.field label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
}

input[type="email"],
input[type="password"],
input[type="text"] {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
}

input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.btn {
  border: 0;
  border-radius: 999px;
  padding: 12px 22px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  background: var(--surface-2);
  color: var(--text);
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
}

.btn-block { width: 100%; }

.btn:disabled { opacity: 0.55; cursor: default; }

.error {
  color: var(--bad);
  font-size: 14px;
  margin: 12px 0 0;
  min-height: 1.2em;
}

/* ---------- coque ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 20px;
  background: rgba(7, 10, 18, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand .brand-mark { margin-right: 2px; }

.brand small {
  color: var(--muted);
  font-weight: 500;
}

.spacer { flex: 1; }

.who {
  color: var(--muted);
  font-size: 13px;
  text-align: right;
  line-height: 1.3;
}

.who b { color: var(--text); display: block; font-weight: 600; }

main { padding: 22px 20px 60px; max-width: 1100px; margin: 0 auto; }

h2 { font-size: 18px; margin: 0 0 4px; letter-spacing: -0.02em; }

.section-sub { color: var(--muted); font-size: 14px; margin: 0 0 20px; }

/* ---------- cartes ---------- */

.cards {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  text-align: left;
  font: inherit;
  color: inherit;
  cursor: pointer;
  display: block;
  width: 100%;
}

.card:hover { border-color: #2c3a52; }

.card h3 { margin: 0 0 3px; font-size: 16px; }

.card .meta { color: var(--muted); font-size: 13px; }

/* ---------- etat d'un vehicule ---------- */

.bus-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  margin-bottom: 10px;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--muted);
}

.dot.ok { background: var(--ok); }
.dot.warn { background: var(--warn); }
.dot.bad { background: var(--bad); }

.bus-id { font-weight: 600; }

.bus-meta { color: var(--muted); font-size: 13px; }

.pill {
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  white-space: nowrap;
}

.pill.warn { background: rgba(255, 179, 64, 0.14); color: var(--warn); }
.pill.bad { background: rgba(255, 92, 92, 0.14); color: var(--bad); }

.empty {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 40px 24px;
  text-align: center;
  color: var(--muted);
}

@media (max-width: 640px) {
  main { padding: 18px 14px 48px; }
  .topbar { padding: 10px 14px; }
  .bus-row { flex-wrap: wrap; }
}

/* ---------- administration : listes, onglets, formulaires ---------- */

.page-head {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}

.page-head .btn { margin-left: auto; }

.back {
  display: inline-block;
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
  margin-bottom: 16px;
}

.back:hover { color: var(--text); }

.company-title { display: flex; align-items: center; gap: 14px; }

.logo {
  border-radius: 10px;
  object-fit: contain;
  background: var(--surface-2);
  flex-shrink: 0;
  display: block;
}

.logo-letter {
  display: grid;
  place-items: center;
  color: #12161e;
  font-weight: 800;
  font-size: 17px;
  border-radius: 10px;
}

.logo-row { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.logo-preview { flex-shrink: 0; }

.card-company { display: flex; align-items: center; gap: 14px; text-decoration: none; }

/* ---------- onglets ---------- */

.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 20px;
  overflow-x: auto;
}

.tab {
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  padding: 10px 14px;
  cursor: pointer;
  white-space: nowrap;
}

.tab:hover { color: var(--text); }
.tab.on { color: var(--accent); border-bottom-color: var(--accent); }

.panel-head {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.panel-head .section-sub { margin: 0; flex: 1 1 240px; }

/* ---------- lignes ---------- */

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  margin-bottom: 9px;
  flex-wrap: wrap;
}

.row-main { min-width: 0; }
.row-title { font-weight: 600; }
.row-meta { color: var(--muted); font-size: 13px; }

/* ---------- boutons ---------- */

.btn-sm { padding: 8px 15px; font-size: 13.5px; }

.btn-ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
}

.btn-ghost:hover { color: var(--text); border-color: #2c3a52; }

/* ---------- formulaires ---------- */

.form-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  max-width: 560px;
}

.hint { color: var(--muted); font-size: 12.5px; margin: 6px 0 0; }

.form-error { color: var(--bad); font-size: 14px; margin: 10px 0 0; min-height: 1.2em; }

.form-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }

textarea {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  resize: vertical;
}

input[type="number"] {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
}

input[type="file"] { color: var(--muted); font-size: 13.5px; }

input.color {
  width: 56px;
  height: 38px;
  padding: 3px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  cursor: pointer;
}

/* ---------- panneau modal ---------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(4, 6, 11, .74);
  backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  padding: 20px;
  overflow-y: auto;
}

.sheet {
  width: min(100%, 460px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 26px;
  max-height: 90vh;
  overflow-y: auto;
}

.sheet h2 { font-size: 19px; margin: 0 0 18px; }

.sheet-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; flex-wrap: wrap; }

/* ---------- notification ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  translate: -50% 0;
  z-index: 200;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 12px 20px;
  border-radius: 999px;
  font-size: 14.5px;
  box-shadow: 0 16px 40px -18px rgba(0, 0, 0, .9);
  max-width: calc(100vw - 32px);
  text-align: center;
}

.toast-bad { border-color: var(--bad); color: var(--bad); }

@media (max-width: 640px) {
  .page-head .btn { margin-left: 0; width: 100%; }
  .row { align-items: flex-start; }
  .row .btn { flex: 1 1 auto; }
}

/* ---------- connexion Google ---------- */

.btn-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 11px;
  background: #ffffff;
  color: #1f1f1f;
  font-weight: 600;
  padding: 13px 22px;
}

.btn-google:hover:not(:disabled) { background: #f1f3f6; }
.btn-google .g { display: inline-flex; line-height: 0; }

.login-card .hint { margin-top: 16px; text-align: center; }

/* ---------- navigation principale ---------- */

.nav { display: flex; gap: 4px; margin-left: 10px; }

.nav-link {
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  padding: 7px 12px;
  border-radius: 999px;
}

.nav-link:hover { color: var(--text); background: var(--surface-2); }
.nav-link.on { color: var(--accent-ink); background: var(--accent); }

/* ---------- catalogue ---------- */

.card-item { display: flex; gap: 13px; align-items: flex-start; }

.poster {
  border-radius: 6px;
  object-fit: cover;
  background: var(--surface-2);
  flex-shrink: 0;
  display: block;
}

.poster-empty {
  display: block;
  border: 1px dashed var(--line);
  border-radius: 6px;
}

.meta-warn { color: var(--warn); }

.notice {
  border: 1px solid var(--warn);
  background: rgba(255, 179, 64, .1);
  color: var(--text);
  border-radius: var(--radius);
  padding: 13px 16px;
  margin-bottom: 18px;
  font-size: 14px;
}

.row-on { border-color: #2c3a52; }

.field-row { display: flex; gap: 14px; flex-wrap: wrap; }
.field-row > * { flex: 1 1 150px; }

.select, input[type="date"] {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
}

@media (max-width: 640px) {
  .nav { margin-left: 0; order: 3; width: 100%; }
  .topbar { flex-wrap: wrap; }
}

/* ---------- import de catalogue ---------- */

.head-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-left: auto; }
.page-head .head-actions .btn { margin-left: 0; }
.import-wrap { display: inline-flex; }

.meta-file {
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 11.5px;
  opacity: .75;
  word-break: break-all;
}

@media (max-width: 640px) {
  .head-actions { width: 100%; }
  .head-actions .btn { flex: 1 1 auto; }
}

/* ---------- tournée : l'écart entre l'intention et le réel ---------- */

.tour-figures {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 22px;
}

.figure {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
}

.figure b {
  display: block;
  font-size: 25px;
  font-weight: 650;
  letter-spacing: -0.02em;
  /* Des nombres qui se comparent d'une carte a l'autre doivent s'aligner. */
  font-variant-numeric: tabular-nums;
}

.figure span { color: var(--muted); font-size: 13px; }
.figure.warn b { color: var(--warn); }
.figure.ok b { color: var(--ok); }

.tour-list { display: flex; flex-direction: column; gap: 12px; }

.gap-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
}

/* Un vehicule a jour ne demande rien : il s'efface sans disparaitre. */
.gap-idle { opacity: 0.62; }
.gap-idle:hover { opacity: 1; }

.gap-head { display: flex; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
/* La pastille se cale sur la PREMIERE ligne, celle du nom. Centree, elle
   glissait en face de la deuxieme ligne des que la meta se repliait. */
.gap-head .dot { margin-top: 6px; }
.gap-none { color: var(--muted); font-size: 13.5px; margin: 12px 0 0; }

.gap-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.gap-stat {
  background: var(--surface-2);
  border-radius: 10px;
  padding: 11px 13px;
}

.gap-stat b { display: block; font-size: 15px; font-variant-numeric: tabular-nums; }
.gap-stat span { color: var(--muted); font-size: 13px; }
.gap-stat small { display: block; color: var(--muted); font-size: 12px; margin-top: 3px; opacity: .8; }
.gap-stat.bad b { color: var(--bad); }

.gap-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }

.gap-detail section { margin-bottom: 20px; }
.gap-detail h3 { font-size: 15px; margin: 0 0 4px; }

.gap-lines { list-style: none; margin: 10px 0 0; padding: 0; }

/* Grille plutot que flex : le titre, ses fichiers et le poids occupent des
   places fixes. En flex, un nom de fichier un peu long renvoyait le poids a la
   ligne et la colonne de droite cessait de s'aligner. */
.gap-lines li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 2px 14px;
  align-items: baseline;
  padding: 9px 0;
  border-top: 1px solid var(--line);
}

.gap-line-title { grid-column: 1; grid-row: 1; }
.gap-files { grid-column: 1; grid-row: 2; }
.gap-lines .gap-line-side { grid-column: 2; grid-row: 1 / span 2; margin-left: 0; text-align: right; }

.gap-line-title { font-weight: 600; }

.gap-lines code {
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 11.5px;
  color: var(--muted);
  word-break: break-all;
}

.gap-line-side { margin-left: auto; color: var(--muted); font-size: 12.5px; white-space: nowrap; }

.row-bus .row-meta + .row-meta { margin-top: 2px; }

@media (max-width: 640px) {
  .gap-actions .btn { flex: 1 1 auto; }
  .gap-lines li { grid-template-columns: 1fr; }
  .gap-lines .gap-line-side { grid-column: 1; grid-row: 3; text-align: left; }
}

/* Au telephone, une meta un peu longue poussait la pastille d'etat sur une
   ligne a elle seule. Elle doit rester collee au nom du vehicule : c'est le
   couple nom + couleur qui se lit d'un coup d'oeil. */
.gap-head .row-main { flex: 1 1 60%; min-width: 0; }

/* Une serie aligne autant de fichiers que d'episodes manquants. */
.gap-files { display: flex; flex-direction: column; gap: 2px; min-width: 0; }

/* ---------- audience : ce que les passagers regardent vraiment ---------- */

.audience-head { font-size: 17px; margin: 26px 0 6px; }
.audience-head:first-child { margin-top: 4px; }

.rank { display: flex; flex-direction: column; gap: 2px; margin-bottom: 8px; }

.rank-row {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.rank-index {
  width: 22px;
  text-align: right;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  flex-shrink: 0;
}

.rank-main { min-width: 0; flex: 1; }
.rank-title { font-weight: 600; margin-bottom: 2px; }

.rank-hours {
  font-weight: 650;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  flex-shrink: 0;
}

/* La barre porte la comparaison, le chiffre porte la valeur : l'une sans
   l'autre oblige a choisir entre lire vite et lire juste. */
.bar {
  height: 5px;
  background: var(--surface-2);
  border-radius: 999px;
  margin-top: 7px;
  overflow: hidden;
}

.bar span {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
}

.vehicle-figures { text-align: right; }
.vehicle-figures b { display: block; font-size: 15px; font-variant-numeric: tabular-nums; }
.vehicle-figures span { color: var(--muted); font-size: 12.5px; }

@media (max-width: 640px) {
  .rank-row { flex-wrap: wrap; }
  .rank-main { flex: 1 1 60%; }
  .vehicle-figures { text-align: left; width: 100%; }
}
