/* webMVF client styles (v2): 3-column layout, modals, media tiles, whiteboard. */
:root {
  --bg: #1e1f22;
  --bg2: #2b2d31;
  --bg3: #313338;
  --bg4: #383a40;
  --text: #dbdee1;
  --muted: #949ba4;
  --accent: #5865f2;
  --accent2: #4752c4;
  --green: #23a55a;
  --red: #f23f43;
  --gold: #f0b232;
  --border: #111214;
}

* { box-sizing: border-box; }

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

.hidden { display: none !important; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 13px; }
.center-text { text-align: center; }

/* stroke icons from the inline sprite */
svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ico { width: 16px; height: 16px; flex: none; }

button {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 8px 14px;
  font-size: 14px;
  cursor: pointer;
  font-family: inherit;
}
button:hover { background: var(--accent2); }
button:disabled { opacity: 0.5; cursor: default; }
input, select, textarea {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 14px;
  font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: 1px solid var(--accent); }

.iconbtn {
  background: none;
  border: none;
  color: var(--muted);
  padding: 6px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.iconbtn:hover { background: var(--bg4); color: var(--text); }
.iconbtn svg { width: 18px; height: 18px; }

/* ---------- overlays ---------- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

/* landing gets a soft radial glow behind the box */
#landing {
  background: radial-gradient(1200px 800px at 50% 18%, #33353c 0%, #1e1f22 55%, #17181a 100%);
}

/* landing gets a soft radial glow behind the box */
#landing {
  background: radial-gradient(1200px 800px at 50% 18%, #33353c 0%, #1e1f22 55%, #17181a 100%);
}

/* landing gets a soft radial glow behind the box */
.overlay#landing { background: radial-gradient(1100px 700px at 50% 15%, #2a2b31 0%, #141517 65%); }
.landing-box {
  background: var(--bg2);
  padding: 36px 40px;
  border-radius: 12px;
  text-align: center;
  width: 340px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.55);
}
.landing-box h1 { margin: 0 0 6px; font-size: 28px; color: #fff; }
.landing-box p { margin: 0 0 18px; }
.avatar-row { display: flex; justify-content: center; margin-bottom: 18px; }
.avatar-btn { background: none; border: none; padding: 0; width: 72px; height: 72px; }
.avatar-btn:hover { filter: brightness(1.15); }
.avatar-lg { width: 72px; height: 72px; border-radius: 50%; object-fit: cover; }
.avatar-letter {
  width: 72px; height: 72px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 30px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
#nameInput { width: 100%; margin-bottom: 12px; font-size: 16px; padding: 10px 12px; }
#enterBtn { width: 100%; padding: 10px; font-size: 15px; }

/* modal */
.modal {
  background: var(--bg2);
  border-radius: 12px;
  padding: 24px;
  width: 420px;
  max-width: 92vw;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.55);
}
.modal h2 { margin: 0 0 10px; font-size: 20px; color: #fff; }
.modal h3 { margin: 0 0 8px; font-size: 15px; color: #fff; }
.modal label { display: block; color: var(--muted); margin: 10px 0 4px; font-size: 13px; }
.modal label.chk { display: flex; align-items: center; gap: 6px; margin-top: 12px; color: var(--text); }
.modal label.chk input { width: auto; margin: 0; padding: 0; }
.modal input[type=text], .modal input[type=password], .modal select { width: 100%; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }
.acc-av { display: flex; align-items: center; gap: 12px; margin: 10px 0 4px; }
.acc-av-img { width: 56px; height: 56px; border-radius: 50%; object-fit: cover; flex: none; }
.avatar-letter.acc-av-img { width: 56px; height: 56px; font-size: 24px; display: flex; align-items: center; justify-content: center; }
#devPreview { width: 100%; border-radius: 8px; margin-top: 10px; background: #000; }
#devStatus { margin-top: 8px; }

/* admin modal bits */
.admin-sec { margin-bottom: 14px; }
.admin-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.admin-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-role { width: 92px; padding: 5px; }
.admin-btn {
  background: var(--bg4);
  width: 32px; height: 30px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.admin-btn svg { width: 14px; height: 14px; }
.admin-btn.danger { background: var(--red); }
.admin-btn.danger:hover { background: #c23037; }
.row { display: flex; gap: 8px; }
.row input { flex: 1; min-width: 0; }

/* ---------- main layout ---------- */
#app { height: 100vh; }
#body { display: grid; grid-template-columns: 240px 1fr; height: 100%; }

/* sidebar */
#sidebar {
  background: var(--bg2);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}
.server-name {
  padding: 14px 16px;
  font-weight: 700;
  color: #fff;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.server-name .ver { font-size: 11px; font-weight: 400; opacity: 0.45; }
.side-head {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px 4px;
}
.side-head .count { font-size: 12px; letter-spacing: 0; }
#roomList { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; min-height: 0; }
#roomList li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 7px 16px;
  cursor: pointer;
  color: var(--muted);
}
#roomList li:hover { background: var(--bg3); color: var(--text); }
#roomList li.active { background: var(--bg4); color: var(--text); }
.rname { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rlock { width: 14px; height: 14px; }
.rcount { font-size: 12px; color: var(--muted); }

/* users nested under their room (own row: li is flex-wrap) */
.room-users { list-style: none; margin: 0 0 4px; padding: 0 0 0 12px; flex: 0 0 100%; }
.room-users .member {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 3px 10px 3px 14px;
  color: var(--muted);
}
.mrow { display: flex; align-items: center; gap: 6px; min-width: 0; }
.minicam { width: 100%; }
.minicam video {
  width: 100%;
  height: 44px;
  object-fit: cover;
  border-radius: 4px;
  background: var(--bg4);
  display: block;
}
.room-users .member-avatar { width: 20px; height: 20px; }
.room-users .mname { font-size: 13px; }
.room-users .mname.mine { cursor: pointer; }
.room-users .mname.mine:hover { text-decoration: underline; }
.avatar-sm { width: 24px; height: 24px; border-radius: 50%; object-fit: cover; flex: none; }
.avatar-letter.avatar-sm {
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.member-avatar { width: 24px; height: 24px; }
.mname { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.admin-star { width: 14px; height: 14px; color: var(--gold); }
.open-lock { width: 14px; height: 14px; cursor: pointer; }
.open-lock:hover { color: var(--text); }
.mic-on { color: var(--green); }
.mic-off { color: var(--red); }
.out-muted { color: var(--red); }
.invite-btn { width: 14px; height: 14px; cursor: pointer; }
.invite-btn:hover { color: var(--text); }
.vabar { width: 4px; height: 16px; border-radius: 2px; background: transparent; flex: none; }
.vabar.l1 { background: rgba(35, 165, 90, 0.5); }
.vabar.l2 { background: var(--green); }

/* main */
#main { display: flex; flex-direction: column; overflow: hidden; min-width: 0; }
#roombar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}
.room-title { font-weight: 700; font-size: 17px; color: #fff; }
.share-hint { color: var(--muted); font-size: 12px; margin-right: 6px; }
.topbar-spacer { flex: 1; }
.ctlbtn {
  background: var(--bg4);
  width: 40px;
  height: 34px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.ctlbtn svg { width: 20px; height: 20px; }
.ctlbtn.on { background: var(--green); }
.ctlbtn.off { background: var(--red); }
.ctlbtn:hover { filter: brightness(1.15); background: var(--bg4); }
.ctlbtn.on:hover { background: var(--green); }
.ctlbtn.off:hover { background: var(--red); }
.mic-boost {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 10px;
  background: var(--bg4);
  border-radius: 6px;
}
.mic-boost .ico { color: var(--muted); }
.mic-boost input { width: 80px; padding: 0; border: none; background: none; accent-color: var(--accent); }
.mic-boost .mono { font-size: 12px; min-width: 34px; text-align: right; }

/* chat (right tab) */
#chatMsgs {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.msg { line-height: 1.35; word-wrap: break-word; font-size: 14px; display: flex; flex-wrap: wrap; align-items: flex-start; }
.msg .who { font-weight: 700; }
.msg .when { color: var(--muted); font-size: 11px; margin-left: 6px; margin-right: 6px; }
.msg.system { color: var(--muted); font-style: italic; justify-content: center; }
.msg .attach { display: inline-block; margin: 2px 0; }
.attach-img { max-width: 280px; max-height: 280px; border-radius: 8px; display: block; }
.attach-video { width: 320px; max-width: 100%; border-radius: 8px; display: block; }
.msg audio { width: 260px; max-width: 100%; }
#chatInputRow {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--bg2);
  border-top: 1px solid var(--border);
}
#chatInput { flex: 1; min-width: 0; }

/* main tabs (full width, no column separation) */
#mainTabs { display: flex; border-bottom: 1px solid var(--border); flex: 0 0 auto; background: var(--bg2); }
.tabbtn {
  flex: 1;
  background: none;
  border: none;
  color: var(--muted);
  padding: 10px 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 13px;
  border-bottom: 2px solid transparent;
}
.tabbtn svg { width: 16px; height: 16px; }
.tabbtn:hover { background: none; color: var(--text); }
.tabbtn.active { color: var(--text); border-bottom-color: var(--accent); }
.tabpane { flex: 1; display: none; flex-direction: column; overflow: hidden; min-height: 0; }
.tabpane.active { display: flex; }

/* conference grid (all cameras) */
#confGrid {
  flex: 1;
  display: grid;
  gap: 8px;
  padding: 10px;
  grid-template-columns: repeat(1, 1fr);
  align-content: start;
  overflow-y: auto;
}
#confEmpty { margin: auto; padding: 24px; }
/* hide the (empty) grid so the hint can be centered */
#tab-conf:has(#confEmpty:not(.hidden)) #confGrid { display: none; }

/* screenshare tab: one big view of the active screen share */
#shareStage { flex: 1; display: flex; align-items: center; justify-content: center; background: #000; position: relative; min-height: 0; }
#shareVideo { width: 100%; height: 100%; object-fit: contain; }
#shareEmpty { margin: auto; padding: 24px; }
.share-name { position: absolute; left: 10px; bottom: 10px; background: rgba(0, 0, 0, 0.6); padding: 2px 8px; border-radius: 4px; font-size: 13px; }
#tab-share:has(#shareEmpty:not(.hidden)) #shareStage { display: none; }
.tile {
  position: relative;
  background: var(--bg3);
  border-radius: 8px;
  overflow: hidden;
  aspect-ratio: 16 / 10;
  min-height: 0;
}
.tile video { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile .tile-avatar {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg4);
}
.tile .tile-avatar .avatar-sm { width: 56px; height: 56px; font-size: 22px; }
.tile .uname {
  position: absolute;
  left: 8px;
  bottom: 8px;
  background: rgba(0, 0, 0, 0.6);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 13px;
  max-width: 60%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tile.talking { outline: 3px solid var(--green); }
.tilebar {
  position: absolute;
  right: 8px;
  bottom: 8px;
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(0, 0, 0, 0.6);
  border-radius: 6px;
  padding: 2px 6px;
  opacity: 0;
  transition: opacity 0.15s;
}
.tile:hover .tilebar { opacity: 1; }
.tilebar svg { width: 14px; height: 14px; }
.tilebar input { width: 70px; padding: 0; border: none; background: none; accent-color: var(--accent); }

/* whiteboard */
#wbToolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}
.wbtn {
  background: var(--bg4);
  width: 32px;
  height: 30px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.wbtn svg { width: 16px; height: 16px; }
.wbtn.active { background: var(--accent); }
#wbColor { width: 34px; height: 30px; padding: 2px; background: var(--bg4); cursor: pointer; }
#wbSize { padding: 5px; }
#wbCanvas {
  flex: 1;
  width: 100%;
  background: #fff;
  touch-action: none;
  cursor: crosshair;
  display: block;
  min-height: 0;
}

/* watch */
#watchAdd {
  display: flex;
  gap: 8px;
  padding: 10px;
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}
#watchUrl { flex: 1; min-width: 0; }
#watchPlayUrlBtn { padding: 8px 14px; }
#watchPlaylist {
  list-style: none;
  margin: 0;
  padding: 4px 8px;
  flex: 0 1 auto;
  max-height: 130px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  border-bottom: 1px solid var(--border);
}
.plitem {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
}
.plitem:hover { background: var(--bg3); color: var(--text); }
.plitem.current { background: var(--bg4); color: var(--text); }
.plnum { width: 18px; text-align: right; color: var(--muted); flex: 0 0 auto; }
.pltitle { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plrm { flex: 0 0 auto; }
#watchStage { flex: 1; display: flex; flex-direction: column; padding: 10px; gap: 8px; min-height: 0; }
#watchBar {
  position: relative;
  background: #000;
  border-radius: 8px;
  overflow: hidden;
  flex: 1;
  min-height: 0;
  display: flex;
}
#watchVideo { width: 100%; height: 100%; object-fit: contain; display: block; }
#watchOverlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.75);
  font-size: 15px;
  padding: 16px;
  text-align: center;
}
#watchControls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}
#watchPlayBtn, #watchStopBtn {
  background: var(--bg4);
  width: 34px;
  height: 30px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
#watchPlayBtn svg, #watchStopBtn svg { width: 16px; height: 16px; }
#watchSeek { flex: 1; accent-color: var(--accent); }
#watchVol { width: 90px; flex: none; accent-color: var(--accent); }
#watchTime { color: var(--muted); font-size: 12px; white-space: nowrap; }

/* ---------- status bar ---------- */
#status {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg4);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 6px 12px;
  font-size: 14px;
  z-index: 200;
}
#status .iconbtn { flex: none; }
#status.err { background: var(--red); }

/* ---------- small screens ---------- */
@media (max-width: 1100px) {
  #body { grid-template-columns: 200px 1fr; }
}
@media (max-width: 800px) {
  #body { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  #sidebar { flex-direction: row; flex-wrap: wrap; align-items: center; }
  #roomList { display: flex; flex: 1; }
  #roomList li { margin-right: 4px; }
  #memberList { display: none; }
}
