/* GoLive Activity — tema dark estilo Discord */
:root {
  --bg-page: #1a1a1e;
  --bg-tile: #232428;
  --bg-panel: #2b2d31;
  --bg-elevated: #313338;
  --bg-input: #1e1f22;
  --border: rgba(255, 255, 255, 0.06);
  --text: #f2f3f5;
  --text-muted: #b5bac1;
  --text-dim: #80848e;
  --accent: #5865f2;
  --accent-hover: #4752c4;
  --green: #23a55a;
  --red: #f23f43;
  --yellow: #f0b232;
  --radius: 8px;
}

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

html, body {
  height: 100%;
  background: var(--bg-page);
  color: var(--text);
  font-family: "gg sans", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  overflow: hidden;
}

body { display: flex; flex-direction: column; }

/* ─── Header mínimo (quase invisível, estilo Discord) ─────────────────── */
#header {
  position: absolute;
  top: 10px;
  left: 14px;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: none;
}
#logo {
  font-weight: 800;
  font-size: 13px;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 6px;
  letter-spacing: 0.3px;
}
#logo .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 8px var(--red);
  animation: pulse 2s infinite;
}
@keyframes pulse { 50% { opacity: 0.4; } }

#room-badge {
  font-size: 12px;
  color: var(--text-dim);
  background: rgba(0, 0, 0, 0.5);
  padding: 3px 10px;
  border-radius: 999px;
}
#room-badge b { color: var(--text-muted); font-weight: 600; }

#me {
  position: absolute;
  top: 10px;
  right: 14px;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-dim);
  background: rgba(0, 0, 0, 0.5);
  padding: 4px 10px;
  border-radius: 999px;
}
#me img { width: 20px; height: 20px; border-radius: 50%; }
#me .name { color: var(--text-muted); font-weight: 600; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ─── Main: grid estilo call do Discord ──────────────────────────────── */
#main { flex: 1; display: flex; min-height: 0; padding: 8px; gap: 8px; }

#grid-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; }

#grid {
  flex: 1;
  display: grid;
  gap: 8px;
  min-height: 0;
  grid-template-columns: 1fr;
  grid-auto-rows: 1fr;
}
#grid[data-count="2"] { grid-template-columns: 1fr 1fr; }
#grid[data-count="3"], #grid[data-count="4"] { grid-template-columns: 1fr 1fr; }
#grid[data-count="5"], #grid[data-count="6"] { grid-template-columns: 1fr 1fr 1fr; }

.tile {
  position: relative;
  background: var(--bg-tile);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
}
.tile canvas, .tile video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.tile .avatar-center {
  width: 35%;
  max-width: 160px;
  aspect-ratio: 1;
  border-radius: 50%;
  object-fit: cover;
}
.tile .you-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(0, 0, 0, 0.6);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 5px;
}
.tile .label {
  position: absolute;
  left: 10px;
  bottom: 10px;
  background: rgba(0, 0, 0, 0.7);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 6px;
  max-width: 70%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tile .live-dot {
  position: absolute;
  top: 10px;
  left: 10px;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 10px var(--red);
  animation: pulse 2s infinite;
}
.tile.speaking { outline: 2px solid var(--green); outline-offset: -2px; }

/* Toolbar flutuante estilo Discord: pílula com botões redondos */
#toolbar {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  display: flex;
  gap: 10px;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(8px);
  padding: 8px 12px;
  border-radius: 999px;
}
.tbtn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: var(--bg-elevated);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.tbtn:hover { background: #3f4147; }
.tbtn.danger { background: var(--red); color: #fff; }
.tbtn.live { background: var(--green); color: #fff; }
.tbtn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tbtn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ─── Sidebar (participants + chat) ──────────────────────────────────── */
#sidebar {
  flex: 0 0 240px;
  background: var(--bg-panel);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
#sidebar h3 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-dim);
  padding: 12px 14px 8px;
}
#peers { flex: 0 0 auto; max-height: 45%; overflow-y: auto; padding: 0 8px; }
.peer {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 5px 8px;
  border-radius: 8px;
  font-size: 14px;
}
.peer:hover { background: var(--bg-elevated); }
.peer img { width: 24px; height: 24px; border-radius: 50%; flex: 0 0 auto; }
.peer .p-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.peer .p-name.me { color: var(--accent); font-weight: 600; }

#chat-box {
  flex: 1;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
#chat-log { flex: 1; overflow-y: auto; padding: 8px 12px; font-size: 13px; line-height: 1.55; color: var(--text-muted); }
#chat-log b { color: var(--text); }
#chat-form { display: flex; gap: 6px; padding: 8px; }
#chat-input {
  flex: 1;
  background: var(--bg-input);
  border: none;
  border-radius: 8px;
  color: var(--text);
  padding: 8px 12px;
  font-size: 13px;
  outline: none;
}

/* ─── Overlays ────────────────────────────────────────────────────────── */
.overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-page);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 50;
  padding: 24px;
  text-align: center;
}
.overlay[hidden] { display: none; }
.overlay p { color: var(--text-muted); }
.spinner {
  width: 30px; height: 30px;
  border: 3px solid var(--bg-elevated);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

#toast-wrap {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 100;
  align-items: center;
}
.toast {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 13px;
  padding: 9px 16px;
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}
.toast.error { border-color: var(--red); }

#status-bar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 3px;
  z-index: 60;
  pointer-events: none;
}
#status-bar.connecting { background: linear-gradient(90deg, transparent, var(--yellow), transparent); background-size: 200% 100%; animation: slide 1.2s infinite; }
#status-bar.error { background: var(--red); }
#status-bar.ok { background: var(--green); }
@keyframes slide { from { background-position: 200% 0; } to { background-position: -200% 0; } }

.hidden { display: none !important; }
.conn {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  font-size: 13px;
  background: var(--bg-tile);
  z-index: 2;
}

/* ─── Teatro mode ("tela cheia" do iframe) ────────────────────────────── */
body.theater #sidebar { display: none; }
body.theater #toolbar { opacity: 0.25; }
body.theater #toolbar:hover { opacity: 1; }
body.theater #header, body.theater #me { opacity: 0.3; }
body.theater #grid .tile { border-radius: 0; }
.big { font-size: 34px; }
