/* shadcn/ui inspired theme (zinc / dark) */
:root {
  --foreground: 0 0% 98%;
  --card: 240 10% 4.9%;
  --muted: 240 3.7% 15.9%;
  --muted-foreground: 240 5% 64.9%;
  --border: 240 3.7% 15.9%;
  --ring: 240 4.9% 50%;
  --radius: 0.65rem;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: #000;
  color: hsl(var(--foreground));
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

/* Player fills the whole viewport */
.player {
  position: relative;
  width: 100vw;
  height: 100vh;
  background: #000;
  outline: none;
  overflow: hidden;
}
.player video {
  width: 100%;
  height: 100%;
  display: block;
  background: #000;
  object-fit: contain;
}

/* ---- icon visibility via state classes (no duplicates) ---- */
.player .i-pause,
.player .i-mute,
.player .i-fs-exit { display: none; }
.player.is-playing .i-play { display: none; }
.player.is-playing .i-pause { display: inline; }
.player.is-muted .i-vol { display: none; }
.player.is-muted .i-mute { display: inline; }
.player.is-fullscreen .i-fs { display: none; }
.player.is-fullscreen .i-fs-exit { display: inline; }

/* Center overlay */
.center-overlay {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
}
.big-play {
  pointer-events: auto;
  width: 84px; height: 84px;
  border-radius: 50%;
  border: 1px solid rgb(255 255 255 / 0.15);
  background: rgb(0 0 0 / 0.55);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  backdrop-filter: blur(6px);
  transition: transform 0.15s ease, background 0.15s ease;
}
.big-play:hover { transform: scale(1.06); background: rgb(0 0 0 / 0.7); }
.big-play svg { margin-left: 4px; }
.big-play[hidden] { display: none; }

.spinner {
  width: 52px; height: 52px;
  border: 3px solid rgb(255 255 255 / 0.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.spinner[hidden] { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Offline / streamer off */
.offline-overlay {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 8px;
  padding: 24px;
  text-align: center;
  color: hsl(var(--foreground));
  background:
    radial-gradient(120% 90% at 50% 40%, rgb(24 24 27 / 0.92), rgb(0 0 0 / 0.96));
  z-index: 25;
}
.offline-overlay[hidden] { display: none; }
.offline-overlay svg { color: hsl(var(--muted-foreground)); opacity: 0.9; }
.offline-title { font-size: 1.15rem; font-weight: 700; }
.offline-sub { font-size: 0.85rem; color: hsl(var(--muted-foreground)); }
.offline-retry {
  margin-top: 6px;
  font-size: 0.75rem;
  color: rgb(255 255 255 / 0.45);
  font-variant-numeric: tabular-nums;
}

/* Unmute hint */
.unmute-hint {
  position: absolute;
  top: 16px; left: 16px;
  display: inline-flex; align-items: center; gap: 7px;
  height: 38px; padding: 0 14px;
  font-size: 0.82rem; font-weight: 600;
  color: #fff; cursor: pointer;
  border: 1px solid rgb(255 255 255 / 0.18);
  border-radius: 999px;
  background: rgb(0 0 0 / 0.6);
  backdrop-filter: blur(6px);
  z-index: 20;
  animation: pulse-soft 2s ease-in-out infinite;
}
.unmute-hint:hover { background: rgb(0 0 0 / 0.8); }
.unmute-hint[hidden] { display: none; }
@keyframes pulse-soft { 0%,100% { opacity: 1; } 50% { opacity: 0.75; } }

/* Controls */
.controls {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 18px;
  background: linear-gradient(to top, rgb(0 0 0 / 0.85), rgb(0 0 0 / 0));
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 10;
}
.player:hover .controls,
.player:focus-within .controls,
.player.show-controls .controls,
.player:not(.is-playing) .controls { opacity: 1; transform: translateY(0); }

.ctrl-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 40px; min-width: 40px; padding: 0 9px;
  border: none; border-radius: calc(var(--radius) - 3px);
  background: transparent; color: #fff;
  cursor: pointer;
  transition: background 0.15s ease;
}
.ctrl-btn:hover { background: rgb(255 255 255 / 0.14); }
.ctrl-btn-text { font-size: 0.82rem; font-weight: 500; }

.spacer { flex: 1; }

/* Live button */
.live-btn {
  display: inline-flex; align-items: center; gap: 7px;
  height: 32px; padding: 0 12px;
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.04em;
  border-radius: 999px;
  border: 1px solid rgb(255 255 255 / 0.15);
  background: rgb(255 255 255 / 0.06);
  color: rgb(255 255 255 / 0.7); cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.live-btn:hover { background: rgb(255 255 255 / 0.14); }
.live-btn .live-dot { width: 7px; height: 7px; border-radius: 50%; background: #6b7280; }
.live-btn.is-live { color: #fff; }
.live-btn.is-live .live-dot { background: #ef4444; animation: pulse 1.5s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.3; } }

/* Volume */
.volume { display: flex; align-items: center; }
.slider {
  -webkit-appearance: none; appearance: none;
  height: 4px; border-radius: 999px;
  /* trilho com preenchimento até o nível atual (--vol: 0..1) */
  background:
    linear-gradient(to right, #fff 0%, #fff calc(var(--vol, 1) * 100%),
      rgb(255 255 255 / 0.28) calc(var(--vol, 1) * 100%), rgb(255 255 255 / 0.28) 100%);
  cursor: pointer; margin: 0;
}
.volume-slider {
  width: 0; opacity: 0;
  transition: width 0.22s ease, opacity 0.22s ease, margin 0.22s ease;
}
.volume:hover .volume-slider,
.volume:focus-within .volume-slider { width: 76px; opacity: 1; margin: 0 8px 0 2px; }
.slider::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 12px; height: 12px; border-radius: 50%;
  background: #fff; border: none; cursor: pointer;
  box-shadow: 0 0 0 1px rgb(0 0 0 / 0.2);
  transition: transform 0.12s ease;
}
.slider::-webkit-slider-thumb:hover { transform: scale(1.15); }
.slider::-moz-range-thumb {
  width: 12px; height: 12px; border-radius: 50%;
  background: #fff; border: none; cursor: pointer;
  box-shadow: 0 0 0 1px rgb(0 0 0 / 0.2);
}

.latency {
  font-size: 0.78rem; font-variant-numeric: tabular-nums;
  color: rgb(255 255 255 / 0.7);
  padding: 0 6px;
}

/* Quality menu */
.menu-wrap { position: relative; }
.menu {
  position: absolute;
  bottom: calc(100% + 10px); right: 0;
  min-width: 140px;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: calc(var(--radius) - 2px);
  padding: 4px;
  box-shadow: 0 10px 30px -10px rgb(0 0 0 / 0.7);
  z-index: 30;
}
.menu[hidden] { display: none; }
.menu-item {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%;
  padding: 8px 10px;
  font-size: 0.82rem;
  border: none; background: transparent; color: hsl(var(--foreground));
  border-radius: calc(var(--radius) - 4px);
  cursor: pointer; text-align: left;
}
.menu-item:hover { background: hsl(var(--muted)); }
.menu-item.active { font-weight: 600; }
.menu-item .check { opacity: 0; }
.menu-item.active .check { opacity: 1; }

/* Status (errors) */
.status {
  position: absolute;
  top: 16px; right: 16px;
  margin: 0;
  font-size: 0.8rem;
  color: hsl(var(--muted-foreground));
  z-index: 20;
  max-width: 60vw;
  text-align: right;
}
.status:empty { display: none; }
.status.error {
  color: #fecaca;
  background: rgb(127 29 29 / 0.85);
  border: 1px solid rgb(248 113 113 / 0.4);
  padding: 8px 12px;
  border-radius: calc(var(--radius) - 2px);
}

@media (max-width: 560px) {
  .latency { display: none; }
  .controls { padding: 12px 12px; }
}
