/* ==========================================================================
   Page de test du live — thème sombre façon TikTok Live
   ========================================================================== */

:root {
  --bg: #0b0b0f;
  --surface: #16161d;
  --surface-2: #20202a;
  --border: #2c2c38;
  --text: #f4f4f6;
  --muted: #9a9aa8;
  --pink: #fe2c55;
  --cyan: #25f4ee;
  --success: #2ecc71;
  --radius: 16px;
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { background: var(--bg); color: var(--text); font-family: var(--font); }

body { min-height: 100vh; line-height: 1.5; }

a { color: var(--cyan); }

button, input { font: inherit; color: inherit; }

.hidden { display: none !important; }

/* ------------------------------- En-tête ---------------------------------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.15rem; text-decoration: none; color: var(--text); }
.brand-dot {
  width: 12px; height: 12px; border-radius: 50%; background: var(--pink);
  box-shadow: -3px 0 0 var(--cyan); animation: pulse 1.6s infinite;
}
@keyframes pulse { 50% { opacity: .45; } }

.container { max-width: 1100px; margin: 0 auto; padding: 24px 16px 48px; }

/* -------------------------------- Cartes ---------------------------------- */
.grid { display: grid; gap: 20px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px;
}
.card h2 { font-size: 1.2rem; margin-bottom: 4px; }
.card p.sub { color: var(--muted); font-size: .92rem; margin-bottom: 18px; }

label { display: block; font-size: .82rem; color: var(--muted); margin: 12px 0 6px; }

input[type='text'] {
  width: 100%; padding: 12px 14px; border-radius: 12px;
  background: var(--surface-2); border: 1px solid var(--border); outline: none;
}
input[type='text']:focus { border-color: var(--cyan); }

/* -------------------------------- Boutons --------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 18px; border-radius: 12px; border: 1px solid transparent;
  font-weight: 700; cursor: pointer; transition: transform .1s, opacity .2s, background .2s;
  text-decoration: none;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-block { width: 100%; margin-top: 18px; }
.btn-primary { background: var(--pink); color: #fff; }
.btn-primary:hover:not(:disabled) { background: #ff4a6e; }
.btn-secondary { background: var(--surface-2); border-color: var(--border); }
.btn-secondary:hover:not(:disabled) { border-color: var(--cyan); }
.btn-danger { background: transparent; border-color: var(--pink); color: var(--pink); }
.btn-sm { padding: 8px 12px; font-size: .85rem; border-radius: 10px; }
.btn.off { background: var(--pink); border-color: var(--pink); color: #fff; }

/* -------------------------- Liste des lives actifs ------------------------ */
.section-title { display: flex; align-items: center; justify-content: space-between; margin: 32px 0 14px; }
.section-title h2 { font-size: 1.1rem; }

.rooms { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.room-card {
  display: block; padding: 16px; border-radius: 14px; text-decoration: none; color: var(--text);
  background: linear-gradient(160deg, #2a1220, var(--surface) 60%); border: 1px solid var(--border);
  transition: border-color .2s, transform .2s;
}
.room-card:hover { border-color: var(--pink); transform: translateY(-2px); }
.room-card .title { font-weight: 700; margin: 10px 0 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room-card .meta { color: var(--muted); font-size: .85rem; }
.empty { color: var(--muted); font-size: .92rem; padding: 18px; border: 1px dashed var(--border); border-radius: 14px; text-align: center; }

/* ----------------------------- Badges / pastilles ------------------------- */
.badge-live {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--pink); color: #fff; font-weight: 800; font-size: .72rem;
  padding: 3px 8px; border-radius: 6px; letter-spacing: .05em;
}
.badge-live::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: #fff; animation: pulse 1.2s infinite; }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(0, 0, 0, .55); backdrop-filter: blur(6px);
  padding: 4px 10px; border-radius: 999px; font-size: .8rem; font-weight: 600;
}

/* ------------------------------ Vue « live » ------------------------------ */
.live-layout { display: grid; gap: 20px; grid-template-columns: minmax(0, 420px) minmax(0, 1fr); align-items: start; }
@media (max-width: 820px) { .live-layout { grid-template-columns: 1fr; } }

/* Cadre vidéo vertical 9:16, comme sur mobile */
.stage {
  position: relative; width: 100%; aspect-ratio: 9 / 16; max-height: 78vh;
  background: #000; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border);
  margin: 0 auto;
}
.stage video { width: 100%; height: 100%; object-fit: cover; background: #000; }
.stage video.mirror { transform: scaleX(-1); }

/* Grille des personnes sur scène (hôte + invités) */
.video-grid { position: absolute; inset: 0; display: grid; gap: 2px; background: #000; }
.video-grid[data-count='2'] { grid-template-rows: 1fr 1fr; }
.video-grid[data-count='3'],
.video-grid[data-count='4'] { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }
.video-grid[data-count='3'] .tile:first-child { grid-column: span 2; }

.tile { position: relative; overflow: hidden; background: #111; min-height: 0; }
.tile-label {
  position: absolute; left: 8px; bottom: 8px; max-width: calc(100% - 16px);
  background: rgba(0, 0, 0, .55); padding: 2px 8px; border-radius: 999px;
  font-size: .75rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tile-kick {
  position: absolute; top: 8px; right: 8px; width: 28px; height: 28px; border-radius: 50%;
  border: none; background: rgba(254, 44, 85, .9); color: #fff; font-weight: 800; cursor: pointer;
}
/* Quand il y a des invités, on décale les vignettes sous l'en-tête du live */
.video-grid:not([data-count='1']) .tile-kick { top: 56px; }

/* Demandes pour monter sur scène */
.requests { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.request-row { display: flex; align-items: center; gap: 8px; }
.request-row span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }

/* Bouton j'aime et cœurs qui montent sur la vidéo */
.like-btn {
  position: absolute; right: 12px; bottom: 16px; width: 52px; height: 52px; border-radius: 50%;
  border: none; background: rgba(0, 0, 0, .5); font-size: 1.4rem; cursor: pointer; z-index: 2;
}
.like-btn:active { transform: scale(.9); }
.heart {
  position: absolute; bottom: 70px; font-size: 1.4rem; pointer-events: none; z-index: 2;
  animation: floatUp 1.8s ease-out forwards;
}
@keyframes floatUp {
  to { transform: translateY(-240px) scale(1.4); opacity: 0; }
}

.stage-top {
  position: absolute; inset: 0 0 auto 0; padding: 12px;
  display: flex; justify-content: space-between; align-items: flex-start; gap: 8px;
  background: linear-gradient(rgba(0, 0, 0, .55), transparent);
}
.stage-host { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.stage-host strong { font-size: .95rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stage-host span { font-size: .78rem; color: #ddd; }
.stage-badges { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }

/* Messages au centre de la vidéo (connexion, live terminé…) */
.stage-overlay {
  position: absolute; inset: 0; display: flex; flex-direction: column; gap: 14px;
  align-items: center; justify-content: center; text-align: center; padding: 24px;
  background: rgba(0, 0, 0, .7);
}
.spinner {
  width: 38px; height: 38px; border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, .2); border-top-color: var(--pink);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Chat superposé en bas de la vidéo */
.stage-chat {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 12px;
  max-height: 42%; overflow-y: auto; display: flex; flex-direction: column; gap: 6px;
  background: linear-gradient(transparent, rgba(0, 0, 0, .6));
  mask-image: linear-gradient(transparent, #000 25%);
}
.chat-msg { font-size: .88rem; text-shadow: 0 1px 2px #000; word-wrap: break-word; }
.chat-msg b { color: var(--cyan); margin-right: 6px; }
.chat-msg.system { color: #ccc; font-style: italic; }

.chat-form { display: flex; gap: 8px; margin-top: 12px; }
.chat-form input { flex: 1; }

/* Panneau latéral (partage, contrôles) */
.panel { display: flex; flex-direction: column; gap: 16px; }
.share-box { display: flex; gap: 8px; }
.share-box input { flex: 1; font-size: .85rem; }
.controls { display: flex; flex-wrap: wrap; gap: 8px; }

/* Petit message flottant (copié, erreur…) */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px);
  background: var(--surface-2); border: 1px solid var(--border); padding: 12px 18px;
  border-radius: 12px; opacity: 0; transition: all .25s; pointer-events: none; z-index: 50;
  max-width: calc(100% - 32px);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { border-color: var(--pink); }
