/* ==========================================================================
   MeetRoom — visual theme aligned with the Alfawz design system:
   ivory/soft-bg surfaces, teal primary + gold accent, Tajawal type,
   generous radii and soft luxury shadows instead of hard dark panels.
   ========================================================================== */
:root {
  --color-white: #FFFFFF;
  --color-ivory: #F7F5F1;
  --color-soft-bg: #EEE8DF;
  --color-stone: #DAD1C2;

  --color-primary: #1A939E;
  --color-primary-700: #116D76;
  --color-primary-900: #0A4F56;
  --color-primary-light: #4FB8C0;
  --color-primary-soft: #CDEBED;

  --color-gold: #BAA213;
  --color-gold-700: #8F7B0D;
  --color-gold-light: #D7C14D;
  --color-gold-soft: #F3E9B2;

  --color-emerald: #1F7A6C;
  --color-navy: #17324D;

  --color-heading: #1E1E1E;
  --color-text: #2A2A2A;
  --color-muted: #8B857B;
  --color-text-light: #F7F5F1;
  --color-text-inverse: #FFFFFF;

  --color-danger: #B00020;
  --color-danger-soft: rgba(176, 0, 32, 0.08);

  --gradient-primary: linear-gradient(135deg, #116D76, #1A939E, #4FB8C0);
  --gradient-gold: linear-gradient(135deg, #8F7B0D, #BAA213, #D7C14D);
  --gradient-premium: linear-gradient(135deg, #0A4F56, #1A939E, #BAA213);

  --border-soft: 1px solid #DAD1C2;
  --border-gold: 1px solid rgba(186, 162, 19, 0.35);

  --shadow-soft: 0 12px 30px rgba(0, 0, 0, 0.08);
  --shadow-primary: 0 10px 25px rgba(26, 147, 158, 0.18);
  --shadow-gold: 0 10px 25px rgba(186, 162, 19, 0.18);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  --transition-fast: 0.2s ease;
  --transition: 0.3s ease;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: linear-gradient(180deg, var(--color-ivory), var(--color-soft-bg));
  color: var(--color-text);
  font-family: "Tajawal", "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; }
a { color: var(--color-primary); text-decoration: none; }
::selection { background: var(--color-primary); color: #fff; }

button {
  cursor: pointer;
  border: 1px solid var(--color-stone);
  background: var(--color-white);
  color: var(--color-text);
  border-radius: var(--radius-md);
  transition: background var(--transition), color var(--transition), border-color var(--transition), transform var(--transition-fast), box-shadow var(--transition);
}
button:hover { border-color: var(--color-primary); }
button:focus-visible, a:focus-visible, input:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}
button:disabled { opacity: .5; cursor: not-allowed; }

input[type="text"], input[type="email"] {
  background: var(--color-white);
  border: 1px solid rgba(186, 162, 19, 0.18);
  color: var(--color-text);
  border-radius: var(--radius-md);
  padding: 11px 13px;
  font-size: 14.5px;
  font-family: inherit;
}
input[type="text"]:focus, input[type="email"]:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 4px rgba(26, 147, 158, 0.10);
}
input::placeholder { color: var(--color-muted); }

.btn-primary {
  background: var(--gradient-primary);
  border-color: transparent;
  color: #fff;
  font-weight: 700;
  box-shadow: var(--shadow-primary);
}
.btn-primary:hover { box-shadow: 0 14px 28px rgba(26, 147, 158, 0.25); transform: translateY(-1px); }

.btn-gold {
  background: var(--gradient-gold);
  border-color: transparent;
  color: #241f04;
  font-weight: 700;
  box-shadow: var(--shadow-gold);
}
.btn-gold:hover { box-shadow: 0 14px 28px rgba(186, 162, 19, 0.26); transform: translateY(-1px); }

.btn-danger {
  background: transparent;
  border-color: rgba(176, 0, 32, 0.30);
  color: var(--color-danger);
}
.btn-danger:hover { background: var(--color-danger-soft); }

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--color-muted);
}
.btn-ghost:hover { color: var(--color-primary); border-color: var(--color-stone); }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; padding: 4px 11px; border-radius: 999px;
  border: 1px solid rgba(186, 162, 19, 0.20); color: var(--color-muted);
  font-weight: 700; letter-spacing: .01em; background: rgba(255,255,255,.6);
}
.pill.gold { color: var(--color-gold-700); border-color: rgba(186,162,19,.35); background: var(--color-gold-soft); }
.pill.teal { color: var(--color-primary-700); border-color: rgba(26,147,158,.30); background: var(--color-primary-soft); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--color-muted); flex: none; }
.dot.live { background: var(--color-danger); box-shadow: 0 0 0 3px var(--color-danger-soft); animation: pulse 1.6s infinite; }
.dot.on { background: var(--color-primary); }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .45; } }

/* ---------------------------------- Lobby -------------------------------- */
.lobby { min-height: 100%; display: grid; grid-template-columns: 1.1fr 1fr; }
@media (max-width: 880px) { .lobby { grid-template-columns: 1fr; } }

.lobby-hero {
  position: relative; overflow: hidden;
  background:
    radial-gradient(circle at top right, rgba(26,147,158,0.10), transparent 35%),
    radial-gradient(circle at bottom left, rgba(186,162,19,0.10), transparent 35%),
    var(--color-white);
  border-right: var(--border-soft);
  display: flex; flex-direction: column; justify-content: space-between; padding: 48px;
}
@media (max-width: 880px) { .lobby-hero { border-right: none; border-bottom: var(--border-soft); padding: 32px; } }

.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 18px; color: var(--color-heading); }
.brand .mark {
  width: 30px; height: 30px; border-radius: var(--radius-sm); background: var(--gradient-primary);
  display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 14px; box-shadow: var(--shadow-primary);
}

.lobby-hero h1 {
  font-size: clamp(32px, 5vw, 48px); line-height: 1.18; font-weight: 900; letter-spacing: -0.5px;
  max-width: 12ch; margin: 40px 0 16px; color: var(--color-heading);
}
.lobby-hero p { color: var(--color-muted); max-width: 36ch; font-size: 1.02rem; line-height: 1.9; margin: 0; }

.waveform { display: flex; align-items: flex-end; gap: 4px; height: 46px; margin-top: 36px; }
.waveform span { width: 4px; border-radius: 2px; background: var(--color-stone); animation: wave 1.8s ease-in-out infinite; }
.waveform span:nth-child(odd) { background: var(--color-gold-light); }
@keyframes wave { 0%,100% { height: 20%; } 50% { height: 100%; } }

.hero-foot { display: flex; gap: 22px; color: var(--color-muted); font-size: 13px; margin-top: 40px; }
.hero-foot b { color: var(--color-primary-700); font-weight: 800; }

.lobby-panel { display: flex; align-items: center; justify-content: center; padding: 48px; }
.panel-card { width: 100%; max-width: 400px; }
.panel-card h2 { font-size: 22px; font-weight: 800; margin: 0 0 4px; color: var(--color-heading); }
.panel-card .sub { color: var(--color-muted); font-size: 14px; margin: 0 0 26px; }

.tabs { display: flex; gap: 4px; background: var(--color-soft-bg); border: var(--border-soft); border-radius: var(--radius-md); padding: 4px; margin-bottom: 22px; }
.tabs button { flex: 1; background: transparent; border: none; padding: 9px 0; color: var(--color-muted); font-size: 13.5px; font-weight: 700; border-radius: var(--radius-sm); }
.tabs button.active { background: var(--color-white); color: var(--color-primary-700); box-shadow: 0 4px 12px rgba(0,0,0,0.06); }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 12.5px; color: var(--color-heading); font-weight: 700; letter-spacing: .01em; }

.form-view { display: none; }
.form-view.active { display: block; }

.submit-row { margin-top: 20px; }
.submit-row button { width: 100%; padding: 13px 0; font-size: 14.5px; }

.hint { font-size: 12.5px; color: var(--color-muted); margin-top: 12px; line-height: 1.7; }
.error-box {
  display: none; background: var(--color-danger-soft); border: 1px solid rgba(176,0,32,.20);
  color: #8a0019; font-size: 13px; padding: 10px 12px; border-radius: var(--radius-md); margin-bottom: 14px;
}
.error-box.show { display: block; }

/* ---------------------------------- Room --------------------------------- */
.room { height: 100vh; display: flex; flex-direction: column; background: var(--color-soft-bg); }

.room-topbar {
  height: 64px; flex: none; display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px; border-bottom: var(--border-soft);
  background: rgba(255,255,255,0.88); backdrop-filter: blur(12px);
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.room-title { font-weight: 800; font-size: 15px; color: var(--color-heading); }
.room-code-chip {
  font-size: 12px; color: var(--color-primary-700); border: 1px solid rgba(26,147,158,.25);
  background: var(--color-primary-soft); border-radius: 999px; padding: 4px 11px; cursor: pointer; font-weight: 700;
}
.room-code-chip:hover { border-color: var(--color-primary); }
.topbar-right { display: flex; align-items: center; gap: 10px; }
#elapsed { font-weight: 700; font-size: 13px; color: var(--color-muted); min-width: 46px; text-align: right; }

.room-body { flex: 1; display: flex; min-height: 0; }

.stage { flex: 1; padding: 18px; overflow: auto; min-width: 0; position: relative; }
.video-grid { display: grid; gap: 14px; height: 100%; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); grid-auto-rows: minmax(140px, 1fr); }
.video-grid.spotlight-mode { grid-template-columns: 1fr; grid-auto-rows: 1fr; }
.tile {
  position: relative; background: var(--color-navy); border: 1px solid rgba(186,162,19,.14);
  border-radius: var(--radius-lg); overflow: hidden; display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-soft);
}
.tile.speaking { border-color: var(--color-primary); box-shadow: 0 0 0 2px var(--color-primary) inset, var(--shadow-primary); }
.tile video { width: 100%; height: 100%; object-fit: cover; display: block; background: #10263B; }
.tile video.mirrored { transform: scaleX(-1); }
.tile .avatar-fallback {
  width: 64px; height: 64px; border-radius: 50%; background: linear-gradient(135deg, rgba(26,147,158,.35), rgba(186,162,19,.30));
  display: grid; place-items: center; font-weight: 800; font-size: 22px; color: #fff;
}
.tile-tag {
  position: absolute; left: 10px; bottom: 10px; display: flex; align-items: center; gap: 6px;
  background: rgba(255,255,255,.92); border: 1px solid rgba(186,162,19,.18);
  padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; color: var(--color-heading);
  backdrop-filter: blur(2px);
}
.tile-tag .host-star { color: var(--color-gold-700); }
.tile-tag .cohost-badge {
  font-size: 10px; padding: 1px 6px; border-radius: 999px; background: var(--color-primary-soft);
  color: var(--color-primary-700); font-weight: 800;
}
.tile-icons { position: absolute; top: 10px; right: 10px; display: flex; gap: 6px; }
.tile-icons .ic { width: 26px; height: 26px; border-radius: 50%; background: rgba(255,255,255,.92); display: grid; place-items: center; font-size: 13px; }
.tile-icons .ic.muted { color: var(--color-danger); }
.hand-flag { position: absolute; top: 10px; left: 10px; font-size: 18px; filter: drop-shadow(0 2px 4px rgba(0,0,0,.3)); }

/* Spotlight mode: the shared screen fills the stage; a small collapsible
   thumbnail strip in the corner holds everyone's camera instead. */
.tile.tile-spotlight { width: 100%; height: 100%; }
.tile.tile-spotlight video { object-fit: contain; background: #10263B; }

.thumb-strip {
  position: absolute; right: 26px; bottom: 26px; z-index: 20;
  display: flex; flex-direction: column; align-items: flex-end; gap: 8px;
}
.thumb-toggle {
  width: 34px; height: 34px; border-radius: 50%; padding: 0;
  background: var(--color-white); border: 1px solid var(--color-stone);
  display: grid; place-items: center; box-shadow: var(--shadow-soft); font-size: 13px;
}
.thumb-list {
  display: flex; flex-direction: column; gap: 8px;
  max-height: 58vh; overflow-y: auto; padding: 2px;
}
.thumb-strip.collapsed .thumb-list { display: none; }
.tile.tile-thumb {
  width: 168px; height: 98px; flex: none; border-radius: var(--radius-md); box-shadow: var(--shadow-soft);
}
.tile.tile-thumb .tile-tag { font-size: 10.5px; padding: 3px 8px; }
.tile.tile-thumb .avatar-fallback { width: 38px; height: 38px; font-size: 15px; }
.tile.tile-thumb .tile-icons .ic { width: 20px; height: 20px; font-size: 11px; }

@media (max-width: 760px) {
  .thumb-strip { right: 12px; bottom: 12px; }
  .tile.tile-thumb { width: 120px; height: 72px; }
}

.side-panel {
  width: 340px; flex: none; border-left: var(--border-soft);
  background: rgba(255,255,255,0.92); backdrop-filter: blur(10px);
  display: none; flex-direction: column; min-height: 0;
}
.side-panel.open { display: flex; }
.side-tabs { display: flex; border-bottom: var(--border-soft); flex: none; }
.side-tabs button {
  flex: 1; background: none; border: none; border-radius: 0; padding: 13px 0;
  color: var(--color-muted); font-weight: 700; font-size: 13px; border-bottom: 2px solid transparent;
}
.side-tabs button.active { color: var(--color-primary-700); border-bottom-color: var(--color-gold); }
.side-view { flex: 1; overflow: auto; display: none; padding: 16px; min-height: 0; }
.side-view.active { display: flex; flex-direction: column; }

/* Chat */
#chatLog { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 11px; padding-right: 2px; }
.msg { font-size: 13.5px; line-height: 1.6; }
.msg .who { font-weight: 700; font-size: 12.5px; color: var(--color-primary-700); margin-bottom: 2px; }
.msg .who .ts { color: var(--color-muted); font-weight: 400; margin-left: 6px; }
.msg.system { color: var(--color-muted); font-size: 12.5px; text-align: center; font-style: italic; }
.msg.me .who { color: var(--color-gold-700); }
.msg.announcement {
  background: var(--color-gold-soft); border: var(--border-gold); border-radius: var(--radius-md);
  padding: 9px 11px; font-weight: 600; color: var(--color-gold-700);
}
.chat-input-row { display: flex; gap: 8px; margin-top: 12px; flex: none; }
.chat-input-row input { flex: 1; }
.chat-input-row button { padding: 0 16px; }

/* People / team management */
.people-list { display: flex; flex-direction: column; gap: 4px; }
.waiting-block, .roster-block {
  border: var(--border-gold); background: var(--color-gold-soft); border-radius: var(--radius-md);
  padding: 12px; margin-bottom: 16px;
}
.waiting-block h4, .roster-block h4 {
  margin: 0 0 8px; font-size: 12.5px; color: var(--color-gold-700); font-weight: 800; letter-spacing: .02em;
}
.waiting-row, .person-row, .roster-row {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 9px 7px; border-radius: var(--radius-sm);
}
.person-row:hover { background: rgba(26,147,158,.06); }
.person-name { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--color-heading); font-weight: 600; }
.person-name .host-star { color: var(--color-gold-700); font-size: 12px; }
.role-tag { font-size: 10.5px; padding: 2px 7px; border-radius: 999px; font-weight: 800; }
.role-tag.host { background: var(--color-gold-soft); color: var(--color-gold-700); }
.role-tag.cohost { background: var(--color-primary-soft); color: var(--color-primary-700); }
.role-tag.group { background: rgba(23,50,77,.08); color: var(--color-navy); }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.row-actions button { font-size: 11px; padding: 5px 9px; }
.section-label { font-size: 11.5px; color: var(--color-muted); text-transform: uppercase; letter-spacing: .06em; margin: 16px 0 7px; font-weight: 800; }

.invite-form { display: flex; flex-direction: column; gap: 8px; margin-bottom: 6px; }
.invite-form .row { display: flex; gap: 8px; }
.invite-form input { flex: 1; }
.invite-form button { white-space: nowrap; }
.roster-empty { font-size: 12.5px; color: var(--color-muted); padding: 4px 2px; }
.roster-email { font-size: 11.5px; color: var(--color-muted); }
.roster-status { font-size: 10.5px; padding: 2px 7px; border-radius: 999px; font-weight: 700; }
.roster-status.pending { background: rgba(186,162,19,.14); color: var(--color-gold-700); }
.roster-status.joined { background: rgba(31,122,108,.14); color: var(--color-emerald); }

/* Bottom control bar */
.control-bar {
  flex: none; height: 86px; display: flex; align-items: center; justify-content: center; gap: 10px;
  border-top: var(--border-soft); background: rgba(255,255,255,0.92); backdrop-filter: blur(10px);
  position: relative; padding: 0 16px;
}
.ctrl {
  display: flex; flex-direction: column; align-items: center; gap: 5px; background: none; border: none;
  color: var(--color-muted); padding: 6px 10px; min-width: 62px;
}
.ctrl .icon-btn {
  width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center;
  background: var(--color-white); border: 1px solid var(--color-stone); color: var(--color-heading); font-size: 18px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}
.ctrl span { font-size: 11px; font-weight: 600; }
.ctrl.off .icon-btn { background: var(--color-danger-soft); border-color: rgba(176,0,32,.35); color: var(--color-danger); }
.ctrl.active .icon-btn { background: var(--color-primary-soft); border-color: var(--color-primary); color: var(--color-primary-700); }
.ctrl:hover .icon-btn { border-color: var(--color-primary); }
.ctrl.leave .icon-btn { background: var(--color-danger); border-color: var(--color-danger); color: #fff; }
.ctrl.leave:hover .icon-btn { background: #c8102e; }

.control-bar .divider { width: 1px; height: 32px; background: var(--color-stone); margin: 0 4px; }
.corner-actions { position: absolute; right: 16px; display: flex; gap: 8px; }

.toast-stack { position: fixed; top: 76px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 50; }
.toast {
  background: var(--color-white); border: var(--border-soft); border-radius: var(--radius-md);
  padding: 11px 15px; font-size: 13px; max-width: 300px; box-shadow: var(--shadow-soft); animation: toastIn .18s ease;
}
@keyframes toastIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

.knock-toast { border-color: rgba(186,162,19,.35); }
.knock-toast .row { display: flex; gap: 8px; margin-top: 8px; }
.knock-toast button { flex: 1; padding: 6px 0; font-size: 12px; }

.overlay-screen {
  position: fixed; inset: 0; background: linear-gradient(180deg, var(--color-ivory), var(--color-soft-bg));
  display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 14px; text-align: center; z-index: 100;
}
.overlay-screen h2 { font-weight: 800; color: var(--color-heading); }
.overlay-screen p { color: var(--color-muted); max-width: 32ch; }

.rec-badge { display: none; align-items: center; gap: 6px; font-size: 12px; color: var(--color-danger); font-weight: 700; }
.rec-badge.on { display: flex; }

@media (max-width: 760px) {
  .side-panel { position: fixed; right: 0; top: 64px; bottom: 86px; z-index: 30; width: 100%; max-width: 360px; }
  .ctrl span { display: none; }
  .ctrl { min-width: 46px; }
}
