/* =============================================================================
   styles.css — portage en code de la maquette Claude Design
   Palette, typo et rayons repris tels quels de la charte du site officiel :
   sites/iot-link/public/assets/css/style.css
   ⚠️ Poppins est chargé ici depuis Google Fonts pour l'essai local. En
   production, iot-link.io l'AUTO-HÉBERGE volontairement (RGPD : aucune IP
   transmise à Google) — reprendre les .woff2 du site, pas ce <link>.
   ========================================================================== */

:root {
  --navy: #173d56;
  --navy-deep: #0f2c40;
  --orange: #ffa558;
  --orange-dark: #e88632;
  --blue: #60a1c9;
  --text: #3a4a5a;
  --muted: #6a7886;
  --line: #e4e9ee;
  --line-soft: #f2f5f8;
  --bg-soft: #f4f7fa;
  --white: #fff;
  --green: #5ca86e;
  --amber: #e8a13a;
  --red: #d9534f;
  --pink: #c2185b;
  --radius: 14px;
  --shadow-sm: 0 6px 18px rgba(23, 61, 86, .05);
  --font: 'Poppins', 'Segoe UI', Roboto, -apple-system, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg-soft);
  text-wrap: pretty;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--orange-dark); text-decoration: none; }
a:hover { color: var(--orange); }
table { border-collapse: collapse; width: 100%; }

/* --- Barre du haut -------------------------------------------------------- */
.topbar {
  display: flex; align-items: center; gap: 18px;
  height: 62px; padding: 0 22px;
  background: var(--navy); color: #eaf1f7;
}
.brand { display: flex; align-items: center; gap: 9px; width: 210px; flex-shrink: 0; }
.brand-word { font-size: 17px; font-weight: 600; letter-spacing: -.2px; }
.brand-word .pfx { color: var(--blue); font-weight: 500; }
.topbar-filters { display: flex; align-items: center; gap: 10px; flex-grow: 1; }
.pill-ghost {
  display: flex; align-items: center; gap: 8px; height: 34px; padding: 0 12px;
  border: 1px solid rgba(234, 241, 247, .22); border-radius: 8px;
  font-size: 13px; color: #cddae3;
}
.topbar-tools { display: flex; align-items: center; gap: 16px; }
.flag { display: flex; width: 24px; height: 17px; border-radius: 3px; overflow: hidden; border: 1px solid rgba(255,255,255,.28); }
.flag span { flex-grow: 1; }
.bell-wrap { position: relative; display: flex; }
.badge-dot {
  position: absolute; top: -3px; right: -4px; min-width: 15px; height: 15px; padding: 0 3px;
  border-radius: 8px; background: var(--red); color: #fff;
  font-size: 10px; font-weight: 600; line-height: 15px; text-align: center;
}
.quick-add { display: flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 50%; background: var(--red); }
.user-menu { display: flex; align-items: center; gap: 9px; padding-left: 14px; border-left: 1px solid rgba(234,241,247,.18); }
.avatar { display: flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 50%; background: rgba(96,161,201,.28); font-size: 12px; font-weight: 600; }
.user-menu span { font-size: 13px; color: #cddae3; }

/* --- Cadre principal ------------------------------------------------------ */
.shell { display: flex; align-items: stretch; min-height: calc(100vh - 62px); }

.sidenav {
  display: flex; flex-direction: column; gap: 4px;
  width: 210px; flex-shrink: 0; padding: 18px 12px;
  background: var(--navy-deep);
}
.nav-item {
  display: flex; align-items: center; gap: 11px; height: 40px; padding: 0 12px;
  border-radius: 9px; font-size: 13.5px; color: #9fb2c0; cursor: default;
}
.nav-item.is-active {
  background: rgba(255,255,255,.10); color: #fff; font-weight: 500;
  box-shadow: inset 3px 0 0 var(--orange);
}
.sidenav-foot { margin-top: auto; padding: 12px 10px; border-top: 1px solid rgba(255,255,255,.09); font-size: 11px; color: var(--muted); line-height: 1.5; }

.main { flex-grow: 1; padding: 24px 28px 48px; min-width: 0; }

/* --- En-tête de page ------------------------------------------------------ */
.crumbs { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--muted); margin-bottom: 10px; }
.crumbs .current { color: var(--text); font-weight: 500; }

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; margin-bottom: 18px; flex-wrap: wrap; }
.page-title { font-size: 25px; font-weight: 600; color: var(--navy); letter-spacing: -.4px; }
.title-block { display: flex; flex-direction: column; gap: 8px; }
.chips { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px;
  border-radius: 12px; font-size: 12px; font-weight: 500;
  background: var(--white); border: 1px solid var(--line); color: var(--muted);
}
.chip .dot { width: 7px; height: 7px; border-radius: 50%; }
.chip.ok { background: rgba(92,168,110,.14); color: #3f8a55; border-color: transparent; }
.chip.warn { background: rgba(232,161,58,.16); color: #9a6a12; border-color: transparent; }
.chip.bad { background: rgba(217,83,79,.14); color: #a33a36; border-color: transparent; }
.chip-meta { font-size: 12.5px; color: var(--muted); }

.btn {
  display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 16px;
  border-radius: 20px; border: 1.6px solid var(--line); background: var(--white);
  font-family: inherit; font-size: 13px; font-weight: 500; color: var(--text); cursor: pointer;
}
.btn:hover { border-color: #cfd8e0; }
.head-actions { display: flex; gap: 10px; flex-shrink: 0; }

/* --- Onglets -------------------------------------------------------------- */
.tabs { display: flex; gap: 4px; border-bottom: 1.5px solid var(--line); margin-bottom: 22px; }
.tab {
  display: flex; align-items: center; gap: 8px; height: 42px; padding: 0 20px;
  margin-bottom: -1.5px; border: 0; background: none; cursor: pointer;
  font-family: inherit; font-size: 14px; font-weight: 500; color: var(--muted);
  border-bottom: 2.5px solid transparent;
}
.tab:hover { color: var(--text); }
.tab.is-active { color: var(--navy); font-weight: 600; border-bottom-color: var(--orange); }

/* --- Grilles et cartes ---------------------------------------------------- */
.stack { display: flex; flex-direction: column; gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
/* align-items:start — sans lui, la carte la plus courte s'étire à la hauteur
   de sa voisine et laisse un grand vide (constaté au contrôle visuel). */
.grid-2a { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); gap: 18px; align-items: start; }

.card {
  display: flex; flex-direction: column; gap: 14px; padding: 20px;
  background: var(--white); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.card-title { font-size: 13px; font-weight: 600; color: var(--navy); text-transform: uppercase; letter-spacing: .6px; }

.kv { display: flex; flex-direction: column; gap: 11px; }
.kv-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.kv-row .k { font-size: 12.5px; color: var(--muted); }
.kv-row .v { font-size: 13px; font-weight: 500; color: var(--navy); text-align: right; }
.kv-row.total { padding-top: 11px; border-top: 1px solid var(--line-soft); }
.kv-row.total .v { font-size: 15px; font-weight: 600; }

/* --- Volumes -------------------------------------------------------------- */
.volume-card { flex-direction: row; gap: 20px; }
.volume-figure { display: flex; align-items: baseline; gap: 8px; }
.volume-figure .big { font-size: 30px; font-weight: 600; color: var(--navy); letter-spacing: -.8px; }
.volume-figure .unit { font-size: 15px; color: var(--muted); }
.pct-badge { margin-left: 4px; padding: 2px 9px; border-radius: 11px; font-size: 13px; font-weight: 600; }
.gauge-wrap { display: flex; flex-direction: column; align-items: center; gap: 8px; width: 64px; flex-shrink: 0; }
.gauge { position: relative; width: 56px; height: 158px; border: 2px solid #d7dfe6; border-radius: 12px; background: #f7fafc; overflow: hidden; }
.gauge-fill { position: absolute; left: 0; right: 0; bottom: 0; transition: height .35s ease; }
.gauge-cap { font-size: 10.5px; color: var(--muted); text-align: center; }

/* --- Carte (placeholder) -------------------------------------------------- */
.map {
  position: relative; flex-grow: 1; min-height: 148px; border-radius: 10px; overflow: hidden;
  background: #e8eef2;
  background-image: linear-gradient(#dde5ec 1px, transparent 1px), linear-gradient(90deg, #dde5ec 1px, transparent 1px);
  background-size: 26px 26px;
}
.map .pin { position: absolute; left: 50%; top: 46%; transform: translate(-50%, -100%); }
.map .note { position: absolute; left: 8px; bottom: 7px; font-size: 10px; color: #93a5b2; letter-spacing: .3px; }
.map-meta { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--muted); }

/* --- Consommation --------------------------------------------------------- */
.seg { display: flex; gap: 3px; padding: 3px; border-radius: 9px; background: var(--bg-soft); }
.seg button {
  height: 26px; padding: 0 13px; border: 0; border-radius: 7px; background: none;
  font-family: inherit; font-size: 12.5px; color: var(--muted); cursor: pointer;
}
.seg button.is-active { background: var(--white); color: var(--navy); font-weight: 600; box-shadow: 0 1px 3px rgba(23,61,86,.14); }

.stat { display: flex; flex-direction: column; gap: 4px; padding: 15px 17px; border-radius: 11px; background: #f7fafc; }
.stat .lbl { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.stat .val { font-size: 23px; font-weight: 600; color: var(--navy); letter-spacing: -.5px; }
.stat .val small { font-size: 13px; font-weight: 400; color: var(--muted); }

.chart { display: flex; align-items: flex-end; gap: 6px; height: 168px; padding: 0 2px; }
.chart .col { display: flex; flex-direction: column; align-items: center; gap: 7px; flex-grow: 1; min-width: 0; }
.chart .bar { width: 100%; border-radius: 5px 5px 2px 2px; background: rgba(96,161,201,.55); transition: height .3s ease; }
.chart .bar.refill { background: var(--green); }
.chart .bar.last { background: var(--orange); }
.chart .lbl { font-size: 10.5px; color: var(--muted); white-space: nowrap; }
.chart-foot { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-top: 15px; border-top: 1px solid var(--line-soft); font-size: 12.5px; color: var(--muted); }
.chart-foot strong { color: var(--navy); font-weight: 600; }

/* --- Évènements ----------------------------------------------------------- */
.ev { display: flex; align-items: flex-start; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line-soft); }
.ev .dot { flex-shrink: 0; width: 8px; height: 8px; margin-top: 6px; border-radius: 50%; }
.ev .body { display: flex; flex-direction: column; gap: 2px; flex-grow: 1; min-width: 0; }
.ev .lbl { font-size: 13px; font-weight: 500; color: var(--navy); }
.ev .sub { font-size: 11.5px; color: var(--muted); }
.ev .when { font-size: 11.5px; color: var(--muted); white-space: nowrap; }

/* --- Tableaux ------------------------------------------------------------- */
.tbl-scroll { overflow-x: auto; }
.tbl { font-size: 12.5px; }
.tbl th {
  padding: 0 12px 10px 0; text-align: left; white-space: nowrap;
  font-size: 11px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: .5px;
  border-bottom: 1.5px solid var(--line);
}
.tbl td { padding: 11px 12px 11px 0; border-bottom: 1px solid var(--line-soft); white-space: nowrap; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl .strong { font-weight: 500; color: var(--navy); }
.tbl tr.invalid td { background: rgba(217,83,79,.05); }

.signal { display: inline-flex; align-items: center; gap: 7px; }
.signal .bars { display: inline-flex; align-items: flex-end; gap: 1.6px; height: 11px; }
.signal .bars i { width: 3px; border-radius: 1px; background: #dbe3ea; }
.signal .bars i.on { background: var(--green); }

.pager { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.pager .pages { display: flex; align-items: center; gap: 5px; }
.pager button {
  min-width: 30px; height: 30px; padding: 0 9px; border: 1px solid var(--line);
  border-radius: 8px; background: var(--white); font-family: inherit; font-size: 12.5px;
  color: var(--text); cursor: pointer;
}
.pager button.is-active { background: var(--navy); border-color: var(--navy); color: #fff; font-weight: 600; }
.pager button:disabled { color: #b6c2cc; cursor: default; }

/* --- Bandeau d'information ------------------------------------------------ */
.banner {
  display: flex; align-items: center; gap: 13px; padding: 15px 20px;
  border-radius: 12px; background: rgba(96,161,201,.09); border: 1px dashed #a9c6da;
}
.banner .t { font-size: 13.5px; font-weight: 600; color: #2f6685; }
.banner .d { font-size: 12.5px; color: #5b7e95; }

/* --- ⚠️ Marqueur « non exposé par l'API v1 » ------------------------------
   Le cœur pédagogique de cet essai : au lieu d'inventer une donnée absente,
   on la marque visuellement. La page devient une spec de ce qui manque.     */
.na {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; font-weight: 500; font-style: normal;
  color: #9a6a12; background: rgba(232,161,58,.14);
  padding: 1px 8px; border-radius: 10px; cursor: help;
}
.na::before { content: '—'; opacity: .55; }
.card.is-na { border-style: dashed; border-color: #e3cfa4; background: #fffdf8; }
.card.is-na .card-title { color: #9a6a12; }

.legend {
  display: flex; align-items: flex-start; gap: 12px; margin-top: 26px; padding: 16px 20px;
  border-radius: 12px; background: #fffdf8; border: 1px dashed #e3cfa4;
  font-size: 12.5px; color: #7a5a12; line-height: 1.65;
}
.legend strong { color: #6b4e0d; }
.legend code { font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace; font-size: 11.5px; background: rgba(232,161,58,.15); padding: 1px 5px; border-radius: 4px; }

/* --- États de chargement / erreur ----------------------------------------- */
.loading { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 60px 0; color: var(--muted); font-size: 13px; }
.spinner { width: 16px; height: 16px; border: 2px solid var(--line); border-top-color: var(--orange); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.error { padding: 18px 20px; border-radius: 12px; background: rgba(217,83,79,.08); border: 1px solid rgba(217,83,79,.3); color: #a33a36; font-size: 13px; }

@media (max-width: 1180px) {
  .grid-3, .grid-4, .grid-2a { grid-template-columns: minmax(0, 1fr); }
}

/* =============================================================================
   Ajouts — écrans de liste, navigation et compteur d'appels API
   ========================================================================== */

.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--orange-dark); }
.nav-item[data-href] { cursor: pointer; }
.nav-item[data-href]:hover { color: #cddae3; }

/* Compteur d'appels — rend visible le coût réel de chaque écran */
.meter {
  display: flex; align-items: center; justify-content: space-between; gap: 20px; flex-wrap: wrap;
  padding: 12px 18px; border-radius: 12px;
  background: rgba(96, 161, 201, .09); border: 1px solid rgba(96, 161, 201, .25);
}
.meter-head { font-size: 13px; color: #2f6685; }
.meter-head strong { color: #1d4f6d; font-size: 14px; }
.meter-rows { display: flex; flex-wrap: wrap; gap: 6px; }
.meter-row {
  font-size: 11.5px; color: #4b7a94; background: rgba(255, 255, 255, .65);
  padding: 2px 9px; border-radius: 10px; white-space: nowrap;
}
.meter code { font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace; font-size: 11px; }

/* Outils de liste */
.list-tools { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.search { display: flex; align-items: center; gap: 9px; flex-grow: 1; min-width: 240px;
  height: 38px; padding: 0 14px; border: 1px solid var(--line); border-radius: 20px; background: var(--white); }
.search input { flex-grow: 1; border: 0; outline: 0; font-family: inherit; font-size: 13px; color: var(--text); background: none; }
.search input::placeholder { color: #9aa7b3; }
a.chip { text-decoration: none; }
a.chip:hover { border-color: #cfd8e0; color: var(--text); }

/* Lignes cliquables */
.tbl tr.clickable { cursor: pointer; }
.tbl tr.clickable:hover td { background: #f7fafc; }
.tbl-list td { padding-top: 13px; padding-bottom: 13px; }
.dim { color: #b6c2cc; }

/* Pastille de niveau + mini-barre de remplissage */
.lvl-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 8px; vertical-align: middle; }
.mini-bar { display: block; width: 54px; height: 5px; border-radius: 3px; background: var(--line); overflow: hidden; margin: 0 0 3px auto; }
.mini-bar i { display: block; height: 100%; border-radius: 3px; }

/* Note explicative en pied de carte */
.hint { font-size: 11.5px; color: var(--muted); line-height: 1.6; }
.hint code { font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace; font-size: 11px; background: #eef2f5; padding: 1px 5px; border-radius: 4px; }
.hint strong { color: var(--text); }

.legend { margin-top: 26px; }

/* Bouton d'action principal (ex. Transférer, dans IoT Devices) */
.btn-primary { background: var(--orange); border-color: var(--orange); color: #fff; font-weight: 600; }
.btn-primary:hover { background: var(--btn-dark, #1a2027); border-color: #1a2027; color: #fff; }
.tbl input[type="checkbox"] { width: 15px; height: 15px; accent-color: var(--orange); cursor: pointer; }

/* --- Bloc « Notifications & alertes » : MAQUETTE assumée ------------------
   Le design est montré en vrai, mais rien ne vient de l'API. D'où le badge
   dans le titre et l'encart d'avertissement sous le tableau.               */
.badge-fake {
  margin-left: 9px; padding: 2px 9px; border-radius: 10px;
  background: rgba(232, 161, 58, .16); color: #9a6a12;
  font-size: 10.5px; font-weight: 600; letter-spacing: .3px; text-transform: none;
  vertical-align: middle; white-space: nowrap;
}
.btn-add-sm {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 13px;
  border-radius: 15px; background: var(--orange); color: #fff;
  font-size: 12.5px; font-weight: 600; cursor: default; opacity: .55;
}
.chan {
  display: inline-block; margin-right: 5px; padding: 1px 8px; border-radius: 9px;
  background: #eef2f5; color: var(--muted); font-size: 11.5px;
}
.toggle {
  position: relative; display: inline-flex; align-items: center;
  width: 36px; height: 20px; border-radius: 10px;
  background: #dbe3ea; cursor: pointer; transition: background .18s ease;
}
.toggle.is-on { background: var(--orange); }
.toggle i {
  position: absolute; top: 2px; left: 2px; width: 16px; height: 16px;
  border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.2);
  transition: left .18s ease;
}
.toggle.is-on i { left: 18px; }

.warn-box {
  display: flex; align-items: flex-start; gap: 11px;
  padding: 14px 16px; border-radius: 11px;
  background: #fffdf8; border: 1px dashed #e3cfa4;
  font-size: 12px; color: #7a5a12; line-height: 1.65;
}
.warn-box strong { color: #6b4e0d; }
.warn-box code { font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace; font-size: 11px; background: rgba(232,161,58,.15); padding: 1px 5px; border-radius: 4px; }
