/* =====================================================================
   WebMeet Pro — UI theme (dark, glassmorphism, responsive)
   ===================================================================== */
:root {
  --bg: #0b0d12;
  --bg-2: #11141c;
  --panel: rgba(22, 26, 36, 0.72);
  --panel-solid: #161a24;
  --stroke: rgba(255, 255, 255, 0.10);
  --stroke-2: rgba(255, 255, 255, 0.06);
  --text: #e8ebf2;
  --muted: #98a0b3;
  --primary: #5b8cff;
  --primary-2: #3f6fe0;
  --danger: #ff5b6e;
  --danger-2: #e23b4f;
  --ok: #45d483;
  --warn: #ffcb5b;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  --blur: saturate(160%) blur(16px);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(91, 140, 255, 0.18), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(168, 91, 255, 0.14), transparent 55%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 .4em; font-weight: 650; letter-spacing: -0.01em; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.center { text-align: center; }
.hidden { display: none !important; }
.opt { color: var(--muted); font-weight: 400; font-size: .8em; }

/* ---------- glass surfaces ---------- */
.glass {
  background: var(--panel);
  border: 1px solid var(--stroke);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  box-shadow: var(--shadow);
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5em;
  padding: .7em 1.1em; border-radius: var(--radius-sm);
  border: 1px solid var(--stroke); background: rgba(255,255,255,.05); color: var(--text);
  font: inherit; font-weight: 600; cursor: pointer; transition: .15s ease;
}
.btn:hover { background: rgba(255,255,255,.10); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary { background: linear-gradient(180deg, var(--primary), var(--primary-2)); border-color: transparent; }
.btn-primary:hover { filter: brightness(1.07); }
.btn-danger { background: linear-gradient(180deg, var(--danger), var(--danger-2)); border-color: transparent; }
.btn-ghost { background: transparent; }
.btn-block { display: flex; width: 100%; margin-top: .4rem; }
.btn-sm { padding: .4em .7em; font-size: .85rem; }

/* ---------- forms ---------- */
label { display: block; margin: .7rem 0; font-size: .9rem; color: var(--muted); }
input, select, textarea {
  width: 100%; margin-top: .35rem; padding: .7em .85em;
  background: rgba(0,0,0,.25); border: 1px solid var(--stroke);
  border-radius: var(--radius-sm); color: var(--text); font: inherit;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(91,140,255,.2); }
.checkbox { display: flex; align-items: center; gap: .6rem; }
.checkbox input { width: auto; margin: 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-actions { display: flex; gap: .6rem; margin-top: 1.2rem; flex-wrap: wrap; }

.alert { padding: .7rem .9rem; border-radius: var(--radius-sm); margin: .8rem 0; font-size: .9rem; }
.alert.error { background: rgba(255,91,110,.12); border: 1px solid rgba(255,91,110,.4); color: #ffd0d6; }
.alert.ok { background: rgba(69,212,131,.12); border: 1px solid rgba(69,212,131,.4); color: #c8ffe0; }

/* ---------- brand ---------- */
.logo-dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block;
  background: linear-gradient(135deg, var(--primary), #a85bff); box-shadow: 0 0 12px rgba(91,140,255,.8); }
.auth-brand { display: flex; align-items: center; gap: .5rem; font-weight: 700; margin-bottom: 1rem; }

/* =====================================================================
   Auth + simple pages
   ===================================================================== */
.auth-page, .lobby-page, .shell-page { display: flex; min-height: 100%; }
.auth-page { align-items: center; justify-content: center; padding: 24px; }
.auth-card { width: 100%; max-width: 420px; padding: 2rem; border-radius: var(--radius); }
.form-wrap { max-width: 640px; margin: 5vh auto; padding: 24px; width: 100%; }
.form-card { padding: 2rem; border-radius: var(--radius); }
.back-link { display: inline-block; margin-bottom: 1rem; color: var(--muted); }

/* =====================================================================
   Lobby
   ===================================================================== */
.lobby {
  display: grid; grid-template-columns: 1.4fr 1fr; gap: 24px;
  max-width: 1100px; margin: auto; padding: 24px; width: 100%; align-items: center;
}
.preview-frame { position: relative; aspect-ratio: 16/9; border-radius: var(--radius); overflow: hidden; }
.preview-frame video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); background: #000; }
.preview-off { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1rem; color: var(--muted); }
.avatar-lg { width: 96px; height: 96px; border-radius: 50%; display: grid; place-items: center; font-size: 2rem; font-weight: 700;
  background: linear-gradient(135deg, var(--primary), #a85bff); color: #fff; }
.preview-controls { position: absolute; bottom: 14px; left: 0; right: 0; display: flex; justify-content: center; gap: 14px; }
.round-btn { width: 48px; height: 48px; border-radius: 50%; border: 1px solid var(--stroke); background: rgba(0,0,0,.45);
  color: var(--text); cursor: pointer; display: grid; place-items: center; transition: .15s; }
.round-btn:hover { background: rgba(0,0,0,.7); }
.round-btn.off { background: var(--danger); border-color: transparent; }
.round-btn.primary { background: var(--primary); border-color: transparent; }
.round-btn.ghost { background: transparent; }
.mic-meter { position: absolute; bottom: 6px; left: 14px; right: 14px; height: 4px; background: rgba(255,255,255,.1); border-radius: 4px; overflow: hidden; }
.mic-level { height: 100%; width: 0; background: linear-gradient(90deg, var(--ok), var(--warn)); transition: width .08s; }
.device-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 14px; }
.lobby-join { padding: 2rem; border-radius: var(--radius); }
.waiting-box { display: flex; align-items: center; gap: 12px; margin-top: 1rem; color: var(--muted); }
.spinner { width: 22px; height: 22px; border: 3px solid rgba(255,255,255,.2); border-top-color: var(--primary); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* =====================================================================
   Room
   ===================================================================== */
.room-page { overflow: hidden; }
.room { display: flex; flex-direction: column; height: 100vh; height: 100dvh; padding: 10px; gap: 10px; }

.topbar { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; border-radius: var(--radius); }
.topbar-left { display: flex; align-items: center; gap: 12px; }
.meeting-id { display: flex; flex-direction: column; line-height: 1.2; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.timer { font-variant-numeric: tabular-nums; color: var(--muted); }
.badge { padding: .25em .6em; border-radius: 999px; font-size: .72rem; font-weight: 700; }
.badge.rec { background: rgba(255,91,110,.18); color: #ff8a96; border: 1px solid rgba(255,91,110,.5); animation: pulse 1.4s infinite; }
@keyframes pulse { 50% { opacity: .45; } }

.stage { position: relative; flex: 1; display: flex; gap: 10px; min-height: 0; }

/* ---- video grid ---- */
.video-grid {
  flex: 1; display: grid; gap: 10px; min-height: 0; min-width: 0;
  grid-template-columns: repeat(var(--cols, 1), 1fr);
  grid-auto-rows: 1fr;
}
.tile {
  position: relative; background: #0e1119; border-radius: var(--radius); overflow: hidden;
  border: 1px solid var(--stroke-2); min-height: 0; box-shadow: inset 0 0 0 1px rgba(0,0,0,.2);
  transition: outline-color .15s;
  outline: 2px solid transparent; outline-offset: -2px;
}
.tile video { width: 100%; height: 100%; object-fit: cover; background: #000; }
.tile.self video { transform: scaleX(-1); }
.tile.self.sharing video { transform: none; }
.tile.speaking { outline-color: var(--ok); }
.tile.video-off video { visibility: hidden; }
.tile-avatar { position: absolute; inset: 0; display: none; align-items: center; justify-content: center; }
.tile.video-off .tile-avatar { display: flex; }
.tile-avatar span { width: 84px; height: 84px; border-radius: 50%; display: grid; place-items: center;
  font-size: 1.8rem; font-weight: 700; color: #fff; background: linear-gradient(135deg, var(--primary), #a85bff); }
.tile-bar { position: absolute; left: 8px; bottom: 8px; right: 8px; display: flex; align-items: center; gap: 8px;
  padding: 5px 10px; border-radius: 999px; background: rgba(0,0,0,.45); backdrop-filter: blur(6px); font-size: .82rem; }
.tile-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-mic { width: 16px; height: 16px; flex: none; background: center/contain no-repeat; }
.tile-mic::before { content: "🎤"; font-size: 13px; }
.tile.muted .tile-mic::before { content: "🔇"; }
.tile-hand { display: none; }
.tile.hand-up .tile-hand { display: inline; animation: wave 1s ease-in-out infinite; }
@keyframes wave { 25% { transform: rotate(18deg); } 75% { transform: rotate(-12deg); } }
.tile-pin { position: absolute; top: 8px; right: 8px; width: 30px; height: 30px; border-radius: 8px;
  border: none; background: rgba(0,0,0,.45); color: #fff; cursor: pointer; opacity: 0; transition: .15s; }
.tile:hover .tile-pin { opacity: 1; }

/* pinned (spotlight) layout */
.video-grid.pinned-mode { grid-template-columns: 1fr; grid-auto-rows: auto; grid-template-rows: 1fr auto; }
.video-grid.pinned-mode .tile { display: none; }
.video-grid.pinned-mode .tile.is-pinned { display: block; grid-row: 1; }
.video-grid.pinned-mode .tile:not(.is-pinned) { display: block; }
.video-grid.pinned-mode { grid-template-areas: "spot" "strip"; }
.video-grid.pinned-mode .is-pinned { grid-area: spot; }

/* ---- side panel ---- */
.side-panel { width: 360px; max-width: 84vw; display: flex; flex-direction: column; border-radius: var(--radius); overflow: hidden; }
.side-tabs { display: flex; align-items: center; gap: 4px; padding: 10px; border-bottom: 1px solid var(--stroke-2); }
.side-tab { background: transparent; border: none; color: var(--muted); padding: .5em .8em; border-radius: 8px; cursor: pointer; font: inherit; font-weight: 600; }
.side-tab.active { background: rgba(255,255,255,.08); color: var(--text); }
.side-tab .pill, .pill { background: var(--primary); color: #fff; border-radius: 999px; font-size: .7rem; padding: .05em .5em; }
#closePanel { margin-left: auto; width: 34px; height: 34px; }
.side-body { flex: 1; overflow: auto; padding: 12px; display: flex; flex-direction: column; }

/* chat */
.chat-list { flex: 1; overflow: auto; display: flex; flex-direction: column; gap: 10px; padding-right: 4px; }
.chat-msg { max-width: 92%; }
.chat-msg.mine { align-self: flex-end; text-align: right; }
.chat-meta { font-size: .72rem; color: var(--muted); display: flex; gap: 8px; }
.chat-msg.mine .chat-meta { justify-content: flex-end; }
.chat-author { font-weight: 700; color: var(--text); }
.chat-text { background: rgba(255,255,255,.06); padding: .5em .75em; border-radius: 12px; margin-top: 2px; display: inline-block; word-break: break-word; }
.chat-msg.mine .chat-text { background: rgba(91,140,255,.22); }
.chat-text.emoji { font-size: 1.8rem; background: none; padding: 0; }
.chat-msg.system { align-self: center; color: var(--muted); font-size: .8rem; }
.mention { color: var(--primary); font-weight: 600; }
.chat-form { display: flex; gap: 8px; margin-top: 10px; }
.chat-form input { margin: 0; }

/* people */
.people-list, .waiting-room { display: flex; flex-direction: column; gap: 6px; }
.waiting-room { margin-bottom: 14px; padding-bottom: 12px; border-bottom: 1px solid var(--stroke-2); }
.person, .waiting-person { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 10px; }
.person:hover { background: rgba(255,255,255,.05); }
.person-avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: .8rem;
  background: linear-gradient(135deg, var(--primary), #a85bff); color: #fff; flex: none; }
.person-main { flex: 1; min-width: 0; }
.person-name { font-size: .9rem; display: flex; align-items: center; gap: 6px; }
.person-state { font-size: .8rem; color: var(--muted); display: flex; gap: 6px; }
.person-state .off { opacity: .55; }
.person-actions { display: flex; gap: 4px; }
.person-actions button { width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--stroke); background: rgba(255,255,255,.05); cursor: pointer; }
.tag { font-size: .65rem; padding: .1em .45em; border-radius: 6px; background: rgba(255,255,255,.12); color: var(--muted); }
.tag.host { background: rgba(91,140,255,.25); color: #bcd0ff; }
.tag.you { background: rgba(69,212,131,.22); color: #bff7d8; }
.waiting-person { justify-content: space-between; }
.waiting-actions { display: flex; gap: 6px; }

/* host tab */
.switch-row { display: flex; align-items: center; justify-content: space-between; color: var(--text); }
.switch-row input { width: auto; margin: 0; }

/* ---- control bar ---- */
.controlbar { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; border-radius: var(--radius); }
.ctl-group { display: flex; gap: 8px; }
.ctl { display: flex; flex-direction: column; align-items: center; gap: 3px; min-width: 64px; padding: 8px 10px;
  border-radius: 14px; border: 1px solid var(--stroke); background: rgba(255,255,255,.05); color: var(--text);
  cursor: pointer; font: inherit; transition: .15s; }
.ctl:hover { background: rgba(255,255,255,.12); }
.ctl label { margin: 0; font-size: .68rem; color: var(--muted); cursor: pointer; }
.ctl .ic { font-size: 1.15rem; }
.ctl.on { background: rgba(91,140,255,.22); border-color: rgba(91,140,255,.5); }
.ctl.leave { background: var(--danger); border-color: transparent; }
.ctl.leave label { color: #fff; }
.ctl:disabled { opacity: .4; cursor: not-allowed; }
/* mic/cam show "off" styling when NOT .on */
#micBtn:not(.on), #camBtn:not(.on) { background: rgba(255,91,110,.2); border-color: rgba(255,91,110,.5); }

/* simple emoji icons */
.ic-mic::before { content: "🎤"; } .ic-cam::before { content: "📷"; }
.ic-screen::before { content: "🖥️"; } .ic-hand::before { content: "✋"; }
.ic-emoji::before { content: "😀"; } .ic-rec::before { content: "⏺️"; }
.ic-chat::before { content: "💬"; } .ic-people::before { content: "👥"; }
.ic-leave::before { content: "📞"; }

.reaction-picker { position: absolute; bottom: 84px; left: 16px; display: flex; gap: 8px; padding: 10px; border-radius: 999px; }
.reaction-picker button { background: transparent; border: none; font-size: 1.5rem; cursor: pointer; transition: transform .12s; }
.reaction-picker button:hover { transform: scale(1.3) translateY(-3px); }

/* reactions floating */
.reaction-layer { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.floater { position: absolute; bottom: 8%; display: flex; flex-direction: column; align-items: center; animation: floatUp 3.1s ease-out forwards; }
.floater .emoji { font-size: 2.4rem; }
.floater .who { font-size: .7rem; color: #fff; background: rgba(0,0,0,.5); padding: .1em .5em; border-radius: 999px; }
@keyframes floatUp { 0% { transform: translateY(0) scale(.6); opacity: 0; } 15% { opacity: 1; transform: scale(1); } 100% { transform: translateY(-62vh) scale(1.1); opacity: 0; } }

.toast { position: fixed; bottom: 96px; left: 50%; transform: translateX(-50%); z-index: 50;
  background: var(--panel-solid); border: 1px solid var(--stroke); padding: .7em 1.1em; border-radius: 999px; box-shadow: var(--shadow); }

/* =====================================================================
   Landing / dashboard (index)
   ===================================================================== */
.nav { display: flex; align-items: center; justify-content: space-between; padding: 16px 28px; }
.nav .brand { display: flex; align-items: center; gap: .55rem; font-weight: 800; font-size: 1.15rem; }
.nav-actions { display: flex; gap: 10px; align-items: center; }
.hero { max-width: 1080px; margin: 4vh auto; padding: 0 24px; display: grid; grid-template-columns: 1.1fr 1fr; gap: 40px; align-items: center; }
.hero h1 { font-size: clamp(2rem, 4vw, 3.2rem); line-height: 1.05; }
.hero p.lead { color: var(--muted); font-size: 1.1rem; max-width: 46ch; }
.cta-card { padding: 1.6rem; border-radius: var(--radius); }
.join-row { display: flex; gap: 10px; margin-top: 1rem; }
.join-row input { margin: 0; }
.feature-grid { max-width: 1080px; margin: 2vh auto 6vh; padding: 0 24px; display: grid; grid-template-columns: repeat(auto-fit, minmax(220px,1fr)); gap: 16px; }
.feature { padding: 1.2rem; border-radius: var(--radius); }
.feature .ico { font-size: 1.6rem; }
.history-table { width: 100%; border-collapse: collapse; margin-top: 1rem; }
.history-table th, .history-table td { text-align: left; padding: .6rem .5rem; border-bottom: 1px solid var(--stroke-2); font-size: .9rem; }
.status-pill { font-size: .72rem; padding: .15em .6em; border-radius: 999px; }
.status-active { background: rgba(69,212,131,.2); color: #bff7d8; }
.status-scheduled { background: rgba(255,203,91,.2); color: #ffe6ad; }
.status-ended { background: rgba(255,255,255,.08); color: var(--muted); }

/* =====================================================================
   Responsive
   ===================================================================== */
@media (max-width: 900px) {
  .lobby, .hero { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .side-panel { position: absolute; right: 0; top: 0; bottom: 0; z-index: 30; }
  .ctl label { display: none; }
  .ctl { min-width: 46px; }
  .device-row { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .room { padding: 6px; }
  .controlbar { overflow-x: auto; justify-content: flex-start; }
  .topbar-right .btn { display: none; }
}
