/* =====================================================================
   Neriya Playout — régie
   Langage visuel repris du portfolio Neriya / Éric GUEI :
   bleu nuit profond, bleu Neriya, rouge « tally » réservé à l'antenne,
   vert « preview » réservé à ce qui est prêt.
   ===================================================================== */
:root {
  --bg: #050914;
  --panel: #0A1330;
  --panel-2: #0E1A3F;
  --line: #1A2A5C;
  --ink: #EAF0FF;
  --muted: #9BAAD0;
  --sky: #6CA5FF;
  --tally: #FF3B30;
  --pvw: #2BD97C;
  --warn: #F5B83D;
  --brand: #2C66F6;               /* remplacé par la couleur de la chaîne */
  --head: "Anybody", "Arial Black", Arial, sans-serif;
  --body: "Hanken Grotesk", "Segoe UI", Arial, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;
  --r: 6px;
  color-scheme: dark;
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 400 15px/1.55 var(--body); -webkit-font-smoothing: antialiased; }
a { color: var(--sky); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
:focus-visible { outline: 3px solid var(--sky); outline-offset: 2px; border-radius: 4px; }
h1, h2, h3 { font-family: var(--head); font-stretch: 125%; font-weight: 800; margin: 0 0 12px; line-height: 1.1; letter-spacing: -.005em; }
h1 { font-size: clamp(1.5rem, 2.6vw, 2rem); }
h2 { font-size: 1.05rem; }
h3 { font-size: .95rem; color: var(--muted); margin-top: 18px; }
small, .small { font-size: 13px; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: 13px; font-variant-numeric: tabular-nums; }
.lead { font-size: 17px; margin: 0; }
code { font-family: var(--mono); font-size: 13px; background: var(--bg); padding: 1px 6px; border-radius: 4px; border: 1px solid var(--line); }

/* ---------------------------------------------------------------- cadre */
body { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--panel); border-right: 1px solid var(--line); padding: 20px 12px; display: flex; flex-direction: column; gap: 22px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; gap: 11px; align-items: center; padding: 0 8px; }
.brand strong { display: block; font: 800 1rem/1.15 var(--head); font-stretch: 125%; }
.brand small { color: var(--muted); }
.brand.big { margin-bottom: 18px; }
.brand.big strong { font-size: 1.35rem; }
.dot { width: 14px; height: 14px; border-radius: 3px; background: var(--brand); flex: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 30%, transparent); }
.side nav { display: flex; flex-direction: column; gap: 2px; }
.side nav a { display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: var(--r); color: var(--muted); font-weight: 500; }
.side nav a svg { width: 20px; height: 20px; flex: none; }
.side nav a:hover { background: var(--panel-2); color: var(--ink); text-decoration: none; }
.side nav a.on { background: var(--panel-2); color: var(--ink); box-shadow: inset 3px 0 0 var(--brand); }
.logout { margin-top: auto; }
.who { display: block; color: var(--ink); padding: 0 12px 4px; font-size: 13px; }
.who span { color: var(--muted); }
.logout button { background: none; border: 0; color: var(--muted); cursor: pointer; font: inherit; padding: 8px 12px; }
.logout button:hover { color: var(--ink); }
.version { color: var(--muted); padding: 0 12px; font-size: 12px; opacity: .7; }

main { padding: 0 clamp(16px, 3vw, 36px) 64px; max-width: 1240px; width: 100%; }

/* barre de régie (HUD) */
.hud { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 18px; padding: 14px 0; margin-bottom: 18px; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.hud h1 { margin: 0; margin-right: auto; }
.hud-item { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; }
.hud-item b { color: var(--ink); font-family: var(--mono); font-weight: 500; }
.tally { display: inline-flex; align-items: center; gap: 8px; padding: 5px 12px; border-radius: 4px; font: 700 13px var(--body); background: var(--panel-2); color: var(--muted); border: 1px solid var(--line); white-space: nowrap; }
.tally i { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.tally.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.tally.live { background: var(--tally); border-color: var(--tally); color: #fff; }
.tally.live i { animation: blink 1.2s steps(2, start) infinite; }
.tally.off { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, transparent); }
@keyframes blink { 50% { opacity: .2; } }

/* ---------------------------------------------------------------- éléments */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; margin-bottom: 18px; }
.card > h2:first-child, .card .row-between > h2 { margin-bottom: 12px; }
.stack > .card:last-child { margin-bottom: 0; }

.flash { padding: 12px 14px; border-radius: var(--r); margin-bottom: 16px; border: 1px solid; border-left-width: 4px; }
.flash.ok { background: color-mix(in srgb, var(--pvw) 9%, var(--panel)); border-color: color-mix(in srgb, var(--pvw) 45%, transparent); }
.flash.error { background: color-mix(in srgb, var(--tally) 10%, var(--panel)); border-color: color-mix(in srgb, var(--tally) 55%, transparent); }
.flash.warn { background: color-mix(in srgb, var(--warn) 8%, var(--panel)); border-color: color-mix(in srgb, var(--warn) 45%, transparent); font-size: 14px; }

input, select, textarea { background: var(--bg); border: 1px solid var(--line); color: var(--ink); border-radius: var(--r); padding: 10px 12px; font: inherit; min-width: 0; }
textarea { width: 100%; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--sky) 70%, transparent); outline-offset: 1px; border-color: transparent; }
input[type=color] { padding: 3px; height: 42px; width: 64px; cursor: pointer; }
input[type=checkbox], input[type=radio] { accent-color: var(--brand); width: 17px; height: 17px; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--muted); }
label.inline { flex-direction: row; align-items: center; gap: 8px; color: var(--ink); }
label small { color: var(--muted); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 42px; background: var(--panel-2); color: var(--ink); border: 2px solid var(--line); border-radius: var(--r); padding: 0 16px; font: 700 14px var(--body); cursor: pointer; white-space: nowrap; text-decoration: none; }
.btn:hover { border-color: var(--sky); text-decoration: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { filter: brightness(1.12); }
.btn.ghost { background: transparent; }
.btn.danger { color: #FF8A82; background: transparent; }
.btn.danger:hover { border-color: var(--tally); }
.btn.small { min-height: 34px; padding: 0 11px; font-size: 13px; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .5; cursor: wait; }

.row { display: flex; gap: 10px; align-items: center; margin: 10px 0; }
.row.wrap { flex-wrap: wrap; }
.row > input:not([type=checkbox]):not([type=file]):not([type=color]) { flex: 1; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; align-items: end; }
.form-grid .full { grid-column: 1 / -1; }

.table { width: 100%; border-collapse: collapse; }
.table td, .table th { padding: 11px 8px; border-top: 1px solid var(--line); vertical-align: middle; text-align: left; }
.table th { color: var(--muted); font-weight: 500; font-size: 13px; border-top: 0; }
.table tr:first-child td { border-top: 0; }
.table td.actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.table td.big { font: 500 18px var(--mono); }
.table td.num, .table th.num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }
.table tr.dim { opacity: .45; }
.actions form, .media-actions form { margin: 0; }

.tag { display: inline-flex; align-items: center; gap: 6px; font: 600 12px var(--body); padding: 3px 9px; border-radius: 4px; background: var(--panel-2); border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.tag.program { color: #fff; background: var(--brand); border-color: var(--brand); }
.tag.rotation { color: var(--sky); border-color: color-mix(in srgb, var(--sky) 40%, transparent); }
.tag.filler, .tag.safe { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, transparent); }
.tag.live { color: #fff; background: var(--tally); border-color: var(--tally); }
.tag.st-ready, .tag.dst-ok { color: var(--pvw); border-color: color-mix(in srgb, var(--pvw) 40%, transparent); }
.tag.st-processing, .tag.st-pending, .tag.dst-pending { color: var(--sky); border-color: color-mix(in srgb, var(--sky) 40%, transparent); }
.tag.st-failed, .tag.dst-error { color: #FF8A82; border-color: color-mix(in srgb, var(--tally) 50%, transparent); }
.tag.dst-ok::before, .tag.dst-error::before, .tag.dst-pending::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.bad { color: #FF8A82; }

/* ---------------------------------------------------------------- antenne */
.onair-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 18px; margin-bottom: 18px; align-items: start; }
.monitor { padding: 0; overflow: hidden; margin: 0; }
.screen { position: relative; aspect-ratio: 16/9; background: #000; display: grid; place-items: center; border: 3px solid var(--line); border-radius: var(--r) var(--r) 0 0; transition: border-color .3s; }
.monitor.pgm .screen { border-color: var(--brand); }
.monitor.pgm-live .screen { border-color: var(--tally); }
.screen video { width: 100%; height: 100%; display: block; background: #000; }
.screen-tag { position: absolute; left: 10px; top: 10px; z-index: 2; background: var(--brand); color: #fff; font: 700 12px var(--mono); padding: 2px 8px; border-radius: 3px; }
.monitor.pgm-live .screen-tag { background: var(--tally); }
.screen-empty { color: var(--muted); text-align: center; padding: 20px; }
.lower { display: grid; grid-template-columns: auto 1fr; align-items: stretch; }
.lower .src { background: var(--brand); color: #fff; font: 800 13px var(--head); font-stretch: 125%; padding: 12px 14px; display: flex; align-items: center; }
.monitor.pgm-live .lower .src { background: var(--tally); }
.lower .src.filler, .lower .src.safe { background: var(--warn); color: #1a1200; }
.lower .ttl { background: #000; padding: 10px 16px; min-width: 0; }
.lower .ttl strong { display: block; font: 700 17px var(--body); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.timeline { padding: 12px 16px 4px; }
.bar { height: 4px; background: var(--panel-2); border-radius: 2px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--sky); transition: width 1s linear; }
.controls { display: flex; gap: 10px; padding: 12px 16px 16px; flex-wrap: wrap; }

/* le « bus » de sources, comme sur un mélangeur vidéo */
.bus { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.bus button { min-height: 64px; background: var(--bg); color: var(--ink); border: 2px solid var(--line); border-radius: var(--r); font: 800 15px var(--head); font-stretch: 125%; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
.bus button small { font: 500 12px var(--body); color: var(--muted); font-stretch: 100%; }
.bus button:hover { border-color: var(--sky); }
.bus button.ready { border-color: var(--pvw); }
.bus button[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: #fff; }
.bus button[aria-pressed="true"] small { color: #E3EBFF; }
.bus button.live[aria-pressed="true"] { background: var(--tally); border-color: var(--tally); }
.bus-note { margin: 10px 0 0; font-size: 13px; color: var(--muted); }

.figure { display: flex; align-items: baseline; gap: 10px; }
.figure b { font: 800 clamp(2.2rem, 4vw, 3rem)/1 var(--head); font-stretch: 125%; font-variant-numeric: tabular-nums; }
.figure span { color: var(--muted); }
.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: 8px 0; border-top: 1px solid var(--line); }
.list li:first-child { border-top: 0; }
.list .mono { color: var(--sky); margin-right: 8px; }
.inventory { display: flex; flex-wrap: wrap; gap: 6px 18px; color: var(--muted); font-size: 14px; }
.inventory b { color: var(--ink); font-family: var(--mono); font-weight: 500; }

/* bandeau : aperçu fidèle de ce qui passe à l'antenne */
.ticker-preview { overflow: hidden; border-radius: 4px; background: var(--ticker, #b91c1c); color: #fff; height: 40px; display: flex; align-items: center; margin-bottom: 12px; }
.ticker-preview span { white-space: nowrap; padding-left: 100%; font: 700 15px var(--body); animation: crawl 22s linear infinite; }
.ticker-preview.off { background: var(--panel-2); }
.ticker-preview.off span { animation: none; padding-left: 14px; color: var(--muted); font-weight: 500; }
@keyframes crawl { to { transform: translateX(-100%); } }

/* ---------------------------------------------------------------- direct */
.live-grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 18px; margin-bottom: 18px; align-items: start; }
.live-grid .card { margin: 0; }
.live-status { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; align-items: center; padding: 16px; border-radius: var(--r); background: var(--bg); border: 2px solid var(--line); margin-bottom: 14px; }
.live-status strong { font: 800 1.2rem var(--head); font-stretch: 125%; }
.live-status small { grid-column: 2; color: var(--muted); }
.pulse { width: 14px; height: 14px; border-radius: 50%; background: var(--line); grid-row: span 2; }
.live-status.ready { border-color: var(--pvw); }
.live-status.ready .pulse { background: var(--pvw); }
.live-status.on { border-color: var(--tally); background: color-mix(in srgb, var(--tally) 10%, var(--bg)); }
.live-status.on .pulse { background: var(--tally); animation: ring 1.6s infinite; }
@keyframes ring { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--tally) 60%, transparent); } 100% { box-shadow: 0 0 0 12px transparent; } }
.mode-list { display: flex; flex-direction: column; gap: 8px; }
.mode { flex-direction: row; align-items: flex-start; gap: 10px; padding: 12px; border: 2px solid var(--line); border-radius: var(--r); cursor: pointer; color: var(--ink); }
.mode.on { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 10%, transparent); }
.mode input { margin-top: 3px; }
.mode span { display: flex; flex-direction: column; }
.copy-row { display: flex; gap: 8px; align-items: flex-end; margin: 10px 0; }
.copy-row label { flex: 1; }
.copy-row input, .copy-row textarea { font-family: var(--mono); font-size: 13px; }
.tips { margin: 0; padding-left: 18px; color: var(--muted); font-size: 14px; }
.tips li { padding: 2px 0; }

/* ---------------------------------------------------------------- audience */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; margin-bottom: 18px; }
.kpis .card { margin: 0; }
.kpis .figure b { font-size: clamp(1.8rem, 3vw, 2.4rem); }
.kpis p { margin: 6px 0 0; color: var(--muted); font-size: 13px; }
.kpis .card.now { border-color: color-mix(in srgb, var(--tally) 45%, var(--line)); }
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: 240px; overflow: visible; }
.chart .grid line { stroke: var(--line); stroke-width: 1; }
.chart .axis text { fill: var(--muted); font: 12px var(--body); }
.chart .area { fill: color-mix(in srgb, var(--sky) 16%, transparent); }
.chart .line { fill: none; stroke: var(--sky); stroke-width: 2; stroke-linejoin: round; }
.chart .cross { stroke: var(--muted); stroke-dasharray: 3 3; }
.chart .marker { fill: var(--sky); stroke: var(--panel); stroke-width: 2; }
.tip { position: absolute; pointer-events: none; background: var(--bg); border: 1px solid var(--line); border-radius: 4px; padding: 6px 10px; font-size: 13px; white-space: nowrap; transform: translate(-50%, -110%); }
.tip b { font-family: var(--mono); }
.split { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.meter { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center; padding: 7px 0; }
.meter .track { grid-column: 1 / -1; height: 6px; background: var(--panel-2); border-radius: 3px; overflow: hidden; }
.meter .track i { display: block; height: 100%; background: var(--sky); border-radius: 3px; }

/* serveur */
.mini-meters { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px 24px; }
.meter .track i.warn { background: var(--warn); }
.meter .track i.hot { background: var(--tally); }
.kpis .meter { padding: 8px 0 0; }
@media (max-width: 760px) { .mini-meters { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ---------------------------------------------------------------- médias */
.drop { position: relative; border: 2px dashed var(--line); border-radius: var(--r); padding: 30px; text-align: center; transition: .2s; }
.drop.over { border-color: var(--sky); background: color-mix(in srgb, var(--sky) 8%, transparent); }
.drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.drop p { margin: 0; }
.up { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); font-size: 14px; }
.up .bar { grid-column: 1 / -1; }
.up.err { color: #FF8A82; }
.tabs { display: flex; gap: 4px; background: var(--bg); padding: 4px; border-radius: var(--r); border: 1px solid var(--line); }
.tabs a { padding: 6px 12px; border-radius: 4px; color: var(--muted); font-size: 14px; }
.tabs a:hover { text-decoration: none; color: var(--ink); }
.tabs a.on { background: var(--panel-2); color: var(--ink); }
.media-row { display: flex; gap: 12px; justify-content: space-between; align-items: center; padding: 12px 0; border-top: 1px solid var(--line); }
.media-main { flex: 1; min-width: 0; }
.title-input { width: 100%; background: transparent; border-color: transparent; font-weight: 700; padding: 6px 8px; margin-left: -8px; }
.title-input:hover, .title-input:focus { border-color: var(--line); background: var(--bg); }
.meta { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; color: var(--muted); font-size: 13px; }
.meta select { padding: 4px 8px; font-size: 13px; }
.media-actions { display: flex; gap: 6px; }
.error-text { color: #FF8A82; font-size: 13px; margin: 6px 0 0; }

.checklist { max-height: 340px; overflow: auto; border: 1px solid var(--line); border-radius: var(--r); margin: 10px 0; }
.checklist label { flex-direction: row; align-items: center; gap: 10px; padding: 9px 12px; border-top: 1px solid var(--line); color: var(--ink); cursor: pointer; }
.checklist label:first-child { border-top: 0; }
.checklist label span { flex: 1; }
.filter { width: 100%; }
.days { display: flex; gap: 6px; flex-wrap: wrap; grid-column: 1 / -1; }
.day { flex-direction: row; cursor: pointer; }
.day input { position: absolute; opacity: 0; pointer-events: none; }
.day span { padding: 8px 12px; border-radius: var(--r); border: 2px solid var(--line); color: var(--muted); font-weight: 700; }
.day input:checked + span { background: var(--brand); border-color: var(--brand); color: #fff; }
.day input:focus-visible + span { outline: 3px solid var(--sky); outline-offset: 2px; }
.logo-preview { width: 240px; height: 120px; border-radius: var(--r); display: grid; place-items: center; background: repeating-conic-gradient(#0d1530 0 25%, #121d40 0 50%) 0 0 / 16px 16px; border: 1px solid var(--line); }
.logo-preview img { max-width: 100%; max-height: 100%; }

/* ---------------------------------------------------------------- connexion */
body.guest { display: grid; grid-template-columns: minmax(0, 1fr); place-items: center; min-height: 100vh; padding: 20px; background: radial-gradient(ellipse 60% 50% at 70% 20%, color-mix(in srgb, var(--brand) 22%, transparent), transparent 70%), var(--bg); }
body.guest .flash { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); }
.login { width: min(400px, 100%); display: flex; flex-direction: column; gap: 14px; padding: 30px; border-top: 4px solid var(--brand); }

/* ---------------------------------------------------------------- mobile */
@media (max-width: 1000px) {
  .onair-grid, .live-grid { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  body { grid-template-columns: minmax(0, 1fr); padding-bottom: 66px; }
  .side { position: fixed; bottom: 0; top: auto; left: 0; right: 0; height: auto; flex-direction: row; padding: 6px; z-index: 10; border-right: 0; border-top: 1px solid var(--line); }
  .side .brand, .side .logout, .side .version { display: none; }
  .side nav { flex-direction: row; width: 100%; overflow-x: auto; scrollbar-width: none; }
  .side nav a { flex-direction: column; gap: 2px; font-size: 10.5px; padding: 6px 4px; min-width: 56px; flex: 1 0 auto; }
  .side nav a.on { box-shadow: inset 0 3px 0 var(--brand); }
  .hud { gap: 10px; }
  .hud .hud-clock { display: none; }
  .split { grid-template-columns: 1fr; }
  .media-row { flex-direction: column; align-items: stretch; }
  .copy-row { flex-wrap: wrap; }
  .copy-row label { flex-basis: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
