/* =========================================================
   Optelco Meet — tema navy + biru
   ========================================================= */
:root {
  --bg: #0d1426;
  --bg-2: #121a30;
  --panel: #1a2442;
  --panel-2: #222e52;
  --panel-3: #2a3760;
  --line: #2c3a63;
  --text: #eef2fb;
  --muted: #94a0bf;
  --accent: #4d7cfe;
  --accent-2: #3d68e8;
  --accent-soft: rgba(77, 124, 254, .16);
  --danger: #ef4d5a;
  --ok: #2ecc8f;
  --warn: #f5b84a;
  --radius: 14px;
  --radius-sm: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
a { color: inherit; }
.muted { color: var(--muted); }
.error { color: var(--danger); min-height: 1.4em; margin: 12px 0 0; font-size: 14px; }
code { background: var(--panel-2); padding: 2px 8px; border-radius: 6px; font-size: 13px; }

/* Ikon */
.i {
  width: 20px; height: 20px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round;
}

/* Brand */
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; }
.brand-logo {
  width: 36px; height: 36px; border-radius: 10px; background: var(--accent);
  display: grid; place-items: center; color: #fff;
  box-shadow: 0 4px 14px rgba(77, 124, 254, .35);
}
.brand-logo .i { width: 20px; height: 20px; stroke-width: 2; }
.brand-name { font-weight: 700; font-size: 17px; letter-spacing: .2px; }

/* Tombol */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid transparent; border-radius: var(--radius-sm); padding: 11px 18px;
  background: var(--panel-2); color: var(--text); font: inherit; font-weight: 600;
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-2); }
.btn.outline { background: transparent; border-color: #4a5880; }
.btn.outline:hover, .btn.outline.active { border-color: var(--text); background: rgba(255,255,255,.04); }
.btn.block { display: flex; width: 100%; margin-top: 18px; }
.btn.small { padding: 7px 12px; font-size: 13px; }
.btn.small .i { width: 16px; height: 16px; }

/* Form */
label { display: block; font-size: 13px; color: var(--muted); margin: 14px 0 6px; text-align: left; }
.opt { opacity: .7; }
input {
  width: 100%; padding: 11px 14px; border-radius: var(--radius-sm); border: 1px solid var(--line);
  background: var(--bg-2); color: var(--text); font: inherit;
}
input::placeholder { color: #66729a; }
input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.row { display: flex; gap: 10px; align-items: stretch; }
.hint { font-size: 13px; color: var(--muted); margin: 10px 0 0; }

/* =========================================================
   Beranda
   ========================================================= */
body.home {
  min-height: 100%;
  background:
    radial-gradient(900px 500px at 85% -10%, rgba(77,124,254,.18), transparent 60%),
    radial-gradient(700px 400px at -10% 110%, rgba(77,124,254,.10), transparent 60%),
    var(--bg);
}
.shell { max-width: 1040px; margin: 0 auto; padding: 28px 28px 40px; min-height: 100vh; display: flex; flex-direction: column; }
.home-head { display: flex; justify-content: space-between; align-items: center; }
.eyebrow { font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }

.hero { padding: 72px 0 40px; max-width: 640px; }
.hero h1 { font-size: clamp(30px, 5vw, 46px); line-height: 1.12; margin: 0 0 14px; letter-spacing: -.02em; }
.lead { color: #c3cbe2; font-size: 17px; margin: 0 0 28px; }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.action-panel {
  margin-top: 20px; padding: 18px 20px 20px; background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius); max-width: 520px;
  animation: rise .18s ease-out;
}
.action-panel label { margin-top: 0; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }

.features { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: auto; }
.feature {
  background: var(--panel); border: 1px solid transparent; border-radius: var(--radius);
  padding: 22px 16px; display: flex; flex-direction: column; align-items: center; gap: 10px;
  font-weight: 600; font-size: 14px; transition: border-color .15s;
}
.feature:hover { border-color: var(--line); }
.feature .i { width: 24px; height: 24px; color: #9db6ff; }
.home-foot { text-align: center; color: var(--muted); font-size: 13px; margin-top: 22px; }

/* =========================================================
   Layar masuk / selesai
   ========================================================= */
.center-screen {
  min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background: radial-gradient(800px 500px at 50% -10%, rgba(77,124,254,.16), transparent 60%), var(--bg);
}
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 30px;
  width: 100%; max-width: 420px; box-shadow: 0 20px 60px rgba(0,0,0,.35);
}
.card h2 { margin: 22px 0 4px; font-size: 22px; }
.card .muted { margin: 0 0 6px; }

/* =========================================================
   Layar meeting
   ========================================================= */
#call { display: flex; flex-direction: column; height: 100vh; background: var(--bg); }
.topbar {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 10px 18px; background: var(--bg-2); border-bottom: 1px solid var(--line);
}
.topbar .brand-logo { width: 30px; height: 30px; border-radius: 8px; }
.topbar .brand-logo .i { width: 17px; height: 17px; }
.topbar .brand-name { font-size: 15px; }
.topbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.topbar-right { display: flex; gap: 12px; align-items: center; }
.sep { width: 1px; height: 20px; background: var(--line); }
.room-code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 14px; }
.timer { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 14px; }
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  background: rgba(245,184,74,.14); color: var(--warn); font-size: 12px; font-weight: 600;
  padding: 3px 9px; border-radius: 999px;
}
.badge .i { width: 13px; height: 13px; }

.body { flex: 1; display: flex; min-height: 0; }
.grid {
  flex: 1; display: grid; gap: 16px; padding: 24px; overflow-y: auto;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  align-content: center; max-width: 1080px; width: 100%; margin: 0 auto;
}
.tile {
  position: relative; background: var(--panel); border-radius: var(--radius);
  aspect-ratio: 16 / 10; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 12px;
  border: 2px solid transparent; transition: border-color .12s, box-shadow .12s;
}
.tile.speaking:not(.is-muted) { border-color: var(--ok); box-shadow: 0 0 0 4px rgba(46,204,143,.15); }
.avatar {
  width: 72px; height: 72px; border-radius: 50%; display: grid; place-items: center;
  font-size: 26px; font-weight: 700; color: #fff;
}
.tile .name { font-weight: 600; max-width: 90%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile .status {
  position: absolute; top: 10px; right: 10px; color: var(--danger);
}
.tile .status:empty { display: none; }
.tile .status .i { width: 18px; height: 18px; }
.tile .conn { position: absolute; bottom: 12px; font-size: 12px; color: var(--muted); }
.host-badge {
  position: absolute; top: 10px; left: 10px; display: none; align-items: center; gap: 5px;
  background: rgba(245,184,74,.14); color: var(--warn); font-size: 12px; font-weight: 600;
  padding: 3px 9px 3px 7px; border-radius: 999px;
}
.host-badge .i { width: 14px; height: 14px; }
.tile.is-host .host-badge { display: inline-flex; }
.tile-menu { position: absolute; top: 8px; right: 8px; display: none; gap: 6px; }
body.i-am-host .tile:hover .status { visibility: hidden; }
.tile-menu button {
  border: 0; border-radius: 8px; width: 34px; height: 34px; cursor: pointer;
  background: var(--panel-3); color: var(--text); display: grid; place-items: center;
}
.tile-menu button .i { width: 17px; height: 17px; }
.tile-menu button:hover { background: #34437a; }
.tile-menu button.danger { background: var(--danger); color: #fff; }
body.i-am-host .tile:hover .tile-menu,
body.i-am-host .tile:focus-within .tile-menu { display: flex; }
@media (hover: none) { body.i-am-host .tile-menu { display: flex; } }

/* Kontrol bawah */
.controls {
  display: flex; justify-content: center; gap: 10px; padding: 12px 16px 14px;
  background: var(--bg-2); border-top: 1px solid var(--line);
}
.host-ctrls { display: contents; }
.ctrl {
  position: relative; min-width: 76px; height: 60px; border-radius: 12px; border: 0;
  background: transparent; color: var(--text); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  font: inherit; transition: background .15s;
}
.ctrl:hover { background: var(--panel); }
.ctrl .i { width: 22px; height: 22px; }
.ctrl-label { font-size: 12px; color: var(--muted); }
.ctrl.on { background: var(--accent-soft); color: #9db6ff; }
.ctrl.off { color: var(--danger); }
.ctrl.off .ctrl-label { color: var(--danger); }
.ctrl.danger { background: var(--danger); color: #fff; margin-left: 8px; }
.ctrl.danger .ctrl-label { color: #fff; }
.ctrl.danger:hover { background: #d93f4b; }
.dot {
  position: absolute; top: 4px; right: 14px; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 999px; background: var(--danger); color: #fff; font-size: 11px; font-weight: 700;
  display: grid; place-items: center;
}

/* Chat */
.chat {
  width: 330px; background: var(--bg-2); border-left: 1px solid var(--line);
  display: flex; flex-direction: column; min-height: 0;
}
.chat-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.icon-btn { background: none; border: 0; color: var(--muted); cursor: pointer; display: grid; place-items: center; padding: 4px; border-radius: 6px; }
.icon-btn:hover { color: var(--text); background: var(--panel); }
.chat-list { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 85%; }
.msg.mine { align-self: flex-end; text-align: right; }
.msg-head { font-size: 12px; color: var(--muted); margin-bottom: 3px; }
.msg-body {
  background: var(--panel-2); padding: 8px 12px; border-radius: 12px; white-space: pre-wrap;
  word-break: break-word; display: inline-block; text-align: left;
}
.msg.mine .msg-body { background: var(--accent); color: #fff; }
.msg.system { align-self: center; max-width: 100%; font-size: 12px; color: var(--muted); text-align: center; }
.chat-form { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); }
.chat-form input { padding: 9px 12px; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%) translateY(16px);
  background: #0a0f1ee6; border: 1px solid var(--line); padding: 10px 16px; border-radius: 10px;
  font-size: 14px; opacity: 0; pointer-events: none; transition: .2s; max-width: 90vw; z-index: 10;
}
.toast.show { opacity: 1; transform: translateX(-50%); }

/* =========================================================
   Responsif
   ========================================================= */
@media (max-width: 760px) {
  .features { grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
  .feature { padding: 16px 8px; font-size: 13px; text-align: center; }
  .hero { padding: 48px 0 32px; }
  .chat { position: fixed; inset: 0 0 86px 0; width: auto; z-index: 5; border-left: 0; }
  .topbar .brand-name, .sep { display: none; }
  #copyLink span { display: none; }
}
@media (max-width: 520px) {
  .shell { padding: 20px 18px 28px; }
  .eyebrow { display: none; }
  .row { flex-direction: column; }
  .grid { grid-template-columns: repeat(2, 1fr); padding: 14px; gap: 10px; }
  .tile { aspect-ratio: 1 / 1; }
  .avatar { width: 56px; height: 56px; font-size: 20px; }
  .ctrl { min-width: 0; flex: 1; padding: 0 4px; }
  .ctrl-label { font-size: 11px; }
  .ctrl.danger { margin-left: 0; }
}

/* ---- Pemilih bahasa ---- */
.head-right { display: flex; align-items: center; gap: 18px; }
.lang-picker {
  position: relative; display: inline-flex; align-items: center; gap: 6px; margin: 0;
  padding: 6px 10px; border: 1px solid var(--line); border-radius: 999px;
  color: var(--muted); font-size: 13px; cursor: pointer; background: rgba(255,255,255,.02);
}
.lang-picker:hover { border-color: #4a5880; color: var(--text); }
.lang-picker .i { width: 16px; height: 16px; }
.lang-picker select {
  appearance: none; -webkit-appearance: none; background: transparent; border: 0;
  color: inherit; font: inherit; cursor: pointer; padding-right: 2px; outline: none;
}
.lang-picker select option { background: var(--panel); color: var(--text); }
.card-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.credit { margin-top: 6px; font-size: 11px; opacity: .6; }
.credit a { text-decoration: none; }
.credit a:hover { text-decoration: underline; }

/* =========================================================
   Video, berbagi layar, layout presentasi
   ========================================================= */
.tile { overflow: hidden; gap: 0; }
.tile .vid {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; background: #000; display: none;
}
.tile.has-video .vid { display: block; }
.tile.has-video .avatar { display: none; }
.tile.mirror .vid { transform: scaleX(-1); }
.tile.is-screen .vid { object-fit: contain; background: #05080f; }
.tile.has-video { cursor: zoom-in; }
.tile:fullscreen { border-radius: 0; border: 0; }
.tile:fullscreen .vid { object-fit: contain; }

.name-bar {
  position: absolute; left: 10px; bottom: 10px; max-width: calc(100% - 20px);
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(8, 12, 24, .62); backdrop-filter: blur(6px);
  padding: 4px 10px; border-radius: 8px; font-size: 13px;
}
.tile:not(.has-video) .name-bar { background: transparent; backdrop-filter: none; }
.name-bar .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.name-bar .status { position: static; color: var(--danger); display: inline-flex; }
.name-bar .status:empty { display: none; }
.name-bar .status .i { width: 15px; height: 15px; }
body.i-am-host .tile:hover .status { visibility: visible; }
.tile .host-badge, .tile .tile-menu, .tile .name-bar, .tile .conn { z-index: 2; }
.tile .conn { bottom: auto; top: 50%; transform: translateY(44px); }
.tile.has-video .conn { top: 12px; transform: none; left: 50%; translate: -50% 0;
  background: rgba(8,12,24,.62); padding: 2px 8px; border-radius: 6px; }

/* Grid menyesuaikan jumlah peserta */
.grid[data-count="1"] { grid-template-columns: minmax(0, 860px); justify-content: center; }
.grid[data-count="2"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid[data-count="3"], .grid[data-count="4"] { grid-template-columns: repeat(2, minmax(0, 1fr)); max-width: 980px; }
.grid[data-count="5"], .grid[data-count="6"] { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid[data-count="7"], .grid[data-count="8"], .grid[data-count="9"] { grid-template-columns: repeat(3, minmax(0, 1fr)); }

/* Mode presentasi: layar yang dibagikan besar, peserta lain di strip bawah */
.grid.presenting {
  max-width: none; align-content: start;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)) !important;
  grid-auto-rows: auto; gap: 10px; padding: 14px;
}
.grid.presenting .tile { aspect-ratio: 16 / 10; }
.grid.presenting .tile .avatar { width: 48px; height: 48px; font-size: 18px; }
.grid.presenting .tile.is-screen {
  grid-column: 1 / -1; order: -1; aspect-ratio: auto; height: calc(100vh - 300px); min-height: 240px;
}

/* Tombol share disembunyikan bila browser tidak mendukung (mis. HP) */
.ctrl[hidden] { display: none !important; }

/* Pratinjau kamera di layar masuk */
.preview {
  position: relative; margin: 16px 0 4px; aspect-ratio: 16 / 9; border-radius: 12px;
  overflow: hidden; background: var(--bg-2); border: 1px solid var(--line);
}
.preview video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); display: none; }
.preview.has-video video { display: block; }
.preview-off {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 8px; color: var(--muted); font-size: 13px;
}
.preview.has-video .preview-off { display: none; }
.preview-off .i { width: 28px; height: 28px; }
.preview-ctrls {
  position: absolute; left: 0; right: 0; bottom: 10px; display: flex; justify-content: center; gap: 10px;
}
.round {
  width: 42px; height: 42px; border-radius: 50%; border: 0; cursor: pointer;
  background: rgba(34, 46, 82, .92); color: var(--text); display: grid; place-items: center;
}
.round:hover { background: var(--panel-3); }
.round.off { background: var(--danger); color: #fff; }

@media (max-width: 520px) {
  .grid[data-count="1"] { grid-template-columns: 1fr; }
  .grid[data-count="3"], .grid[data-count="4"], .grid[data-count="5"], .grid[data-count="6"],
  .grid[data-count="7"], .grid[data-count="8"], .grid[data-count="9"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.presenting .tile.is-screen { height: 46vh; }
  .controls { gap: 2px; padding: 8px 6px 10px; }
  .ctrl { height: 54px; }
  .ctrl-label { font-size: 10px; }
}
.name-bar .name { max-width: none; min-width: 0; }
.tile .conn:empty { display: none; }
