/* =========================================================================
   BroFlix - charte graphique
   Direction "densite pro" (Linear/Raycast), IBM Plex, palette encre/cuivre.
   Regle dure : pas de carte a bordure coloree (motif trop reconnaissable).
   Les statuts passent par un point colore + du mono, jamais par un bandeau.
   ========================================================================= */

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

:root {
  color-scheme: dark;

  --ink-950: #08090c;
  --ink-900: #0c0e12;
  --ink-850: #111318;
  --ink-800: #15181e;
  --ink-750: #191d24;
  --ink-700: #1e232b;
  --ink-600: #272d37;
  --ink-500: #353d4a;

  --txt-hi: #e9ebef;
  --txt-mid: #99a2b0;
  --txt-low: #667084;

  --copper: #e08348;
  --copper-hi: #f0975e;
  --copper-dim: rgba(224, 131, 72, 0.12);
  --copper-line: rgba(224, 131, 72, 0.35);

  --ok: #4ade80;
  --warn: #fbbf24;
  --err: #f87171;

  --sans: 'IBM Plex Sans', system-ui, -apple-system, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, 'Cascadia Code', monospace;

  --r-sm: 4px;
  --r-md: 6px;
  --r-lg: 10px;

  --sidebar-w: 216px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--ink-900);
  color: var(--txt-hi);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--copper-line); }

/* --------------------------------------------------------------- primitives */

.mono { font-family: var(--mono); }

.micro {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--txt-low);
}

button, select, input {
  font-family: inherit;
  font-size: 13px;
  color: var(--txt-hi);
  background: var(--ink-750);
  border: 1px solid var(--ink-600);
  border-radius: var(--r-md);
  padding: 7px 11px;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
}

button { cursor: pointer; }
button:hover { background: var(--ink-700); border-color: var(--ink-500); }
button:active { transform: translateY(0.5px); }

button:focus-visible, select:focus-visible, input:focus-visible {
  outline: none;
  border-color: var(--copper-line);
  box-shadow: 0 0 0 3px var(--copper-dim);
}

button.primary {
  background: var(--copper);
  border-color: var(--copper);
  color: #1b0f06;
  font-weight: 600;
}
button.primary:hover { background: var(--copper-hi); border-color: var(--copper-hi); }

button.ghost { background: transparent; border-color: transparent; color: var(--txt-mid); }
button.ghost:hover { background: var(--ink-750); color: var(--txt-hi); }

button.danger:hover { border-color: var(--err); color: var(--err); background: rgba(248, 113, 113, 0.08); }

input { background: var(--ink-850); }
input::placeholder { color: var(--txt-low); }

/* Point de statut : remplace tout bandeau/bordure coloree. */
.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex: none;
  display: inline-block;
  background: var(--txt-low);
}
.dot.ok { background: var(--ok); box-shadow: 0 0 8px rgba(74, 222, 128, 0.5); }
.dot.warn { background: var(--warn); box-shadow: 0 0 8px rgba(251, 191, 36, 0.45); }
.dot.err { background: var(--err); }
.dot.pulse { animation: pulse 1.6s ease-in-out infinite; }

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }

.tag {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.04em;
  color: var(--txt-mid);
  background: var(--ink-750);
  border: 1px solid var(--ink-600);
  border-radius: var(--r-sm);
  padding: 2px 6px;
  white-space: nowrap;
}
.tag.accent { color: var(--copper); border-color: var(--copper-line); background: var(--copper-dim); }

/* ============================================================ ADMIN (local) */

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--ink-950);
  border-right: 1px solid var(--ink-700);
  display: flex;
  flex-direction: column;
  padding: 18px 12px 12px;
  gap: 24px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 8px;
}

.brand-mark {
  width: 22px;
  height: 22px;
  border-radius: var(--r-sm);
  background: var(--copper);
  display: grid;
  place-items: center;
  flex: none;
}
.brand-mark::after {
  content: '';
  width: 0;
  height: 0;
  border-left: 7px solid #1b0f06;
  border-top: 4.5px solid transparent;
  border-bottom: 4.5px solid transparent;
  margin-left: 2px;
}

.brand-name {
  font-family: var(--mono);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.12em;
}

.nav { display: flex; flex-direction: column; gap: 2px; }

.nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  background: transparent;
  border: none;
  border-radius: var(--r-md);
  padding: 7px 9px;
  color: var(--txt-mid);
  font-size: 13px;
  text-align: left;
}
.nav-item:hover { background: var(--ink-850); color: var(--txt-hi); }
.nav-item.active { background: var(--ink-800); color: var(--txt-hi); box-shadow: inset 0 0 0 1px var(--ink-700); }
.nav-item .count { font-family: var(--mono); font-size: 11px; color: var(--txt-low); }
.nav-item.active .count { color: var(--copper); }

.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; padding: 0 8px; }
.sidebar-stat { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sidebar-stat .v { font-family: var(--mono); font-size: 11px; color: var(--txt-mid); }

.main { min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--ink-700);
  background: var(--ink-900);
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar h1 { font-size: 15px; font-weight: 600; margin: 0; }
.topbar .spacer { flex: 1; }

.content { padding: 20px 24px 56px; }

/* Lignes plates plutot que des cartes : densite et lisibilite. */
.rows { border: 1px solid var(--ink-700); border-radius: var(--r-lg); overflow: hidden; background: var(--ink-850); }

.row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--ink-800);
}
.row:last-child { border-bottom: none; }
.row:hover { background: var(--ink-800); }

.row-head {
  padding: 9px 16px;
  background: var(--ink-900);
  border-bottom: 1px solid var(--ink-700);
  display: flex;
  align-items: center;
  gap: 10px;
}

.row-main { min-width: 0; flex: 1; }
.row-title {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 8px;
}
.row-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 5px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--txt-low);
}
.row-meta .sep { opacity: 0.4; }
.row-actions { display: flex; gap: 6px; flex: none; }

/* Barre de filtres */
.filterbar {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 0 2px 14px;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  color: var(--txt-mid);
  cursor: pointer;
  user-select: none;
  padding: 5px 10px 5px 8px;
  border: 1px solid var(--ink-600);
  border-radius: var(--r-md);
  background: var(--ink-850);
}
.check:hover { border-color: var(--ink-500); color: var(--txt-hi); }
.check:has(input:checked) { color: var(--txt-hi); }

.check input {
  appearance: none;
  width: 14px;
  height: 14px;
  margin: 0;
  padding: 0;
  border: 1px solid var(--ink-500);
  border-radius: 3px;
  background: var(--ink-900);
  display: grid;
  place-items: center;
  flex: none;
}
.check input:checked { background: var(--copper); border-color: var(--copper); }
.check input:checked::after {
  content: '';
  width: 8px;
  height: 4px;
  border-left: 2px solid #1b0f06;
  border-bottom: 2px solid #1b0f06;
  transform: rotate(-45deg) translate(0.5px, -1px);
}
.check .count { font-family: var(--mono); font-size: 11px; color: var(--txt-low); }
.filterbar .spacer { flex: 1; }

/* Barre de progression d'encodage */
.progress {
  position: relative;
  height: 3px;
  border-radius: 999px;
  background: var(--ink-700);
  overflow: hidden;
  margin-top: 8px;
  max-width: 340px;
}
.progress span { position: absolute; inset: 0 auto 0 0; background: var(--copper); transition: width 400ms linear; }

.queue-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border: 1px solid var(--ink-700);
  border-radius: var(--r-lg);
  background: var(--ink-850);
  margin-bottom: 14px;
  font-size: 13px;
  color: var(--txt-mid);
}
.queue-banner .mono { color: var(--txt-hi); }

.empty {
  padding: 44px 20px;
  text-align: center;
  color: var(--txt-low);
  border: 1px dashed var(--ink-600);
  border-radius: var(--r-lg);
  font-size: 13px;
}
.empty strong { display: block; color: var(--txt-mid); font-weight: 500; margin-bottom: 4px; }

.error-text { color: var(--err); font-size: 13px; }

/* Ecran de connexion hote */
.gate { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.gate-card {
  width: 100%;
  max-width: 340px;
  background: var(--ink-850);
  border: 1px solid var(--ink-700);
  border-radius: var(--r-lg);
  padding: 26px 24px;
}
.gate-card .brand { padding: 0; margin-bottom: 18px; }
.gate-card p { color: var(--txt-mid); font-size: 13px; margin: 0 0 16px; }
.gate-form { display: flex; flex-direction: column; gap: 10px; }
.gate-form input { padding: 9px 12px; }

/* Bandeau de lien de room genere */
.link-out {
  margin-top: 16px;
  border: 1px solid var(--ink-700);
  background: var(--ink-850);
  border-radius: var(--r-lg);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.link-out code {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--copper);
  word-break: break-all;
  flex: 1;
  min-width: 220px;
}

.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink-700);
  border: 1px solid var(--ink-500);
  color: var(--txt-hi);
  font-size: 13px;
  padding: 9px 16px;
  border-radius: 999px;
  z-index: 100;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
}

/* ================================================================= LECTEUR */

body.player { background: var(--ink-950); }

.stage {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.player-topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--ink-800);
}
.player-topbar .title {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.player-topbar .spacer { flex: 1; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--txt-mid);
  border: 1px solid var(--ink-700);
  background: var(--ink-850);
  border-radius: 999px;
  padding: 4px 10px;
  white-space: nowrap;
}

.screen {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  overflow: hidden;
}

video {
  width: 100%;
  height: 100%;
  max-height: calc(100vh - 106px);
  display: block;
  object-fit: contain;
  background: #000;
}

/* Barre de controle maison : les controles natifs cassaient la charte. */
.controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 40px 16px 12px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.92) 0%, rgba(0, 0, 0, 0.6) 55%, transparent 100%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  opacity: 1;
  transition: opacity 260ms ease;
}
.screen.idle .controls { opacity: 0; pointer-events: none; }
.screen.idle { cursor: none; }

.scrub {
  position: relative;
  height: 16px;
  display: flex;
  align-items: center;
  cursor: pointer;
  touch-action: none;
}
.scrub-track {
  position: relative;
  height: 3px;
  width: 100%;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  overflow: hidden;
  transition: height 120ms ease;
}
.scrub:hover .scrub-track { height: 5px; }
.scrub-buffer { position: absolute; inset: 0 auto 0 0; background: rgba(255, 255, 255, 0.22); width: 0; }
.scrub-fill { position: absolute; inset: 0 auto 0 0; background: var(--copper); width: 0; }
.scrub-knob {
  position: absolute;
  top: 50%;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--copper);
  transform: translate(-50%, -50%) scale(0);
  transition: transform 120ms ease;
  pointer-events: none;
}
.scrub:hover .scrub-knob, .scrub.dragging .scrub-knob { transform: translate(-50%, -50%) scale(1); }

.ctl-row { display: flex; align-items: center; gap: 6px; }

.ctl {
  background: transparent;
  border: none;
  color: var(--txt-hi);
  padding: 7px;
  border-radius: var(--r-md);
  display: grid;
  place-items: center;
  line-height: 0;
}
.ctl:hover { background: rgba(255, 255, 255, 0.12); }
.ctl svg { width: 19px; height: 19px; fill: currentColor; }
.ctl.big svg { width: 25px; height: 25px; }

.time {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--txt-mid);
  white-space: nowrap;
  padding: 0 6px;
}
.time .cur { color: var(--txt-hi); }

.ctl-row .spacer { flex: 1; }

.volume { display: flex; align-items: center; gap: 6px; }
.volume input[type=range] {
  -webkit-appearance: none;
  appearance: none;
  width: 76px;
  height: 3px;
  border: none;
  padding: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.2);
}
.volume input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--txt-hi);
  cursor: pointer;
}

/* Popover reglages (pistes audio / sous-titres) */
.settings-wrap { position: relative; }

.popover {
  position: absolute;
  right: 0;
  bottom: calc(100% + 10px);
  width: 252px;
  max-height: 320px;
  overflow-y: auto;
  background: var(--ink-850);
  border: 1px solid var(--ink-600);
  border-radius: var(--r-lg);
  box-shadow: 0 16px 44px rgba(0, 0, 0, 0.6);
  padding: 8px;
  z-index: 30;
}
.popover-group + .popover-group { margin-top: 6px; border-top: 1px solid var(--ink-700); padding-top: 6px; }
.popover-title { padding: 6px 8px 4px; }

.opt {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  background: transparent;
  border: none;
  border-radius: var(--r-md);
  padding: 7px 8px;
  color: var(--txt-mid);
  font-size: 13px;
  text-align: left;
}
.opt:hover { background: var(--ink-750); color: var(--txt-hi); }
.opt.selected { color: var(--copper); }
.opt .check { width: 13px; flex: none; opacity: 0; }
.opt.selected .check { opacity: 1; }
.opt .label { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.center-play {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.45);
  border: none;
  cursor: pointer;
  z-index: 5;
}
.center-play span {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: var(--copper);
  display: grid;
  place-items: center;
  box-shadow: 0 10px 40px rgba(224, 131, 72, 0.35);
}
.center-play svg { width: 30px; height: 30px; fill: #1b0f06; margin-left: 4px; }

.player-error {
  margin: 18px auto;
  max-width: 520px;
  text-align: center;
  color: var(--err);
  font-size: 13px;
  border: 1px dashed rgba(248, 113, 113, 0.4);
  border-radius: var(--r-lg);
  padding: 16px;
}

/* =============================================================== RESPONSIVE */

@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }

  .sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    overflow-x: auto;
    border-right: none;
    border-bottom: 1px solid var(--ink-700);
  }
  .sidebar .brand { padding: 0; }
  .brand-name { display: none; }
  .nav { flex-direction: row; gap: 4px; }
  .nav-item { white-space: nowrap; }
  .sidebar-foot { display: none; }

  .topbar { padding: 12px 14px; }
  .content { padding: 14px 14px 44px; }
  .row-head { top: 48px; }

  .row { flex-wrap: wrap; gap: 10px; }
  .row-actions { width: 100%; }
  .row-actions button { flex: 1; }
}

@media (max-width: 720px) {
  video { max-height: none; }
  .stage { min-height: 100dvh; }

  .controls { padding: 46px 10px 10px; gap: 6px; }
  .ctl { padding: 9px; }
  .ctl svg { width: 22px; height: 22px; }
  .ctl.big svg { width: 28px; height: 28px; }
  .scrub { height: 22px; }
  .scrub-track { height: 4px; }
  .scrub-knob { transform: translate(-50%, -50%) scale(1); }
  .time { font-size: 11px; padding: 0 2px; }
  .volume { display: none; }
  .popover { width: min(84vw, 280px); max-height: 54vh; }
  .player-topbar { padding: 10px 12px; }
}
