/* P84 call UI — shared by student app and admin panel. Mobile-first.
   Uses the app's CSS variables with safe fallbacks so it works on either page
   regardless of the exact token names. */

.call-overlay {
  position: fixed;
  inset: 0;
  z-index: 4000;
  display: flex;
  align-items: stretch;
  justify-content: center;
  background: #0b1220;
  color: #f5f7fa;
  font-family: var(--font-en, 'Plus Jakarta Sans', system-ui, sans-serif);
}
.call-overlay[hidden] { display: none; }

.call-screen {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
}
.call-screen[hidden] { display: none; }

/* ── Ringing screen ─────────────────────────────────────────── */
.call-ringing {
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 32px 24px calc(40px + env(safe-area-inset-bottom));
  gap: 18px;
}
.call-caller-avatar {
  width: 110px; height: 110px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 48px;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.12);
  animation: callPulse 1.6s ease-in-out infinite;
}
@keyframes callPulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(59,130,246,.45); }
  50%     { box-shadow: 0 0 0 22px rgba(59,130,246,0); }
}
.call-caller-name { font-size: 26px; font-weight: 700; margin-top: 8px; }
.call-status-text { font-size: 15px; opacity: .75; }

.call-actions {
  margin-top: auto;
  display: flex;
  gap: 48px;
  justify-content: center;
  width: 100%;
}
.call-btn {
  border: 0; cursor: pointer; color: #fff;
  width: 72px; height: 72px; border-radius: 50%;
  font-size: 13px; font-weight: 600;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  transition: transform .12s ease, filter .12s ease;
}
.call-btn:active { transform: scale(.94); }
.call-btn::before { font-size: 26px; }
.call-accept  { background: #16a34a; }
.call-accept::before  { content: '📞'; }
.call-decline { background: #dc2626; }
.call-decline::before { content: '📵'; }

/* ── Active call screen ─────────────────────────────────────── */
.call-active { background: #0b1220; }

.call-video-stage {
  position: relative;
  flex: 1;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
#call-remote-video {
  width: 100%; height: 100%;
  object-fit: cover;
  background: #000;
  display: none;            /* shown only when remote video arrives */
}
.call-video-stage.has-remote-video #call-remote-video { display: block; }
.call-video-stage.has-remote-video .call-audio-only   { display: none; }

#call-local-video {
  position: absolute;
  right: 14px; bottom: 14px;
  width: 96px; height: 132px;
  object-fit: cover;
  border-radius: 12px;
  border: 2px solid rgba(255,255,255,.6);
  background: #000;
  box-shadow: 0 4px 16px rgba(0,0,0,.4);
  display: none;
  z-index: 2;
}
.call-video-stage.has-local-video #call-local-video { display: block; }

.call-audio-only {
  display: flex; flex-direction: column; align-items: center; gap: 14px;
}
.call-peer-name { font-size: 22px; font-weight: 700; }

/* Top bar: quality + timer + reconnect */
.call-topbar {
  position: absolute;
  top: calc(12px + env(safe-area-inset-top));
  left: 0; right: 0;
  display: flex; align-items: center; justify-content: center; gap: 12px;
  font-size: 14px;
  z-index: 3;
}
.call-timer { font-variant-numeric: tabular-nums; opacity: .9; background: rgba(0,0,0,.35); padding: 4px 10px; border-radius: 999px; }
/* Signal-strength bars (like a phone's reception meter) */
.call-signal {
  display: inline-flex; align-items: flex-end; gap: 2px;
  height: 18px; padding: 3px 8px; border-radius: 8px;
  background: rgba(0,0,0,.35);
}
.call-signal i {
  width: 3px; border-radius: 1px; background: rgba(255,255,255,.28);
  transition: background .2s ease;
}
.call-signal i:nth-child(1) { height: 25%; }
.call-signal i:nth-child(2) { height: 45%; }
.call-signal i:nth-child(3) { height: 65%; }
.call-signal i:nth-child(4) { height: 82%; }
.call-signal i:nth-child(5) { height: 100%; }
.call-signal[data-level="good"]   i.on { background: #22c55e; }
.call-signal[data-level="medium"] i.on { background: #f59e0b; }
.call-signal[data-level="poor"]   i.on { background: #ef4444; }

/* Floating-panel header with a close (×) button */
.call-panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 13px; font-weight: 600; }
.call-panel-x { background: none; border: 0; color: #fff; font-size: 16px; line-height: 1; cursor: pointer; padding: 2px 4px; }
@keyframes callBlink { 50% { opacity: .3; } }
.call-reconnect {
  background: #b45309; padding: 4px 12px; border-radius: 999px; font-size: 12px;
}
.call-reconnect[hidden] { display: none; }

/* Bottom controls — each control is a button + a text caption that always
   states the CURRENT state (so it's never ambiguous what's on/off). Colour
   reinforces it: red = "off/muted" alert state, white = active/engaged. */
.call-controls {
  display: flex; align-items: flex-start; justify-content: center;
  flex-wrap: wrap;
  gap: 16px;
  padding: 16px 16px calc(20px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, rgba(0,0,0,.6), transparent);
  z-index: 3;
}
.call-ctrl-wrap { display: flex; flex-direction: column; align-items: center; gap: 6px; width: 60px; }
.call-ctrl {
  border: 0; cursor: pointer; color: #fff;
  background: rgba(255,255,255,.16);
  width: 56px; height: 56px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; line-height: 1;
  transition: transform .12s ease, background .12s ease, box-shadow .12s ease;
}
.call-ctrl:active { transform: scale(.92); }
/* OFF / muted — red alert (mic muted, camera off-as-alert, user muted) */
.call-ctrl.ctrl-danger { background: #dc2626; color: #fff; box-shadow: 0 0 0 2px rgba(220,38,38,.45); }
/* ON / engaged — solid white (camera on, screen sharing) */
.call-ctrl.ctrl-active { background: #ffffff; color: #0b1220; box-shadow: 0 0 0 2px rgba(255,255,255,.55); }
/* recording — pulsing red */
.call-ctrl.ctrl-rec-on { background: #dc2626; color: #fff; animation: callBlink 1.2s steps(2) infinite; }
.call-ctrl-end, .call-ctrl-end:hover { background: #dc2626; color: #fff; }
.call-ctrl-end:active { background: #b91c1c; }
.call-ctrl-cap {
  font-size: 11px; line-height: 1.2; text-align: center; opacity: .85;
  min-height: 14px; max-width: 64px;
}
.call-ctrl-cap.cap-danger { color: #fca5a5; opacity: 1; font-weight: 600; }
.call-ctrl-cap.cap-active { color: #fff; opacity: 1; font-weight: 600; }

/* ── Admin extras ───────────────────────────────────────────── */
.call-controls-admin { flex-wrap: wrap; gap: 16px; }
.call-ctrl-rec[aria-pressed="true"] { background: #dc2626; color: #fff; }

.call-rec-indicator {
  background: rgba(220,38,38,.9); padding: 4px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 700; letter-spacing: .04em;
}
.call-rec-indicator[hidden] { display: none; }
.call-rec-indicator::first-letter { color: #fff; }

/* Quality panel + recording menu (floating cards above the control bar) */
.call-quality-panel, .call-rec-menu, .call-device-panel {
  position: absolute;
  left: 50%; transform: translateX(-50%);
  bottom: 104px;
  background: #1e293b;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 14px;
  padding: 16px 18px;
  display: flex; flex-direction: column; gap: 12px;
  min-width: 250px; max-width: 92vw;
  z-index: 4;
  box-shadow: 0 12px 40px rgba(0,0,0,.5);
}
.call-quality-panel[hidden], .call-rec-menu[hidden], .call-device-panel[hidden] { display: none; }
.call-quality-panel label, .call-rec-menu label, .call-device-panel label {
  display: flex; flex-direction: column; gap: 6px; font-size: 13px;
}
.call-quality-panel input[type="range"], .call-device-panel input[type="range"] { width: 100%; }
.call-rec-menu select, .call-device-panel select {
  padding: 7px 9px; border-radius: 8px; border: 1px solid rgba(255,255,255,.18);
  background: #0f172a; color: #f5f7fa; font: inherit; max-width: 100%;
}
.call-dev-note { font-size: 12px; line-height: 1.4; color: #fcd34d; margin: 0; }
.call-dev-note[hidden] { display: none; }
.call-rec-menu button, .call-preview-actions button {
  padding: 9px 14px; border-radius: 9px; border: 0; cursor: pointer;
  font: inherit; font-weight: 600; background: rgba(255,255,255,.14); color: #fff;
}
.call-rec-menu button:active, .call-preview-actions button:active { transform: scale(.96); }
.call-preview-actions .primary, .call-rec-menu button { background: #2563eb; }

/* Camera preview modal (admin confirms before sharing video) */
.call-preview {
  position: absolute; inset: 0; z-index: 6;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.7);
}
.call-preview[hidden] { display: none; }
.call-preview-box {
  background: #1e293b; border-radius: 16px; padding: 18px;
  display: flex; flex-direction: column; gap: 14px; align-items: center;
  width: min(420px, 92vw);
}
.call-preview-title { font-size: 16px; font-weight: 700; }
#call-preview-video {
  width: 100%; aspect-ratio: 4 / 3; object-fit: cover;
  background: #000; border-radius: 12px; transform: scaleX(-1); /* mirror like a selfie */
}
.call-preview-actions { display: flex; gap: 12px; width: 100%; }
.call-preview-actions button { flex: 1; }
.call-preview-actions button:not(.primary) { background: rgba(255,255,255,.14); }

/* Wider screens (admin desktop): center the active call nicely */
@media (min-width: 768px) {
  .call-btn  { width: 84px; height: 84px; }
  .call-ctrl { width: 64px; height: 64px; font-size: 24px; }
  #call-local-video { width: 160px; height: 120px; }
}
