/* ============================================================
   CitasPro — estilos
   Paleta: teal primario, coral de acento, verde WhatsApp.
   Mobile-first, tarjetas blancas, bordes redondeados.
   ============================================================ */

:root {
  --teal: #0D9488;
  --teal-dark: #0F766E;
  --teal-light: #CCFBF1;
  --coral: #F97316;
  --coral-dark: #EA580C;
  --whatsapp: #25D366;
  --whatsapp-dark: #1DA851;
  --bg: #F8FAFC;
  --card: #FFFFFF;
  --texto: #0F172A;
  --texto-suave: #64748B;
  --borde: #E2E8F0;
  --rojo: #EF4444;
  --azul: #3B82F6;
  --gris: #94A3B8;
  --radius: 16px;
  --radius-sm: 12px;
  --sombra: 0 2px 10px rgba(15, 23, 42, 0.06);
  --sombra-modal: 0 20px 50px rgba(15, 23, 42, 0.25);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "Plus Jakarta Sans", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--texto);
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3 { margin: 0 0 4px; }
p { margin: 0 0 8px; }
button { font-family: inherit; }
a { color: var(--teal-dark); }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: none; border-radius: var(--radius-sm);
  padding: 12px 18px; font-size: 15px; font-weight: 600;
  cursor: pointer; transition: transform .05s, opacity .15s, background .15s;
  text-decoration: none;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-block { width: 100%; }
.btn-lg { padding: 14px 20px; font-size: 16px; }
.btn-sm { padding: 7px 12px; font-size: 13px; border-radius: 10px; }
.btn-primary { background: var(--teal); color: #fff; }
.btn-primary:hover { background: var(--teal-dark); }
.btn-ghost { background: #EEF2F6; color: var(--texto); }
.btn-ghost:hover { background: #E2E8F0; }
.btn-danger { background: #FEE2E2; color: #B91C1C; }
.btn-danger:hover { background: #FECACA; }
.btn-whatsapp { background: var(--whatsapp); color: #fff; }
.btn-whatsapp:hover { background: var(--whatsapp-dark); }

/* ---------- Login ---------- */
.pantalla-login, .pantalla-licencia {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px; background: linear-gradient(160deg, var(--teal) 0%, var(--teal-dark) 55%, #0b3b37 100%);
}
.login-card {
  background: var(--card); border-radius: 24px; padding: 36px 28px; max-width: 380px; width: 100%;
  text-align: center; box-shadow: var(--sombra-modal);
}
.login-logo { font-size: 48px; margin-bottom: 4px; }
.login-card h1 { font-size: 28px; font-weight: 800; color: var(--teal-dark); }
.login-sub { color: var(--texto-suave); margin-bottom: 22px; }
.login-card .btn { margin-bottom: 10px; }
.login-progreso { min-height: 18px; font-size: 13px; color: var(--texto-suave); }

.licencia-card {
  background: var(--card); border-radius: 24px; padding: 36px 28px; max-width: 420px; width: 100%;
  text-align: center; box-shadow: var(--sombra-modal);
}
.licencia-icono { font-size: 46px; }
.planes-grid { display: flex; gap: 12px; margin: 18px 0; }
.plan-card { flex: 1; background: var(--teal-light); border-radius: var(--radius-sm); padding: 14px; }
.plan-card b { display: block; color: var(--teal-dark); }
.plan-card span { font-weight: 700; font-size: 18px; }
.licencia-card .btn { margin-top: 8px; margin-bottom: 8px; width: 100%; }

/* ---------- App shell ---------- */
.app-shell { display: flex; flex-direction: column; min-height: 100vh; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--teal); color: #fff; padding: 14px 18px;
  position: sticky; top: 0; z-index: 20;
}
.topbar-brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 17px; }
.topbar-logo { font-size: 20px; }
.topbar-right { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.sync-label { opacity: .9; display: none; }
@media (min-width: 640px) { .sync-label { display: inline; } }
.sync-dot { width: 9px; height: 9px; border-radius: 50%; background: #4ADE80; box-shadow: 0 0 0 3px rgba(74,222,128,.25); }
.sync-dot.syncing { background: #FBBF24; box-shadow: 0 0 0 3px rgba(251,191,36,.25); }
.sync-dot.offline { background: #F87171; box-shadow: 0 0 0 3px rgba(248,113,113,.25); }
.avatar-user { width: 30px; height: 30px; border-radius: 50%; border: 2px solid rgba(255,255,255,.6); object-fit: cover; }
.avatar-user.grande { width: 56px; height: 56px; }

.vista { flex: 1; padding: 16px 16px 90px; max-width: 720px; margin: 0 auto; width: 100%; }

.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  display: flex; background: var(--card); border-top: 1px solid var(--borde);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  box-shadow: 0 -2px 12px rgba(15,23,42,.05);
}
.bottom-nav button {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: none; border: none; padding: 6px 2px; font-size: 11px; color: var(--texto-suave);
  border-radius: 10px; cursor: pointer;
}
.bottom-nav button.activo { color: var(--teal-dark); font-weight: 700; }
.nav-icono { font-size: 20px; }

/* ---------- Encabezados / tarjetas ---------- */
.pantalla-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.pantalla-header h2 { font-size: 20px; }
.card {
  background: var(--card); border-radius: var(--radius); padding: 16px;
  box-shadow: var(--sombra); margin-bottom: 14px;
}
.card-titulo { font-weight: 700; margin-bottom: 10px; font-size: 14px; color: var(--texto-suave); text-transform: uppercase; letter-spacing: .03em; }
.card-titulo-fila { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; font-weight: 700; }
.perfil-card { display: flex; align-items: center; gap: 12px; }

.btn-volver { background: none; border: none; color: var(--teal-dark); font-weight: 600; padding: 6px 0 14px; cursor: pointer; font-size: 14px; }

/* ---------- Buscador / inputs ---------- */
.input-buscar, .input {
  width: 100%; padding: 11px 14px; border: 1px solid var(--borde); border-radius: var(--radius-sm);
  font-size: 14px; margin-bottom: 12px; background: #fff; color: var(--texto);
}
.input-sm { padding: 7px 10px; margin-bottom: 0; font-size: 13px; }
textarea.input { resize: vertical; font-family: inherit; }
label { display: block; font-size: 13px; font-weight: 600; color: var(--texto-suave); margin-bottom: 4px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.check-linea { display: flex; align-items: center; gap: 8px; font-weight: 500; color: var(--texto); }
.check-linea input { width: auto; margin: 0; }

/* ---------- Lista de pacientes ---------- */
.lista-pacientes { display: flex; flex-direction: column; gap: 8px; }
.card-paciente { display: flex; align-items: center; gap: 12px; cursor: pointer; padding: 12px 14px; }
.card-paciente:active { background: #F1F5F9; }
.card-paciente-info { flex: 1; }
.card-paciente-nombre { font-weight: 700; }
.card-paciente-tel { font-size: 13px; color: var(--texto-suave); }

.avatar-inicial {
  width: 40px; height: 40px; border-radius: 50%; background: var(--teal-light); color: var(--teal-dark);
  display: flex; align-items: center; justify-content: center; font-weight: 800; flex-shrink: 0;
}
.avatar-inicial.grande { width: 56px; height: 56px; font-size: 22px; }
.ficha-header { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.ficha-sub { color: var(--texto-suave); font-size: 13px; }
.datos-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 6px; }
.datos-grid span { display: block; font-size: 12px; color: var(--texto-suave); }
.notas { background: #FFFBEB; border-radius: 10px; padding: 10px; font-size: 13px; }
.acciones-fila { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

/* ---------- Listas simples (citas, mensajes) ---------- */
.lista-simple { display: flex; flex-direction: column; gap: 8px; }
.fila-simple {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 12px; border-radius: 12px; background: #F8FAFC;
}
.fila-cita { cursor: pointer; }
.fila-cita:active { background: #F1F5F9; }
.fila-sub { font-size: 12px; color: var(--texto-suave); }
.fila-mensaje { align-items: flex-start; flex-direction: column; }
.texto-mensaje { background: #ECFDF5; border-radius: 10px; padding: 8px 10px; font-size: 13px; margin-top: 6px; white-space: pre-wrap; }
.muted { color: var(--texto-suave); font-size: 13px; }

/* ---------- Stats / dashboard ---------- */
.stats-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 14px; }
.stat-card { background: var(--card); border-radius: var(--radius-sm); padding: 14px; box-shadow: var(--sombra); text-align: center; }
.stat-num { font-size: 24px; font-weight: 800; color: var(--teal-dark); }
.stat-label { font-size: 12px; color: var(--texto-suave); }
.stat-alerta .stat-num { color: var(--coral-dark); }

/* ---------- Estado vacío ---------- */
.estado-vacio { text-align: center; padding: 26px 16px; color: var(--texto-suave); }
.estado-vacio-icono { font-size: 34px; margin-bottom: 6px; }

/* ---------- Tabs / chips ---------- */
.tabs-sub { display: flex; gap: 8px; margin-bottom: 14px; }
.tab-sub { flex: 1; background: var(--card); border: 1px solid var(--borde); border-radius: 10px; padding: 9px; font-weight: 600; color: var(--texto-suave); cursor: pointer; }
.tab-sub.activo { background: var(--teal); color: #fff; border-color: var(--teal); }
.chip-grupo { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { background: #F1F5F9; border: 1px solid transparent; border-radius: 999px; padding: 4px 6px; cursor: pointer; }
.chip-activo { border-color: var(--teal); }

.semana-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; font-weight: 600; font-size: 13px; }
.dia-semana.dia-hoy { border: 2px solid var(--teal); }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.badge-azul { background: #DBEAFE; color: #1D4ED8; }
.badge-teal { background: var(--teal-light); color: var(--teal-dark); }
.badge-verde { background: #DCFCE7; color: #15803D; }
.badge-gris { background: #F1F5F9; color: var(--texto-suave); }
.badge-rojo { background: #FEE2E2; color: #B91C1C; }

/* ---------- Modal ---------- */
.modal-host { position: fixed; inset: 0; z-index: 100; display: none; }
.modal-host.open { display: block; }
.modal-backdrop {
  position: absolute; inset: 0; background: rgba(15,23,42,.5);
  display: flex; align-items: flex-end; justify-content: center;
}
@media (min-width: 640px) { .modal-backdrop { align-items: center; } }
.modal-card {
  background: var(--card); width: 100%; max-width: 480px; max-height: 92vh; overflow-y: auto;
  border-radius: 20px 20px 0 0; padding: 20px; box-shadow: var(--sombra-modal);
}
@media (min-width: 640px) { .modal-card { border-radius: 20px; } }
.modal-header { margin-bottom: 12px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.modal-anuncio img { width: 100%; border-radius: 12px; margin-bottom: 10px; }

/* ---------- Toasts ---------- */
.toast-host { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: #1E293B; color: #fff; padding: 10px 18px; border-radius: 10px; font-size: 13px; box-shadow: var(--sombra-modal); animation: toast-in .18s ease-out; }
.toast.exito { background: var(--teal-dark); }
.toast.error { background: #B91C1C; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }

/* ---------- Admin ---------- */
.fila-admin-usuario { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 10px; border-radius: 10px; background: #F8FAFC; margin-bottom: 8px; }
.fila-admin-info { flex: 1 1 140px; }
