/* ============================================================
   LEO — Feuille de style (prototype)
   Mobile-first · thème clair / sombre · univers chantier/BTP
   ============================================================ */

:root {
  --primary:        #1e293b;   /* anthracite / bleu foncé */
  --primary-soft:   #334155;
  --accent:         #cf8045;   /* ambre premium (orange chantier adouci) */
  --accent-dark:    #b56a32;
  --safety:         #e0b14b;   /* doré sécurité (sourd) */

  /* Couleurs sémantiques douces pour avatars/icônes */
  --av-blue:        #5b7a99;
  --av-clay:        #a86b5e;
  --av-sage:        #5f8a78;

  --bg:             #f1f5f9;
  --surface:        #ffffff;
  --surface-2:      #f8fafc;
  --text:           #0f172a;
  --text-muted:     #64748b;
  --border:         #e2e8f0;

  --ok:             #16a34a;
  --ok-bg:          #dcfce7;
  --warn:           #d97706;
  --warn-bg:        #fef3c7;
  --bad:            #dc2626;
  --bad-bg:         #fee2e2;
  --info:           #2563eb;
  --info-bg:        #dbeafe;

  --shadow:         0 1px 3px rgba(15,23,42,.08), 0 1px 2px rgba(15,23,42,.06);
  --shadow-lg:      0 10px 25px rgba(15,23,42,.12);
  --radius:         14px;
  --maxw:           480px;
}

[data-theme="dark"] {
  --primary:        #0f172a;
  --primary-soft:   #1e293b;
  --bg:             #0b1220;
  --surface:        #16203a;
  --surface-2:      #1b274480;
  --text:           #f1f5f9;
  --text-muted:     #94a3b8;
  --border:         #2a3a5c;

  --ok-bg:          #14321f;
  --warn-bg:        #3a2c0a;
  --bad-bg:         #3a1717;
  --info-bg:        #14233f;
  --shadow:         0 1px 3px rgba(0,0,0,.4);
  --shadow-lg:      0 10px 25px rgba(0,0,0,.5);
}

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

body {
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ---------- Shell mobile ---------- */
#app {
  max-width: var(--maxw);
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg);
  position: relative;
  box-shadow: 0 0 40px rgba(0,0,0,.08);
}

/* ---------- Login / sélecteur de rôle ---------- */
.login {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 32px 24px;
  background: linear-gradient(160deg, var(--primary) 0%, #0b1220 100%);
  color: #fff;
  text-align: center;
}
.login .logo {
  font-size: 56px; font-weight: 800; letter-spacing: 2px;
  display: flex; align-items: center; gap: 10px;
}
.login .logo .badge {
  background: var(--accent); color: #fff; border-radius: 14px;
  width: 64px; height: 64px; display: grid; place-items: center; font-size: 34px;
}
.login .tagline { color: #cbd5e1; margin: 8px 0 4px; font-size: 15px; }
.login .sub { color: #94a3b8; font-size: 13px; margin-bottom: 36px; }
.role-grid { display: grid; gap: 14px; width: 100%; max-width: 340px; }
.role-card {
  background: rgba(255,255,255,.07);
  border: 1px solid rgba(255,255,255,.15);
  border-radius: var(--radius);
  padding: 18px 20px; cursor: pointer; text-align: left;
  display: flex; align-items: center; gap: 16px;
  transition: transform .12s, background .12s, border-color .12s;
  color: #fff;
}
.role-card:hover { transform: translateY(-2px); background: rgba(255,255,255,.13); border-color: var(--accent); }
.role-card .ic { width: 48px; height: 48px; border-radius: 12px; display: grid; place-items: center; flex-shrink: 0; }
.role-card h3 { font-size: 17px; }
.role-card p { font-size: 13px; color: #cbd5e1; }
.login .footnote { margin-top: 32px; font-size: 12px; color: #64748b; max-width: 320px; }

/* ---------- Header ---------- */
.app-header {
  position: sticky; top: 0; z-index: 40;
  background: var(--primary); color: #fff;
  padding: 14px 16px; display: flex; align-items: center; gap: 12px;
}
.app-header .ttl { font-weight: 700; font-size: 17px; display: flex; flex-direction: column; }
.app-header .ttl small { font-weight: 400; font-size: 12px; color: #cbd5e1; }
.app-header .logo-mini { background: var(--accent); border-radius: 9px; width: 36px; height: 36px; display: grid; place-items: center; font-weight: 800; }
.app-header .spacer { flex: 1; }
.icon-btn {
  background: rgba(255,255,255,.12); border: none; color: #fff;
  width: 38px; height: 38px; border-radius: 10px; cursor: pointer;
  display: grid; place-items: center; transition: background .12s;
}
.icon-btn:hover { background: rgba(255,255,255,.24); }

/* ---------- Contenu ---------- */
.view { padding: 16px 16px 96px; animation: fade .18s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px);} to {opacity:1; transform:none;} }
.page-title { font-size: 20px; font-weight: 700; margin-bottom: 4px; }
.page-sub { color: var(--text-muted); font-size: 13px; margin-bottom: 16px; }
.section-title { font-size: 15px; font-weight: 700; margin: 22px 0 10px; display: flex; align-items: center; gap: 8px; }
.section-title .link { margin-left: auto; font-size: 13px; color: var(--accent); font-weight: 600; cursor: pointer; }

/* ---------- Cartes ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin-bottom: 12px;
}
.card.tight { padding: 12px 14px; }
.card-row { display: flex; align-items: center; gap: 12px; }
.card h4 { font-size: 15px; margin-bottom: 2px; }
.muted { color: var(--text-muted); font-size: 13px; }
.tiny { font-size: 12px; }

/* ---------- KPI grid ---------- */
.kpi-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.kpi {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px; box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.kpi .kpi-ic { position: absolute; right: 10px; top: 10px; opacity: .25; }
.kpi .kpi-val { font-size: 26px; font-weight: 800; line-height: 1; }
.kpi .kpi-lbl { font-size: 12px; color: var(--text-muted); margin-top: 6px; }
.kpi .kpi-unit { font-size: 14px; font-weight: 600; color: var(--text-muted); }
.kpi.accent { background: linear-gradient(135deg, var(--accent), var(--accent-dark)); color: #fff; border: none; }
.kpi.accent .kpi-lbl { color: #ffe8d6; }
.kpi.dark { background: var(--primary); color: #fff; border: none; }
.kpi.dark .kpi-lbl { color: #cbd5e1; }

/* ---------- Badges statut ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px; white-space: nowrap;
}
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.b-ok    { color: var(--ok);   background: var(--ok-bg); }
.b-warn  { color: var(--warn); background: var(--warn-bg); }
.b-bad   { color: var(--bad);  background: var(--bad-bg); }
.b-info  { color: var(--info); background: var(--info-bg); }
.b-grey  { color: var(--text-muted); background: var(--surface-2); }

/* ---------- Boutons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-size: 15px; font-weight: 600; padding: 12px 18px; border-radius: 12px;
  border: none; cursor: pointer; transition: filter .12s, transform .08s; width: 100%;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { filter: brightness(1.05); }
.btn-dark { background: var(--primary); color: #fff; }
.btn-ghost { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn-sm { padding: 8px 12px; font-size: 13px; width: auto; flex-shrink: 0; }
.btn-row { display: flex; gap: 10px; }

/* ---------- Formulaires ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 12px 14px; border: 1px solid var(--border);
  border-radius: 11px; background: var(--surface); color: var(--text);
  font-size: 15px; font-family: inherit;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(249,115,22,.15);
}
.field textarea { min-height: 72px; resize: vertical; }
.field-row { display: flex; gap: 10px; }
.field-row .field { flex: 1; }
.calc-box {
  background: var(--surface-2); border: 1px dashed var(--border); border-radius: 11px;
  padding: 12px 14px; display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px;
}
.calc-box .v { font-weight: 800; font-size: 18px; }
.calc-box .v.sup { color: var(--accent); }
.chip-group { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 8px 14px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface); cursor: pointer; font-size: 14px; user-select: none;
}
.chip.on { background: var(--accent); color: #fff; border-color: var(--accent); }
/* Tâches de pointage : une ligne par tâche, avec quantité réalisée optionnelle */
#pt-taches { flex-direction: column; align-items: stretch; }
.tache-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tache-line .chip { flex: 0 0 auto; }
.qte-wrap { display: inline-flex; align-items: center; gap: 6px; }
.qte-input {
  width: 96px; padding: 7px 10px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); font-size: 14px;
}
.upload-zone {
  border: 2px dashed var(--border); border-radius: 12px; padding: 18px;
  text-align: center; color: var(--text-muted); cursor: pointer; font-size: 14px;
}
.upload-zone:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- Listes / lignes ---------- */
.list-row {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; margin-bottom: 10px;
}
.list-row .grow { flex: 1; min-width: 0; }
.list-row .grow .t { font-weight: 600; font-size: 14px; }
.list-row .grow .s { font-size: 12px; color: var(--text-muted); }
.avatar {
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center;
  color: #fff; font-weight: 700; font-size: 14px; flex-shrink: 0;
}
.avatar.sm { width: 32px; height: 32px; font-size: 12px; }

/* ---------- Doc item ---------- */
.doc { display: flex; align-items: center; gap: 12px; }
.doc .pdf { background: var(--bad-bg); color: var(--bad); width: 42px; height: 42px; border-radius: 10px; display: grid; place-items: center; font-weight: 800; font-size: 11px; flex-shrink: 0; }
/* Le bloc texte d'une ligne de données peut rétrécir et le nom (souvent sans
   espaces) se couper, pour que le bouton d'action reste aligné sur le padding. */
.doc .grow, .card-row .grow { min-width: 0; }
.doc .t { overflow-wrap: anywhere; }

/* ---------- Onglets internes ---------- */
.subtabs { display: flex; gap: 6px; background: var(--surface-2); padding: 5px; border-radius: 12px; margin-top: 18px; margin-bottom: 16px; }
.subtab { flex: 1; text-align: center; padding: 9px; border-radius: 9px; font-size: 13px; font-weight: 600; cursor: pointer; color: var(--text-muted); }
.subtab.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

/* ---------- Bottom nav (ouvrier) ---------- */
.bottom-nav {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: var(--maxw); background: var(--surface);
  border-top: 1px solid var(--border); display: flex; z-index: 50;
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.nav-item {
  position: relative;
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 9px 0 10px; cursor: pointer; color: var(--text-muted); font-size: 11px; font-weight: 600;
  border: none; background: none; transition: color .12s;
}
.nav-item span { white-space: nowrap; }
.nav-item.on { color: var(--accent); }
.nav-item.on svg { stroke: var(--accent); }
/* Pastille de compteur (éléments en attente d'action) sur la barre du bas */
.nav-badge {
  position: absolute; top: 4px; left: 50%; transform: translateX(5px);
  min-width: 16px; height: 16px; padding: 0 4px; box-sizing: border-box;
  background: var(--bad); color: #fff; border-radius: 999px;
  font-size: 10px; font-weight: 700; line-height: 16px; text-align: center;
}

/* ---------- Sidebar / nav responsable ---------- */
.resp-nav { display: flex; gap: 6px; overflow-x: auto; padding: 0 16px 4px; -ms-overflow-style: none; scrollbar-width: none; }
.resp-nav::-webkit-scrollbar { display: none; }
.resp-nav .r {
  flex-shrink: 0; padding: 9px 14px; border-radius: 999px; background: var(--surface);
  border: 1px solid var(--border); font-size: 13px; font-weight: 600; cursor: pointer;
  display: flex; align-items: center; gap: 7px; color: var(--text-muted);
}
.resp-nav .r.on { background: var(--primary); color: #fff; border-color: var(--primary); }
.resp-nav .r .pill { background: var(--accent); color: #fff; border-radius: 999px; font-size: 11px; padding: 1px 7px; }

/* ---------- Table validation ---------- */
.vrow {
  display: flex; align-items: center; gap: 10px; padding: 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; margin-bottom: 10px;
}
.vrow .chk { width: 20px; height: 20px; accent-color: var(--accent); flex-shrink: 0; }
.vrow .info { flex: 1; min-width: 0; }
.vrow .info .a { font-weight: 600; font-size: 14px; }
.vrow .info .b { font-size: 12px; color: var(--text-muted); }
.act-btn {
  width: 36px; height: 36px; border-radius: 9px; border: none; cursor: pointer;
  display: grid; place-items: center; flex-shrink: 0;
}
.act-ok  { background: var(--ok-bg);  color: var(--ok); }
.act-bad { background: var(--bad-bg); color: var(--bad); }

/* ---------- Bulk bar ---------- */
.bulk-bar {
  position: sticky; top: 64px; z-index: 30; background: var(--primary); color: #fff;
  border-radius: 12px; padding: 10px 12px; display: flex; align-items: center; gap: 10px; margin-bottom: 12px;
}
.bulk-bar .cnt { font-weight: 700; }
.bulk-bar .spacer { flex: 1; }

/* ---------- Toast ---------- */
#toast {
  position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--primary); color: #fff; padding: 12px 20px; border-radius: 12px;
  font-size: 14px; font-weight: 600; box-shadow: var(--shadow-lg); z-index: 100;
  opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s; max-width: 90%;
  display: flex; align-items: center; gap: 8px;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Empty state ---------- */
.empty { text-align: center; padding: 40px 20px; color: var(--text-muted); }
.empty svg { opacity: .4; margin-bottom: 10px; }

/* ---------- Detail header ---------- */
.detail-hero {
  background: linear-gradient(135deg, var(--primary), var(--primary-soft));
  color: #fff; border-radius: var(--radius); padding: 18px; margin-bottom: 16px;
}
.detail-hero h2 { font-size: 19px; margin-bottom: 4px; }
.detail-hero .meta { font-size: 13px; color: #cbd5e1; display: flex; align-items: center; gap: 6px; margin-top: 4px; }

.back-link { display: inline-flex; align-items: center; gap: 6px; color: var(--text-muted); font-size: 14px; cursor: pointer; margin-bottom: 12px; font-weight: 600; }
.back-link:hover { color: var(--accent); }

.divider { height: 1px; background: var(--border); margin: 14px 0; }
.kv { display: flex; justify-content: space-between; padding: 7px 0; font-size: 14px; }
.kv .k { color: var(--text-muted); }
.kv .v { font-weight: 600; text-align: right; }

/* ============================================================
   ADAPTATION GRAND ÉCRAN — « colonne élargie »
   Le mobile (<768px) reste strictement identique. Au-delà, l'app
   s'élargit et les KPI passent sur plus de colonnes. On ne pilote
   que --maxw (largeur du shell : header, contenu, navs) + les grilles.
   ============================================================ */

/* Tablette / petit portable */
@media (min-width: 768px) {
  :root { --maxw: 700px; }
  .view { padding: 22px 24px 100px; }
  .kpi-grid { grid-template-columns: repeat(3, 1fr); }
}

/* Ordinateur */
@media (min-width: 1200px) {
  :root { --maxw: 880px; }
  .view { padding: 26px 32px 110px; }
  .kpi-grid { grid-template-columns: repeat(4, 1fr); }
  /* un peu plus d'air sur les grands titres en grand écran */
  .page-title { font-size: 26px; }
}

/* ============================================================
   SKELETON DE CHARGEMENT
   Affiché pendant l'hydratation Supabase (renderSkeleton dans app.js).
   S'appuie sur les variables de thème : suit automatiquement le skin
   MiniMax et le mode sombre.
   ============================================================ */
.skeleton-wrap {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 18px 16px 100px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.sk-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.sk {
  background: linear-gradient(90deg,
    color-mix(in srgb, var(--text-muted) 12%, transparent) 25%,
    color-mix(in srgb, var(--text-muted) 22%, transparent) 37%,
    color-mix(in srgb, var(--text-muted) 12%, transparent) 63%);
  background-size: 400% 100%;
  animation: sk-shimmer 1.3s ease-in-out infinite;
  border-radius: 7px;
}
.sk-line { height: 14px; }
.sk-line.w40 { width: 40%; }
.sk-line.w80 { width: 80%; }
@keyframes sk-shimmer {
  0%   { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}
@media (prefers-reduced-motion: reduce) {
  .sk { animation: none; }
}

/* Bandeau d'alerte du rapport mensuel (pointages encore en attente). */
.rap-warn {
  display: flex; align-items: center; gap: 7px;
  background: color-mix(in srgb, var(--warn, #d9892b) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--warn, #d9892b) 45%, transparent);
  color: color-mix(in srgb, var(--warn, #d9892b) 78%, var(--text, #1a1a1a));
  padding: 8px 11px; border-radius: 8px;
  font-size: 12.5px; line-height: 1.35; margin: 4px 0 12px;
}
