@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@500&family=IBM+Plex+Sans:wght@400;500;600&display=swap');

:root {
  --ink: #101820;
  --muted: #55626C;
  --ground: #F4F6F7;
  --surface: #FFFFFF;
  --line: #DCE2E5;
  --line-soft: #EDF1F2;
  --field: #7A8790;
  --brand: #13BBD2;          /* cyan du logo, décoratif */
  --primary: #0A6C7A;        /* cyan foncé, lisible sur fond blanc */
  --primary-hover: #08525D;
  --primary-soft: #E2F5F8;
  --primary-ink: #064652;
  --warn-soft: #FBEFD9;
  --warn-ink: #8A5200;
  --neutral-soft: #ECEFF0;
  --neutral-ink: #3E4A52;
  --danger-ink: #A12C2C;
  --radius: 12px;
  font-family: 'IBM Plex Sans', system-ui, sans-serif;
  color: var(--ink);
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--ground); line-height: 1.45; }
a { color: var(--primary); }
a:hover { color: var(--primary-hover); }
h1, h2, h3 { margin: 0; font-weight: 600; }
.mono { font-family: 'IBM Plex Mono', monospace; }
.muted { color: var(--muted); }
.hidden { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Champs et boutons ---------- */
label { font-size: 14px; font-weight: 500; }
input[type=text], input[type=email], input[type=password], input[type=number], select, textarea {
  font: inherit; font-size: 15px; color: var(--ink); background: #fff;
  border: 1px solid var(--field); border-radius: 8px; padding: 0 12px; min-height: 44px; width: 100%;
}
textarea { padding: 12px; resize: vertical; }
select[multiple] { padding: 6px; min-height: 140px; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible {
  outline: 3px solid var(--brand); outline-offset: 2px;
}
.field { display: flex; flex-direction: column; gap: 6px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px; border-radius: 8px; border: 1px solid transparent;
  font: inherit; font-size: 15px; font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); color: #fff; }
.btn-secondary { background: #fff; color: var(--ink); border-color: var(--field); font-weight: 500; }
.btn-secondary:hover { background: var(--ground); color: var(--ink); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-small { min-height: 36px; padding: 0 12px; font-size: 13px; }

.pill { display: inline-block; font-size: 12px; font-weight: 500; padding: 3px 10px; border-radius: 999px; white-space: nowrap; }
.pill-moving { background: var(--primary-soft); color: var(--primary-ink); }
.pill-stopped { background: var(--neutral-soft); color: var(--neutral-ink); }
.pill-offline { background: var(--warn-soft); color: var(--warn-ink); }
.pill-none { background: #fff; color: var(--muted); border: 1px solid var(--line); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.card h2 { font-size: 16px; }
.notice { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 8px; font-size: 14px; }
.notice-info { background: var(--primary-soft); color: var(--primary-ink); }
.notice-error { background: #FBE7E7; color: var(--danger-ink); }
.notice-warn { background: var(--warn-soft); color: var(--warn-ink); }

/* ---------- Tableaux ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 13px; font-weight: 500; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
th.num { text-align: right; }
td.num { text-align: right; font-family: 'IBM Plex Mono', monospace; }

/* ---------- Mise en page appli ---------- */
.shell { min-height: 100vh; display: flex; flex-wrap: wrap; }
.sidebar {
  flex: 1 1 220px; background: var(--surface); border-right: 1px solid var(--line);
  padding: 24px 16px; display: flex; flex-direction: column; gap: 28px;
}
.sidebar .logo { display: block; padding: 0 8px; text-decoration: none; }
.sidebar .logo img { width: 156px; height: auto; display: block; }
.sidebar .logo span { display: block; font-size: 12px; color: var(--muted); margin-top: 6px; letter-spacing: .02em; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav a {
  display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 12px; border-radius: 8px;
  color: var(--neutral-ink); text-decoration: none; font-size: 14px;
}
.nav a:hover { background: var(--ground); color: var(--ink); }
.nav a[aria-current=page] { background: var(--primary-soft); color: var(--primary-ink); font-weight: 600; }
.nav svg { width: 18px; height: 18px; flex: 0 0 auto; }
.account { margin-top: auto; border-top: 1px solid var(--line); padding: 16px 8px 0; display: flex; flex-direction: column; gap: 8px; font-size: 14px; }
.account button { background: none; border: 0; padding: 0; min-height: 44px; font: inherit; color: var(--neutral-ink); cursor: pointer; text-align: left; display: flex; align-items: center; gap: 10px; }
.account button:hover { color: var(--ink); }

.content { flex: 999 1 560px; min-width: 0; padding: 32px 40px 48px; }
.content > .inner { max-width: 1160px; margin: 0 auto; display: flex; flex-direction: column; gap: 24px; }
.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 16px; }
.page-head h1 { font-size: 28px; }
.page-head p { margin: 6px 0 0; color: var(--muted); font-size: 14px; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; }
.kpi { display: flex; flex-direction: column; gap: 6px; }
.kpi .label { font-size: 13px; color: var(--muted); }
.kpi .value { font-family: 'IBM Plex Mono', monospace; font-size: 32px; font-weight: 500; }
.kpi .value.moving { color: var(--primary); }
.kpi .value.offline { color: var(--warn-ink); }

.row { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-start; }
#map { height: 400px; border-radius: 8px; background: #E9ECE8; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 13px; color: var(--neutral-ink); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }

.quota { display: flex; flex-direction: column; gap: 8px; font-size: 13px; }
.bar { height: 8px; border-radius: 999px; background: var(--neutral-soft); overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--primary); }
.bar > span.high { background: var(--warn-ink); }

/* Groupes de véhicules sur la carte */
.cluster { display: flex; align-items: center; justify-content: center; border-radius: 50%;
  background: rgba(10, 108, 122, .9); color: #fff; font: 600 13px 'IBM Plex Sans', sans-serif;
  border: 3px solid rgba(255, 255, 255, .85); box-shadow: 0 1px 4px rgba(0, 0, 0, .25); }
.cluster.warn { background: rgba(184, 116, 0, .92); }

/* ---------- Rapports ---------- */
.templates { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; flex: 2 1 540px; min-width: 0; }
.template {
  text-align: left; font: inherit; color: inherit; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px;
  display: flex; flex-direction: column; gap: 8px;
}
.template:hover { border-color: var(--field); }
.template[aria-pressed=true] { border: 2px solid var(--primary); padding: 17px; background: #F3FBFC; }
.template h3 { font-size: 16px; }
.template p { margin: 0; font-size: 14px; color: var(--neutral-ink); }
.template .tag { font-size: 12px; color: var(--muted); }
.template .tag.ai { color: var(--primary-ink); font-weight: 500; }
.params { flex: 1 1 320px; min-width: 0; display: flex; flex-direction: column; gap: 16px; }

.report-body { display: flex; flex-direction: column; gap: 14px; }
.report-meta { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; justify-content: space-between; }

/* ---------- Assistant ---------- */
.chat { flex: 3 1 560px; min-width: 0; display: flex; flex-direction: column; padding: 0; min-height: 620px; }
.chat-head { padding: 18px 24px; border-bottom: 1px solid var(--line); }
.chat-head p { margin: 4px 0 0; font-size: 14px; color: var(--muted); }
.messages { flex: 1 1 auto; padding: 24px; display: flex; flex-direction: column; gap: 18px; overflow-y: auto; max-height: 64vh; }
.msg { max-width: 88%; font-size: 15px; line-height: 1.55; }
.msg.user { align-self: flex-end; background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 14px 14px 4px 14px; white-space: pre-wrap; }
.msg.assistant { align-self: flex-start; background: var(--ground); padding: 14px 18px; border-radius: 14px 14px 14px 4px; }
.msg.assistant p { margin: 0 0 10px; }
.msg.assistant p:last-child { margin-bottom: 0; }
.msg.assistant table { background: #fff; margin: 8px 0; }
.msg.assistant .table-wrap { margin: 8px 0; }
.msg.thinking { align-self: flex-start; background: var(--primary-soft); color: var(--primary-ink); padding: 10px 14px; border-radius: 999px; font-size: 13px; }
.empty-chat { color: var(--muted); font-size: 14px; }
.suggestions { display: flex; flex-wrap: wrap; gap: 8px; }
.suggestions button { min-height: 36px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line); background: #fff; font: inherit; font-size: 13px; color: var(--neutral-ink); cursor: pointer; }
.suggestions button:hover { border-color: var(--field); color: var(--ink); }
.composer { border-top: 1px solid var(--line); padding: 16px 24px 20px; display: flex; flex-direction: column; gap: 12px; }
.composer form { display: flex; gap: 10px; align-items: flex-end; }
.composer textarea { flex: 1 1 auto; min-height: 52px; }
.send { width: 52px; height: 52px; flex: 0 0 auto; border: 0; border-radius: 10px; background: var(--primary); color: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.send:hover { background: var(--primary-hover); }
.send:disabled { opacity: .5; cursor: not-allowed; }
.side { flex: 1 1 260px; min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.side dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; font-size: 14px; }
.side dt { color: var(--muted); }
.side dd { margin: 0; font-weight: 500; }
.conv-list { display: flex; flex-direction: column; }
.conv-list button { text-align: left; min-height: 44px; background: none; border: 0; border-bottom: 1px solid var(--line-soft); font: inherit; font-size: 14px; color: var(--primary); cursor: pointer; padding: 8px 0; }
.conv-list button:hover { color: var(--primary-hover); text-decoration: underline; }

/* ---------- Connexion ---------- */
.auth { min-height: 100vh; display: flex; flex-wrap: wrap; }
.auth-brand { flex: 1 1 480px; background: var(--ink); color: #E8ECEE; padding: 56px; display: flex; flex-direction: column; justify-content: space-between; gap: 48px; }
.auth-brand .logo-box { background: #fff; border-radius: 12px; padding: 14px 18px; align-self: flex-start; }
.auth-brand .logo-box img { width: 190px; display: block; }
.auth-brand h1 { font-size: 40px; line-height: 1.15; max-width: 520px; letter-spacing: -0.01em; }
.auth-brand ul { margin: 24px 0 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 16px; color: #C9D2D6; font-size: 16px; max-width: 520px; }
.auth-brand li { display: flex; gap: 12px; align-items: flex-start; }
.auth-brand li svg { flex: 0 0 auto; margin-top: 2px; color: var(--brand); }
.auth-brand small { color: #A5B1B6; font-size: 13px; }
.auth-form { flex: 1 1 480px; display: flex; align-items: center; justify-content: center; padding: 56px 24px; }
.auth-form > div { width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: 20px; }
.auth-form h2 { font-size: 28px; }

@media (max-width: 720px) {
  .content { padding: 24px 16px 40px; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--line); gap: 16px; }
  .account { margin-top: 0; }
  .auth-brand { padding: 32px 24px; }
  .auth-brand h1 { font-size: 30px; }
}
