/* ==========================================================================
   MediMeet — Animated clinic room (AI Coordinator hero)
   A looping, purely decorative preview: the AI scribe writes, the provider
   speaks, and a department request is claimed in real time.
   ========================================================================== */

.clinic-live {
  --cl-bg: #06111e;
  --cl-panel: rgba(9, 19, 31, 0.86);
  --cl-line: rgba(148, 178, 214, 0.16);
  --cl-text: #eef4fb;
  --cl-muted: #93a7bf;
  --cl-lime: #d9ff3f;
  --cl-cyan: #2fe2ff;
  --cl-purple: #a06bff;
  --cl-amber: #ffd166;
  --cl-pink: #ff4fd8;

  position: relative;
  isolation: isolate;
  display: flex;
  flex-direction: column;
  aspect-ratio: 16 / 9.55;
  overflow: hidden;
  border-radius: 15px 15px 5px 5px;
  background:
    radial-gradient(70% 90% at 84% 0%, rgba(160, 107, 255, 0.16), transparent 62%),
    radial-gradient(55% 75% at 0% 100%, rgba(47, 226, 255, 0.09), transparent 70%),
    var(--cl-bg);
  color: var(--cl-text);
  font-family: var(--font-body);
  font-size: clamp(5px, 1.42cqw, 11px);
  line-height: 1.35;
  user-select: none;
}

.clinic-live *,
.clinic-live *::before,
.clinic-live *::after {
  box-sizing: border-box;
}

/* ---------- Top bar ---------- */

.clinic-live__top {
  display: flex;
  align-items: center;
  gap: 0.9em;
  flex: none;
  padding: 0.8em 1.1em;
  border-bottom: 1px solid var(--cl-line);
  background: rgba(5, 14, 24, 0.72);
}

.clinic-room {
  display: flex;
  align-items: baseline;
  gap: 0.5em;
  min-width: 0;
  font-family: var(--font-head);
  font-size: 1.5em;
  font-weight: 800;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.clinic-room em {
  overflow: hidden;
  font-family: var(--font-body);
  font-size: 0.52em;
  font-style: normal;
  font-weight: 500;
  letter-spacing: 0;
  color: var(--cl-muted);
  text-overflow: ellipsis;
}

.clinic-calls {
  display: flex;
  gap: 0.4em;
  margin-left: auto;
}

.clinic-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
  padding: 0.35em 0.65em;
  border: 1px solid var(--cl-line);
  border-radius: var(--shape-full);
  font-size: 0.8em;
  font-weight: 500;
  color: var(--cl-muted);
  white-space: nowrap;
}

.clinic-chip b {
  font-weight: 650;
  color: var(--cl-text);
}

.clinic-chip--warn {
  border-color: rgba(255, 209, 102, 0.42);
  background: rgba(255, 209, 102, 0.06);
  color: var(--cl-amber);
}

.clinic-chip--warn i {
  width: 0.45em;
  height: 0.45em;
  border-radius: 50%;
  background: var(--cl-amber);
  box-shadow: 0 0 0 0.3em rgba(255, 209, 102, 0.12);
  animation: clinic-chip-pulse 2.8s ease-in-out infinite;
}

.clinic-live__status {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  flex: none;
  font-size: 0.72em;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--cl-lime);
}

.clinic-live__status i {
  width: 0.45em;
  height: 0.45em;
  border-radius: 50%;
  background: var(--cl-lime);
  box-shadow: 0 0 0 0 rgba(217, 255, 63, 0.45);
  animation: clinic-live-pulse 2.4s ease-out infinite;
}

/* ---------- Body layout ---------- */

.clinic-live__body {
  display: grid;
  grid-template-columns: 1.05fr 1.9fr 1.08fr;
  gap: 0.6em;
  flex: 1;
  min-height: 0;
  padding: 0.6em;
}

.live-pane {
  position: relative;
  min-width: 0;
  min-height: 0;
  padding: 0.75em;
  overflow: hidden;
  border: 1px solid var(--cl-line);
  border-radius: 0.85em;
  background: var(--cl-panel);
}

/* ---------- AI scribe ---------- */

.live-scribe {
  display: flex;
  flex-direction: column;
  gap: 0.55em;
}

.live-tabs {
  display: flex;
  gap: 0.3em;
  flex: none;
}

.live-tab {
  padding: 0.28em 0.58em;
  border: 1px solid transparent;
  border-radius: var(--shape-full);
  font-size: 0.72em;
  color: var(--cl-muted);
  white-space: nowrap;
}

.live-tab.is-on {
  border-color: rgba(160, 107, 255, 0.5);
  background: rgba(160, 107, 255, 0.13);
  color: #e6d8ff;
}

.live-scribe__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.45em;
  flex: none;
}

.live-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.32em;
  padding: 0.24em 0.48em;
  border-radius: var(--shape-full);
  background: rgba(160, 107, 255, 0.16);
  color: #dccbff;
  font-size: 0.63em;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
}

.live-chip::before {
  content: "";
  width: 0.4em;
  height: 0.4em;
  flex: none;
  border-radius: 50%;
  background: var(--cl-purple);
  box-shadow: 0 0 0 0.24em rgba(160, 107, 255, 0.16);
  animation: clinic-chip-pulse 3.2s ease-in-out infinite;
}

.live-scribe__head strong {
  font-family: var(--font-head);
  font-size: 0.8em;
  font-weight: 700;
  color: var(--cl-text);
  white-space: nowrap;
}

.live-scribe__head b {
  font-weight: 700;
  color: var(--cl-lime);
}

.live-lines {
  display: flex;
  flex-direction: column;
  gap: 0.38em;
  min-height: 0;
}

.live-line {
  display: flex;
  gap: 0.42em;
  font-size: 0.72em;
  line-height: 1.32;
  color: var(--cl-muted);
  opacity: 0;
  transform: translateY(0.4em);
  animation: clinic-line-in 12s var(--ease-enter) infinite;
  animation-delay: calc(var(--n) * 0.65s);
}

.live-line::before {
  content: "";
  width: 0.32em;
  height: 0.32em;
  flex: none;
  margin-top: 0.46em;
  border-radius: 50%;
  background: var(--cl-cyan);
  box-shadow: 0 0 0 0.2em rgba(47, 226, 255, 0.12);
}

.live-wave {
  display: flex;
  align-items: flex-end;
  gap: 0.16em;
  height: 1.35em;
  margin-top: auto;
  padding: 0 0.1em;
}

.live-suggest {
  display: flex;
  align-items: center;
  gap: 0.4em;
  padding: 0.42em 0.52em;
  border: 1px solid rgba(217, 255, 63, 0.22);
  border-radius: 0.5em;
  background: rgba(217, 255, 63, 0.06);
  font-size: 0.64em;
  color: var(--cl-text);
}

.live-suggest__dot {
  width: 0.35em;
  height: 0.35em;
  flex: none;
  border-radius: 50%;
  background: var(--cl-lime);
  box-shadow: 0 0 0 0.2em rgba(217, 255, 63, 0.12);
  animation: clinic-chip-pulse 2.6s ease-in-out infinite;
}

.live-suggest__go {
  margin-left: auto;
  color: var(--cl-lime);
  font-weight: 700;
}

.live-wave i {
  flex: 1;
  height: 100%;
  border-radius: 0.18em;
  background: linear-gradient(180deg, var(--cl-cyan), var(--cl-purple));
  transform: scaleY(0.35);
  transform-origin: bottom;
  opacity: 0.78;
  animation: clinic-wave 1.6s ease-in-out infinite;
  animation-delay: calc(var(--b) * -0.11s);
}

.live-scribe__foot {
  display: flex;
  align-items: center;
  gap: 0.45em;
  flex: none;
  font-size: 0.63em;
  color: var(--cl-muted);
}

.live-action {
  display: inline-flex;
  align-items: center;
  flex: none;
  padding: 0.36em 0.55em;
  border-radius: var(--shape-full);
  background: var(--cl-lime);
  color: #071000;
  font-weight: 700;
  white-space: nowrap;
}

/* ---------- Video tile ---------- */

.live-video {
  padding: 0;
  background: #0a1522;
}

.live-video::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 3;
  border-radius: inherit;
  box-shadow:
    inset 0 0 0 1px rgba(47, 226, 255, 0.22),
    inset 0 0 2.4em rgba(47, 226, 255, 0.1);
  pointer-events: none;
  animation: clinic-video-glow 5s ease-in-out infinite;
}

.live-provider {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.live-provider img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 24%;
  animation: clinic-provider-breathe 9s ease-in-out infinite;
}

.live-video__shade {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: linear-gradient(180deg, rgba(6, 17, 30, 0.16), transparent 30%, transparent 58%, rgba(6, 17, 30, 0.86));
}

.live-video__scan {
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  z-index: 2;
  height: 16%;
  background: linear-gradient(180deg, transparent, rgba(47, 226, 255, 0.17), transparent);
  opacity: 0;
  animation: clinic-scan 7s linear infinite;
  pointer-events: none;
}

.live-video__tag {
  position: absolute;
  top: 0.7em;
  left: 0.7em;
  z-index: 4;
  display: flex;
  align-items: center;
  gap: 0.35em;
  padding: 0.28em 0.55em;
  border: 1px solid rgba(160, 107, 255, 0.5);
  border-radius: var(--shape-full);
  background: rgba(160, 107, 255, 0.2);
  color: #e7dbff;
  font-size: 0.63em;
  font-weight: 600;
  white-space: nowrap;
  backdrop-filter: blur(4px);
}

.live-video__tag i {
  width: 0.38em;
  height: 0.38em;
  border-radius: 50%;
  background: var(--cl-purple);
  animation: clinic-tag-pulse 2.4s ease-in-out infinite;
}

.live-video__name {
  position: absolute;
  bottom: 0.7em;
  left: 0.7em;
  z-index: 4;
  padding: 0.26em 0.52em;
  border: 1px solid var(--cl-line);
  border-radius: 0.45em;
  background: rgba(6, 17, 30, 0.8);
  color: var(--cl-text);
  font-size: 0.66em;
  white-space: nowrap;
  backdrop-filter: blur(4px);
}

.live-caption {
  position: absolute;
  right: 0.7em;
  bottom: 2.85em;
  left: 0.7em;
  z-index: 4;
  padding: 0.5em 0.65em;
  border: 1px solid rgba(47, 226, 255, 0.24);
  border-radius: 0.55em;
  background: rgba(6, 17, 30, 0.82);
  color: var(--cl-text);
  font-size: 0.74em;
  animation: clinic-caption 9s var(--ease-enter) infinite;
  backdrop-filter: blur(4px);
}

/* ---------- People + requests rail ---------- */

.live-side {
  display: flex;
  flex-direction: column;
  gap: 0.55em;
}

.live-people {
  display: flex;
  align-items: center;
  gap: 0.32em;
  flex: none;
  padding: 0.5em 0.6em;
  border: 1px solid var(--cl-line);
  border-radius: 0.8em;
  background: var(--cl-panel);
}

.live-avatar {
  position: relative;
  display: grid;
  place-items: center;
  width: 1.9em;
  height: 1.9em;
  flex: none;
  border-radius: 50%;
  background: linear-gradient(140deg, var(--cl-cyan), var(--cl-purple));
  color: #06111e;
  font-size: 0.68em;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.live-avatar--2 {
  background: linear-gradient(140deg, var(--cl-lime), #39e58c);
}

.live-avatar--3 {
  background: linear-gradient(140deg, var(--cl-amber), var(--cl-pink));
}

.live-avatar.is-speaking::after {
  content: "";
  position: absolute;
  inset: -0.22em;
  border: 1px solid var(--cl-cyan);
  border-radius: 50%;
  animation: clinic-speak-ring 2.4s ease-out infinite;
}

.live-people__label {
  margin-left: auto;
  font-size: 0.62em;
  font-weight: 600;
  color: var(--cl-muted);
  white-space: nowrap;
}

.live-requests {
  display: flex;
  flex-direction: column;
  gap: 0.38em;
  flex: 1;
  min-height: 0;
  padding: 0.6em;
  overflow: hidden;
  border: 1px solid var(--cl-line);
  border-radius: 0.8em;
  background: var(--cl-panel);
}

.live-requests__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4em;
  flex: none;
  font-size: 0.68em;
  font-weight: 600;
  color: var(--cl-muted);
}

.live-requests__head b {
  display: grid;
  place-items: center;
  min-width: 1.9em;
  height: 1.6em;
  padding: 0 0.3em;
  border-radius: var(--shape-full);
  background: rgba(255, 209, 102, 0.14);
  color: var(--cl-amber);
  font-size: 0.9em;
}

.live-thread {
  padding: 0.45em 0.5em;
  border: 1px solid var(--cl-line);
  border-radius: 0.55em;
  background: rgba(6, 17, 30, 0.45);
}

.live-thread--claim {
  animation: clinic-thread-claim 12s var(--ease-emphasized) infinite;
}

.live-thread__meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.3em;
  margin-bottom: 0.22em;
  font-size: 0.6em;
  color: var(--cl-muted);
}

.live-thread__meta span:first-child {
  overflow: hidden;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.live-status {
  display: inline-grid;
  flex: none;
  padding: 0.16em 0.44em;
  border-radius: var(--shape-full);
  background: rgba(255, 209, 102, 0.14);
  color: var(--cl-amber);
  font-weight: 650;
  white-space: nowrap;
}

.live-status--claimed {
  background: rgba(47, 226, 255, 0.12);
  color: var(--cl-cyan);
}

.live-status--done {
  background: rgba(57, 229, 140, 0.12);
  color: #39e58c;
}

.live-status--swap > span {
  grid-area: 1 / 1;
}

.live-status--swap .is-claimed {
  opacity: 0;
  animation: clinic-status-claim 12s var(--ease-emphasized) infinite;
}

.live-status--swap .is-raised {
  animation: clinic-status-raised 12s var(--ease-emphasized) infinite;
}

.live-thread p {
  overflow: hidden;
  font-size: 0.7em;
  line-height: 1.3;
  color: var(--cl-text);
  text-overflow: ellipsis;
}

/* ---------- Floating AI notification ---------- */

.live-toast {
  position: absolute;
  bottom: 1em;
  left: 1em;
  z-index: 8;
  display: flex;
  align-items: center;
  gap: 0.45em;
  max-width: 60%;
  padding: 0.5em 0.62em;
  border: 1px solid rgba(217, 255, 63, 0.32);
  border-radius: 0.7em;
  background: rgba(8, 18, 28, 0.94);
  box-shadow: 0 0.8em 2em rgba(0, 0, 0, 0.42);
  font-size: 0.72em;
  color: var(--cl-muted);
  opacity: 0;
  transform: translateY(0.8em) scale(0.97);
  animation: clinic-toast 12s var(--ease-emphasized) infinite;
  backdrop-filter: blur(6px);
}

.live-toast strong {
  color: var(--cl-text);
}

.live-toast em {
  flex: none;
  font-style: normal;
  font-size: 0.88em;
  color: var(--cl-lime);
  white-space: nowrap;
}

.live-toast__spark {
  display: grid;
  place-items: center;
  width: 1.9em;
  height: 1.9em;
  flex: none;
  border-radius: 0.45em;
  background: rgba(217, 255, 63, 0.14);
  color: var(--cl-lime);
  font-size: 0.9em;
}

/* ---------- Keyframes ---------- */

@keyframes clinic-line-in {
  0%, 16% { opacity: 0; transform: translateY(0.4em); }
  23%, 78% { opacity: 1; transform: none; }
  87%, 100% { opacity: 0; transform: translateY(0.18em); }
}

@keyframes clinic-wave {
  0%, 100% { transform: scaleY(0.28); }
  50% { transform: scaleY(1); }
}

@keyframes clinic-provider-breathe {
  0%, 100% { transform: scale(1.02) translateY(0); }
  50% { transform: scale(1.055) translateY(-1.2%); }
}

@keyframes clinic-scan {
  0% { transform: translateY(-140%); opacity: 0; }
  8% { opacity: 0.55; }
  55% { opacity: 0.5; }
  70%, 100% { transform: translateY(660%); opacity: 0; }
}

@keyframes clinic-video-glow {
  0%, 100% { opacity: 0.55; }
  50% { opacity: 1; }
}

@keyframes clinic-caption {
  0%, 100% { opacity: 0.9; }
  50% { opacity: 1; }
}

@keyframes clinic-chip-pulse {
  0%, 100% { opacity: 0.55; }
  50% { opacity: 1; }
}

@keyframes clinic-live-pulse {
  0% { box-shadow: 0 0 0 0 rgba(217, 255, 63, 0.45); }
  70%, 100% { box-shadow: 0 0 0 0.55em rgba(217, 255, 63, 0); }
}

@keyframes clinic-tag-pulse {
  0%, 100% { opacity: 0.55; transform: scale(0.9); }
  50% { opacity: 1; transform: scale(1.15); }
}

@keyframes clinic-speak-ring {
  0% { transform: scale(1); opacity: 0.65; }
  100% { transform: scale(1.55); opacity: 0; }
}

@keyframes clinic-thread-claim {
  0%, 32% {
    border-color: var(--cl-line);
    background: rgba(6, 17, 30, 0.45);
    box-shadow: none;
  }
  40%, 72% {
    border-color: rgba(47, 226, 255, 0.48);
    background: rgba(47, 226, 255, 0.07);
    box-shadow: 0 0 0 1px rgba(47, 226, 255, 0.08);
  }
  82%, 100% {
    border-color: var(--cl-line);
    background: rgba(6, 17, 30, 0.45);
    box-shadow: none;
  }
}

@keyframes clinic-status-raised {
  0%, 34% { opacity: 1; }
  40%, 100% { opacity: 0; }
}

@keyframes clinic-status-claim {
  0%, 34% { opacity: 0; }
  40%, 100% { opacity: 1; }
}

@keyframes clinic-toast {
  0%, 24% { opacity: 0; transform: translateY(0.8em) scale(0.97); }
  30%, 71% { opacity: 1; transform: none; }
  80%, 100% { opacity: 0; transform: translateY(0.4em) scale(0.99); }
}

/* ---------- Small screens ---------- */

/* Phones: drop the requests rail and simplify the chrome so the two main
   panes can keep a legible scale inside a narrow laptop screen. */
@container (max-width: 480px) {
  .clinic-live {
    font-size: clamp(7.5px, 2.15cqw, 9.8px);
  }

  .clinic-live__top {
    gap: 0.5em;
    padding: 0.65em 0.85em;
  }

  .clinic-calls,
  .clinic-room em,
  .live-side {
    display: none;
  }

  .clinic-room {
    font-size: 1.4em;
  }

  .clinic-live__body {
    grid-template-columns: 1.12fr 1.88fr;
    gap: 0.5em;
    padding: 0.5em;
  }

  .live-scribe {
    gap: 0.4em;
    padding: 0.6em 0.65em;
  }

  .live-tabs,
  .live-wave,
  .live-scribe__foot,
  .live-suggest {
    display: none;
  }

  .live-line {
    font-size: 0.92em;
  }

  .live-scribe__head {
    flex-wrap: wrap;
    gap: 0.25em;
  }

  .live-chip {
    font-size: 0.68em;
  }

  .live-scribe__head strong {
    font-size: 0.82em;
  }

  .live-video__tag {
    top: 0.55em;
    left: 0.55em;
    font-size: 0.7em;
  }

  .live-video__name {
    top: 0.55em;
    right: 0.55em;
    bottom: auto;
    left: auto;
    font-size: 0.74em;
  }

  .live-caption {
    right: 0.55em;
    bottom: 2.45em;
    left: 0.55em;
    padding: 0.4em 0.5em;
    font-size: 0.74em;
  }

  .live-toast {
    bottom: 0.6em;
    left: 0.6em;
    max-width: 84%;
    font-size: 0.78em;
  }
}

/* Large phones and small tablets: keep two panes rather than three */
@media (min-width: 512px) and (max-width: 700px) {
  .clinic-live {
    font-size: clamp(8px, 2.05cqw, 9.8px);
  }

  .clinic-live__body {
    grid-template-columns: 1.12fr 1.88fr;
  }

  .live-side,
  .clinic-calls {
    display: none;
  }

  .live-video__name {
    top: 0.55em;
    right: 0.55em;
    bottom: auto;
    left: auto;
  }
}

/* Very small phones: keep only the essentials */
@container (max-width: 340px) {
  .live-caption {
    display: none;
  }

  .live-line:nth-child(3) {
    display: none;
  }
}

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  .clinic-live__status i,
  .clinic-chip--warn i,
  .live-chip::before,
  .live-line,
  .live-wave i,
  .live-provider img,
  .live-video::after,
  .live-video__scan,
  .live-video__tag i,
  .live-caption,
  .live-avatar.is-speaking::after,
  .live-thread--claim,
  .live-status--swap .is-raised,
  .live-status--swap .is-claimed,
  .live-toast {
    animation: none;
  }

  .live-line,
  .live-toast {
    opacity: 1;
    transform: none;
  }

  .live-suggest__dot {
    animation: none;
  }

  .live-wave i {
    transform: scaleY(0.7);
  }

  .live-video__scan {
    display: none;
  }

  .live-status--swap .is-raised {
    opacity: 1;
  }

  .live-status--swap .is-claimed {
    opacity: 0;
  }
}
