/* AMAN Meetings web — tokens from the AMAN Station product family:
   light shell = merchant dashboard / Management "M" kit, dark room = the
   phones' MeetingRoomScreen. Arabic-first: logical properties only, never a
   global flip; .num/.code isolate LTR runs. */

:root {
  /* light shell (M kit) */
  --bg: #f6f7f9;
  --card: #ffffff;
  --primary: #136ad5;
  --primary-soft: #e8f1fc;
  --success: #29bf48;
  --warning: #fcae39;
  --danger: #ff5a5a;
  --gray: #9aa0a6;
  --text: #0c0c0c;
  --sub: #919191;
  --border: #eceef2;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 2px 6px rgba(16, 24, 40, 0.05);
  /* dark room */
  --room-bg: #111418;
  --room-bar: #181c22;
  --room-stage: #000000;
  --ctl-idle: #2a2f36;
  --ctl-label: #e8eaed;
  --room-meta: #aeb4bc;
  --live-pill: #34c759;
  --speak-ring: #29bf48;
  --font: "IBM Plex Sans Arabic", -apple-system, BlinkMacSystemFont, "Segoe UI",
    Roboto, "Noto Sans Arabic", sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  background: var(--bg);
  color: var(--text);
}
.num { direction: ltr; unicode-bidi: isolate; font-variant-numeric: tabular-nums; }
.code { direction: ltr; unicode-bidi: isolate; font-family: ui-monospace, Menlo, monospace; }
.ltr { direction: ltr; unicode-bidi: isolate; }

button { font-family: inherit; cursor: pointer; border: none; }
input {
  font-family: inherit;
  font-size: 15px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  background: #fff;
  color: var(--text);
}
input:focus { outline: 2px solid var(--primary); outline-offset: -1px; border-color: var(--primary); }

/* ---------- light shell (lobby, login, waiting) ---------- */
.shell {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  gap: 16px;
}
.brand { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.brand img { width: 44px; height: 44px; border-radius: 10px; }
.brand .name { font-size: 20px; font-weight: 700; }
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  padding: 24px;
  width: 100%;
  max-width: 420px;
}
.card h1 { font-size: 18px; margin: 0 0 6px; }
.card .hint { color: var(--sub); margin: 0 0 18px; font-size: 13px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 13px; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 20px;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 700;
  width: 100%;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:disabled { background: var(--gray); cursor: default; }
.btn-soft { background: var(--primary-soft); color: var(--primary); }
.btn-ghost { background: transparent; color: var(--sub); min-height: 36px; font-weight: 500; }
.error-box {
  background: #fff5f5;
  border: 1px solid #ffd7d7;
  color: #c43d3d;
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 14px;
  font-size: 13px;
  white-space: pre-line;
}
.status-line { color: var(--sub); font-size: 13px; text-align: center; }
.lang-toggle { position: fixed; top: 14px; inset-inline-end: 16px; z-index: 10; } /* below .panel (20): the panel must cover it when open */
.lang-toggle button {
  background: var(--card); border: 1px solid var(--border); border-radius: 10px;
  padding: 6px 12px; font-size: 13px; color: var(--sub);
}

/* preview tile in the lobby */
.preview {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: var(--room-bg);
  border-radius: var(--radius);
  overflow: hidden;
  position: relative;
  margin-bottom: 14px;
}
.preview video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.preview .initials {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: var(--room-meta); font-size: 36px; font-weight: 700;
}
.preview-ctls { position: absolute; bottom: 10px; inset-inline-start: 0; width: 100%; display: flex; justify-content: center; gap: 10px; }

/* waiting room spinner */
.spinner {
  width: 28px; height: 28px; border-radius: 50%;
  border: 3px solid var(--primary-soft); border-top-color: var(--primary);
  animation: spin 0.9s linear infinite; margin: 0 auto 14px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- dark room ---------- */
.room {
  z-index: 15; /* above the body-level lang-toggle (10): the room owns the screen */
  position: fixed; inset: 0;
  background: var(--room-bg);
  display: flex; flex-direction: column;
  color: var(--ctl-label);
}
.room-top {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; min-height: 52px;
}
.room-title { font-weight: 700; font-size: 15px; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pill-live {
  background: var(--live-pill); color: #fff; font-weight: 700;
  border-radius: 999px; padding: 4px 12px; font-size: 13px;
}
.pill-locked { background: var(--warning); color: #111; font-weight: 700; border-radius: 999px; padding: 4px 12px; font-size: 12px; }
.room-stage { flex: 1; position: relative; min-height: 0; padding: 8px 16px; }
.grid {
  height: 100%; display: grid; gap: 10px;
  grid-template-columns: repeat(var(--cols, 3), 1fr);
  align-content: center;
}
.tile {
  background: var(--room-bar);
  border-radius: var(--radius);
  position: relative;
  overflow: hidden;
  aspect-ratio: 16 / 10;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid transparent;
}
.tile.speaking { border-color: var(--speak-ring); }
.tile video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.tile video.mirror { transform: scaleX(-1); }
.tile .avatar {
  width: 64px; height: 64px; border-radius: 50%;
  background: var(--ctl-idle); color: var(--ctl-label);
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; font-weight: 700;
}
.tile .nameplate {
  position: absolute; bottom: 8px; inset-inline-start: 8px;
  background: rgba(0, 0, 0, 0.55); color: #fff;
  border-radius: 8px; padding: 3px 10px; font-size: 12px;
  display: flex; align-items: center; gap: 6px; max-width: calc(100% - 16px);
}
.nameplate .mic-off { color: var(--gray); }
.stage-share {
  position: absolute; inset: 8px 16px;
  background: var(--room-stage); border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.stage-share video { max-width: 100%; max-height: 100%; }
.share-strip {
  position: absolute; bottom: 16px; inset-inline-start: 24px;
  display: flex; gap: 8px; max-width: 40%; overflow-x: auto;
}
.share-strip .tile { width: 160px; flex: none; aspect-ratio: 16/10; box-shadow: 0 2px 10px rgba(0,0,0,.5); }
.share-banner {
  position: absolute; top: 16px; inset-inline-start: 50%; transform: translateX(var(--tx, -50%));
  background: rgba(40, 44, 52, 0.95); color: var(--ctl-label);
  padding: 8px 16px; border-radius: 999px; font-size: 13px; z-index: 5;
}
[dir="rtl"] .share-banner { --tx: 50%; }
.reconnect-banner {
  position: absolute; top: 0; inset-inline: 0;
  background: var(--warning); color: #111; text-align: center;
  padding: 6px; font-weight: 700; font-size: 13px; z-index: 9;
}
.room-bar {
  background: var(--room-bar);
  display: flex; align-items: center; justify-content: center;
  gap: 18px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
}
.ctl { display: flex; flex-direction: column; align-items: center; gap: 5px; background: none; }
.ctl .disc {
  width: 56px; height: 56px; border-radius: 28px;
  background: var(--ctl-idle); color: var(--ctl-label);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; position: relative; transition: background 0.15s;
}
.ctl.active .disc { background: var(--primary); }
.ctl.danger .disc { background: var(--danger); }
.ctl .lbl { color: var(--ctl-label); font-size: 11px; }
.ctl .count {
  position: absolute; top: -4px; inset-inline-end: -4px;
  background: var(--danger); color: #fff; border-radius: 999px;
  font-size: 11px; font-weight: 700; min-width: 18px; height: 18px;
  display: flex; align-items: center; justify-content: center; padding: 0 4px;
}
.toast {
  position: fixed; bottom: 110px; inset-inline-start: 50%; transform: translateX(var(--tx, -50%));
  background: rgba(40, 44, 52, 0.95); color: #fff;
  padding: 10px 18px; border-radius: 999px; font-size: 13px; z-index: 50;
}
[dir="rtl"] .toast { --tx: 50%; }

/* participants side panel */
.panel {
  position: fixed; top: 0; bottom: 0; inset-inline-end: 0;
  width: 320px; max-width: 90vw;
  background: var(--card); color: var(--text);
  box-shadow: 0 0 30px rgba(0, 0, 0, 0.35);
  display: flex; flex-direction: column; z-index: 20;
}
.panel header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
  font-weight: 700;
}
.panel .list { flex: 1; overflow-y: auto; padding: 8px 0; }
.panel .sect { padding: 10px 16px 4px; color: var(--sub); font-size: 12px; font-weight: 700; }
.prow { display: flex; align-items: center; gap: 10px; padding: 9px 16px; }
.prow .pavatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--primary-soft); color: var(--primary);
  display: flex; align-items: center; justify-content: center; font-weight: 700; flex: none;
}
.prow .pname { flex: 1; min-width: 0; }
.prow .pname .n { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.prow .pname .r { color: var(--sub); font-size: 12px; }
.prow .acts { display: flex; gap: 6px; }
.prow .acts button {
  background: var(--primary-soft); color: var(--primary);
  border-radius: 8px; padding: 6px 10px; font-size: 12px; font-weight: 700;
}
.prow .acts button.reject { background: #fff0f0; color: var(--danger); }
.prow .micstate { color: var(--gray); font-size: 14px; }
.menu {
  position: absolute; background: var(--card); border: 1px solid var(--border);
  border-radius: 10px; box-shadow: var(--shadow); padding: 4px; z-index: 30; min-width: 180px;
}
.menu button {
  display: block; width: 100%; text-align: start; background: none;
  padding: 9px 12px; border-radius: 8px; font-size: 13px; color: var(--text);
}
.menu button:hover { background: var(--bg); }
.menu button.danger { color: var(--danger); }

/* modal confirm */
.modal-back { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.55); z-index: 40; display: flex; align-items: center; justify-content: center; }
.modal { background: var(--card); color: var(--text); border-radius: 18px; padding: 22px; width: 92%; max-width: 360px; }
.modal h2 { font-size: 16px; margin: 0 0 8px; }
.modal p { color: var(--sub); margin: 0 0 18px; font-size: 13px; }
.modal .row { display: flex; gap: 10px; }
.modal .row .btn { flex: 1; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-cancel { background: var(--bg); color: var(--text); }

/* meetings list (signed-in home) */
.home { width: 100%; max-width: 560px; }
.mrow {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
}
.mrow:last-child { border-bottom: none; }
.mrow .minfo { flex: 1; min-width: 0; }
.mrow .mtitle { font-weight: 700; }
.mrow .mmeta { color: var(--sub); font-size: 12px; margin-top: 2px; }
.badge { border-radius: 999px; padding: 3px 10px; font-size: 12px; font-weight: 700; }
.badge.live { background: #e9f9ee; color: var(--success); }
.badge.sched { background: var(--primary-soft); color: var(--primary); }
.mrow .btn { width: auto; min-height: 40px; padding: 0 16px; font-size: 13px; }

/* room chrome the classes above don't cover (web-only states) */
.room-center {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; padding: 32px; text-align: center;
}
.room-center .msg { font-size: 17px; font-weight: 700; white-space: pre-line; }
.room-center .btn { max-width: 320px; }
.room-center .spinner { border-color: var(--ctl-idle); border-top-color: var(--primary); }
.icon-btn {
  background: none; color: var(--ctl-label); width: 40px; height: 40px; border-radius: 20px;
  display: inline-flex; align-items: center; justify-content: center; flex: none;
}
.icon-btn:hover { background: var(--ctl-idle); }
.panel .icon-btn:hover { background: var(--bg); }
[dir="rtl"] .flip-rtl svg { transform: scaleX(-1); }
.self-share-card {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; padding: 32px; text-align: center;
}
.self-share-card .disc-big {
  width: 96px; height: 96px; border-radius: 48px; background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center; margin-bottom: 10px;
}
.self-share-card .t { font-size: 19px; font-weight: 700; }
.self-share-card .s { color: var(--room-meta); font-size: 14px; }
.audio-unblock {
  position: absolute; top: 58px; inset-inline-start: 50%; transform: translateX(var(--tx, -50%));
  z-index: 8; background: var(--primary); color: #fff; border-radius: 999px;
  padding: 9px 18px; font-weight: 700; font-size: 13px;
}
[dir="rtl"] .audio-unblock { --tx: 50%; }

@media (max-width: 720px) {
  .grid { --cols: 2 !important; }
  .room-bar { gap: 10px; }
  .ctl .disc { width: 50px; height: 50px; }
}
