/* ============================================================================
 * SANATORIO LOAR — Estilos Compartidos de Chat en Tiempo Real, Escáner QR,
 * Llamada Entrante, Avatar de Perfil y Selector Telefónico Internacional
 *
 * PALETA ESTRICTA (CERO CELESTE):
 * - Blancos (#FFFFFF, #FAFAFA), grises (#F3F4F6, #E5E7EB, #6B7280, #18181B)
 * - Acento verde oscuro (#0F3D2E, hover #0A2B20), alerta roja (#B91C1C / #FEF2F2)
 * ============================================================================ */

html,
body {
  max-width: 100%;
  overflow-x: clip;
}

/* ---------- AVATARES ---------- */
.rt-avatar-img {
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid #e5e7eb;
  background-color: #f3f4f6;
  flex-shrink: 0;
  display: block;
}

.rt-avatar {
  border-radius: 50%;
  background-color: #f3f4f6;
  border: 1px solid #d1d5db;
  color: #0f3d2e;
  font-weight: 700;
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
}

.rt-avatar--admin {
  background-color: #edf3f0;
  border-color: #c7d7d0;
  color: #0f3d2e;
}

/* ---------- CHAT PERSISTENTE ESTILO DISCORD / WHATSAPP (100dvh) ---------- */
.rt-chat-shell {
  display: flex;
  flex-direction: column;
  background-color: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  overflow: hidden;
  min-height: 480px;
  height: calc(100dvh - 152px);
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

@media (max-width: 899px) {
  .rt-chat-shell.is-mobile-fullscreen {
    position: fixed;
    inset: 0;
    z-index: 65;
    width: 100%;
    max-width: 100vw;
    height: 100%;
    height: 100dvh;
    padding-top: env(safe-area-inset-top, 0px);
    border-radius: 0;
    border: 0;
    overflow: hidden;
  }
}

/* ---------- BANNERS DE ANUNCIOS INSTITUCIONALES ---------- */
.loar-ann-stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}

.loar-ann-stack.is-compact {
  margin-bottom: 12px;
}

.loar-ann-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 13px 14px;
  background-color: #ffffff;
  border: 1px solid #e4e4e7;
  border-left: 3px solid #0f3d2e;
  border-radius: 10px;
  color: #18181b;
  box-shadow: 0 1px 2px rgba(24, 24, 27, 0.04);
}

.loar-ann-card--warning {
  background-color: #fafaf9;
  border-color: #d4d4d8;
  border-left-color: #18181b;
}

.loar-ann-card--urgent {
  background-color: #fef2f2;
  border-color: #fecaca;
  border-left-color: #b91c1c;
}

.loar-ann-ico {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background-color: #f4f4f5;
  color: #0f3d2e;
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
}

.loar-ann-card--urgent .loar-ann-ico {
  background-color: #fee2e2;
  color: #b91c1c;
}

.loar-ann-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.loar-ann-title {
  font-size: 13.5px;
  font-weight: 700;
  color: #18181b;
  line-height: 1.3;
}

.loar-ann-card--urgent .loar-ann-title {
  color: #991b1b;
}

.loar-ann-msg {
  margin: 0;
  font-size: 13px;
  line-height: 1.48;
  color: #3f3f46;
  white-space: pre-line;
}

.loar-ann-reason {
  font-size: 12.5px;
  color: #52525b;
  margin-top: 2px;
}

.loar-ann-card--urgent .loar-ann-reason {
  color: #991b1b;
}

.loar-ann-close {
  width: 30px;
  height: 30px;
  border-radius: 6px;
  border: 0;
  background: transparent;
  color: #71717a;
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  flex-shrink: 0;
}

.loar-ann-close:hover {
  background-color: rgba(24, 24, 27, 0.06);
  color: #18181b;
}

.rt-chat-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  background-color: #ffffff;
  border-bottom: 1px solid #e5e7eb;
  flex-shrink: 0;
}

.rt-chat-topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-inline-size: 0;
  flex: 1;
}

.rt-chat-peer-info {
  min-inline-size: 0;
  display: flex;
  flex-direction: column;
}

.rt-chat-peer-name {
  font-size: 14.5px;
  font-weight: 700;
  color: #18181b;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rt-chat-peer-sub {
  font-size: 11.5px;
  color: #6b7280;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rt-chat-topbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.rt-chat-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.rt-conv-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 12px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  background-color: #ffffff;
  text-align: left;
  cursor: pointer;
  transition: background-color 150ms ease, border-color 150ms ease;
}

.rt-conv-row:hover {
  background-color: #fafafa;
  border-color: #d1d5db;
}

.rt-conv-row.has-unread {
  border-left: 3px solid #0f3d2e;
}

.rt-conv-main {
  flex: 1;
  min-inline-size: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.rt-conv-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.rt-conv-name {
  font-size: 14px;
  font-weight: 700;
  color: #18181b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rt-conv-time {
  font-size: 11px;
  color: #6b7280;
  flex-shrink: 0;
}

.rt-conv-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.rt-conv-preview {
  font-size: 12.5px;
  color: #6b7280;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 0;
}

.rt-conv-tag {
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  border-radius: 4px;
  background-color: #f3f4f6;
  border: 1px solid #e5e7eb;
  color: #4b5563;
  font-size: 10.5px;
  font-weight: 600;
  flex-shrink: 0;
}

.rt-conv-tag--admin {
  background-color: #edf3f0;
  border-color: #c7d7d0;
  color: #0f3d2e;
}

.rt-unread-pill {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background-color: #0f3d2e;
  color: #ffffff;
  font-size: 11px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* Mensajes */
.rt-messages-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  padding: 14px 12px;
  background-color: #fafafa;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.rt-msg-row {
  display: flex;
  flex-direction: column;
  max-width: 86%;
  min-width: 0;
  align-self: flex-start;
  box-sizing: border-box;
}

.rt-msg-row.is-self {
  align-self: flex-end;
}

.rt-msg-bubble {
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid #e5e7eb;
  background-color: #ffffff;
  color: #18181b;
  font-size: 13.5px;
  line-height: 1.45;
  word-break: break-word;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.rt-msg-row.is-self .rt-msg-bubble {
  background-color: #0f3d2e;
  border-color: #0f3d2e;
  color: #ffffff;
}

.rt-msg-sender {
  font-size: 11px;
  font-weight: 700;
  color: #4b5563;
  margin-bottom: 3px;
}

.rt-msg-row.is-self .rt-msg-sender {
  color: rgba(255, 255, 255, 0.8);
}

.rt-msg-text {
  white-space: pre-wrap;
  margin: 0;
}

.rt-msg-time {
  display: block;
  margin-top: 4px;
  font-size: 10.5px;
  color: #9ca3af;
  text-align: right;
}

.rt-msg-row.is-self .rt-msg-time {
  color: rgba(255, 255, 255, 0.72);
}

/* Adjuntos en burbujas */
.rt-msg-attachments {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 6px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.rt-att-img-btn {
  padding: 0;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 8px;
  overflow: hidden;
  background: #f3f4f6;
  cursor: pointer;
  width: 100%;
  max-width: min(240px, 100%);
  box-sizing: border-box;
}

.rt-att-img-btn img {
  width: 100%;
  max-height: 220px;
  object-fit: cover;
  display: block;
}

.rt-att-video-wrap {
  display: flex;
  flex-direction: column;
  gap: 3px;
  width: 100%;
  max-width: min(250px, 100%);
  min-width: 0;
  box-sizing: border-box;
}

.rt-att-video {
  width: 100%;
  max-width: 100%;
  max-height: 240px;
  border-radius: 8px;
  background: #111111;
  display: block;
}

.rt-att-video-name {
  font-size: 11px;
  opacity: 0.82;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rt-att-doc-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  background-color: #f3f4f6;
  border: 1px solid #e5e7eb;
  color: #18181b;
  text-decoration: none;
  width: 100%;
  max-width: min(250px, 100%);
  min-width: 0;
  box-sizing: border-box;
}

.rt-msg-row.is-self .rt-att-doc-link {
  background-color: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.24);
  color: #ffffff;
}

.rt-att-doc-meta {
  flex: 1;
  min-inline-size: 0;
  display: flex;
  flex-direction: column;
}

.rt-att-doc-meta strong {
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rt-att-doc-meta small {
  font-size: 10.5px;
  opacity: 0.8;
}

/* Barra de adjuntos pendientes (hasta 5) */
.rt-pending-bar {
  padding: 8px 12px;
  background-color: #f9fafb;
  border-top: 1px solid #e5e7eb;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}

.rt-pending-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11.5px;
  color: #4b5563;
}

.rt-pending-clear {
  background: none;
  border: 0;
  color: #b91c1c;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
}

.rt-pending-strip {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.rt-pending-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px;
  border-radius: 6px;
  background-color: #ffffff;
  border: 1px solid #d1d5db;
  max-width: 165px;
  flex-shrink: 0;
}

.rt-pending-thumb {
  width: 28px;
  height: 28px;
  border-radius: 4px;
  object-fit: cover;
  flex-shrink: 0;
}

.rt-pending-ico {
  font-size: 18px;
  color: #0f3d2e;
  flex-shrink: 0;
}

.rt-pending-name {
  font-size: 11.5px;
  color: #18181b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rt-pending-remove {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 0;
  background: #f3f4f6;
  color: #b91c1c;
  font-weight: 700;
  font-size: 14px;
  line-height: 1;
  display: grid;
  place-items: center;
  cursor: pointer;
  flex-shrink: 0;
}

.rt-upload-progress {
  height: 4px;
  background: #e5e7eb;
  width: 100%;
  overflow: hidden;
  flex-shrink: 0;
}

.rt-upload-progress-bar {
  height: 100%;
  background: #0f3d2e;
  transition: width 150ms linear;
}

.rt-composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 10px calc(10px + env(safe-area-inset-bottom, 0px));
  background-color: #ffffff;
  border-top: 1px solid #e5e7eb;
  flex-shrink: 0;
}

.rt-attach-btn {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  border: 1px solid #d1d5db;
  background-color: #f9fafb;
  color: #18181b;
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  flex-shrink: 0;
}

.rt-attach-btn:hover {
  background-color: #f3f4f6;
}

.rt-composer-input {
  flex: 1;
  min-inline-size: 0;
  min-height: 40px;
  max-height: 110px;
  padding: 9px 12px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  background-color: #ffffff;
  color: #18181b;
  font-size: 14px;
  line-height: 1.35;
  resize: none;
}

.rt-composer-input:focus {
  outline: none;
  border-color: #0f3d2e;
}

.rt-send-btn {
  width: 42px;
  height: 40px;
  border-radius: 8px;
  border: 0;
  background-color: #0f3d2e;
  color: #ffffff;
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  flex-shrink: 0;
}

.rt-send-btn:hover:not(:disabled) {
  background-color: #0a2b20;
}

.rt-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ---------- TARJETA DE CANJE DE CÓDIGO (LOCK CONSULTA VIRTUAL) ---------- */
.voucher-lock-card {
  background-color: #ffffff;
  border: 1px solid #e5e7eb;
  border-left: 3px solid #0f3d2e;
  border-radius: 10px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.voucher-lock-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.voucher-lock-ico {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background-color: #f3f4f6;
  border: 1px solid #e5e7eb;
  color: #0f3d2e;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.voucher-input-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.voucher-code-input {
  flex: 1 1 180px;
  min-inline-size: 0;
  min-height: 42px;
  padding: 8px 12px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  background-color: #fafafa;
  color: #18181b;
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.voucher-code-input:focus {
  outline: none;
  border-color: #0f3d2e;
  background-color: #ffffff;
}

.voucher-help-links {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid #e5e7eb;
}

.voucher-article-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: #0f3d2e;
  text-decoration: underline;
}

/* ---------- ESCÁNER QR MÓVIL (100dvh) ---------- */
.qr-scanner-overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  height: 100dvh;
  background-color: #111111;
  color: #ffffff;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.qr-scanner-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: calc(12px + env(safe-area-inset-top, 0px)) 16px 12px;
  background: rgba(17, 17, 17, 0.92);
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  flex-shrink: 0;
}

.qr-scanner-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: center;
  background: #09090b;
  overflow: hidden;
}

.qr-scanner-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.qr-scanner-reticle {
  position: absolute;
  width: min(72vw, 260px);
  height: min(72vw, 260px);
  border: 3px solid #0f3d2e;
  border-radius: 12px;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.45);
  pointer-events: none;
}

.qr-scanner-footer {
  padding: 14px 16px calc(16px + env(safe-area-inset-bottom, 0px));
  background: #ffffff;
  color: #18181b;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex-shrink: 0;
}

/* ---------- OVERLAY LLAMADA ENTRANTE DE EMERGENCIA ---------- */
.emergency-ring-overlay {
  position: fixed;
  inset: 0;
  z-index: 95;
  background: rgba(15, 23, 20, 0.72);
  backdrop-filter: blur(6px);
  display: grid;
  place-items: center;
  padding: 20px;
}

.emergency-ring-card {
  width: 100%;
  max-width: 370px;
  background-color: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 24px 20px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  box-shadow: 0 20px 44px rgba(0, 0, 0, 0.25);
}

.emergency-ring-avatar {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid #0f3d2e;
  animation: loar-ring-pulse 1.6s infinite;
}

@keyframes loar-ring-pulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(15, 61, 46, 0.35);
  }
  50% {
    box-shadow: 0 0 0 12px rgba(15, 61, 46, 0);
  }
}

.emergency-ring-actions {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 4px;
}

/* ---------- SELECTOR TELEFÓNICO EN MI CUENTA ---------- */
.loar-phone-picker {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.loar-phone-row {
  display: flex;
  align-items: stretch;
  width: 100%;
}

.loar-dial-trigger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 10px;
  border: 1px solid #d1d5db;
  border-right: 0;
  border-radius: 8px 0 0 8px;
  background: #f3f4f6;
  color: #18181b;
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
}

.loar-dial-chevron {
  font-size: 17px;
  color: #6b7280;
}

.loar-phone-input {
  flex: 1;
  min-inline-size: 0;
  min-height: 40px;
  padding: 8px 11px;
  border: 1px solid #d1d5db;
  border-radius: 0 8px 8px 0;
  background: #ffffff;
  color: #18181b;
  font-size: 14px;
}

.loar-phone-input:focus {
  outline: none;
  border-color: #0f3d2e;
}

.loar-dial-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 60;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.14);
  overflow: hidden;
}

.loar-dial-search-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  background: #fafafa;
  border-bottom: 1px solid #e5e7eb;
  color: #6b7280;
}

.loar-dial-search {
  width: 100%;
  border: 0;
  background: transparent;
  outline: none;
  font-size: 13.5px;
  color: #18181b;
}

.loar-dial-list {
  max-height: 210px;
  overflow-y: auto;
}

.loar-dial-group {
  position: sticky;
  top: 0;
  padding: 5px 10px;
  background: #f3f4f6;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  color: #6b7280;
}

.loar-dial-item {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border: 0;
  border-bottom: 1px solid #f3f4f6;
  background: #ffffff;
  text-align: left;
  font-size: 13px;
  cursor: pointer;
}

.loar-dial-item:hover {
  background: #f3f4f6;
}

.loar-dial-item.is-selected {
  background: #edf3f0;
  color: #0f3d2e;
  font-weight: 700;
}

.loar-dial-item-left {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-inline-size: 0;
}

.loar-dial-item-code {
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 12px;
  color: #4b5563;
}

.country-flag-img {
  width: 20px;
  height: 15px;
  object-fit: cover;
  border-radius: 2px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  flex-shrink: 0;
}

/* ---------- EDITOR DE FOTO DE PERFIL EN MI CUENTA / DOCTOR CUENTA ---------- */
.profile-avatar-editor {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  background: #ffffff;
}

.profile-avatar-editor-meta {
  flex: 1;
  min-inline-size: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* ---------- PIN SHAKE ANIMATION ---------- */
@keyframes loar-pin-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

.is-pin-shake {
  animation: loar-pin-shake 280ms ease-in-out;
}
