/* ═══════════════════════════════════════════════════════════════════
   TIMBRE VIRTUAL — Estilos globales
   Modo claro / moderno
   ═══════════════════════════════════════════════════════════════════ */

/* ── Variables ──────────────────────────────────────────────────── */
:root {
  --primary:       #2563EB;
  --primary-light: #EFF6FF;
  --primary-dark:  #1D4ED8;
  --accent:        #0EA5E9;
  --success:       #10B981;
  --warning:       #F59E0B;
  --danger:        #EF4444;
  --bg:            #F8FAFC;
  --bg-card:       #FFFFFF;
  --border:        #E2E8F0;
  --text:          #0F172A;
  --text-muted:    #64748B;
  --text-light:    #94A3B8;
  --shadow-sm:     0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow:        0 4px 16px rgba(0,0,0,.08);
  --shadow-lg:     0 10px 40px rgba(0,0,0,.12);
  --radius:        14px;
  --radius-sm:     8px;
  --font:          'Inter', system-ui, -apple-system, sans-serif;
  --transition:    .18s ease;
}

/* ── Reset ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100%;
  line-height: 1.6;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
input, button, select, textarea { font-family: inherit; }

/* ── Layout utilitarios ─────────────────────────────────────────── */
.container { max-width: 1100px; margin: 0 auto; padding: 0 20px; }
.flex      { display: flex; }
.flex-col  { flex-direction: column; }
.items-center  { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2  { gap: 8px; }
.gap-3  { gap: 12px; }
.gap-4  { gap: 16px; }
.mt-2   { margin-top: 8px; }
.mt-4   { margin-top: 16px; }
.mt-6   { margin-top: 24px; }
.w-full { width: 100%; }
.text-center { text-align: center; }
.text-muted  { color: var(--text-muted); }
.text-sm     { font-size: .875rem; }
.text-xs     { font-size: .75rem; }
.font-semibold { font-weight: 600; }
.font-bold   { font-weight: 700; }
.hidden      { display: none !important; }
.grow        { flex: 1; }

/* ── Card ───────────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.card-body { padding: 24px; }
.card-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 1rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── Botones ────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  border: none;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  text-decoration: none;
}
.btn:disabled { opacity: .5; pointer-events: none; }
.btn-primary  { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(37,99,235,.35); }
.btn-success  { background: var(--success); color: #fff; }
.btn-success:hover { filter: brightness(1.05); transform: translateY(-1px); }
.btn-danger   { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(1.05); }
.btn-ghost    { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg); color: var(--text); }
.btn-icon     { padding: 9px; border-radius: 50%; }
.btn-sm       { padding: 7px 14px; font-size: .82rem; }
.btn-lg       { padding: 14px 28px; font-size: 1rem; }

/* ── Inputs ─────────────────────────────────────────────────────── */
.input-group { display: flex; flex-direction: column; gap: 5px; }
.input-group label { font-size: .85rem; font-weight: 500; color: var(--text); }
.input {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .95rem;
  transition: border-color var(--transition), box-shadow var(--transition);
  background: #fff;
  color: var(--text);
}
.input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.input::placeholder { color: var(--text-light); }

/* ── Navbar ─────────────────────────────────────────────────────── */
.navbar {
  --navbar-h: 60px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: var(--navbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}
.navbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--primary);
  text-decoration: none;
}
.navbar-brand svg { width: 26px; height: 26px; }
.navbar-campana { height: calc(var(--navbar-h) - 20px); width: auto; flex-shrink: 0; }
.navbar-actions { display: flex; align-items: center; gap: 12px; }
.navbar-qring   { position: absolute; left: 50%; transform: translateX(-50%); height: calc(var(--navbar-h) - 16px); width: auto; pointer-events: none; }

/* ── Auth page ──────────────────────────────────────────────────── */
.auth-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(135deg, #EFF6FF 0%, #F0F9FF 60%, #F8FAFC 100%);
}
.auth-card {
  width: 100%;
  max-width: 420px;
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 40px;
}
.auth-logo {
  text-align: center;
  margin-bottom: 28px;
}
.auth-logo .logo-icon {
  width: 56px; height: 56px;
  background: var(--primary-light);
  border-radius: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
  color: var(--primary);
}
.auth-logo h1 { font-size: 1.4rem; font-weight: 700; }
.auth-logo p  { color: var(--text-muted); font-size: .9rem; }
.auth-tabs {
  display: flex;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px;
  margin-bottom: 24px;
}
.auth-tab {
  flex: 1;
  padding: 8px;
  text-align: center;
  font-size: .875rem;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  transition: all var(--transition);
  color: var(--text-muted);
}
.auth-tab.active { background: var(--primary); color: #fff; }
.auth-form { display: flex; flex-direction: column; gap: 16px; }

/* ── Dashboard ──────────────────────────────────────────────────── */
.page-header {
  padding: 28px 0 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 28px;
}
.page-header h1 { font-size: 1.5rem; font-weight: 700; }
.page-header p  { color: var(--text-muted); font-size: .9rem; margin-top: 2px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }

@media (max-width: 760px) {
  .grid-2 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr; }
}

/* Stat cards */
.stat-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.stat-icon {
  width: 46px; height: 46px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}
.stat-info p { font-size: .82rem; color: var(--text-muted); }
.stat-info h2 { font-size: 1.6rem; font-weight: 700; }

/* Doorbells grid */
.doorbell-card {
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  transition: box-shadow var(--transition), border-color var(--transition);
}
.doorbell-card:hover { box-shadow: var(--shadow); border-color: #CBD5E1; }
.doorbell-name {
  font-weight: 700;
  font-size: 1rem;
  display: flex;
  align-items: center;
  gap: 8px;
}
.status-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--success);
  display: inline-block;
  box-shadow: 0 0 0 3px rgba(16,185,129,.2);
}
.qr-wrap {
  background: var(--bg);
  border-radius: 10px;
  padding: 12px;
  text-align: center;
}
.qr-wrap img { width: 160px; height: 160px; margin: 0 auto; }
.qr-url {
  font-size: .72rem;
  color: var(--text-muted);
  margin-top: 6px;
  word-break: break-all;
}
.doorbell-actions { display: flex; gap: 8px; }

/* Visits list */
.visit-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}
.visit-item:last-child { border-bottom: none; }
.visit-item:hover { background: var(--bg); }
.visit-avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: 1rem;
  flex-shrink: 0;
}
.visit-info { flex: 1; }
.visit-info strong { font-size: .95rem; display: block; }
.visit-info span   { font-size: .8rem; color: var(--text-muted); }
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: .75rem;
  font-weight: 600;
}
.badge-waiting   { background: #FEF3C7; color: #92400E; }
.badge-attending { background: #D1FAE5; color: #065F46; }
.badge-ended     { background: #F1F5F9; color: #475569; }

/* ── Ring page (visitante) ──────────────────────────────────────── */
.ring-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, #EFF6FF 0%, #F0F9FF 100%);
  padding: 20px;
}
.ring-card {
  width: 100%;
  max-width: 440px;
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.ring-header {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  padding: 14px 20px 10px;
  text-align: center;
}
.ring-header-top {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 4px;
}
.ring-header .bell-icon {
  width: 40px; height: 40px;
  background: rgba(255,255,255,.2);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  margin: 0;
  font-size: 1.1rem;
  flex-shrink: 0;
}
.ring-header h2 { font-size: 1.1rem; font-weight: 700; margin: 0; }
.ring-header p  { opacity: .8; font-size: .78rem; margin: 0; }
.ring-body { padding: 24px; }

/* Bell button */
.bell-btn {
  width: 90px; height: 90px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 2rem;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto;
  box-shadow: 0 6px 24px rgba(37,99,235,.4);
  transition: transform .15s, box-shadow .15s;
  position: relative;
}
.bell-btn:hover { transform: scale(1.06); }
.bell-btn:active { transform: scale(.96); }
.bell-btn.ringing { animation: bell-pulse 1s infinite; }

@keyframes bell-pulse {
  0%, 100% { box-shadow: 0 6px 24px rgba(37,99,235,.4); }
  50%       { box-shadow: 0 6px 40px rgba(37,99,235,.7), 0 0 0 12px rgba(37,99,235,.1); }
}

/* ── Chat ───────────────────────────────────────────────────────── */
.chat-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 300px;
  max-height: 420px;
  background: #fff;
}
.msg {
  display: flex;
  flex-direction: column;
  max-width: 78%;
  gap: 3px;
}
.msg.from-visitor { align-self: flex-end; align-items: flex-end; }
.msg.from-host    { align-self: flex-start; align-items: flex-start; }
.msg.system       { align-self: center; max-width: 100%; }
.msg-bubble {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: .9rem;
  line-height: 1.5;
  word-break: break-word;
}
.from-visitor .msg-bubble {
  background: var(--primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.from-host .msg-bubble {
  background: #fff;
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
  color: var(--text);
}
.system .msg-bubble {
  background: #FEF3C7;
  color: #92400E;
  font-size: .8rem;
  padding: 6px 14px;
  border-radius: 99px;
}
.msg-time { font-size: .7rem; color: var(--text-light); }

.chat-input-area {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  background: #fff;
  border-top: 1px solid var(--border);
}
.chat-input {
  flex: 1;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: 99px;
  font-size: .9rem;
  transition: border-color var(--transition);
}
.chat-input:focus { outline: none; border-color: var(--primary); }
.chat-send-btn {
  width: 40px; height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background var(--transition), transform .1s;
  flex-shrink: 0;
}
.chat-send-btn:hover { background: var(--primary-dark); }
.chat-send-btn:active { transform: scale(.93); }

/* ── Attend page ────────────────────────────────────────────────── */
.attend-layout {
  max-width: 780px;
  margin: 28px auto;
  padding: 0 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.visitor-info-card {
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: sticky;
  top: 60px;
  z-index: 90;
  box-shadow: var(--shadow-sm);
}
.visitor-info-card .left {
  display: flex;
  align-items: center;
  gap: 14px;
}
.visitor-avatar-lg {
  width: 52px; height: 52px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: 1.2rem;
  flex-shrink: 0;
}
.mode-selector {
  display: flex;
  gap: 6px;
  flex-wrap: nowrap;
}
.mode-btn {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: .78rem;
  font-weight: 600;
  color: var(--text-muted);
  background: #fff;
  transition: all var(--transition);
  flex: 1;
  justify-content: center;
  white-space: nowrap;
}
.mode-btn .mode-icon { font-size: 1rem; }
.mode-btn:hover, .mode-btn.active {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary);
}
.mode-btn.mode-unavailable {
  opacity: .4;
  cursor: not-allowed;
  text-decoration: line-through;
}
.mode-btn.mode-unavailable:hover {
  border-color: var(--border);
  background: #fff;
  color: var(--text-muted);
}

/* ── Video / Audio ──────────────────────────────────────────────── */
.media-section {
  background: #0F172A;
  border-radius: var(--radius);
  overflow: hidden;
  position: relative;
  min-height: 260px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.video-remote, .video-local {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.video-local-pip {
  position: absolute;
  bottom: 12px;
  right: 12px;
  width: 120px;
  border-radius: 10px;
  border: 2px solid rgba(255,255,255,.3);
  background: #1E293B;
}
.media-controls {
  display: flex;
  justify-content: center;
  gap: 12px;
  padding: 16px;
}
.media-btn {
  width: 46px; height: 46px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  font-size: 1.1rem;
  display: flex; align-items: center; justify-content: center;
  transition: all .15s;
}
.media-btn.on  { background: rgba(255,255,255,.12); color: #fff; }
.media-btn.off { background: var(--danger); color: #fff; }
.media-btn.end { background: var(--danger); color: #fff; width: 56px; height: 56px; }
.media-btn:hover { transform: scale(1.1); }

/* Waiting overlay */
.waiting-overlay {
  text-align: center;
  color: rgba(255,255,255,.8);
  padding: 40px;
}
.waiting-overlay .spinner {
  width: 48px; height: 48px;
  border: 3px solid rgba(255,255,255,.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Toast notificación ─────────────────────────────────────────── */
.notif-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--danger);
  color: #fff;
  font-size: .7rem;
  font-weight: 700;
}

/* ── Scrollbar ──────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #CBD5E1; border-radius: 99px; }

/* ── Animations ─────────────────────────────────────────────────── */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.fade-in { animation: fadeIn .25s ease; }

@keyframes ring-animation {
  0%, 100% { transform: rotate(0); }
  15%       { transform: rotate(18deg); }
  30%       { transform: rotate(-16deg); }
  45%       { transform: rotate(12deg); }
  60%       { transform: rotate(-8deg); }
  75%       { transform: rotate(4deg); }
}
.ring-anim { animation: ring-animation .6s ease; }

/* ── Responsive ─────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .auth-card { padding: 28px 20px; }
  .navbar { padding: 0 16px; }
  .visitor-info-card { flex-direction: column; align-items: flex-start; }
  .mode-selector { justify-content: center; width: 100%; }
}

/* ── Bottom navigation bar (mobile app) ─────────────────────────── */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: calc(62px + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: #fff;
  border-top: 1px solid var(--border);
  box-shadow: 0 -2px 12px rgba(0,0,0,.08);
  z-index: 300;
  flex-direction: row;
  align-items: stretch;
}
.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: .65rem;
  font-weight: 600;
  color: var(--text-muted);
  text-decoration: none;
  background: transparent;
  border: none;
  cursor: pointer;
  transition: color var(--transition);
  padding: 6px 4px 2px;
  -webkit-tap-highlight-color: transparent;
  line-height: 1;
}
.bottom-nav-item i { font-size: 1.2rem; line-height: 1; }
.bottom-nav-item > span:last-child { font-size: .62rem; margin-top: 2px; }
.bottom-nav-item.active { color: var(--primary); }
.bottom-nav-item:hover { text-decoration: none; color: var(--primary); }
.bottom-nav-icon {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
}

/* Punto rojo de notificación en el ícono de Visitas */
.bottom-notif-dot {
  position: absolute;
  top: -2px; right: -4px;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--danger);
  border: 2px solid #fff;
}

/* ── Mobile app layout ──────────────────────────────────────────── */
@media (max-width: 760px) {
  /* Espacio para el bottom nav + safe area iOS */
  body { padding-bottom: calc(62px + env(safe-area-inset-bottom, 0px)); }

  /* Mostrar bottom nav */
  .bottom-nav { display: flex; }

  /* Ocultar acciones del navbar en mobile (están en el bottom nav) */
  .navbar-actions { display: none; }
  .navbar-actions:has(.navbar-action-always) { display: flex; }
  .navbar-actions .navbar-action-always ~ *:not(.navbar-action-always) { display: none; }

  /* Logo QRing!: estático a la derecha en mobile */
  .navbar-qring { position: static; transform: none; height: 30px; margin-left: auto; }

  /* Tab switching: ocultar sección inactiva */
  .dashboard-section             { display: none !important; }
  .dashboard-section.mobile-active { display: block !important; }

  /* Invertir orden de columnas: visitas primero en mobile */
  #section-visits    { order: 1; }
  #section-doorbells { order: 2; }

  /* Grid en mobile: columna única */
  .dashboard-grid { grid-template-columns: 1fr; gap: 0; }

  /* Header más compacto */
  .page-header { display: none; }
  .page-header h1 { font-size: 1.2rem; }
  .page-header p  { display: none; }

  /* Stats: fila horizontal compacta */
  .stats-grid {
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 8px;
  }
  .stat-card {
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 12px 8px;
    gap: 6px;
  }
  .stat-icon { width: 36px; height: 36px; font-size: 1rem; }
  .stat-info h2 { font-size: 1.3rem; }
  .stat-info p  { font-size: .68rem; }

  /* Container: menos padding lateral */
  .container { padding: 0 12px; }
}

/* ── Audio call card ──────────────────────────────────────────────── */
.audio-call-card {
  background: linear-gradient(160deg, #1E293B 0%, #0F172A 100%);
  border-radius: var(--radius);
  padding: 16px 20px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  color: #fff;
}
.audio-call-identity {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
}
.audio-call-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.audio-call-avatar {
  width: 48px; height: 48px;
  flex-shrink: 0;
  border-radius: 50%;
  background: rgba(37,99,235,.2);
  border: 2px solid rgba(37,99,235,.4);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem;
  color: #93C5FD;
  font-weight: 700;
  position: relative;
}
.audio-call-avatar.speaking::after {
  content: '';
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  border: 2px solid rgba(37,99,235,.55);
  animation: audio-pulse .8s ease-out infinite;
}
@keyframes audio-pulse {
  0%   { transform: scale(1); opacity: .8; }
  100% { transform: scale(1.65); opacity: 0; }
}
.audio-call-name   { font-size: 1.05rem; font-weight: 600; color: #E2E8F0; }
.audio-call-status { font-size: .78rem; color: #94A3B8; }
.audio-bars {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 4px;
  height: 36px;
}
.audio-bar {
  width: 5px;
  background: linear-gradient(to top, #2563EB, #38BDF8);
  border-radius: 3px;
  height: 4px;
  min-height: 4px;
  transition: height .07s ease;
}
.audio-call-controls { display: flex; gap: 12px; margin-top: 4px; }

/* ── Modal llamada entrante ─────────────────────────────────────── */
.incoming-avatar {
  width: 80px; height: 80px; border-radius: 50%;
  background: linear-gradient(135deg, #2563EB, #0EA5E9);
  color: #fff; font-size: 2rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 4px;
  position: relative;
}
.incoming-avatar::before,
.incoming-avatar::after {
  content: '';
  position: absolute; inset: 0; border-radius: 50%;
  border: 2px solid rgba(37,99,235,.45);
  animation: incoming-ring 1.6s ease-out infinite;
}
.incoming-avatar::after { animation-delay: .8s; }
@keyframes incoming-ring {
  0%   { transform: scale(1);    opacity: .8; }
  100% { transform: scale(2.1);  opacity: 0; }
}

/* ── Storage options ─────────────────────────────────────────────── */
.storage-option {
  display: flex;
  align-items: center;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
}
.storage-option:has(input:checked) {
  border-color: var(--primary);
  background: var(--primary-light);
}
.storage-option input[type="radio"] { display: none; }
.storage-option-body {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}
.storage-option-body strong { display: block; font-size: .88rem; }
.storage-option-body span   { font-size: .76rem; color: var(--text-muted); }

/* ── Visit subtabs ───────────────────────────────────────────────── */
.visit-subtab {
  padding: 7px 16px;
  border: 1.5px solid var(--border);
  border-radius: 99px;
  background: #fff;
  color: var(--text-muted);
  font-size: .83rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  gap: 6px;
}
.visit-subtab.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

/* ── History items ───────────────────────────────────────────────── */
.history-item { border-bottom: 1px solid var(--border); }
.history-item:last-child { border-bottom: none; }
.history-item-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  cursor: pointer;
  transition: background var(--transition);
}
.history-item-header:hover { background: var(--bg); }
.history-item-header .fa-chevron-down {
  margin-left: auto;
  transition: transform .2s;
}
.history-item.open .history-item-header .fa-chevron-down {
  transform: rotate(180deg);
}
.history-item-body {
  display: none;
  padding: 0 20px 16px 20px;
}
.history-item.open .history-item-body { display: block; }
.history-item-meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  font-size: .76rem;
  color: var(--text-muted);
  margin-top: 3px;
}
.history-messages {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
  max-height: 240px;
  overflow-y: auto;
  padding: 4px 0;
}
.history-msg {
  padding: 8px 12px;
  border-radius: 12px;
  font-size: .85rem;
  max-width: 80%;
  word-break: break-word;
}
.history-msg.visitor {
  background: var(--primary);
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 3px;
}
.history-msg.host {
  background: #fff;
  border: 1px solid var(--border);
  color: var(--text);
  align-self: flex-start;
  border-bottom-left-radius: 3px;
}
.history-no-chat {
  font-size: .83rem;
  color: var(--text-muted);
  font-style: italic;
  margin: 8px 0 0;
}

/* ── GPS badge en doorbell-card ─────────────────────────────────── */
.gps-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: #D1FAE5;
  color: #059669;
  font-size: .65rem;
  flex-shrink: 0;
  margin-left: 2px;
}

/* ── GPS Location Check Screen ──────────────────────────────────── */
.gps-screen {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: linear-gradient(160deg, #1e3a8a 0%, #1D4ED8 45%, #0369a1 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 24px 20px;
  transition: opacity .45s ease;
}
.gps-screen.fading {
  opacity: 0;
  pointer-events: none;
}
.gps-screen-card {
  width: 100%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  align-items: center;
  color: #fff;
}

/* Pulsing location icon */
.gps-icon-ring {
  position: relative;
  width: 96px; height: 96px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 28px;
}
.gps-icon-inner {
  width: 96px; height: 96px;
  border-radius: 50%;
  background: rgba(255,255,255,.18);
  display: flex; align-items: center; justify-content: center;
  font-size: 2.4rem;
  position: relative;
  z-index: 1;
  transition: background .3s;
}
.gps-icon-inner.gps-success { background: rgba(16,185,129,.35); }
.gps-icon-inner.gps-error   { background: rgba(239,68,68,.35); }
.gps-pulse {
  position: absolute; inset: 0;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,.3);
  animation: gps-pulse-anim 2.2s ease-out infinite;
}
.gps-pulse-2 { animation-delay: .75s; }
.gps-pulse-3 { animation-delay: 1.5s; }
@keyframes gps-pulse-anim {
  0%   { transform: scale(1);   opacity: .9; }
  100% { transform: scale(2.6); opacity: 0; }
}

.gps-screen-card h1 {
  font-size: 1.4rem; font-weight: 800;
  margin: 0 0 4px;
  text-align: center;
}
.gps-doorbell-name {
  font-size: .88rem; opacity: .72;
  margin-bottom: 28px;
  text-align: center;
}

/* Info panel */
.gps-info-panel {
  width: 100%;
  background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 14px;
  padding: 20px;
  margin-bottom: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  backdrop-filter: blur(6px);
}
.gps-info-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.gps-info-row > i {
  font-size: 1rem;
  margin-top: 2px;
  flex-shrink: 0;
  opacity: .9;
}
.gps-info-row strong {
  display: block;
  font-size: .85rem;
  font-weight: 700;
  margin-bottom: 2px;
}
.gps-info-row span {
  font-size: .78rem;
  opacity: .8;
  line-height: 1.55;
}

/* CTA button */
.gps-share-btn {
  width: 100%;
  padding: 17px 24px;
  border: none;
  border-radius: 14px;
  background: #fff;
  color: #1D4ED8;
  font-size: 1rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: transform .15s, box-shadow .15s;
  box-shadow: 0 4px 24px rgba(0,0,0,.22);
}
.gps-share-btn:hover  { transform: translateY(-2px); box-shadow: 0 8px 32px rgba(0,0,0,.28); }
.gps-share-btn:active { transform: scale(.97); }
.gps-share-btn:disabled { opacity: .55; pointer-events: none; }
.gps-share-btn.gps-success-btn { background: #D1FAE5; color: #065F46; }
.gps-share-btn.gps-error-btn   { background: #FEE2E2; color: #B91C1C; }

.gps-hint {
  font-size: .78rem;
  opacity: .72;
  margin-top: 14px;
  text-align: center;
  line-height: 1.55;
  min-height: 20px;
}
.gps-hint.gps-hint-error {
  opacity: 1;
  color: #FCA5A5;
}

/* ring-content fade-in after GPS pass */
@keyframes ringContentIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Leaflet dentro de SweetAlert2 ──────────────────────────────── */
/* Corrige z-index de capas Leaflet para que queden dentro del modal */
.swal2-popup .leaflet-pane         { z-index: 1 !important; }
.swal2-popup .leaflet-tile-pane    { z-index: 2 !important; }
.swal2-popup .leaflet-overlay-pane { z-index: 4 !important; }
.swal2-popup .leaflet-marker-pane  { z-index: 6 !important; }
.swal2-popup .leaflet-popup-pane   { z-index: 8 !important; }
/* Permite que el contenido HTML del popup muestre el mapa correctamente */
.swal2-html-container { overflow: visible !important; }
