/* ===== SA-MP Watchparty — thème sombre façon GTA San Andreas ===== */
:root {
  --bg: #0b0e11;
  --panel: #13181d;
  --panel-2: #0e1216;
  --border: #22303c;
  --text: #e8eaf0;
  --muted: #8b93a7;
  --accent: #6eeb83;         /* vert SA-MP */
  --accent-2: #fca311;       /* orange GTA */
  --gold: #ffd166;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: radial-gradient(1100px 420px at 50% -120px, rgba(110, 235, 131, .10), transparent 70%), var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---------- En-tête minimaliste : le titre de la vidéo d'abord ---------- */
header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: linear-gradient(180deg, #161d23, #10151a);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
#video-title {
  color: var(--text);
  font-size: 22px;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
  letter-spacing: .3px;
}
#video-meta {
  color: var(--muted);
  font-size: 14px;
  white-space: nowrap;
  flex-shrink: 0;
}

/* Rond rouge animé : "en direct" à côté du compteur de joueurs */
#live-viewers-dot {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #ff3b3b;
  flex-shrink: 0;
  animation: livePulse 1.4s infinite;
}
@keyframes livePulse {
  0%   { box-shadow: 0 0 0 0 rgba(255, 59, 59, .75); }
  70%  { box-shadow: 0 0 0 11px rgba(255, 59, 59, 0); }
  100% { box-shadow: 0 0 0 0 rgba(255, 59, 59, 0); }
}
#viewers {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 16px;
  white-space: nowrap;
}
#viewers-count {
  font-size: 28px;
  font-weight: 800;
  color: var(--gold);
  text-shadow: 0 0 14px rgba(255, 209, 102, .45);
  transition: transform .2s;
}
#viewers-count.pop { animation: countPop .4s ease; }
@keyframes countPop {
  0% { transform: scale(1); }
  40% { transform: scale(1.35); }
  100% { transform: scale(1); }
}
#viewers-names {
  color: var(--muted);
  font-size: 13px;
  max-width: 26vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.viewer-name { font-weight: 600; }

/* ---------- Colonnes ---------- */
main {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  grid-template-rows: minmax(0, 1fr);
  gap: 12px;
  padding: 12px;
}
#player-col { display: flex; flex-direction: column; min-width: 0; min-height: 0; }

/* ---------- Lecteur ---------- */
#player-wrap {
  position: relative;
  width: 100%;
  flex: 1;
  min-height: 0;
  background: #000;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
#player { position: absolute; inset: 0; width: 100%; height: 100%; }
#sound-overlay {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, .35);
  z-index: 10;
  cursor: pointer;
}
#sound-overlay.show { display: flex; }
#btn-sound {
  font-size: 17px;
  padding: 12px 24px;
  border-radius: 999px;
  background: var(--accent);
  border-color: var(--accent);
  font-weight: 600;
  box-shadow: 0 4px 20px rgba(0, 0, 0, .5);
}
#btn-sound:hover { background: #ff6681; }
#player-placeholder {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 15px;
  text-align: center;
  padding: 20px;
  line-height: 1.6;
}
#player-placeholder b { color: var(--text); }

.burst {
  position: absolute;
  bottom: 26%;
  pointer-events: none;
  z-index: 5;
  animation: rise 1.8s ease-out forwards;
  text-shadow: 0 0 18px rgba(255, 255, 255, .75), 0 4px 18px rgba(0, 0, 0, .8);
  filter: drop-shadow(0 0 10px rgba(255, 209, 102, .55));
}
@keyframes rise {
  0%   { opacity: 0; transform: translateY(10px) scale(.4) rotate(-8deg); }
  12%  { opacity: 1; }
  100% { opacity: 0; transform: translateY(-170px) scale(1.8) rotate(10deg); }
}

/* ---------- Overlay timecode vidéo ---------- */
#video-time {
  position: absolute;
  bottom: 8px;
  right: 10px;
  z-index: 5;
  background: rgba(0, 0, 0, .55);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  pointer-events: none;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 3px rgba(0, 0, 0, .8);
}

/* ---------- Barre de vote skip (temps restant) ---------- */
#skip-bar {
  position: relative;
  margin-top: 8px;
  height: 28px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  flex-shrink: 0;
}
#skip-bar.hide { display: none; }
#skip-bar-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--accent-2), #ff4d4d);
  transition: width .8s linear;
}
#skip-bar-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 4px rgba(0, 0, 0, .9);
}

/* ---------- Barre turbo (vitesse votée) ---------- */
#speed-bar {
  position: relative;
  margin-top: 8px;
  height: 28px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  flex-shrink: 0;
}
#speed-bar.hide { display: none; }
#speed-bar-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #22d3ee, #3b82f6);
  transition: width .8s linear;
}
#speed-bar-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 4px rgba(0, 0, 0, .9);
}

/* ---------- Boutons de vote vitesse ---------- */
#speed-row {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
  align-items: center;
}
#speed-row .speed-label {
  color: var(--muted);
  font-size: 13px;
  margin-right: 2px;
}
#speed-row button {
  font-size: 13px;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 999px;
  color: var(--text);
}
#speed-row button:not(:disabled):hover { border-color: #22d3ee; color: #a5f3fc; }
#speed-row button.active { border-color: #22d3ee; color: #22d3ee; box-shadow: 0 0 10px rgba(34, 211, 238, .35); }
#speed-row button.voted { border-color: var(--gold); color: var(--gold); }

/* ---------- Contrôles ---------- */
#controls { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
button {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
  font-size: 14px;
  font-family: inherit;
  transition: background .15s;
}
button:hover { background: #1d2330; }
button:active { transform: translateY(1px); }
button:disabled { opacity: .45; cursor: default; }
button:disabled:hover { background: var(--panel); }
#btn-skip { border-color: #3a3327; }
#btn-skip:not(:disabled) { border-color: var(--accent-2); color: var(--gold); }
/* Vote en cours : le bouton clignote pour montrer où appuyer */
#btn-skip.voting {
  border-color: var(--gold);
  color: var(--gold);
  animation: pulseVote 1s infinite;
  box-shadow: 0 0 14px rgba(255, 209, 102, .45);
}
#speed-row.voting button {
  border-color: #22d3ee;
  color: #22d3ee;
  animation: pulseVote 1s infinite;
  box-shadow: 0 0 12px rgba(34, 211, 238, .4);
}
@keyframes pulseVote {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.07); }
}
#skip-info { color: var(--muted); font-size: 13px; }
#btn-cc { font-weight: 800; letter-spacing: 1px; }
#btn-cc.cc-on { border-color: #6ee7ff; color: #6ee7ff; box-shadow: 0 0 10px rgba(110, 231, 255, .3); }
#btn-cc.cc-off { color: var(--muted); text-decoration: line-through; opacity: .7; }

/* ---------- Slider de volume custom ---------- */
#vol-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 90px;
  height: 6px;
  border-radius: 999px;
  background:
    linear-gradient(90deg, var(--accent), var(--accent)) 0 / var(--fill, 70%) 100% no-repeat,
    var(--panel-2);
  outline: none;
  cursor: pointer;
  align-self: center;
  border: 1px solid var(--border);
}
#vol-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--accent);
  box-shadow: 0 0 8px rgba(110, 235, 131, .4);
}
#vol-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--accent);
}

/* ---------- Émotes ---------- */
#emotes-bar { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
#emotes-bar button {
  font-size: 26px;
  padding: 7px 12px;
  border-radius: 12px;
  line-height: 1;
}

/* ---------- Tchat ---------- */
#chat-col {
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  min-height: 0;
}
#messages {
  flex: 1;
  overflow-y: auto;
  padding: 10px 12px;
  font-size: 14px;
  line-height: 1.55;
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: #2a3342 transparent;
}
#messages::-webkit-scrollbar { width: 10px; }
#messages::-webkit-scrollbar-track { background: transparent; }
#messages::-webkit-scrollbar-thumb {
  background: #2a3342;
  border-radius: 999px;
  border: 2px solid var(--panel);
}
#messages::-webkit-scrollbar-thumb:hover { background: #3a4757; }
.msg { word-break: break-word; margin-bottom: 3px; }
.msg .time { color: #5a6275; font-size: 11px; margin-right: 6px; }
.msg .name { font-weight: 600; }
.msg .name { cursor: pointer; }
.msg .name:hover { text-decoration: underline; }
.msg .name.bot { color: #ffd166 !important; }
.msg .text { color: var(--text); white-space: pre-wrap; }
.msg.sys { color: var(--muted); font-style: italic; font-size: 13px; }
.msg.react .text {
  color: var(--gold);
  font-weight: 700;
  font-size: 14px;
  text-shadow: 0 0 12px rgba(255, 209, 102, .35);
}
.msg.react { margin-bottom: 5px; }
.msg.me .text {
  color: #9fb3c8;
  font-style: italic;
}
.msg.me .star { color: #5a6275; font-weight: 700; }
.msg.me { margin-bottom: 4px; }
.msg.vote .text { color: var(--accent-2); font-weight: 600; }
.msg.ai .text { color: #6ee7ff; font-weight: 600; }
.msg.ai { margin-bottom: 5px; }
.msg .text b { color: #fff; }
.msg .text code {
  background: rgba(255, 255, 255, .08);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0 4px;
  font-size: 12px;
  font-family: Consolas, 'Courier New', monospace;
  color: #a5f3fc;
}
.msg .tc {
  color: #6ee98b;
  font-size: 10px;
  font-weight: 700;
  margin-left: 6px;
  padding: 0 6px;
  border: 1px solid rgba(110, 233, 139, .35);
  border-radius: 8px;
  white-space: nowrap;
  cursor: help;
  font-variant-numeric: tabular-nums;
}

/* ---------- Séparateurs de jour ---------- */
.day-sep {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .6px;
  margin: 12px 0 6px;
}
.day-sep::before,
.day-sep::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ---------- Bulles des messages timecodés (montent comme les émotes) ---------- */
.tc-bubble {
  position: absolute;
  bottom: 18%;
  max-width: 62%;
  background: rgba(13, 17, 22, .88);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 8px 14px;
  font-size: 14px;
  pointer-events: none;
  z-index: 6;
  box-shadow: 0 6px 22px rgba(0, 0, 0, .6);
  animation: bubbleRise 3.8s ease-out forwards;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.tc-bubble-name { font-weight: 700; }
.tc-bubble-text { color: var(--text); }
@keyframes bubbleRise {
  0%   { opacity: 0; transform: translateY(16px) scale(.9); }
  12%  { opacity: 1; transform: translateY(0) scale(1); }
  80%  { opacity: 1; }
  100% { opacity: 0; transform: translateY(-120px) scale(1.03); }
}

#chat-input-row {
  display: flex;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
#chat-input {
  flex: 1;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 9px 12px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  min-width: 0;
}
#chat-input:focus { border-color: var(--accent); }
#btn-send { background: var(--accent); border-color: var(--accent); font-weight: 600; }
#btn-send:hover { background: #ff6681; }

/* ---------- Modal pseudo ---------- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .75);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 50;
}
.overlay.show { display: flex; }
.modal {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 26px;
  width: min(92vw, 380px);
  text-align: center;
}
.modal h2 { font-size: 18px; margin-bottom: 8px; }
.modal p { color: var(--muted); font-size: 14px; margin-bottom: 16px; }
.modal input {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 10px 12px;
  font-size: 15px;
  outline: none;
  text-align: center;
}
.modal input:focus { border-color: var(--accent); }
.modal button {
  width: 100%;
  margin-top: 12px;
  background: var(--accent);
  border-color: var(--accent);
  font-weight: 600;
  padding: 10px;
}
.modal button:hover { background: #ff6681; }

/* ---------- Alerte stockage indisponible ---------- */
#data-warning {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 200;
  background: #b3403c;
  color: #fff;
  text-align: center;
  font-size: 13px;
  padding: 6px 12px;
}
#data-warning.hide { display: none; }

/* ---------- Toast ---------- */
#toast {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  background: #2a1016;
  border: 1px solid var(--accent);
  color: #ffd7de;
  padding: 9px 16px;
  border-radius: 10px;
  font-size: 14px;
  opacity: 0;
  transition: opacity .25s;
  pointer-events: none;
  z-index: 60;
  max-width: 90vw;
}
#toast.show { opacity: 1; }

/* ---------- Plein écran (avec le tchat) ---------- */
#btn-fs-exit {
  display: none;
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 60;
  font-size: 16px;
  padding: 8px 15px;
  border-radius: 999px;
  background: rgba(20, 26, 32, .85);
  border-color: var(--border);
}
body.fs #btn-fs-exit { display: block; }
body.fs #player-wrap {
  position: fixed;
  inset: 0 380px 0 0;
  z-index: 40;
  border: none;
  border-radius: 0;
}
body.fs #chat-col {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 380px;
  z-index: 41;
  border-radius: 0;
  border: none;
  border-left: 1px solid var(--border);
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  body { overflow: auto; }
  main { grid-template-columns: 1fr; grid-template-rows: none; overflow-y: auto; }
  #player-wrap { flex: none; aspect-ratio: 16 / 9; }
  /* La barre de commandes (son, skip, turbo) est déplacée en haut du tchat par le JS :
     elle ne flotte plus sur la vidéo ni ne recouvre l'input. */
  #controls, #speed-row {
    position: static;
    margin: 0;
    width: 100%;
    justify-content: center;
    background: var(--panel-2);
    border-radius: 0;
    flex-shrink: 0;
  }
  #controls { padding: 6px; border-bottom: 1px solid var(--border); }
  #speed-row { padding: 5px 6px; border-bottom: 1px solid var(--border); }
  #controls button { padding: 6px 10px; font-size: 13px; }
  #vol-slider { width: 70px; }
  #speed-row button { padding: 5px 10px; font-size: 12px; }
  #video-time { top: 8px; right: 10px; bottom: auto; }
  #skip-bar, #speed-bar { margin-top: 6px; }
  #chat-col { height: 48vh; min-height: 300px; }
  #video-title { max-width: 60vw; }
  body.fs #player-wrap { inset: 0 0 56vh 0; }
  body.fs #chat-col {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 56vh;
    border-left: none;
    border-top: 1px solid var(--border);
  }
  body.fs #btn-fs-exit { top: 10px; right: 10px; }
}
