#view-llamado-pacientes {
  --ltv-teal: #0d9488;
  --ltv-teal-light: #ccfbf1;
  --ltv-teal-dark: #0f766e;
  --ltv-teal-glow: rgba(13, 148, 136, 0.22);
  --ltv-slate-50: #f8fafc;
  --ltv-slate-200: #e2e8f0;
  --ltv-slate-500: #64748b;
  --ltv-slate-700: #334155;
  --ltv-slate-800: #1e293b;
  --ltv-slate-900: #0f172a;
}

#view-llamado-pacientes:not(.hidden) ~ .app-footer {
  display: none;
}

.ltv-page {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--ltv-slate-50);
}

/* ── Topbar ── */
.ltv-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  padding: 0 clamp(16px, 3vw, 32px);
  background: #fff;
  border-bottom: 1px solid var(--ltv-slate-200);
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.04);
  position: sticky;
  top: 0;
  z-index: 20;
  flex-shrink: 0;
}

.ltv-topbar-left,
.ltv-topbar-right {
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 0;
}

.ltv-topbar-right {
  justify-content: flex-end;
  gap: 8px;
}

.ltv-topbar-center {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  pointer-events: none;
}

.ltv-topbar-title {
  margin: 0;
  font-size: clamp(0.9rem, 2vw, 1.05rem);
  font-weight: 700;
  color: var(--ltv-slate-800);
}

.ltv-topbar-reloj {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--ltv-slate-500);
  margin-top: 2px;
}

#view-llamado-pacientes .ltv-toolbar-btn {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 8px !important;
  height: 44px !important;
  min-height: 44px !important;
  padding: 0 16px !important;
  border-radius: 12px !important;
  border: 2px solid #cbd5e1 !important;
  background: #fff !important;
  color: var(--ltv-slate-700) !important;
  font-size: 0.88rem !important;
  font-weight: 700 !important;
  cursor: pointer !important;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.06) !important;
  transition: all 0.18s ease !important;
}

#view-llamado-pacientes .ltv-toolbar-btn svg {
  flex-shrink: 0;
  stroke: currentColor !important;
}

#view-llamado-pacientes .ltv-toolbar-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.12) !important;
}

#view-llamado-pacientes .ltv-toolbar-btn--back {
  border-color: #94a3b8 !important;
  background: #f1f5f9 !important;
  color: var(--ltv-slate-800) !important;
}

#view-llamado-pacientes .ltv-toolbar-btn--audio {
  border-color: #6366f1 !important;
  background: #eef2ff !important;
  color: #4338ca !important;
}

#view-llamado-pacientes .ltv-toolbar-btn--audio:hover,
#view-llamado-pacientes .ltv-toolbar-btn--audio.is-ready {
  background: #6366f1 !important;
  color: #fff !important;
  border-color: #4f46e5 !important;
}

#view-llamado-pacientes .ltv-toolbar-btn--config {
  border-color: var(--ltv-teal) !important;
  background: var(--ltv-teal-light) !important;
  color: var(--ltv-teal-dark) !important;
}

#view-llamado-pacientes .ltv-toolbar-btn--config:hover {
  background: var(--ltv-teal) !important;
  color: #fff !important;
  border-color: var(--ltv-teal-dark) !important;
}

#view-llamado-pacientes .ltv-toolbar-btn--fullscreen {
  border-color: #0ea5e9 !important;
  background: #e0f2fe !important;
  color: #0369a1 !important;
}

#view-llamado-pacientes .ltv-toolbar-btn--fullscreen:hover,
#view-llamado-pacientes .ltv-toolbar-btn--fullscreen.is-active {
  background: #0ea5e9 !important;
  color: #fff !important;
  border-color: #0284c7 !important;
}

#view-llamado-pacientes .ltv-fs-icon-compress.hidden,
#view-llamado-pacientes .ltv-fs-icon-expand.hidden {
  display: none !important;
}

#view-llamado-pacientes .ltv-toolbar-btn--audio {
  display: none !important;
}

#view-llamado-pacientes.ltv-is-fullscreen .ltv-topbar {
  display: none !important;
}

#view-llamado-pacientes.ltv-is-fullscreen .ltv-body {
  padding: 0;
}

#view-llamado-pacientes.ltv-is-fullscreen .ltv-status-bar,
#view-llamado-pacientes.ltv-is-fullscreen .ltv-alerta-bloqueo {
  display: none !important;
}

.ltv-cons-grid {
  display: none !important;
}

/* ── Pantalla reposo: logo ── */
.ltv-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  padding: clamp(16px, 3vw, 32px);
  min-height: 0;
  gap: clamp(12px, 2vw, 20px);
}

.ltv-status-bar {
  flex-shrink: 0;
  text-align: center;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--ltv-teal-dark);
  background: var(--ltv-teal-light);
  border: 1px solid rgba(13, 148, 136, 0.2);
  border-radius: 12px;
  padding: 10px 16px;
}

.ltv-status-bar--warn {
  color: #b45309;
  background: #fffbeb;
  border-color: #fcd34d;
}

.ltv-status-bar--audio-off {
  color: #4338ca;
  background: #eef2ff;
  border-color: #c7d2fe;
}

.ltv-alerta-bloqueo {
  flex-shrink: 0;
  text-align: center;
  font-size: 0.88rem;
  color: #991b1b;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 12px;
  padding: 12px 16px;
}

.ltv-alerta-bloqueo.hidden,
.ltv-status-bar.hidden {
  display: none;
}

.ltv-idle {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  min-height: 200px;
  transition: opacity 0.35s ease, filter 0.35s ease;
}

.ltv-idle.is-dimmed {
  opacity: 0.35;
  filter: blur(2px);
}

.ltv-idle-logo {
  width: min(680px, 85vw);
  height: auto;
  object-fit: contain;
}

.ltv-idle-logo--negro {
  filter: brightness(0);
}

/* ── Pop-up llamado ── */
.ltv-popup {
  position: fixed;
  inset: 0;
  z-index: 10060;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(20px, 4vw, 48px);
  pointer-events: none;
}

.ltv-popup.hidden {
  display: none;
}

.ltv-popup-backdrop {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 50% 40%, rgba(13, 148, 136, 0.18) 0%, transparent 70%),
    rgba(15, 23, 42, 0.72);
  backdrop-filter: blur(10px);
  animation: ltvPopupFadeIn 0.4s ease;
}

.ltv-popup.is-animate .ltv-popup-backdrop {
  animation: ltvPopupFadeIn 0.4s ease;
}

.ltv-popup-card {
  position: relative;
  width: min(780px, 100%);
  text-align: center;
  padding: clamp(40px, 5vw, 60px) clamp(28px, 4vw, 52px) clamp(36px, 4vw, 52px);
  border-radius: 28px;
  background: linear-gradient(165deg, #ffffff 0%, #f0fdfa 48%, #ecfdf5 100%);
  border: 1px solid rgba(255, 255, 255, 0.85);
  box-shadow:
    0 0 0 1px rgba(13, 148, 136, 0.12),
    0 32px 80px rgba(15, 23, 42, 0.35),
    0 0 80px rgba(13, 148, 136, 0.15);
  overflow: hidden;
  pointer-events: auto;
}

.ltv-popup.is-animate .ltv-popup-card {
  animation: ltvPopupSlideUp 0.55s cubic-bezier(0.22, 1, 0.36, 1);
}

.ltv-popup-nombre {
  position: relative;
  z-index: 1;
  margin: 0 0 clamp(16px, 2.5vw, 24px);
  font-size: clamp(2.1rem, 7.5vw, 4.2rem);
  font-weight: 800;
  line-height: 1.08;
  letter-spacing: -0.03em;
  color: var(--ltv-slate-900);
  word-break: break-word;
  text-wrap: balance;
}

.ltv-popup-instruccion {
  position: relative;
  z-index: 1;
  margin: 0 0 clamp(22px, 3vw, 32px);
  font-size: clamp(1rem, 2.2vw, 1.25rem);
  font-weight: 600;
  color: var(--ltv-slate-500);
}

.ltv-popup-doctor {
  margin: 0 0 clamp(20px, 3vw, 28px);
  font-size: clamp(1rem, 2.5vw, 1.35rem);
  font-weight: 600;
  color: var(--ltv-slate-500);
}

.ltv-popup-doctor.hidden {
  display: none;
}

.ltv-popup-consultorio {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: clamp(140px, 28vw, 220px);
  min-height: clamp(100px, 18vw, 140px);
  padding: clamp(16px, 3vw, 24px) clamp(36px, 7vw, 64px);
  border-radius: 22px;
  background: linear-gradient(145deg, #0d9488 0%, #0f766e 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.2),
    0 12px 32px rgba(13, 148, 136, 0.4);
}

.ltv-popup-cons-label {
  display: none;
}

.ltv-popup-cons-num {
  font-size: clamp(3.5rem, 14vw, 7rem);
  font-weight: 800;
  line-height: 1;
  color: #fff;
  letter-spacing: -0.04em;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
}

@keyframes ltvPopupFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes ltvPopupSlideUp {
  from {
    opacity: 0;
    transform: translateY(40px) scale(0.94);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ── Drawer consultorios ── */
.ltv-drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(4px);
  z-index: 10040;
}

.ltv-drawer-backdrop.hidden {
  display: none;
}

.ltv-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(420px, 92vw);
  background: #fff;
  z-index: 10050;
  display: flex;
  flex-direction: column;
  box-shadow: -8px 0 40px rgba(15, 23, 42, 0.12);
  transform: translateX(0);
  transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}

.ltv-drawer.hidden {
  transform: translateX(100%);
  pointer-events: none;
  visibility: hidden;
}

.ltv-drawer-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 24px 24px 20px;
  border-bottom: 1px solid var(--ltv-slate-200);
}

.ltv-drawer-header h2 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--ltv-slate-800);
}

.ltv-drawer-subtitle {
  margin: 4px 0 0;
  font-size: 0.84rem;
  color: var(--ltv-slate-500);
  line-height: 1.45;
}

.ltv-drawer-close {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 10px;
  background: #f1f5f9;
  color: var(--ltv-slate-500);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ltv-drawer-close:hover {
  background: #e2e8f0;
  color: var(--ltv-slate-800);
}

.ltv-drawer-actions {
  display: flex;
  gap: 8px;
  padding: 16px 24px 0;
}

.ltv-drawer-action {
  flex: 1;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--ltv-slate-200);
  background: #f8fafc;
  color: var(--ltv-slate-700);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

.ltv-drawer-action:hover {
  border-color: var(--ltv-teal);
  color: var(--ltv-teal-dark);
  background: var(--ltv-teal-light);
}

.ltv-drawer-list {
  flex: 1;
  overflow-y: auto;
  padding: 16px 24px 32px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ltv-toggle-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid var(--ltv-slate-200);
  background: #fff;
  cursor: pointer;
  user-select: none;
}

.ltv-toggle-item:hover {
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
}

.ltv-toggle-item.is-on {
  border-color: rgba(13, 148, 136, 0.35);
  background: linear-gradient(135deg, #fff 0%, var(--ltv-teal-light) 120%);
}

.ltv-toggle-item.is-off {
  opacity: 0.72;
  background: #f8fafc;
}

.ltv-toggle-item-info {
  flex: 1;
  min-width: 0;
}

.ltv-toggle-item-nombre {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--ltv-slate-800);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ltv-toggle-item-cons {
  font-size: 0.78rem;
  color: var(--ltv-slate-500);
  margin-top: 2px;
}

.ltv-toggle-item-cons-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 6px;
  background: var(--ltv-teal-light);
  color: var(--ltv-teal-dark);
  font-weight: 800;
  font-size: 0.75rem;
  margin-right: 4px;
}

.ltv-switch {
  position: relative;
  width: 44px;
  height: 26px;
  flex-shrink: 0;
}

.ltv-switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.ltv-switch-track {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: #cbd5e1;
  cursor: pointer;
  transition: background 0.22s;
}

.ltv-switch-track::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.15);
  transition: transform 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}

.ltv-switch input:checked + .ltv-switch-track {
  background: var(--ltv-teal);
}

.ltv-switch input:checked + .ltv-switch-track::after {
  transform: translateX(18px);
}

/* ── Historial reciente ── */
.ltv-historial {
  flex-shrink: 0;
  width: min(320px, 100%);
  align-self: flex-end;
  background: #fff;
  border: 1px solid var(--ltv-slate-200);
  border-radius: 16px;
  padding: 16px 18px;
  box-shadow: 0 4px 20px rgba(15, 23, 42, 0.06);
}

.ltv-historial.hidden {
  display: none;
}

.ltv-historial-titulo {
  margin: 0 0 12px;
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ltv-slate-500);
}

.ltv-historial-lista {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: min(42vh, 360px);
  overflow-y: auto;
}

.ltv-historial-item {
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--ltv-slate-50);
  border: 1px solid var(--ltv-slate-200);
}

.ltv-historial-item-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--ltv-teal-dark);
}

.ltv-historial-hora {
  color: var(--ltv-slate-500);
}

.ltv-historial-nombre {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--ltv-slate-800);
  line-height: 1.25;
}

.ltv-historial-doc {
  display: block;
  margin-top: 2px;
  font-size: 0.75rem;
  color: var(--ltv-slate-500);
}

/* ── Grid consultorios activos ── */
.ltv-cons-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  flex-shrink: 0;
}

.ltv-cons-grid.hidden {
  display: none;
}

.ltv-cons-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 72px;
  padding: 10px 14px;
  border-radius: 14px;
  background: #fff;
  border: 2px solid rgba(13, 148, 136, 0.25);
  box-shadow: 0 2px 8px rgba(13, 148, 136, 0.08);
}

.ltv-cons-chip-num {
  font-size: 1.5rem;
  font-weight: 800;
  line-height: 1;
  color: var(--ltv-teal-dark);
}

.ltv-cons-chip-nombre {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--ltv-slate-500);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

#view-llamado-pacientes.ltv-is-fullscreen .ltv-historial {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 10;
  max-width: min(340px, 40vw);
}

@media (max-width: 768px) {
  .ltv-topbar-center {
    position: static;
    transform: none;
    flex: 1 1 100%;
    text-align: center;
    order: -1;
    width: 100%;
    padding-bottom: 4px;
  }

  .ltv-topbar {
    flex-wrap: wrap;
    height: auto;
    padding: 10px 14px;
    gap: 8px;
  }

  #view-llamado-pacientes .ltv-toolbar-btn span:not(.ltv-fs-label) {
    display: none;
  }

  #view-llamado-pacientes .ltv-fs-label {
    display: none;
  }

  #view-llamado-pacientes .ltv-toolbar-btn {
    height: 40px !important;
    min-height: 40px !important;
    padding: 0 12px !important;
  }

  .ltv-historial {
    width: 100%;
    align-self: stretch;
  }
}
