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

body {
  font-family: system-ui, 'Segoe UI', Roboto, sans-serif;
  background: #0f1117;
  color: #e6e8ee;
  min-height: 100vh;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 24px;
  background: #161a23;
  border-bottom: 1px solid #262b38;
}
header h1 { font-size: 20px; }
#user-info { display: flex; gap: 12px; align-items: center; }

.hidden { display: none !important; }

.card {
  background: #161a23;
  border: 1px solid #262b38;
  border-radius: 12px;
  padding: 24px;
}

.center-card {
  max-width: 360px;
  margin: 80px auto;
}

form { display: flex; flex-direction: column; gap: 12px; margin-top: 16px; }

input {
  background: #0f1117;
  border: 1px solid #2e3444;
  border-radius: 8px;
  color: #e6e8ee;
  padding: 10px 12px;
  font-size: 14px;
  width: 100%;
}
input:focus { outline: none; border-color: #e23b3b; }

.btn {
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  color: #fff;
}
.btn-primary { background: #e23b3b; }
.btn-primary:hover { background: #c22f2f; }
.btn-danger { background: #7a1f1f; }
.btn-ghost { background: transparent; border: 1px solid #2e3444; color: #e6e8ee; }
.btn-ghost:hover { background: #1d2230; }

.error { color: #ff6b6b; font-size: 13px; }
.muted { color: #8b91a3; font-size: 13px; margin-top: 8px; }

#view-events { padding: 24px; }
.toolbar {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
}
.toolbar h2 { flex: 1; }

.event-row {
  display: flex;
  align-items: center;
  gap: 16px;
  background: #161a23;
  border: 1px solid #262b38;
  border-radius: 10px;
  padding: 14px 18px;
  margin-bottom: 10px;
}
.event-row .info { flex: 1; }
.event-row .info .sub { color: #8b91a3; font-size: 13px; margin-top: 4px; }

/* Reporter en direct : bordure rouge animée + halo */
.event-row.is-live {
  border-color: #e23b3b;
  animation: liveGlow 1.6s ease-in-out infinite;
}
@keyframes liveGlow {
  0%, 100% { box-shadow: 0 0 6px rgba(226,59,59,.25); border-color: #e23b3b; }
  50%      { box-shadow: 0 0 22px rgba(226,59,59,.65); border-color: #ff5b5b; }
}

.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}
.badge.live { background: #e23b3b; color: #fff; }
.badge.scheduled { background: #2b4a7a; color: #cfe1ff; }
.badge.ended { background: #2e3444; color: #8b91a3; }

#view-watch { padding: 24px; }
.watch-grid {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 20px;
}
@media (max-width: 900px) { .watch-grid { grid-template-columns: 1fr; } }

.video-wrap {
  background: #000;
  border-radius: 12px;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  display: flex;
  align-items: center;
  justify-content: center;
}
#video-container { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }
#video-container video { width: 100%; height: 100%; object-fit: contain; }
#video-placeholder { color: #8b91a3; }

.controls h3 { margin-bottom: 12px; }
.controls label { display: block; font-size: 13px; color: #8b91a3; margin-bottom: 6px; }
.controls button { width: 100%; margin-top: 10px; }
.controls hr { border: none; border-top: 1px solid #262b38; margin: 18px 0; }
.controls ul { list-style: none; }
.controls li { padding: 6px 0; border-bottom: 1px solid #1d2230; font-size: 14px; }

/* Reporter view */
.reporter-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding: 24px;
}
#reporter-preview {
  width: min(720px, 90vw);
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
#reporter-preview video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1); /* miroir selfie */
}
.reporter-controls { display: flex; gap: 16px; align-items: center; }
.golive {
  width: 160px;
  height: 160px;
  border-radius: 50%;
  border: none;
  background: #e23b3b;
  color: #fff;
  font-size: 22px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 0 30px rgba(226, 59, 59, 0.5);
}
.golive:hover { background: #c22f2f; }
#reporter-preview.live { outline: 3px solid #e23b3b; }
.quality-select {
  background: #161a23;
  border: 1px solid #2e3444;
  border-radius: 8px;
  color: #e6e8ee;
  padding: 10px 12px;
  font-size: 14px;
}

/* ---------- Multiviewer (régie) ---------- */
.mv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.mv-tile {
  background: #000;
  border: 2px solid #262b38;
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.mv-tile.onair { border-color: #e23b3b; box-shadow: 0 0 14px rgba(226,59,59,.45); }
.mv-video {
  aspect-ratio: 16 / 9;
  position: relative;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.mv-video video { width: 100%; height: 100%; object-fit: cover; }
.mv-footer {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; background: #161a23;
}
.mv-name { flex: 1; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mv-name .dot { color: #e23b3b; }
/* Indicateur qualité réseau du reporter (LiveKit connectionQuality) */
.mv-net {
  position: absolute; top: 6px; right: 6px; z-index: 2;
  font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 10px;
  background: rgba(0,0,0,.65); color: #4ade80; display: none;
}
.mv-net[data-q="good"] { color: #facc15; }
.mv-net[data-q="poor"] { color: #fb923c; }
.mv-net[data-q="lost"] { color: #f87171; }
.mv-tally {
  border: 1px solid #2e3444; background: transparent; color: #e6e8ee;
  border-radius: 6px; padding: 4px 10px; font-size: 12px; font-weight: 700;
  cursor: pointer;
}
.mv-tally.active { background: #e23b3b; border-color: #e23b3b; }
.mv-watch {
  border: 1px solid #2e3444; background: transparent; color: #e6e8ee;
  border-radius: 6px; padding: 4px 10px; font-size: 12px; cursor: pointer;
}
.mv-history-title { margin: 8px 0 12px; color: #8b91a3; font-size: 15px; }

/* ---------- Monitoring (stats + VU) ---------- */
.video-col { display: flex; flex-direction: column; gap: 12px; }
.monitor-strip {
  display: flex; align-items: center; gap: 18px;
  padding: 10px 16px; flex-wrap: wrap;
}
.monitor-strip .stat { display: flex; flex-direction: column; }
.monitor-strip .stat span { font-size: 11px; color: #8b91a3; text-transform: uppercase; }
.monitor-strip .stat strong { font-size: 15px; font-variant-numeric: tabular-nums; }
.vumeter {
  flex: 1; min-width: 80px; height: 12px;
  background: #0f1117; border: 1px solid #2e3444; border-radius: 6px;
  overflow: hidden;
}
#vu-fill {
  height: 100%; width: 0;
  background: linear-gradient(90deg, #2fbf71 60%, #e8b93e 85%, #e23b3b);
  transition: width 80ms linear;
}

/* ---------- Régie (tally, messages, rec) ---------- */
.msg-row { display: flex; gap: 8px; margin-top: 10px; }
.msg-row input { flex: 1; }
.msg-row .btn { width: auto; margin-top: 0; }
.btn.tally-on { background: #e23b3b; animation: tallyPulse 1.2s infinite; }
@keyframes tallyPulse { 50% { opacity: .65; } }
.btn.rec-on { background: #e23b3b; }
#rec-info { min-height: 1em; }

/* Tally côté reporter web */
.onair-banner {
  background: #e23b3b; color: #fff; font-weight: 800;
  padding: 8px 22px; border-radius: 6px; letter-spacing: 1px;
  animation: tallyPulse 1.2s infinite;
}
#reporter-preview.onair-frame { outline: 4px solid #e23b3b; }

/* Journal de chat studio ↔ reporter */
.reporter-chat {
  margin-top: 8px;
  max-height: 150px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.chat-msg {
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 13px;
  word-break: break-word;
}
.chat-msg.from { background: #1d2230; }
.chat-msg.to { background: #2a3550; text-align: right; }

/* Panneaux (Mes liens, Mes reporters, modal de création) */
.panel {
  background: #161a23;
  border: 1px solid #262b38;
  border-radius: 12px;
  padding: 14px 18px;
}
.panel-title {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 12px;
}
#modal-create .panel {
  box-shadow: 0 12px 48px rgba(0,0,0,.6);
}
