* {
  box-sizing: border-box;
}

/* Tokens de cor no padrão shadcn/ui (tema "zinc"), lidos pelo tailwind.config no index.html */
:root {
  --background: 0 0% 100%;
  --foreground: 240 10% 3.9%;
  --card: 0 0% 100%;
  --card-foreground: 240 10% 3.9%;
  --primary: 240 5.9% 10%;
  --primary-foreground: 0 0% 98%;
  --secondary: 240 4.8% 95.9%;
  --secondary-foreground: 240 5.9% 10%;
  --muted: 240 4.8% 95.9%;
  --muted-foreground: 240 3.8% 46.1%;
  --accent: 240 4.8% 95.9%;
  --accent-foreground: 240 5.9% 10%;
  --destructive: 0 84.2% 60.2%;
  --destructive-foreground: 0 0% 98%;
  --border: 240 5.9% 90%;
  --input: 240 5.9% 90%;
  --ring: 240 5.9% 10%;
  --radius: 0.6rem;
}

.dark {
  --background: 240 10% 3.9%;
  --foreground: 0 0% 98%;
  --card: 240 5.9% 8%;
  --card-foreground: 0 0% 98%;
  --primary: 0 0% 98%;
  --primary-foreground: 240 5.9% 10%;
  --secondary: 240 3.7% 15.9%;
  --secondary-foreground: 0 0% 98%;
  --muted: 240 3.7% 15.9%;
  --muted-foreground: 240 5% 64.9%;
  --accent: 240 3.7% 15.9%;
  --accent-foreground: 0 0% 98%;
  --destructive: 0 62.8% 30.6%;
  --destructive-foreground: 0 0% 98%;
  --border: 240 3.7% 15.9%;
  --input: 240 3.7% 15.9%;
  --ring: 240 4.9% 83.9%;
}

body {
  font-family: Arial, Helvetica, sans-serif;
  margin: 0;
  padding: 0;
  text-align: center;
  transition: background-color 0.2s ease, color 0.2s ease;
}

#matrixCanvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  background: #030706;
  opacity: 0.72;
  pointer-events: none;
  z-index: -1;
}

body > *:not(#matrixCanvas) {
  position: relative;
  z-index: 1;
}

header {
  justify-content: center !important;
  margin-top: 48px;
}

#themeToggle {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 900;
}

.video-box {
  width: 480px;
  max-width: 90vw;
}

video {
  width: 100%;
  border-radius: 6px;
  background: #000;
}

video:fullscreen {
  width: 100vw;
  height: 100vh;
  object-fit: contain;
  border-radius: 0;
  background: #000;
}

.remote-controls {
  margin-top: 8px;
}

.close-btn,
.fullscreen-btn,
.quality-btn,
.viewers-btn,
body.watching .volume-control {
  transition: opacity 0.3s ease;
}

body.controls-hidden .close-btn,
body.controls-hidden .fullscreen-btn,
body.controls-hidden .quality-btn,
body.controls-hidden .viewers-btn,
body.controls-hidden .volume-control,
body.controls-hidden .quality-panel,
body.controls-hidden .viewers-panel {
  opacity: 0;
  pointer-events: none;
}

body.controls-hidden #remoteVideo {
  cursor: none;
}

.close-btn {
  position: fixed;
  top: 16px;
  right: 16px;
  width: 36px;
  height: 36px;
  padding: 0;
  font-size: 16px;
  line-height: 1;
  border-radius: 9999px;
  z-index: 900;
}

.fullscreen-btn {
  position: fixed;
  right: 16px;
  bottom: 16px;
  width: 36px;
  height: 36px;
  padding: 0;
  font-size: 18px;
  line-height: 1;
  border-radius: 9999px;
  z-index: 900;
  /* !important necessário: o Tailwind CDN injeta seu CSS depois deste arquivo,
     então "inline-flex" da classe .btn (mesma especificidade) venceria o cascade */
  display: none !important;
}

body.watching .fullscreen-btn {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
}

.volume-control {
  display: flex;
  align-items: center;
  gap: 8px;
}

.volume-control input[type='range'] {
  width: 100px;
}

.volume-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  margin: 0;
  font-size: 16px;
  line-height: 1;
  background: transparent;
  border: none;
  color: hsl(var(--foreground));
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.overlay {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 24px;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.overlay > .card {
  width: min(420px, 100%);
  max-width: none;
  margin: 0;
}

body.modal-open {
  overflow: hidden;
}

.viewers-popover {
  position: static;
}

body:not(.watching) #viewersBtn,
body:not(.watching) #viewersPanel,
body:not(.watching) #qualityBtn,
body:not(.watching) #qualityPanel,
body:not(.watching) .close-btn,
body:not(.watching) #volumeControl {
  display: none !important;
}

.quality-btn {
  position: fixed;
  right: 125px;
  bottom: 16px;
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 9999px;
  z-index: 900;
}

.viewers-btn {
  position: fixed;
  right: 64px;
  width: 56px;
  height: 36px;
  bottom: 16px;
  border-radius: 9999px;
  z-index: 900;
}

.quality-panel {
  position: fixed;
  right: 20px;
  bottom: 68px;
  width: 220px;
  padding: 12px 16px;
  text-align: left;
  z-index: 900;
}

.quality-control {
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: hsl(var(--foreground));
  font-size: 11px;
  text-transform: uppercase;
}

.quality-control select {
  min-width: 188px;
}

.viewers-panel {
  position: fixed;
  right: 4px;
  bottom: 68px;
  width: 220px;
  max-height: 300px;
  overflow-y: auto;
  padding: 12px 16px;
  text-align: left;
  z-index: 900;
}

.viewers-panel ul {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 14px;
}

.viewers-panel li {
  padding: 4px 0;
  border-top: 1px solid hsl(var(--border));
}

.viewers-panel li:first-child {
  border-top: none;
}

.viewers-panel .empty {
  color: hsl(var(--muted-foreground));
  font-style: italic;
}

/* Enquanto assiste, a página toda vira o player: some tudo, exceto o vídeo e seus controles */
body.watching header,
body.watching #localBox,
body.watching .broadcast-lobby,
body.watching .command-bar {
  display: none;
}

body.watching main {
  padding: 0;
}

body.watching .videos {
  display: block;
  padding: 0;
  gap: 0;
}

body.watching #remoteBox {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  max-width: none;
  padding: 0;
  margin: 0;
  border-radius: 0;
  border: none;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
}

body.watching #matrixCanvas {
  display: none;
}

body.watching #remoteVideo {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 0;
}

body.watching .remote-controls {
  margin: 0;
}

body.watching .volume-control {
  position: fixed;
  right: 168px;
  bottom: 16px;
  z-index: 900;
  background: hsl(var(--background));
  border: 1px solid hsl(var(--input));
  border-radius: 9999px;
  padding: 0 4px 0 0;
}

body.watching .volume-control #volumeSlider {
  display: none;
}

body.watching .volume-control.slider-open #volumeSlider {
  display: block;
}

body.watching .volume-icon {
  color: hsl(var(--foreground));
}

/* Lobby de transmissões */
.broadcast-lobby {
  min-height: 320px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.lobby-empty {
  width: min(420px, 100%);
  aspect-ratio: 1.85;
  border: 1px dashed hsl(var(--border));
  border-radius: var(--radius);
  background: hsl(var(--muted));
  color: hsl(var(--muted-foreground));
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.lobby-empty:hover:not(:disabled),
.lobby-empty:focus-visible:not(:disabled) {
  background: hsl(var(--accent));
  color: hsl(var(--accent-foreground));
  outline: 2px solid hsl(var(--ring));
  outline-offset: 2px;
}

.lobby-empty:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.lobby-empty span {
  font-size: 44px;
  font-weight: 300;
  line-height: 1;
}

.broadcast-list {
  width: min(620px, 100%);
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 16px;
}

.broadcast-card {
  min-height: 116px;
  padding: 10px;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  background: hsl(var(--card));
  color: hsl(var(--card-foreground));
  cursor: pointer;
  text-align: left;
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  column-gap: 12px;
  row-gap: 2px;
  align-items: center;
  align-content: center;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.broadcast-card:hover,
.broadcast-card:focus-visible {
  background: hsl(var(--accent));
  color: hsl(var(--accent-foreground));
  outline: 2px solid hsl(var(--ring));
  outline-offset: 2px;
}

.broadcast-card strong,
.broadcast-card span {
  display: block;
}

.broadcast-thumbnail {
  display: block;
  width: 120px;
  aspect-ratio: 16 / 9;
  grid-row: span 3;
  border-radius: calc(var(--radius) - 2px);
  background: hsl(var(--muted));
  object-fit: cover;
}

.broadcast-card strong {
  font-size: 17px;
}

.broadcast-card span {
  margin: 0;
  font-size: 12px;
  text-transform: uppercase;
}

.status {
  margin: 22px 0 0;
  font-size: 14px;
  color: hsl(var(--muted-foreground));
}

.videos {
  display: flex;
  justify-content: center;
}

.video-box {
  width: min(720px, 100%);
  padding: 12px;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  background: hsl(var(--card));
  overflow: hidden;
}

.video-box video {
  display: block;
  border-radius: 6px;
}

.preview-label {
  margin: 0;
  padding: 9px 12px;
  font-size: 13px;
  text-align: left;
}

.command-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  justify-content: center;
  gap: 12px;
}

.command {
  display: flex;
  flex: 0 1 auto;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  text-transform: uppercase;
  white-space: nowrap;
  color: hsl(var(--muted-foreground));
}

.broadcaster-viewers {
  font-size: 13px;
  text-transform: none;
  color: hsl(var(--muted-foreground));
}

@media (max-width: 600px) {
  .broadcast-lobby { min-height: 280px; }
  .command-bar { align-items: stretch; }
  .command { flex: 1 1 100%; }
  .command button { width: 100%; }
}

