/* GTS LiveKit Meeting - room styles. Uses the GTS token bridge so it
   inherits the site/dashboard theme (light/dark via [data-theme]). */
#gts-room {
	display: flex;
	flex-direction: column;
	gap: 12px;
	padding: 16px;
	background: var(--surf, #16161f);
	border-radius: 12px;
	min-height: 260px;
	font-family: "DM Sans", system-ui, sans-serif;
}
#gts-room .gts-room-loading,
#gts-room .gts-room-error {
	display: flex; flex-direction: column; align-items: center; justify-content: center;
	gap: 14px;
	min-height: 220px;
	color: var(--muted, #8b8ca0);
	font-size: 15px;
	text-align: center;
	padding: 24px;
}
#gts-room .gts-spinner {
	width: 34px; height: 34px;
	border: 3px solid var(--border, #2c2c3a);
	border-top-color: var(--accent, #f5b301);
	border-radius: 50%;
	animation: gts-spin 0.8s linear infinite;
}
@keyframes gts-spin { to { transform: rotate(360deg); } }

/* ---- Stage (tiles area) ---- */
#gts-room .gts-stage { min-height: 320px; }

/* Grid layout */
#gts-room .gts-layout-grid {
	display: grid;
	gap: 12px;
	grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

/* Speaker layout: big main + filmstrip */
#gts-room .gts-layout-speaker {
	display: grid;
	grid-template-rows: 1fr auto;
	gap: 12px;
}
#gts-room .gts-layout-speaker .gts-main { min-height: 380px; display: flex; }
#gts-room .gts-layout-speaker .gts-main .gts-tile { flex: 1; aspect-ratio: auto; }
#gts-room .gts-filmstrip {
	display: flex; gap: 10px; overflow-x: auto; padding-bottom: 4px;
}
#gts-room .gts-filmstrip .gts-tile {
	flex: 0 0 180px; aspect-ratio: 16/9;
}

/* ---- Tiles ---- */
#gts-room .gts-tile {
	position: relative;
	background: #000;
	border-radius: 12px;
	overflow: hidden;
	aspect-ratio: 16 / 9;
	cursor: default;
}
#gts-room .gts-layout-speaker .gts-tile { cursor: pointer; }
#gts-room .gts-tile video { width: 100%; height: 100%; object-fit: cover; }
#gts-room .gts-tile-noavatar {
	width: 100%; height: 100%;
	display: flex; align-items: center; justify-content: center;
	font-size: 42px; font-weight: 600; color: #fff;
	background: linear-gradient(135deg, #2a2a3a, #15151f);
}
#gts-room .gts-tile-label {
	position: absolute; left: 8px; bottom: 8px;
	background: rgba(0,0,0,0.6); color: #fff;
	padding: 3px 8px; border-radius: 6px; font-size: 12px;
	max-width: calc(100% - 16px);
	overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
#gts-room .gts-tile-hand {
	position: absolute; right: 8px; top: 8px;
	background: var(--accent, #f5b301); color: #000;
	padding: 2px 7px; border-radius: 6px;
	font-size: 11px; font-weight: 700; letter-spacing: 0.04em;
}

/* ---- Moderator controls on a tile ---- */
#gts-room .gts-tile-mod {
	position: absolute; left: 8px; top: 8px;
	display: flex; gap: 6px;
	opacity: 0; transition: opacity 0.15s;
}
#gts-room .gts-tile:hover .gts-tile-mod { opacity: 1; }
#gts-room .gts-mod-btn {
	border: 0; border-radius: 6px; cursor: pointer;
	padding: 3px 8px; font-size: 11px; font-weight: 600; color: #fff;
}
#gts-room .gts-mod-mute { background: rgba(40,40,55,0.92); }
#gts-room .gts-mod-kick { background: rgba(200,45,45,0.92); }
#gts-room .gts-mod-btn:disabled { opacity: 0.5; cursor: default; }

/* ---- Controls bar ---- */
#gts-room .gts-bar {
	display: flex; flex-wrap: wrap; gap: 8px;
	justify-content: center;
	padding-top: 4px;
}
#gts-room .gts-btn {
	border: 1px solid var(--border, #2c2c3a);
	background: var(--surf2, #21212e);
	color: var(--txt, #e7e7ee);
	border-radius: 999px;
	padding: 8px 16px;
	font-size: 13px; font-weight: 500; cursor: pointer;
	font-family: inherit;
	transition: background 0.15s, border-color 0.15s;
}
#gts-room .gts-btn:hover { background: var(--surf-3, #2c2c3a); }
#gts-room .gts-btn.gts-active {
	background: var(--accent, #f5b301); color: #000; border-color: transparent;
}
#gts-room .gts-btn-leave {
	background: rgba(200,45,45,0.15);
	border-color: rgba(200,45,45,0.5);
	color: #ff6b6b;
}
#gts-room .gts-btn-leave:hover { background: rgba(200,45,45,0.28); }

/* ---- Additional moderator tile buttons ---- */
#gts-room .gts-mod-speak { background: rgba(40,90,160,0.92); }
#gts-room .gts-mod-lower { background: rgba(150,110,30,0.92); }

/* Screen-share active tile fills the main area cleanly (contain, not cover) */
#gts-room .gts-layout-speaker .gts-main .gts-tile video { object-fit: contain; background: #000; }

/* ---- Content wrapper (stage + optional chat side-by-side) ---- */
#gts-room .gts-content { display: flex; gap: 12px; align-items: stretch; }
#gts-room .gts-content .gts-stage { flex: 1; min-width: 0; }
#gts-room .gts-content.gts-has-chat .gts-stage { flex: 1 1 auto; }

/* ---- Built-in chat panel ---- */
#gts-room .gts-chat {
	flex: 0 0 300px;
	display: flex; flex-direction: column;
	background: var(--surf2, #1b1b27);
	border: 1px solid var(--border, #2c2c3a);
	border-radius: 12px;
	overflow: hidden;
	max-height: 600px;
}
#gts-room .gts-chat-log {
	flex: 1; overflow-y: auto; padding: 12px;
	display: flex; flex-direction: column; gap: 8px;
	min-height: 200px;
}
#gts-room .gts-chat-msg {
	display: flex; flex-direction: column; gap: 1px;
	font-size: 13px; line-height: 1.35;
}
#gts-room .gts-chat-name { font-weight: 600; color: var(--accent, #f5b301); font-size: 12px; }
#gts-room .gts-chat-mine .gts-chat-name { color: var(--muted, #8b8ca0); }
#gts-room .gts-chat-text { color: var(--txt, #e7e7ee); word-wrap: break-word; overflow-wrap: anywhere; }
#gts-room .gts-chat-form {
	display: flex; gap: 6px; padding: 8px;
	border-top: 1px solid var(--border, #2c2c3a);
}
#gts-room .gts-chat-input {
	flex: 1; min-width: 0;
	background: var(--surf, #16161f);
	border: 1px solid var(--border, #2c2c3a);
	border-radius: 8px; padding: 8px 10px;
	color: var(--txt, #e7e7ee); font-size: 13px; font-family: inherit;
}
#gts-room .gts-chat-send {
	border: 0; border-radius: 8px; cursor: pointer;
	background: var(--accent, #f5b301); color: #000;
	padding: 0 14px; font-size: 13px; font-weight: 600; font-family: inherit;
}

/* Stack chat under video on narrow screens */
@media (max-width: 760px) {
	#gts-room .gts-content { flex-direction: column; }
	#gts-room .gts-chat { flex-basis: auto; max-height: 280px; }
}

/* ---- Pre-join screen ---- */
#gts-room .gts-prejoin {
	display: flex; flex-direction: column; align-items: stretch; gap: 16px;
	padding: 24px; max-width: 520px; margin: 0 auto;
}
#gts-room .gts-prejoin-preview {
	width: 100%; max-height: 300px; height: 300px;
	background: #000; border-radius: 12px;
	object-fit: contain; display: block;
}
#gts-room .gts-prejoin-nocam {
	width: 100%; aspect-ratio: 16/9; max-height: 300px; border-radius: 12px;
	background: linear-gradient(135deg, #2a2a3a, #15151f);
	display: flex; align-items: center; justify-content: center;
	color: var(--muted, #8b8ca0); font-size: 14px; text-align: center; padding: 0 24px;
}
#gts-room .gts-prejoin-controls {
	display: flex; flex-wrap: wrap; gap: 12px; width: 100%; justify-content: center;
}
#gts-room .gts-prejoin-join { min-width: 180px; justify-content: center; }

/* ---- Device select (shared: prejoin + modal) ---- */
#gts-room .gts-device-select {
	display: flex; flex-direction: column; gap: 4px;
	font-size: 12px; color: var(--muted, #8b8ca0); flex: 1; min-width: 200px;
}
#gts-room .gts-device-select select {
	background: var(--surf, #16161f);
	border: 1px solid var(--border, #2c2c3a);
	border-radius: 8px; padding: 8px 10px;
	color: var(--txt, #e7e7ee); font-size: 13px; font-family: inherit;
	max-width: 100%;
}

/* ---- Device settings modal ---- */
#gts-room .gts-modal-overlay {
	position: fixed; inset: 0; z-index: 50;
	background: rgba(0,0,0,0.55);
	display: flex; align-items: center; justify-content: center;
}
#gts-room .gts-modal {
	background: var(--surf2, #1b1b27);
	border: 1px solid var(--border, #2c2c3a);
	border-radius: 14px; padding: 20px;
	width: min(92vw, 380px);
	display: flex; flex-direction: column; gap: 14px;
}
#gts-room .gts-modal-title { font-size: 16px; font-weight: 600; color: var(--txt, #e7e7ee); }
#gts-room .gts-modal-note { font-size: 13px; color: var(--muted, #8b8ca0); }
#gts-room .gts-modal-close { justify-content: center; }

/* ---- Pin button + pinned indicator ---- */
#gts-room .gts-pin-btn {
	position: absolute; right: 8px; top: 8px;
	border: 0; border-radius: 6px; cursor: pointer;
	padding: 3px 10px; font-size: 11px; font-weight: 600;
	background: rgba(40,40,55,0.92); color: #fff;
	opacity: 0; transition: opacity 0.15s;
}
#gts-room .gts-tile:hover .gts-pin-btn { opacity: 1; }
#gts-room .gts-pin-btn.gts-active {
	opacity: 1; background: var(--accent, #f5b301); color: #000;
}
/* When a tile also shows a raised-hand badge (top-right), nudge pin left. */
#gts-room .gts-tile-hand + .gts-pin-btn,
#gts-room .gts-tile-hand ~ .gts-pin-btn { right: 58px; }
#gts-room .gts-tile-pinned {
	position: absolute; left: 8px; top: 8px;
	background: var(--accent, #f5b301); color: #000;
	padding: 2px 7px; border-radius: 6px;
	font-size: 11px; font-weight: 700; letter-spacing: 0.04em;
}
/* Moderator controls sit top-left; if pinned badge is there, shift them down. */
#gts-room .gts-tile-pinned ~ .gts-tile-mod { top: 36px; }

/* ---- Green room: waiting screen + backstage banner ---- */
#gts-room .gts-waiting {
	display: flex; flex-direction: column; align-items: center; justify-content: center;
	gap: 10px; min-height: 340px; text-align: center; padding: 40px 32px;
}

/* Calm "standing by" pulse - three concentric rings breathing outward. */
#gts-room .gts-waiting-pulse {
	position: relative; width: 72px; height: 72px; margin-bottom: 10px;
	display: flex; align-items: center; justify-content: center;
}
#gts-room .gts-waiting-pulse span {
	position: absolute; left: 50%; top: 50%;
	width: 18px; height: 18px; border-radius: 50%;
	background: var(--accent, #f5b301);
	transform: translate(-50%, -50%);
}
#gts-room .gts-waiting-pulse span:nth-child(1) { animation: gts-breathe 2.4s ease-out infinite; }
#gts-room .gts-waiting-pulse span:nth-child(2) { animation: gts-breathe 2.4s ease-out infinite 0.8s; }
#gts-room .gts-waiting-pulse span:nth-child(3) {
	width: 12px; height: 12px; background: var(--accent, #f5b301); opacity: 1; animation: none;
}
@keyframes gts-breathe {
	0%   { width: 14px; height: 14px; opacity: 0.55; }
	100% { width: 72px; height: 72px; opacity: 0; }
}

#gts-room .gts-waiting-eyebrow {
	font-size: 11px; font-weight: 700; letter-spacing: 0.16em;
	color: var(--accent, #f5b301);
}
#gts-room .gts-waiting-title {
	font-size: 20px; font-weight: 600; color: var(--txt, #e7e7ee);
	max-width: 460px; line-height: 1.3;
}
#gts-room .gts-waiting-sub {
	font-size: 14px; color: var(--muted, #8b8ca0); max-width: 420px; line-height: 1.5;
}
#gts-room .gts-waiting-host {
	margin-top: 8px; font-size: 14px; color: var(--txt, #e7e7ee); font-weight: 500;
	display: inline-flex; align-items: baseline;
}
#gts-room .gts-dots i {
	display: inline-block; opacity: 0.35; font-style: normal; color: var(--accent, #f5b301);
	animation: gts-dot 1.4s infinite both;
}
#gts-room .gts-dots i:nth-child(2) { animation-delay: 0.2s; }
#gts-room .gts-dots i:nth-child(3) { animation-delay: 0.4s; }
@keyframes gts-dot { 0%, 60%, 100% { opacity: 0.2; } 30% { opacity: 1; } }

#gts-room .gts-backstage {
	background: rgba(245,179,1,0.14);
	border: 1px solid var(--accent, #f5b301);
	color: var(--accent, #f5b301);
	border-radius: 10px;
	padding: 8px 14px;
	font-size: 13px; font-weight: 600; text-align: center;
}

/* Go Live button - prominent when in lobby (active state = green-ish accent) */
#gts-room .gts-btn-live.gts-active {
	background: #1db954; color: #fff; border-color: transparent;
}

/* ---- Roster / participant panel ---- */
#gts-room .gts-roster {
	position: absolute; top: 0; right: 0; z-index: 40;
	width: min(86vw, 300px); height: 100%;
	background: var(--surf2, #1b1b27);
	border-left: 1px solid var(--border, #2c2c3a);
	border-radius: 0 12px 12px 0;
	display: flex; flex-direction: column;
	overflow-y: auto;
	box-shadow: -8px 0 24px rgba(0,0,0,0.35);
}
#gts-room { position: relative; }
#gts-room .gts-roster-head {
	display: flex; align-items: center; justify-content: space-between;
	padding: 12px 14px; border-bottom: 1px solid var(--border, #2c2c3a);
}
#gts-room .gts-roster-title {
	font-size: 12px; font-weight: 700; letter-spacing: 0.04em;
	text-transform: uppercase; color: var(--muted, #8b8ca0);
}
#gts-room .gts-roster-count {
	min-width: 22px; text-align: center;
	background: var(--accent, #f5b301); color: #000;
	border-radius: 999px; padding: 1px 8px;
	font-size: 12px; font-weight: 700;
}
#gts-room .gts-roster-list { display: flex; flex-direction: column; padding: 6px 0; }
#gts-room .gts-roster-row {
	display: flex; align-items: center; gap: 10px;
	padding: 8px 14px;
}
#gts-room .gts-roster-mono {
	flex: 0 0 28px; width: 28px; height: 28px; border-radius: 50%;
	display: flex; align-items: center; justify-content: center;
	background: linear-gradient(135deg, #2a2a3a, #15151f);
	color: #fff; font-size: 12px; font-weight: 600;
}
#gts-room .gts-roster-name {
	flex: 1; min-width: 0; font-size: 13px; color: var(--txt, #e7e7ee);
	overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
#gts-room .gts-roster-icons { display: flex; gap: 4px; align-items: center; }
#gts-room .gts-roster-hand {
	background: var(--accent, #f5b301); color: #000;
	border-radius: 5px; padding: 1px 5px; font-size: 9px; font-weight: 700;
}
#gts-room .gts-roster-muted {
	color: var(--muted, #8b8ca0); font-size: 11px;
}
#gts-room .gts-roster-waiting {
	margin-top: auto; border-top: 1px solid var(--border, #2c2c3a);
	padding-bottom: 8px;
}
#gts-room .gts-roster-waiting .gts-roster-count { background: #1db954; color: #fff; }
#gts-room .gts-roster-waiting-note {
	padding: 0 14px 10px; font-size: 12px; color: var(--muted, #8b8ca0);
}

/* ---- Viewer pre-join (no devices) ---- */
#gts-room .gts-prejoin-viewer {
	gap: 12px; padding: 40px 32px; text-align: center; align-items: center;
}
#gts-room .gts-viewer-icon { font-size: 40px; opacity: 0.9; }
#gts-room .gts-viewer-title {
	font-size: 20px; font-weight: 600; color: var(--txt, #e7e7ee);
}
#gts-room .gts-viewer-sub {
	font-size: 14px; color: var(--muted, #8b8ca0); max-width: 380px; line-height: 1.5;
}

/* ---- Split (70/30) stage ---- */
#gts-room .gts-layout-split {
	display: grid;
	grid-template-columns: 70% 30%;
	gap: 12px;
}
#gts-room .gts-split-primary { min-width: 0; display: flex; }
#gts-room .gts-split-primary .gts-tile {
	flex: 1; aspect-ratio: auto; min-height: 360px;
}
#gts-room .gts-split-primary .gts-tile video { object-fit: contain; background: #000; }
#gts-room .gts-split-side {
	display: flex; flex-direction: column; gap: 10px;
	overflow-y: auto; max-height: 520px; min-width: 0;
}
#gts-room .gts-split-side .gts-tile { aspect-ratio: 16/9; }

@media (max-width: 760px) {
	#gts-room .gts-layout-split { grid-template-columns: 1fr; }
	#gts-room .gts-split-side { flex-direction: row; max-height: none; }
	#gts-room .gts-split-side .gts-tile { flex: 0 0 140px; }
}

/* ---- Redesigned control bar: grouped + flowing ---- */
#gts-room .gts-bar {
	display: flex; align-items: center; gap: 10px;
	flex-wrap: wrap;
}
#gts-room .gts-bar-group {
	display: flex; align-items: center; gap: 6px;
	padding: 4px; border-radius: 12px;
	background: rgba(255,255,255,0.03);
}
#gts-room .gts-bar-spacer { flex: 1 1 auto; }

/* Danger state for an active mic-on -> showing "Mute" affordance kept subtle */
#gts-room .gts-btn-leave {
	background: #3a1620; color: #ff6b81; border-color: transparent;
}
#gts-room .gts-btn-leave:hover { background: #4a1828; }

/* ---- Host dropdown menu ---- */
#gts-room .gts-host-wrap { position: relative; }
#gts-room .gts-btn-host { font-weight: 600; }
#gts-room .gts-host-menu {
	position: absolute; bottom: calc(100% + 8px); right: 0;
	min-width: 180px; z-index: 60;
	background: var(--surf2, #1b1b27);
	border: 1px solid var(--border, #2c2c3a);
	border-radius: 12px; padding: 6px;
	display: none; flex-direction: column; gap: 4px;
	box-shadow: 0 12px 32px rgba(0,0,0,0.45);
}
#gts-room .gts-host-open .gts-host-menu { display: flex; }
#gts-room .gts-host-item {
	width: 100%; text-align: left; justify-content: flex-start;
}

/* ---- Split-solo: collapse the empty side column ---- */
#gts-room .gts-layout-split.gts-split-solo { grid-template-columns: 1fr; }
#gts-room .gts-split-primary .gts-tile {
	width: 100%; min-height: 420px; background: #000;
	display: flex; align-items: center; justify-content: center;
}
#gts-room .gts-split-primary .gts-tile video {
	width: 100%; height: 100%; object-fit: contain;
}

/* ---- Empty stage placeholder (viewer waiting / presenter not yet on) ---- */
#gts-room .gts-stage-empty {
	grid-column: 1 / -1;
	display: flex; align-items: center; justify-content: center;
	min-height: 320px; padding: 40px;
	text-align: center; font-size: 15px;
	color: var(--muted, #8b8ca0);
}

/* ---- Full screen: whole room fills the screen ---- */
#gts-room:fullscreen,
#gts-room:-webkit-full-screen {
	width: 100vw; height: 100vh;
	background: var(--bg, #0f0f17);
	padding: 14px; box-sizing: border-box;
	display: flex; flex-direction: column;
}
/* The content (stage + chat) takes the available height; the bar sits below. */
#gts-room:fullscreen .gts-content,
#gts-room:-webkit-full-screen .gts-content {
	flex: 1 1 auto; min-height: 0;
}
#gts-room:fullscreen .gts-stage,
#gts-room:-webkit-full-screen .gts-stage {
	height: 100%;
}
#gts-room:fullscreen .gts-bar,
#gts-room:-webkit-full-screen .gts-bar {
	flex: 0 0 auto; margin-top: 10px;
}
