:root {
  --bg-canvas: #0b0c0f;      /* backdrop video, hampir hitam ala Zoom/Discord dark */
  --bg-surface: #17181d;    /* topbar, dock, sidebar */
  --bg-surface-2: #1f2127;  /* hover / tile kosong */
  --bg-surface-3: #26282f;
  --border: #2a2c33;
  --text: #f3f4f6;
  --text-muted: #9a9da6;
  --accent: #4f7dff;        /* biru khas aplikasi meeting */
  --accent-hover: #3f68e0;
  --danger: #ef4444;
  --danger-strong: #dc2626;
  --speaking: #34d399;      /* hijau, indikator sedang bicara */
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
}

body {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg-canvas);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; cursor: pointer; }
input { font: inherit; }

/* =====================================================
   LOBBY (index.php)
   ===================================================== */

.lobby-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 15% 10%, rgba(79, 125, 255, .18), transparent 40%),
    radial-gradient(circle at 85% 90%, rgba(52, 211, 153, .12), transparent 40%),
    var(--bg-canvas);
}

.lobby-shell { width: min(880px, 100%); }

.lobby-grid {
  display: grid;
  grid-template-columns: 1.15fr .85fr;
  gap: 20px;
  align-items: stretch;
}

.hero-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 36px;
  box-shadow: 0 30px 90px rgba(0, 0, 0, .45);
}

.brand-mark {
  width: 46px;
  height: 46px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 14px;
  letter-spacing: .5px;
  margin-bottom: 18px;
}

.hero-card h1 { font-size: 30px; margin: 0 0 8px; letter-spacing: -.02em; }
.hero-card p { color: var(--text-muted); line-height: 1.6; margin: 0 0 26px; max-width: 40ch; }

.join-form { display: grid; gap: 14px; }

.join-form label {
  display: grid;
  gap: 7px;
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 600;
}

.join-form input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  background: var(--bg-canvas);
  color: var(--text);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

.join-form input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79, 125, 255, .18);
}

.primary-btn {
  border: 0;
  border-radius: var(--radius-sm);
  padding: 13px 16px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  margin-top: 4px;
  transition: background .15s;
}

.primary-btn:hover { background: var(--accent-hover); }

.feature-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 24px;
}

.feature-row span {
  border: 1px solid var(--border);
  padding: 7px 11px;
  border-radius: 999px;
  background: var(--bg-canvas);
  color: var(--text-muted);
  font-size: 12.5px;
}

/* mockup visual di sisi kanan lobby */

.preview-card {
  background: linear-gradient(160deg, #14161c, #0c0d11);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 260px;
}

.preview-tile {
  position: relative;
  flex: 1;
  border-radius: var(--radius-md);
  background: radial-gradient(circle at 30% 20%, #232636, #101219);
  display: grid;
  place-items: center;
  overflow: hidden;
}

.preview-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 20px;
  box-shadow: 0 0 0 4px rgba(79, 125, 255, .18);
}

.preview-live-dot {
  position: absolute;
  top: 12px;
  left: 12px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--speaking);
  box-shadow: 0 0 0 4px rgba(52, 211, 153, .2);
}

.preview-label {
  position: absolute;
  left: 12px;
  bottom: 12px;
  background: rgba(0, 0, 0, .5);
  padding: 5px 9px;
  border-radius: 8px;
  font-size: 12px;
}

.preview-dock {
  display: flex;
  justify-content: center;
  gap: 10px;
}

.preview-dot {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--bg-surface-2);
  border: 1px solid var(--border);
}

.preview-dot.dot-off { background: rgba(239, 68, 68, .18); border-color: rgba(239, 68, 68, .4); }
.preview-dot.dot-leave { background: var(--danger); border-color: var(--danger); }

/* =====================================================
   MEETING ROOM (room.php)
   ===================================================== */

.meeting-body {
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-canvas);
  overflow: hidden;
}

.topbar {
  flex: 0 0 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
}

.topbar-left { display: flex; align-items: center; gap: 10px; }

.live-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--speaking);
  box-shadow: 0 0 0 0 rgba(52, 211, 153, .5);
  animation: livePulse 2s infinite;
  flex: 0 0 auto;
}

@keyframes livePulse {
  0%   { box-shadow: 0 0 0 0 rgba(52, 211, 153, .45); }
  70%  { box-shadow: 0 0 0 7px rgba(52, 211, 153, 0); }
  100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0); }
}

.meeting-meta { display: flex; align-items: baseline; gap: 10px; }

.meeting-room-code {
  font-family: "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  letter-spacing: .06em;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text);
}

.meeting-timer {
  font-family: "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  font-size: 12.5px;
  color: var(--text-muted);
}

.topbar-right { display: flex; gap: 8px; }

.pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--border);
  background: var(--bg-surface-2);
  color: var(--text);
  padding: 8px 13px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  transition: background .15s;
}

.pill-btn:hover { background: var(--bg-surface-3); }
.pill-btn[aria-pressed="true"] { border-color: rgba(79, 125, 255, .5); color: #dbe4ff; }

/* ---------- Layout utama: video + panel peserta ---------- */

.meeting-main {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr;
  overflow: hidden;
}

.meeting-main.panel-open {
  grid-template-columns: minmax(0, 1fr) 272px;
}

.meeting-main:not(.panel-open) .sidebar { display: none; }

/* Backdrop cuma dipakai di breakpoint mobile (lihat media query di bawah).
   Disembunyikan di sini juga supaya di desktop dia tidak ikut dihitung
   sebagai grid item ketiga -- itu tadi yang bikin sidebar kedorong ke
   baris baru. */
.panel-backdrop { display: none; }

.video-grid {
  min-width: 0;
  padding: 18px 18px 96px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 480px));
  grid-auto-rows: min-content;
  gap: 14px;
  align-content: center;
  justify-content: center;
  overflow: auto;
}

.video-tile {
  position: relative;
  aspect-ratio: 16 / 9;
  background: var(--bg-surface-2);
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: border-color .18s, box-shadow .18s;
}

.video-tile video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Video lokal di-mirror biar terasa natural, seperti webcam pada umumnya */
.video-tile.is-local video { transform: scaleX(-1); }

.video-tile.speaking {
  border-color: var(--speaking);
  box-shadow: 0 0 0 3px rgba(52, 211, 153, .22);
}

.video-tile .tile-name {
  position: absolute;
  left: 10px;
  bottom: 10px;
  background: rgba(0, 0, 0, .55);
  backdrop-filter: blur(2px);
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 600;
  max-width: calc(100% - 20px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.video-tile .status {
  position: absolute;
  right: 10px;
  top: 10px;
  background: rgba(0, 0, 0, .55);
  padding: 5px 8px;
  border-radius: 8px;
  font-size: 11.5px;
  color: #ffb4b4;
}

.video-tile .status:empty { display: none; }

.avatar-tile {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 35% 30%, #232636, #101219);
}

.avatar-circle {
  width: 25%;
  aspect-ratio: 1;
  min-width: 48px;
  max-width: 84px;
  border-radius: 50%;
  background: var(--bg-surface-3);
  color: var(--text);
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: clamp(16px, 4vw, 26px);
}

/* ---------- Panel peserta ---------- */

.sidebar {
  border-left: 1px solid var(--border);
  background: var(--bg-surface);
  padding: 16px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.side-title {
  font-weight: 700;
  font-size: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}

.side-title span {
  color: var(--text-muted);
  font-weight: 500;
  margin-left: 4px;
}

.participant-list {
  padding-top: 8px;
  display: grid;
  gap: 4px;
  align-content: start;
  flex: 1 1 auto;
  overflow-y: auto;
}

.participant {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  transition: background .15s, box-shadow .15s;
}

.participant:hover { background: var(--bg-surface-2); }

.participant.speaking {
  box-shadow: inset 0 0 0 1px rgba(52, 211, 153, .4);
  background: rgba(52, 211, 153, .06);
}

.mini-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--bg-surface-3);
  display: grid;
  place-items: center;
  font-size: 11.5px;
  font-weight: 700;
  flex: 0 0 auto;
}

.participant .you {
  color: var(--text-muted);
  font-size: 11px;
  margin-left: auto;
}

.side-note {
  margin-top: auto;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.5;
  border-top: 1px solid var(--border);
  padding-top: 12px;
  flex: 0 0 auto;
}

/* ---------- Dock kontrol melayang ---------- */

.dock-wrap {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 18px;
  display: flex;
  justify-content: center;
  pointer-events: none;
  z-index: 10;
}

.control-dock {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(23, 24, 29, .92);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .5);
}

.dock-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  width: 64px;
  height: 56px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text);
  transition: background .15s;
}

.dock-btn:hover { background: var(--bg-surface-2); }

.dock-btn .icon-off { display: none; }
.dock-btn.is-off .icon-on { display: none; }
.dock-btn.is-off .icon-off { display: inline-flex; }

.dock-btn.is-off {
  background: rgba(239, 68, 68, .16);
  color: #ffb4b4;
}

.dock-btn.is-off:hover { background: rgba(239, 68, 68, .24); }

.dock-label {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .01em;
}

.dock-divider {
  width: 1px;
  align-self: stretch;
  margin: 6px 2px;
  background: var(--border);
}

.dock-btn-leave {
  width: 60px;
  background: var(--danger);
  color: #fff;
}

.dock-btn-leave:hover { background: var(--danger-strong); }
.dock-btn-leave .dock-label { color: #fff; }

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 96px;
  transform: translateX(-50%) translateY(10px);
  background: var(--bg-surface-3);
  border: 1px solid var(--border);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  color: var(--text);
  max-width: min(90vw, 380px);
  text-align: center;
  font-size: 13.5px;
  z-index: 20;
}

.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* =====================================================
   RESPONSIF
   ===================================================== */

@media (max-width: 900px) {
  .meeting-main.panel-open {
    grid-template-columns: 1fr;
  }
  .meeting-main.panel-open .panel-backdrop {
    display: block;
    position: fixed;
    inset: 60px 0 0 0;
    background: rgba(0, 0, 0, .55);
    z-index: 7;
  }
  .meeting-main.panel-open .sidebar {
    position: fixed;
    top: 60px;
    right: 0;
    bottom: 0;
    width: min(78vw, 280px);
    z-index: 8;
    box-shadow: -18px 0 40px rgba(0, 0, 0, .4);
  }
}

@media (max-width: 640px) {
  .lobby-grid { grid-template-columns: 1fr; }
  .preview-card { display: none; }

  .topbar-right #inviteBtn span { display: none; }
  .meeting-timer { display: none; }

  .video-grid { padding: 12px 12px 108px; gap: 10px; }

  .control-dock { gap: 2px; padding: 6px; }
  .dock-btn { width: 54px; height: 52px; }
  .dock-btn-leave { width: 50px; }
  .dock-label { font-size: 9.5px; }
}
