/* ============================================================
   LTi-Tracking — Design System v3
   Mode sombre/clair fonctionnel + Mobile first
   ============================================================ */

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

/* ── Tokens : MODE SOMBRE (défaut) ──────────────────────── */
:root {
  --accent:      #ff7300;
  --accent-glow: rgba(255,115,0,.22);
  --accent-dim:  rgba(255,115,0,.12);
  --radius:      10px;
  --radius-sm:   6px;
  --radius-lg:   16px;

  /* surfaces sombres */
  --bg:          #0d0d0d;
  --surface:     #161616;
  --surface2:    #1f1f1f;
  --border:      rgba(255,255,255,.08);
  --border-acc:  rgba(255,115,0,.35);

  /* textes */
  --text:        #f0ece8;
  --text-muted:  #8a8178;
  --text-faint:  #4a4540;

  /* statuts */
  --c-green:  #22c55e;
  --c-red:    #ef4444;
  --c-blue:   #3b82f6;
  --c-yellow: #f59e0b;
  --c-purple: #8b5cf6;
  --c-cyan:   #06b6d4;
  --c-slate:  #94a3b8;

  --shadow:    0 2px 12px rgba(0,0,0,.4);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.6);

  --header-h: 56px;
  --font: 'DM Sans', system-ui, sans-serif;
  --mono: 'DM Mono', monospace;
}

/* ── MODE CLAIR ──────────────────────────────────────────── */
/* [data-theme="light"] — couleurs injectées via PHP depuis settings.json */
/* Le toggle JS bascule l'attribut mais les variables CSS viennent du <style> inline */

/* ── Reset ───────────────────────────────────────────────── */
*, *::before, *::after { margin:0; padding:0; box-sizing:border-box; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
  min-height: 100vh;
  transition: background .25s, color .25s;
  -webkit-font-smoothing: antialiased;
}

/* ── Header ──────────────────────────────────────────────── */
.header {
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: 0 1rem;
  position: sticky;
  top: 0;
  z-index: 200;
  box-shadow: var(--shadow);
}

.header-brand {
  font-weight: 700;
  font-size: .95rem;
  color: var(--accent);
  white-space: nowrap;
  letter-spacing: -.01em;
  flex-shrink: 0;
}

.header-nav {
  display: flex;
  gap: .2rem;
  flex-wrap: wrap;
  flex: 1;
  padding: 0 .5rem;
}

.header-nav a {
  color: var(--text-muted);
  text-decoration: none;
  padding: .32rem .65rem;
  border-radius: var(--radius-sm);
  font-size: .82rem;
  font-weight: 500;
  transition: background .15s, color .15s;
  white-space: nowrap;
}
.header-nav a:hover { background: var(--accent-dim); color: var(--text); }
.header-nav a.active {
  background: var(--accent-glow);
  color: var(--accent);
  font-weight: 600;
}

.header-right {
  display: flex;
  align-items: center;
  gap: .6rem;
  flex-shrink: 0;
}

/* Bouton hamburger mobile */
.hamburger {
  display: none;
  flex-direction: column;
  gap: 4px;
  background: none;
  border: none;
  cursor: pointer;
  padding: .4rem;
  border-radius: var(--radius-sm);
}
.hamburger span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: transform .25s, opacity .25s;
}

/* Menu mobile déroulant */
.mobile-nav {
  display: none;
  position: fixed;
  top: var(--header-h);
  left: 0; right: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: .75rem;
  z-index: 199;
  box-shadow: var(--shadow-lg);
  flex-direction: column;
  gap: .2rem;
}
.mobile-nav.open { display: flex; }
.mobile-nav a {
  color: var(--text);
  text-decoration: none;
  padding: .7rem .9rem;
  border-radius: var(--radius-sm);
  font-size: .9rem;
  font-weight: 500;
  transition: background .15s;
}
.mobile-nav a:hover, .mobile-nav a.active {
  background: var(--accent-glow);
  color: var(--accent);
}

/* Toggle thème */
.theme-toggle {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 20px;
  padding: .3rem .7rem;
  font-size: .8rem;
  cursor: pointer;
  transition: all .2s;
  display: flex;
  align-items: center;
  gap: .3rem;
  white-space: nowrap;
}
.theme-toggle:hover { border-color: var(--accent); color: var(--text); }

.user-pill {
  display: flex;
  align-items: center;
  gap: .4rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: .28rem .6rem .28rem .28rem;
  font-size: .78rem;
}
.user-avatar {
  width: 22px;
  height: 22px;
  background: var(--accent);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .7rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}
.user-name { color: var(--text); font-weight: 500; }
.user-role { color: var(--text-muted); font-size: .72rem; }

/* ── Layout principal ────────────────────────────────────── */
.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem;
}

/* ── Boutons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .5rem 1.1rem;
  border-radius: 20px;
  font-size: .83rem;
  font-weight: 600;
  font-family: var(--font);
  text-decoration: none;
  cursor: pointer;
  border: none;
  transition: all .2s;
  white-space: nowrap;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 10px var(--accent-glow);
}
.btn-primary:hover { filter: brightness(1.12); transform: translateY(-1px); }

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border-acc);
  color: var(--text);
}
.btn-ghost:hover { background: var(--accent-dim); }

.btn-danger {
  background: rgba(239,68,68,.15);
  border: 1px solid rgba(239,68,68,.35);
  color: #ef4444;
}
.btn-danger:hover { background: rgba(239,68,68,.25); }

.btn-sm { padding: .28rem .75rem; font-size: .76rem; }
.btn-logout {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: .75rem;
  padding: .25rem .6rem;
  border-radius: 12px;
}
.btn-logout:hover { border-color: var(--c-red); color: var(--c-red); }

/* ── Cartes ──────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
  transition: border-color .2s;
}
.card:hover { border-color: var(--border-acc); }
.card h2 { font-size: 1rem; font-weight: 600; margin-bottom: .85rem; }
.card h3 { font-size: .88rem; font-weight: 600; margin-bottom: .6rem; }

/* ── Formulaires ─────────────────────────────────────────── */
.form { display: flex; flex-direction: column; gap: .85rem; }

.form-row { display: flex; flex-direction: column; gap: .3rem; }
.form-row label { font-size: .8rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }

input[type="text"],
input[type="email"],
input[type="number"],
input[type="password"],
input[type="color"],
select,
textarea {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .6rem .85rem;
  font-size: .88rem;
  font-family: var(--font);
  width: 100%;
  transition: border-color .2s, box-shadow .2s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
input::placeholder { color: var(--text-faint); }
option { background: var(--surface); color: var(--text); }

input[type="color"] {
  padding: .2rem .3rem;
  height: 40px;
  cursor: pointer;
  width: 64px;
}

/* ── Tableaux ────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: .85rem; }
th {
  text-align: left;
  padding: .6rem .9rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  white-space: nowrap;
  background: var(--surface2);
}
th:first-child { border-radius: var(--radius-sm) 0 0 0; }
th:last-child  { border-radius: 0 var(--radius-sm) 0 0; }
td {
  padding: .55rem .9rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tbody tr { transition: background .12s; }
tbody tr:hover td { background: var(--accent-dim); }

/* ── Badges / tags ───────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .2rem .6rem;
  border-radius: 20px;
  font-size: .72rem;
  font-weight: 600;
}
.badge::before {
  content: '';
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: .7;
}

/* ── Alertes ─────────────────────────────────────────────── */
.alert {
  padding: .75rem 1rem;
  border-radius: var(--radius);
  font-size: .85rem;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: .5rem;
}
.alert-success { background: rgba(34,197,94,.12); border: 1px solid rgba(34,197,94,.3); color: #4ade80; }
.alert-error   { background: rgba(239,68,68,.12);  border: 1px solid rgba(239,68,68,.3);  color: #f87171; }

/* ── Utilitaires texte ───────────────────────────────────── */
h1 { font-size: 1.45rem; font-weight: 700; margin-bottom: 1.25rem; letter-spacing: -.02em; }
.text-muted  { color: var(--text-muted); }
.text-accent { color: var(--accent); }
.text-sm     { font-size: .8rem; }
.mono        { font-family: var(--mono); }
.fw-600      { font-weight: 600; }

/* ── Filtres inline ──────────────────────────────────────── */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  align-items: center;
  margin-bottom: 1rem;
}
.filters select,
.filters input[type="text"] {
  width: auto;
  min-width: 130px;
  padding: .4rem .75rem;
  font-size: .82rem;
}

/* ── Kanban ──────────────────────────────────────────────── */
.kanban-wrap {
  display: flex;
  flex-direction: column;
  gap: 0;
  overflow: hidden;
  width: 100%;
}

.kanban-head,
.kanban-body {
  overflow-x: auto;
  overflow-y: visible;
  scrollbar-width: thin;
  scrollbar-color: var(--border-acc) transparent;
  width: 100%;
}
/* Hauteur adaptative : viewport moins header, filtres, onglets années (~200px) */
.kanban-body {
  max-height: calc(100vh - var(--header-h) - 160px);
  overflow-y: auto;
}

.kanban-row {
  display: flex;
  gap: 10px;
  width: 100%;       /* JS override à max-content si scroll nécessaire */
  padding: 0 2px;
  box-sizing: border-box;
}

.kanban-head .kanban-row { padding-bottom: .65rem; }
.kanban-body .kanban-row { padding-bottom: .65rem; align-items: flex-start; }

/* Colonnes : fluides par défaut, JS ajuste si trop petites */
.k-col {
  flex: 1 1 0;
  min-width: 0;
  max-width: none;
}

/* Badge backlog */
.k-backlog-badge {
  display: block;
  font-size: .62rem;
  color: var(--text-muted);
  font-weight: 400;
  margin-top: .15rem;
}

.k-header {
  border-radius: var(--radius);
  padding: .65rem .85rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 3px solid var(--col-color, var(--accent));
  text-align: center;
  position: sticky;
  top: var(--header-h);
  z-index: 10;
}
.k-header-name { font-size: .82rem; font-weight: 600; }
.k-header-count {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1.1;
}
.k-header-total { font-size: .7rem; color: var(--text-muted); margin-top: .1rem; }

/* Cartes kanban */
.k-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .8rem;
  margin-bottom: .5rem;
  font-size: .82rem;
  transition: border-color .2s, box-shadow .2s;
  cursor: default;
}
.k-card:hover {
  border-color: var(--border-acc);
  box-shadow: 0 4px 16px var(--accent-glow);
}
.k-card-title { font-weight: 600; font-size: .84rem; margin-bottom: .35rem; line-height: 1.3; }
.k-card-meta { color: var(--text-muted); display: flex; flex-direction: column; gap: .2rem; }
.k-card-price { color: var(--accent); font-weight: 600; font-family: var(--mono); font-size: .82rem; }
.k-card-actions { margin-top: .6rem; display: flex; gap: .4rem; flex-wrap: wrap; }

details.k-move summary {
  cursor: pointer;
  color: var(--text-muted);
  font-size: .75rem;
  user-select: none;
  margin-top: .4rem;
  list-style: none;
  display: flex;
  align-items: center;
  gap: .3rem;
}
details.k-move summary::before { content: '↕'; font-size: .7rem; }
details.k-move[open] summary { color: var(--accent); }
.k-move-links { display: flex; flex-direction: column; gap: .25rem; margin-top: .4rem; }
.k-move-links a {
  padding: .3rem .6rem;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text-muted);
  background: var(--surface2);
  border: 1px solid var(--border);
  font-size: .75rem;
  transition: all .15s;
}
.k-move-links a:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-dim); }

/* ── Dashboard stats ─────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: .75rem;
  margin-bottom: 1.25rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: .25rem;
  transition: border-color .2s, transform .2s;
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--stat-color, var(--accent));
}
.stat-card:hover { border-color: var(--border-acc); transform: translateY(-2px); }
.stat-label { font-size: .72rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; }
.stat-value { font-size: 1.4rem; font-weight: 700; color: var(--text); line-height: 1.1; font-family: var(--mono); }
.stat-sub   { font-size: .72rem; color: var(--text-muted); }
.stat-icon  { position: absolute; right: .9rem; top: .9rem; font-size: 1.4rem; opacity: .18; }

/* Chart barres */
.chart-bar-wrap { margin-bottom: 1.25rem; }
.chart-bar-wrap h3 { font-size: .9rem; font-weight: 600; margin-bottom: .85rem; }
.bar-row { display: flex; align-items: center; gap: .6rem; margin-bottom: .5rem; font-size: .8rem; }
.bar-label { width: 120px; text-align: right; color: var(--text-muted); font-size: .75rem; flex-shrink: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { flex: 1; height: 8px; background: var(--surface2); border-radius: 4px; overflow: hidden; }
.bar-fill  { height: 100%; border-radius: 4px; background: var(--accent); transition: width .6s cubic-bezier(.4,0,.2,1); }
.bar-val   { font-size: .73rem; color: var(--text-muted); width: 80px; font-family: var(--mono); flex-shrink: 0; }

/* Selecteur d'année */
.year-tabs {
  display: flex;
  gap: .3rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.year-tab {
  padding: .32rem .8rem;
  border-radius: 20px;
  font-size: .8rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font);
  transition: all .2s;
  text-decoration: none;
}
.year-tab:hover { border-color: var(--border-acc); color: var(--text); }
.year-tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.year-tab.all { border-style: dashed; }

/* ── Login ───────────────────────────────────────────────── */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 1rem;
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border-acc);
  border-radius: var(--radius-lg);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
  animation: fadeUp .5s ease;
}
.login-logo { font-size: 1.3rem; font-weight: 700; color: var(--accent); margin-bottom: .3rem; }
.login-sub  { font-size: .85rem; color: var(--text-muted); margin-bottom: 2rem; }
.login-card .btn-primary { width: 100%; justify-content: center; border-radius: var(--radius); padding: .75rem; font-size: .95rem; margin-top: .5rem; }
.login-error { background: rgba(239,68,68,.12); border: 1px solid rgba(239,68,68,.3); color: #f87171; padding: .65rem .9rem; border-radius: var(--radius-sm); font-size: .85rem; margin-bottom: 1rem; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: none; }
}

/* ── Responsive Mobile ───────────────────────────────────── */
@media (max-width: 768px) {
  :root { --header-h: 52px; }

  .header-nav { display: none; }
  .hamburger  { display: flex; }

  .container { padding: .85rem .85rem; }

  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: .5rem; }
  .stat-value { font-size: 1.15rem; }

  h1 { font-size: 1.15rem; margin-bottom: 1rem; }

  .k-col { flex: 0 0 210px; min-width: 210px; }

  .filters { gap: .4rem; }
  .filters select, .filters input { min-width: 110px; }

  table { font-size: .8rem; }
  th, td { padding: .45rem .6rem; }

  .user-name, .user-role { display: none; }
  .theme-toggle span { display: none; }

  /* Tableaux défilants sur mobile */
  .table-wrap { margin: 0 -.85rem; border-radius: 0; }
  .table-wrap table { min-width: 480px; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .login-card { padding: 1.75rem 1.25rem; }
  .year-tabs .year-tab { font-size: .73rem; padding: .28rem .65rem; }
}

/* ── Misc ────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-acc); border-radius: 3px; }

/* Séparateur section */
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .5rem;
  margin-bottom: 1rem;
}
.section-head h1, .section-head h2 { margin-bottom: 0; }

/* Grille 2 colonnes formulaire */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .85rem;
}
@media (max-width: 600px) { .form-grid { grid-template-columns: 1fr; } }

/* Couleur statut inline */
.status-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  vertical-align: middle;
  margin-right: .3rem;
  flex-shrink: 0;
}
.link_retour {
  color: orange;
}