/* call.cliniweb - premiumUI (same tokens/font as me.cliniweb/html/assets/portal.css).
   Lobby = flat header + premium card; in-call = dark full-screen stage. */
@font-face {
  font-family: "Cliniweb Appointment Sans";
  src: url("assets/fonts/OpenSans-Variable.ttf") format("truetype");
  font-style: normal;
  font-weight: 300 800;
  font-display: swap;
}

:root {
  color-scheme: light;
  --premium-canvas: #f5f5f1;
  --premium-surface: #ffffff;
  --premium-ink: #233932;
  --premium-muted: #69756f;
  --premium-line: #e5e9e3;
  --premium-soft: #f3f6f1;
  --premium-accent: #245b4b;
  --premium-accent-dark: #194637;
  --premium-accent-soft: #eaf1eb;
  --premium-success: #42633b;
  --premium-warning: #836d42;
  --premium-danger: #9b3e39;
  --premium-danger-soft: #f8ecea;
  --premium-warning-soft: #f5eddf;
  --field-bg: #fbfcf9;
  --field-line: #e2e7df;
  --secondary-bg: #fbfcf9;
  --secondary-line: #e8ece3;
  --pad: clamp(20px, 5vw, 32px);

  --stage: #111b17;
  --stage-2: #1a2822;
  --glass: rgba(17, 27, 23, .72);
  --glass-line: rgba(255, 255, 255, .09);
  --live: #6fbf8a;
  --wait: #d9b56d;
  --bad: #e07d74;
}

* { box-sizing: border-box; }

html, body { height: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--premium-canvas);
  color: var(--premium-ink);
  font: 400 15px/1.55 "Cliniweb Appointment Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}
a { color: var(--premium-accent); }
[hidden] { display: none !important; }

/* ---- Lobby / status pages ------------------------------------------------ */
.cl-wrap { width: min(560px, calc(100% - 32px)); margin: 0 auto; padding: 28px 0 40px; }

.cl-head { padding: 0 0 18px; }
.cl-head-practice {
  display: flex; align-items: center; gap: 12px;
  font-size: 1.02rem; font-weight: 600; letter-spacing: -.01em;
}
.cl-head-practice::before {
  content: ""; width: 38px; height: 38px; flex: none; border-radius: 9px;
  background: var(--premium-surface) center / 22px no-repeat url("assets/cliniweb.svg");
  border: 1px solid var(--premium-line);
  box-shadow: 0 1px 2px rgba(39,59,36,.04);
}
.cl-head-line { margin: 2px 0 0 50px; color: var(--premium-muted); font-size: .74rem; }
.cl-head-line a { color: inherit; }

.cl-title {
  margin: 0; padding: var(--pad) var(--pad) 4px;
  background: var(--premium-surface);
  border: 1px solid #e2e7df; border-bottom: 0; border-radius: 13px 13px 0 0;
  font-size: clamp(1.4rem, 4.6vw, 1.75rem); font-weight: 550; line-height: 1.2; letter-spacing: -.035em;
}
.cl-main {
  background: var(--premium-surface);
  border: 1px solid #e2e7df; border-radius: 13px;
  box-shadow: 0 3px 5px rgba(39,59,36,.025), 0 18px 40px -32px rgba(31,56,32,.20);
  padding: var(--pad);
  animation: cl-rise .28s ease-out both;
}
.cl-title + .cl-main { border-top: 0; border-radius: 0 0 13px 13px; padding-top: 14px; animation: none; }
@keyframes cl-rise { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.cl-main section + section { margin-top: 22px; padding-top: 20px; border-top: 1px solid var(--premium-line); }
.cl-main h2 {
  margin: 0 0 12px;
  font-size: .66rem; font-weight: 600; letter-spacing: .13em; text-transform: uppercase; color: var(--premium-muted);
}
.cl-lead { margin: 0 0 4px; color: var(--premium-muted); }
.cl-note { margin: 12px 0 0; color: var(--premium-muted); font-size: .78rem; text-align: center; }

.cl-identity dl {
  margin: 0; padding: 4px 14px;
  border: 1px solid var(--secondary-line); border-radius: 9px; background: var(--secondary-bg);
}
.cl-identity dl > div {
  display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--premium-line);
}
.cl-identity dl > div:last-child { border-bottom: 0; }
.cl-identity dt { margin: 0; color: var(--premium-muted); font-size: .78rem; }
.cl-identity dd { margin: 0; font-weight: 600; font-size: .88rem; text-align: right; }

.cl-checks { margin: 0; padding: 0; list-style: none; }
.cl-checks li { position: relative; padding: 4px 0 4px 26px; font-size: .88rem; }
.cl-checks li::before {
  content: ""; position: absolute; left: 0; top: 8px; width: 16px; height: 16px; border-radius: 50%;
  background: var(--premium-accent-soft) center / 10px no-repeat
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23245b4b' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E");
}

.cl-code label { display: block; margin: 16px 0 5px; font-size: .78rem; font-weight: 600; }
.cl-code input {
  width: 100%; min-height: 48px; padding: 10px 12px;
  background: var(--field-bg); border: 1px solid var(--field-line); border-radius: 7px;
  color: var(--premium-ink); font: inherit; font-size: 18px; letter-spacing: .12em; text-transform: lowercase;
}
.cl-code input:focus { background: #fff; border-color: #96b49c; box-shadow: 0 0 0 3px rgba(54,98,57,.08); outline: 0; }
::placeholder { color: #9aa49c; letter-spacing: .04em; opacity: 1; }

.cl-submit {
  display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; min-height: 50px; margin-top: 18px; padding: 0 18px;
  background: var(--premium-accent); border: 1px solid var(--premium-accent); border-radius: 8px;
  color: #fff; font: inherit; font-size: .98rem; font-weight: 600; cursor: pointer;
  box-shadow: 0 2px 3px rgba(28,57,43,.10), inset 0 1px 0 rgba(255,255,255,.08);
  transition: background .12s, border-color .12s, transform .06s;
}
.cl-submit svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.cl-submit:hover { background: var(--premium-accent-dark); border-color: var(--premium-accent-dark); }
.cl-submit:active { transform: translateY(1px); }
.cl-submit:disabled { opacity: .55; cursor: progress; }
.cl-submit:focus-visible { outline: 2px solid #547b42; outline-offset: 2px; }

.cl-error {
  margin: 0 0 16px; padding: 10px 12px; border-radius: 7px;
  background: var(--premium-danger-soft); color: var(--premium-danger); font-size: .84rem; font-weight: 550;
}

.cl-status { padding: 10px 4px 2px; text-align: center; }
.cl-status-icon {
  display: inline-grid; place-items: center; width: 52px; height: 52px; margin-bottom: 14px;
  border-radius: 50%; font-size: 1.45rem; font-weight: 600;
}
.cl-status--error .cl-status-icon { background: var(--premium-danger-soft); color: var(--premium-danger); }
.cl-status--wait .cl-status-icon { background: var(--premium-warning-soft); color: var(--premium-warning); }
.cl-status p { max-width: 44ch; margin: 0 auto; font-size: .92rem; color: var(--premium-muted); }
.cl-status .cl-status-title { margin-bottom: 6px; color: var(--premium-ink); font-size: 1.12rem; font-weight: 600; letter-spacing: -.02em; }
.cl-status + .cl-code { margin-top: 8px; padding-top: 6px; border-top: 1px solid var(--premium-line); }

.cl-foot { display: flex; align-items: center; justify-content: center; gap: 6px; padding: 18px 0 0; color: #8a948e; font-size: .7rem; }
.cl-foot img { width: 12px; height: 14px; object-fit: contain; opacity: .85; }

@media (max-width: 480px) {
  .cl-identity dl > div { flex-direction: column; gap: 1px; }
  .cl-identity dd { text-align: left; }
}

/* ---- In-call stage ------------------------------------------------------- */
.cl-stage {
  position: fixed; inset: 0; z-index: 10; overflow: hidden;
  background: radial-gradient(120% 90% at 50% 40%, var(--stage-2), var(--stage));
  color: #fff;
}
.cl-remote { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: transparent; opacity: 0; transition: opacity .3s; }
.cl-stage.has-remote .cl-remote { opacity: 1; }

.cl-remote-empty { position: absolute; inset: 0; display: grid; place-items: center; transition: opacity .3s; }
.cl-stage.has-remote .cl-remote-empty { opacity: 0; pointer-events: none; }
.cl-avatar {
  position: relative; display: grid; place-items: center; width: 112px; height: 112px; border-radius: 50%;
  background: var(--premium-accent); color: #fff; font-size: 2.1rem; font-weight: 600; letter-spacing: .02em;
  box-shadow: 0 20px 50px -20px rgba(0,0,0,.6);
}
.cl-avatar::before, .cl-avatar::after {
  content: ""; position: absolute; inset: -14px; border-radius: 50%; border: 1px solid rgba(111,191,138,.35);
  animation: cl-ring 2.4s ease-out infinite;
}
.cl-avatar::after { animation-delay: 1.2s; }
@keyframes cl-ring { from { transform: scale(.85); opacity: 1; } to { transform: scale(1.45); opacity: 0; } }

.cl-local {
  position: absolute; right: 18px; bottom: 112px; z-index: 2;
  width: clamp(120px, 20vw, 240px); aspect-ratio: 4 / 3; object-fit: cover;
  border-radius: 12px; border: 1px solid rgba(255,255,255,.18); background: #000;
  box-shadow: 0 14px 34px -14px rgba(0,0,0,.7);
  transform: scaleX(-1);
}

.cl-topbar {
  position: absolute; top: 0; left: 0; right: 0; z-index: 3;
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: max(16px, env(safe-area-inset-top)) 20px 40px;
  background: linear-gradient(to bottom, rgba(10,16,14,.7), rgba(10,16,14,0));
}
.cl-who { min-width: 0; }
.cl-who strong { display: block; font-size: 1rem; font-weight: 600; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cl-who span { display: block; color: rgba(255,255,255,.62); font-size: .74rem; }

.cl-pill {
  display: inline-flex; align-items: center; gap: 8px; flex: none; max-width: 60%;
  padding: 7px 13px; border-radius: 999px;
  background: var(--glass); border: 1px solid var(--glass-line);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  font-size: .78rem; font-weight: 550; line-height: 1.3;
}
.cl-pill i { width: 8px; height: 8px; flex: none; border-radius: 50%; background: var(--wait); }
.cl-pill[data-tone="wait"] i { animation: cl-blink 1.4s ease-in-out infinite; }
.cl-pill[data-tone="live"] i { background: var(--live); box-shadow: 0 0 0 3px rgba(111,191,138,.22); }
.cl-pill[data-tone="warn"] i { background: var(--wait); }
.cl-pill[data-tone="error"] i { background: var(--bad); }
@keyframes cl-blink { 50% { opacity: .3; } }

.cl-controls {
  position: absolute; left: 50%; bottom: max(22px, env(safe-area-inset-bottom)); z-index: 3;
  transform: translateX(-50%);
  display: flex; gap: 10px; padding: 10px;
  background: var(--glass); border: 1px solid var(--glass-line); border-radius: 22px;
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  box-shadow: 0 18px 40px -18px rgba(0,0,0,.6);
}
.cl-ctl {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  width: 68px; height: 62px; padding: 0;
  background: rgba(255,255,255,.08); border: 1px solid transparent; border-radius: 15px;
  color: #fff; font: inherit; font-size: .66rem; font-weight: 550; letter-spacing: .02em; cursor: pointer;
  transition: background .12s, color .12s, transform .06s;
}
.cl-ctl svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.cl-ctl .off { display: none; }
.cl-ctl.is-off { background: #fff; color: var(--premium-danger); }
.cl-ctl.is-off .on { display: none; }
.cl-ctl.is-off .off { display: block; }
.cl-ctl:hover { background: rgba(255,255,255,.16); }
.cl-ctl.is-off:hover { background: #f3f3f0; }
.cl-ctl:active { transform: translateY(1px); }
.cl-ctl:focus-visible { outline: 2px solid var(--live); outline-offset: 2px; }
.cl-ctl--end { background: #b8453e; }
.cl-ctl--end svg { fill: currentColor; stroke: none; }
.cl-ctl--end:hover { background: #a03a34; }

/* stats.js (provider) widget: keep clear of the PiP and controls */
body:has(#lobby:not([hidden])) #stats-wrap { display: none; }
body #stats-wrap { top: 74px; bottom: auto; right: 18px; z-index: 20; }

@media (max-width: 640px) {
  .cl-remote { object-fit: cover; }
  .cl-local { width: 96px; aspect-ratio: 3 / 4; right: 12px; top: 84px; bottom: auto; border-radius: 10px; }
  .cl-topbar { padding-left: 16px; padding-right: 16px; }
  .cl-pill { max-width: 55%; font-size: .72rem; }
  .cl-ctl { width: 62px; height: 58px; }
  body #stats-wrap { top: auto; bottom: 110px; right: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .cl-main { animation: none; }
  .cl-avatar::before, .cl-avatar::after, .cl-pill[data-tone="wait"] i { animation: none; }
}
