/* ==========================================================================
   Noemid Dashboard — site/style.css
   Design sombre premium type Grafana. 100 % offline, aucune dépendance.
   Palette GitHub-dark : fond #0d1117, cartes #161b22, accent #58a6ff.
   ========================================================================== */

/* ---------- Variables de thème ---------- */
:root {
  --bg:        #0d1117;   /* fond global */
  --card:      #161b22;   /* cartes / panneaux */
  --card-2:    #1c2128;   /* cartes secondaires, headers de table */
  --border:    #30363d;   /* bordures */
  --accent:    #58a6ff;   /* bleu accent */
  --ok:        #3fb950;   /* vert */
  --err:       #f85149;   /* rouge */
  --warn:      #d29922;   /* orange */
  --muted:     #8b949e;   /* gris texte secondaire */
  --text:      #e6edf3;   /* texte principal */
  --shadow:    0 1px 3px rgba(0,0,0,.45);
  --radius:    8px;
  --sidebar-w: 240px;

  /* variables pilotées par le prompteur */
  --p-width: 60%;           /* largeur du texte centré */
  --p-font: 48px;           /* taille de police du prompteur */
}

/* ---------- Reset / base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { height: 100%; }
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5rem; }
h2 { font-size: 1.15rem; margin-top: 1.25rem; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code {
  font-family: ui-monospace, "Cascadia Code", Consolas, Menlo, monospace;
  font-size: .9em;
  background: var(--card-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: .05rem .3rem;
}
button {
  font: inherit;
  color: var(--text);
  background: var(--card-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .45rem .8rem;
  cursor: pointer;
  min-height: 32px;
  transition: background .12s, border-color .12s;
}
button:hover { background: #262d36; border-color: var(--muted); }
input[type="search"], input[type="text"] {
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .45rem .7rem;
}
input:focus-visible, button:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* ---------- Layout global : sidebar + main ---------- */
#sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: #010409;                /* encore plus sombre que le fond */
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 30;
}
.brand {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: 1rem;
  border-bottom: 1px solid var(--border);
}
.brand-dot {
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 8px var(--ok);
  flex: none;
}
.brand strong { display: block; font-size: 1.1rem; letter-spacing: .02em; }
.brand small { color: var(--muted); font-size: .72rem; }

#nav { flex: 1; overflow-y: auto; padding: .6rem .6rem 1rem; }
#nav a {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .55rem .75rem;
  margin: 2px 0;
  border-radius: var(--radius);
  color: var(--muted);
  border: 1px solid transparent;
}
#nav a:hover { background: var(--card); color: var(--text); text-decoration: none; }
#nav a.active {
  background: var(--card);
  color: var(--text);
  border-color: var(--border);
  box-shadow: inset 3px 0 0 var(--accent);
}
#nav a .nav-ico { width: 1.1em; text-align: center; flex: none; }
#nav a .nav-badge {
  margin-left: auto;
  font-size: .7rem;
  padding: 0 .4rem;
  border-radius: 10px;
  background: var(--card-2);
  border: 1px solid var(--border);
  color: var(--muted);
}
#nav a .nav-badge.bad { background: rgba(248,81,73,.15); color: var(--err); border-color: rgba(248,81,73,.4); }

.sidebar-foot {
  padding: .75rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: .5rem;
}
.sidebar-foot button { width: 100%; font-size: .85rem; color: var(--muted); }
.sidebar-foot button:hover { color: var(--text); }

#main {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------- Header ---------- */
#header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: .8rem 1.4rem;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}
#page-title { font-size: 1.15rem; margin: 0; flex: 1; }
.stamp {
  font-size: .75rem;
  color: var(--muted);
  background: var(--card-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: .25rem .7rem;
  white-space: nowrap;
}
#btn-menu { display: none; }     /* hamburger mobile (affiché via media query) */

/* ---------- Vue principale ---------- */
#view {
  padding: 1.4rem;
  flex: 1;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
}
#foot {
  padding: .9rem 1.4rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: .75rem;
  display: flex;
  flex-wrap: wrap;
  gap: .4rem 1.4rem;
}

/* ---------- Cartes / panneaux ---------- */
.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem 1.1rem;
  margin-bottom: 1.1rem;
}
.panel > h2, .panel-title {
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  margin: 0 0 .8rem;
}
.grid {
  display: grid;
  gap: 1rem;
}
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }

/* ---------- Cartes KPI ---------- */
.kpi-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  margin-bottom: 1.2rem;
}
.kpi {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: .9rem 1rem .7rem;
  position: relative;
  overflow: hidden;
  cursor: pointer;
}
.kpi::before {                       /* liseré coloré vertical à gauche */
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--accent);
}
.kpi.ok   { --ke: var(--ok); }
.kpi.err  { --ke: var(--err); }
.kpi.warn { --ke: var(--warn); }
.kpi.off  { --ke: var(--muted); }
.kpi::before { background: var(--ke, var(--accent)); }
.kpi .kpi-label { font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.kpi .kpi-value { font-size: 2.1rem; font-weight: 700; color: var(--ke, var(--accent)); line-height: 1.1; }
.kpi .kpi-sub   { font-size: .75rem; color: var(--muted); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: .88rem;
}
.tbl th, .tbl td {
  text-align: left;
  padding: .55rem .7rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.tbl th {
  color: var(--muted);
  font-weight: 600;
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  background: var(--card-2);
  position: sticky;
  top: 0;
}
.tbl tbody tr:hover { background: #1a2130; }
.tbl td.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Badges statut (pill) ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  font-size: .72rem;
  font-weight: 600;
  padding: .1rem .6rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card-2);
  color: var(--muted);
  white-space: nowrap;
}
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.badge.ok   { color: var(--ok);   background: rgba(63,185,80,.12);  border-color: rgba(63,185,80,.45); }
.badge.err  { color: var(--err);  background: rgba(248,81,73,.12);  border-color: rgba(248,81,73,.45); }
.badge.warn { color: var(--warn); background: rgba(210,153,34,.12); border-color: rgba(210,153,34,.45); }
.badge.off  { color: var(--muted); }
.badge.acc  { color: var(--accent); background: rgba(88,166,255,.12); border-color: rgba(88,166,255,.45); }

/* ---------- Accueil : liens rapides ---------- */
.links-list { list-style: none; margin: 0; padding: 0; }
.links-list li { padding: .45rem 0; border-bottom: 1px dashed var(--border); }
.links-list li:last-child { border-bottom: none; }
.links-list a { display: flex; gap: .6rem; align-items: baseline; }
.links-list a span.lbl { color: var(--text); }
.links-list a span.cnt { color: var(--muted); font-size: .8rem; margin-left: auto; }

/* ---------- Content : calendrier ---------- */
.cal-head {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: .8rem;
}
.cal-head h3 { margin: 0; flex: 1; }
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
}
.cal-dow {
  text-align: center;
  font-size: .7rem;
  text-transform: uppercase;
  color: var(--muted);
  padding: .25rem 0;
}
.cal-cell {
  min-height: 72px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px;
  font-size: .75rem;
}
.cal-cell.dim { opacity: .35; }          /* jours hors mois */
.cal-cell.today { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.cal-day { font-weight: 600; color: var(--muted); }
.cal-event {
  margin-top: 3px;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(88,166,255,.15);
  border-left: 2px solid var(--accent);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cal-event.published { background: rgba(63,185,80,.15); border-left-color: var(--ok); }

/* ---------- Content : kanban ---------- */
.kanban { display: grid; gap: .8rem; }
.kanban-cols-5 { grid-template-columns: repeat(5, minmax(150px, 1fr)); }
.kanban-col {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .6rem;
  min-height: 120px;
}
.kanban-col h4 {
  margin: 0 0 .5rem;
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
}
.kanban-col h4 .count {
  background: var(--card-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0 .45rem;
  font-size: .7rem;
}
.kanban-item {
  background: var(--card-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: .35rem .55rem;
  margin-bottom: .4rem;
  font-size: .8rem;
  cursor: pointer;
}
.kanban-item:hover { border-color: var(--accent); }
.kanban-item .k-title {
  display: block;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.kanban-item .k-date { color: var(--muted); font-size: .7rem; }

/* ---------- Content : grille de cards vidéos ---------- */
.video-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}
.video-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: .8rem .9rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: .4rem;
  transition: border-color .12s, transform .12s;
}
.video-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.video-card .v-title { font-weight: 600; font-size: .92rem; }
.video-card .v-desc {
  color: var(--muted);
  font-size: .78rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.video-card .v-foot { display: flex; justify-content: space-between; align-items: center; font-size: .72rem; color: var(--muted); margin-top: auto; }

/* ---------- Fiche vidéo ---------- */
.video-head { display: flex; flex-wrap: wrap; align-items: center; gap: .8rem; margin-bottom: .6rem; }
.video-head h2 { margin: 0; font-size: 1.3rem; }
.script-body { font-size: .95rem; }
.script-body h3 { margin-top: 1.2rem; color: var(--accent); }
.script-body ul { margin: .4rem 0; padding-left: 1.2rem; }
.script-body p { margin: .6rem 0; }

.checklist { list-style: none; margin: 0; padding: 0; }
.checklist li { padding: .3rem 0; border-bottom: 1px dashed var(--border); font-size: .88rem; }
.checklist li:last-child { border-bottom: none; }
.checklist li .ck { margin-right: .5rem; font-weight: 700; }
.checklist li.done { color: var(--muted); text-decoration: line-through; }
.checklist li.done .ck { color: var(--ok); }

.asset-chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.asset-chips .badge { font-weight: 400; }

/* ---------- Projets : phases + barres d'avancement ---------- */
.phase { margin-bottom: .7rem; }
.phase .ph-head {
  display: flex;
  justify-content: space-between;
  font-size: .82rem;
  margin-bottom: .25rem;
}
.phase .ph-head .ph-title { font-weight: 600; }
.progress {
  height: 8px;
  background: var(--card-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
}
.progress .bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--ok));
  border-radius: 999px;
  transition: width .4s ease;
}
.count-chips { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .6rem; }
.count-chips .badge b { font-size: .85rem; }

/* ---------- Listes simples (veille / dreams / fichiers) ---------- */
.simple-list { list-style: none; margin: 0; padding: 0; }
.simple-list li {
  display: flex;
  align-items: baseline;
  gap: .8rem;
  padding: .45rem .2rem;
  border-bottom: 1px solid var(--border);
  font-size: .88rem;
}
.simple-list li:last-child { border-bottom: none; }
.simple-list li:hover { background: #1a2130; }
.simple-list .s-date { color: var(--muted); font-size: .75rem; white-space: nowrap; }
.simple-list .s-proj { margin-left: auto; }
.simple-list .s-snippet { color: var(--muted); font-size: .78rem; }

/* ---------- Bots ---------- */
.bot-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.bot-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .8rem .9rem;
}
.bot-card .b-id { font-weight: 700; color: var(--accent); font-family: ui-monospace, Consolas, monospace; }
.bot-card .b-role { color: var(--muted); font-size: .8rem; margin-top: .25rem; }

/* ---------- Prompteur plein écran (overlay signature) ---------- */
.prompter {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: #000;
  color: #fff;
  display: flex;
  flex-direction: column;
}
.prompter.hidden { display: none; }

.prompter-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: .5rem;
  padding: .6rem 1rem;
  background: rgba(13,17,23,.9);
  border-bottom: 1px solid var(--border);
}
.prompter-controls button {
  min-width: 48px;
  min-height: 48px;
  font-size: 1.1rem;
  background: #10151c;
  border-color: #30363d;
  color: #e6edf3;
}
.prompter-controls button:hover { background: #1c2128; border-color: var(--accent); color: var(--accent); }
.p-speed {
  font-family: ui-monospace, Consolas, monospace;
  font-size: .85rem;
  color: var(--muted);
  min-width: 86px;
  text-align: center;
}
.p-speed b { color: #fff; font-size: 1rem; }
.p-speed.pw { min-width: 70px; }

.prompter-mirror {
  position: fixed;
  right: 12px;
  top: 12px;
  z-index: 1010;
  min-width: 48px;
  min-height: 48px;
  font-size: 1.2rem;
  background: rgba(16,21,28,.85);
}
.prompter-mirror.active { border-color: var(--accent); color: var(--accent); }

.prompter-inner {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.prompter-line {
  display: flex;
  justify-content: space-between;
  padding: .5rem 1.2rem;
  color: var(--muted);
  font-size: .8rem;
}
.prompter-line .hint { color: #4d5966; }
.prompter-idx { font-family: ui-monospace, Consolas, monospace; }

.prompter-stage {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  cursor: grab;
  outline: none;           /* le focus clavier est géré programmatiquement */
  scrollbar-width: thin;
  scrollbar-color: #333 transparent;
}
.prompter-content {
  width: var(--p-width);
  margin: 12vh auto;       /* un tiers d'écran avant lecture */
  font-size: var(--p-font);
  line-height: 1.5;
  text-align: center;
  font-weight: 600;
  white-space: pre-wrap;
  padding-bottom: 45vh;    /* marge de fin : dernier bloc au centre */
  transition: font-size .1s ease-out;
}
.prompter-content.mirror { transform: scaleY(-1); }
.prompter-content h3 { color: #9ecbff; margin: 1.2em 0 .6em; }
.prompter-content p  { margin: .6em 0; }
.prompter-content ul { display: inline-block; text-align: center; list-style: none; padding: 0; margin: .5em 0; }
.prompter-content code { background: rgba(255,255,255,.08); border-color: transparent; color: inherit; font-size: .55em; }
.prompter-content.paused .play-ind {
  position: fixed;
  top: 55%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: min(14vw, 110px);
  color: rgba(255,255,255,.22);
  pointer-events: none;
  z-index: 1005;
}

/* ---------- États vides et erreurs ---------- */
.empty {
  text-align: center;
  padding: 2.4rem 1rem;
  color: var(--muted);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: rgba(22,27,34,.5);
}
.empty .e-ico { font-size: 1.8rem; display: block; margin-bottom: .5rem; opacity: .6; }
.empty .e-sub { font-size: .8rem; margin-top: .35rem; color: #6e7681; }
.error-note {
  background: rgba(248,81,73,.1);
  border: 1px solid rgba(248,81,73,.4);
  color: var(--err);
  border-radius: var(--radius);
  padding: .7rem 1rem;
  margin: 1rem 0;
  font-size: .85rem;
  white-space: pre-wrap;
  word-break: break-word;
}
.skeleton {
  color: var(--muted);
  padding: 2rem;
  text-align: center;
}

/* ---------- Responsive : sidebar repliable en mobile ---------- */
@media (max-width: 860px) {
  #sidebar {
    transform: translateX(-100%);
    transition: transform .2s ease;
    box-shadow: 0 0 30px rgba(0,0,0,.6);
  }
  body.sidebar-open #sidebar { transform: translateX(0); }
  #main { margin-left: 0; }
  #btn-menu { display: inline-flex; }
  #header { padding: .6rem .9rem; }
  #view { padding: .9rem; }
  .kanban-cols-5 { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .cal-cell { min-height: 52px; }
  .kpi .kpi-value { font-size: 1.7rem; }
  /* overlay : clic hors sidebar la referme (géré en JS via .sidebar-open) */
}

/* Barre ne s'affichant qu'au survol/idle sur le prompteur (contrôles discrets) */
@media (hover: hover) {
  .prompter.idle .prompter-controls,
  .prompter.idle .prompter-line .hint,
  .prompter.idle .prompter-mirror { opacity: .25; transition: opacity .3s; }
  .prompter.idle:hover .prompter-controls,
  .prompter.idle:hover .prompter-mirror { opacity: 1; }
}

/* ==========================================================================
   Section CARTOGRAPHIE — vue système animée (SVG)
   ========================================================================== */
.carto-panel { padding-bottom: .6rem; }
.carto-head { display: flex; align-items: center; gap: .8rem; margin-bottom: .4rem; }
.carto-head h2 { margin: 0; }
.carto-stage {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: radial-gradient(1200px 480px at 50% 52%, #10161d 0%, #0b0f14 60%, #090c10 100%);
  overflow: hidden;
}
.carto-svg { display: block; width: 100%; height: auto; }

.carto-t1 { fill: var(--text); font-size: 13.5px; font-weight: 700; text-anchor: middle; }
.carto-t2 { fill: var(--text); font-size: 11px; text-anchor: middle; }
.carto-t3 { fill: var(--muted); font-size: 9.5px; text-anchor: middle; }
.carto-t2.bot-on { fill: #7ee487; font-weight: 700; }
.carto-task-label { fill: var(--muted); font-size: 10.5px; text-anchor: start; font-style: italic; }

/* Anneau du cœur : pulsation lente */
.carto-ring { transform-origin: center; animation: carto-breathe 3.6s ease-in-out infinite; }
@keyframes carto-breathe {
  0%, 100% { transform: scale(1);    stroke-opacity: .9; }
  50%      { transform: scale(1.045); stroke-opacity: .45; }
}

/* Onde d'erreur quand des crons échouent */
.carto-ring-error { stroke: var(--err) !important; animation: carto-ring-error 1.4s ease-in-out infinite; }
@keyframes carto-ring-error {
  0%, 100% { transform: scale(1);    stroke-opacity: .95; }
  50%      { transform: scale(1.10); stroke-opacity: .30; }
}

/* Point de pulsation sur bot actif */
.carto-pulse { animation: carto-dotpulse 1.6s ease-in-out infinite; }
@keyframes carto-dotpulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: .25; }
}

/* Halo sur bot actif */
.carto-leaf.active rect { filter: drop-shadow(0 0 6px rgba(63, 185, 80, .55)); }

.carto-legend {
  display: flex; flex-wrap: wrap; gap: .35rem 1.1rem;
  padding: .55rem .2rem 0; font-size: .74rem; color: var(--muted);
}
.carto-legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: .35rem; vertical-align: middle; }

@media (prefers-reduced-motion: reduce) {
  .carto-ring, .carto-ring-error, .carto-pulse { animation: none; }
}