/* ============================================================
   Cuida a quien te cuidó — Estilos mobile-first
   ============================================================ */

:root {
  --color-principal: #2e7d9e;
  --color-suave: #e8f4f8;
  --color-acento: #f07d3a;
  --color-verde: #4caf7d;
  --color-rojo: #e05252;
  --color-amarillo: #f5c842;
  --color-texto: #2c3e50;
  --color-gris: #8e99a3;
  --color-fondo: #f4f6f8;
  --color-blanco: #ffffff;
  --radio: 14px;
  --radio-sm: 8px;
  --sombra: 0 2px 12px rgba(0,0,0,0.10);
  --sombra-fuerte: 0 4px 24px rgba(0,0,0,0.16);
  --fuente: 'Segoe UI', Arial, sans-serif;
  --tam-base: 17px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: var(--tam-base); -webkit-tap-highlight-color: transparent; }

body {
  font-family: var(--fuente);
  background: var(--color-fondo);
  color: var(--color-texto);
  min-height: 100vh;
  max-width: 480px;
  margin: 0 auto;
  position: relative;
  padding-bottom: 80px; /* espacio para nav inferior */
}

/* ===== CABECERA ===== */
.cabecera {
  background: linear-gradient(135deg, #1e40af 0%, #3b82f6 100%);
  color: white;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
  position: sticky;
  top: 0;
  z-index: 50;
}

.cabecera .btn-volver {
  background: none;
  border: none;
  color: var(--color-blanco);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radio-sm);
  display: none;
}

.cabecera .btn-volver.visible { display: block; }

.cabecera h1 {
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: -0.025em;
}

.cabecera .icono-cabecera { font-size: 1.4rem; }

/* ===== NAVEGACIÓN INFERIOR ===== */
.nav-inferior {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: white;
  border-top: 1px solid hsl(214.3 31.8% 91.4%);
  display: flex;
  justify-content: space-around;
  padding: 8px 0 12px;
  box-shadow: 0 -4px 6px -1px rgba(0,0,0,0.05);
  z-index: 40;
  max-width: 390px;
  margin: 0 auto;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
  color: #94a3b8;
  font-size: 0.65rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: none;
  border: none;
}

.nav-item.activo {
  color: #3b82f6;
  background: #eff6ff;
}

.nav-item .nav-icono {
  font-size: 1.25rem;
}

/* ===== PANTALLAS (vistas) ===== */
.pantalla {
  display: none;
  padding: 16px;
  animation: fadeIn 0.2s ease;
}

.pantalla.activa { display: block; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ===== INICIO / DASHBOARD ===== */
.dashboard-saludo {
  background: linear-gradient(135deg, var(--color-principal), #1a5f7a);
  color: white;
  border-radius: var(--radio);
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: var(--sombra);
}

.dashboard-saludo h2 { font-size: 1.3rem; margin-bottom: 4px; }
.dashboard-saludo p { font-size: 0.9rem; opacity: 0.85; }

.modulos-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.modulo-card {
  background: white;
  border-radius: 12px;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  text-align: center;
  width: 100%;
  border: none;
}

.modulo-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
  border-color: #3b82f6;
}

.modulo-card .mod-icono {
  font-size: 2rem;
  line-height: 1;
}

.modulo-card .mod-nombre {
  font-size: 0.875rem;
  font-weight: 600;
  color: #1e293b;
}

.modulo-card .mod-desc {
  font-size: 0.75rem;
  color: #64748b;
}

.modulo-card.pendiente {
  opacity: 0.6;
  cursor: not-allowed;
}

.modulo-card.pendiente:hover {
  transform: none;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

/* ===== TARJETA PERFIL ===== */
.perfil-card {
  background: var(--color-blanco);
  border-radius: var(--radio);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--sombra);
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  transition: box-shadow 0.2s;
}

.perfil-card:active { box-shadow: var(--sombra-fuerte); }

.perfil-avatar {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--color-suave);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  flex-shrink: 0;
  overflow: hidden;
  border: 2px solid var(--color-principal);
}

.perfil-avatar img { width: 100%; height: 100%; object-fit: cover; }

.perfil-info h3 { font-size: 1rem; font-weight: 700; }
.perfil-info p { font-size: 0.82rem; color: var(--color-gris); }

/* ===== FORMULARIOS ===== */
.form-grupo {
  margin-bottom: 16px;
}

.form-grupo label {
  display: block;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--color-principal);
  margin-bottom: 6px;
}

.form-grupo input,
.form-grupo textarea,
.form-grupo select {
  width: 100%;
  padding: 13px 14px;
  border: 2px solid #dde4ea;
  border-radius: var(--radio-sm);
  font-size: 1rem;
  font-family: var(--fuente);
  background: var(--color-blanco);
  color: var(--color-texto);
  transition: border-color 0.2s;
  -webkit-appearance: none;
}

.form-grupo input:focus,
.form-grupo textarea:focus,
.form-grupo select:focus {
  outline: none;
  border-color: var(--color-principal);
}

.form-grupo textarea { min-height: 90px; resize: vertical; }

/* Zona de foto */
.foto-zona {
  border: 2px dashed var(--color-principal);
  border-radius: var(--radio);
  padding: 20px;
  text-align: center;
  cursor: pointer;
  background: var(--color-suave);
  transition: background 0.2s;
  position: relative;
}

.foto-zona:active { background: #d0e8f0; }
.foto-zona input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.foto-zona .foto-preview { width: 100%; border-radius: var(--radio-sm); display: none; }
.foto-zona .foto-icono { font-size: 2.5rem; display: block; margin-bottom: 6px; }
.foto-zona .foto-texto { font-size: 0.85rem; color: var(--color-gris); }

/* ===== BOTONES ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 22px;
  border-radius: var(--radio);
  font-size: 1rem;
  font-weight: 700;
  font-family: var(--fuente);
  cursor: pointer;
  border: none;
  transition: transform 0.15s, opacity 0.2s;
  text-decoration: none;
}

.btn:active { transform: scale(0.97); }

.btn-principal {
  background: var(--color-principal);
  color: white;
  width: 100%;
}

.btn-acento {
  background: var(--color-acento);
  color: white;
  width: 100%;
}

.btn-verde {
  background: var(--color-verde);
  color: white;
  width: 100%;
}

.btn-rojo {
  background: var(--color-rojo);
  color: white;
}

.btn-secundario {
  background: var(--color-suave);
  color: var(--color-principal);
  border: 2px solid var(--color-principal);
  width: 100%;
}

.btn-icono {
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radio-sm);
  color: var(--color-texto);
}

.btn-sm {
  padding: 8px 14px;
  font-size: 0.85rem;
  width: auto;
}

/* ===== FAB (botón flotante añadir) ===== */
.fab {
  position: fixed;
  bottom: 88px;
  right: 50%;
  transform: translateX(calc(50% + 140px));
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: var(--color-acento);
  color: white;
  font-size: 1.8rem;
  border: none;
  cursor: pointer;
  box-shadow: var(--sombra-fuerte);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99;
  transition: transform 0.2s, box-shadow 0.2s;
}

.fab:active { transform: translateX(calc(50% + 140px)) scale(0.92); }

/* ===== TARJETA MEDICAMENTO ===== */
.med-card {
  background: var(--color-blanco);
  border-radius: var(--radio);
  padding: 14px;
  margin-bottom: 12px;
  box-shadow: var(--sombra);
  cursor: pointer;
  transition: box-shadow 0.2s;
}

.med-card:active { box-shadow: var(--sombra-fuerte); }

.med-card-cabecera {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.med-foto {
  width: 56px;
  height: 56px;
  border-radius: var(--radio-sm);
  object-fit: cover;
  background: var(--color-suave);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  flex-shrink: 0;
  overflow: hidden;
}

.med-foto img { width: 100%; height: 100%; object-fit: cover; }

.med-info { flex: 1; min-width: 0; }
.med-info h3 { font-size: 1rem; font-weight: 700; }
.med-info .med-lab { font-size: 0.78rem; color: var(--color-gris); }
.med-info .med-pa { font-size: 0.82rem; color: var(--color-principal); font-weight: 600; }
.med-info .med-dosis { font-size: 0.85rem; margin-top: 4px; }

.med-alerta {
  background: #fff3cd;
  border-left: 4px solid var(--color-amarillo);
  border-radius: var(--radio-sm);
  padding: 8px 12px;
  font-size: 0.82rem;
  margin-top: 8px;
  color: #7a5c00;
}

.med-alerta.roja {
  background: #fde8e8;
  border-color: var(--color-rojo);
  color: #7a0000;
}

/* ===== BÚSQUEDA CIMA ===== */
.cima-resultado {
  background: var(--color-suave);
  border-radius: var(--radio-sm);
  padding: 12px;
  margin-bottom: 8px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color 0.2s;
}

.cima-resultado:active,
.cima-resultado.seleccionado { border-color: var(--color-principal); }

.cima-resultado h4 { font-size: 0.9rem; font-weight: 700; }
.cima-resultado p { font-size: 0.78rem; color: var(--color-gris); }

/* ===== SECCIÓN / ACORDEÓN ===== */
.seccion {
  background: var(--color-blanco);
  border-radius: var(--radio);
  margin-bottom: 14px;
  box-shadow: var(--sombra);
  overflow: hidden;
}

.seccion-cabecera {
  padding: 14px 16px;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--color-principal);
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.seccion-cabecera .seccion-icono { font-size: 1.2rem; }
.seccion-cabecera .flecha { margin-left: auto; transition: transform 0.3s; }
.seccion-cabecera.abierta .flecha { transform: rotate(180deg); }

.seccion-cuerpo {
  padding: 0 16px;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.35s ease, padding 0.3s;
}

.seccion-cuerpo.abierto {
  max-height: 1000px;
  padding: 0 16px 16px;
}

/* ===== BADGE / ETIQUETA ===== */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 700;
}

.badge-verde { background: #e6f7ee; color: #1e7f4c; }
.badge-amarillo { background: #fff8e1; color: #7a5c00; }
.badge-rojo { background: #fde8e8; color: #c0392b; }
.badge-azul { background: var(--color-suave); color: var(--color-principal); }

/* ===== MODAL ===== */
.modal-fondo {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 200;
  align-items: flex-end;
  justify-content: center;
}

.modal-fondo.visible { display: flex; }

.modal-cuerpo {
  background: var(--color-blanco);
  border-radius: var(--radio) var(--radio) 0 0;
  padding: 20px 16px 32px;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

.modal-handle {
  width: 40px;
  height: 4px;
  background: #dde4ea;
  border-radius: 2px;
  margin: 0 auto 16px;
}

.modal-titulo {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--color-principal);
}

/* ===== SELECTOR DE PERFIL ===== */
.selector-perfil {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 8px;
  margin-bottom: 16px;
  scrollbar-width: none;
}

.selector-perfil::-webkit-scrollbar { display: none; }

.selector-perfil .chip-perfil {
  flex-shrink: 0;
  background: var(--color-suave);
  border: 2px solid transparent;
  border-radius: 40px;
  padding: 8px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.2s;
}

.selector-perfil .chip-perfil.activo {
  border-color: var(--color-principal);
  color: var(--color-principal);
}

/* ===== VACÍO ===== */
.vacio {
  text-align: center;
  padding: 40px 20px;
  color: var(--color-gris);
}

.vacio .vacio-icono { font-size: 3.5rem; display: block; margin-bottom: 12px; }
.vacio p { font-size: 0.95rem; }

/* ===== ESTADO PENDIENTE (módulos no desarrollados) ===== */
.pantalla-pendiente {
  text-align: center;
  padding: 50px 24px;
}

.pantalla-pendiente .pendiente-icono { font-size: 4rem; display: block; margin-bottom: 16px; }
.pantalla-pendiente h2 { font-size: 1.3rem; color: var(--color-principal); margin-bottom: 8px; }
.pantalla-pendiente p { color: var(--color-gris); font-size: 0.92rem; line-height: 1.6; }

/* ===== UTILIDADES ===== */
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.gap-8 { gap: 8px; }
.w-full { width: 100%; }
.texto-gris { color: var(--color-gris); }
.texto-sm { font-size: 0.82rem; }
.texto-centro { text-align: center; }
.negrita { font-weight: 700; }
.separador { height: 1px; background: #eee; margin: 12px 0; }

/* ===== SPINNER ===== */
.spinner {
  display: inline-block;
  width: 22px;
  height: 22px;
  border: 3px solid rgba(255,255,255,0.4);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.cargando-texto {
  text-align: center;
  color: var(--color-gris);
  padding: 20px;
  font-size: 0.9rem;
}

/* ===== TOAST ===== */
.toast {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #2c3e50;
  color: white;
  padding: 12px 20px;
  border-radius: 30px;
  font-size: 0.9rem;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s, transform 0.3s;
  z-index: 300;
  white-space: nowrap;
  max-width: 90vw;
  text-align: center;
}

.toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast.exito { background: var(--color-verde); }
.toast.error { background: var(--color-rojo); }

/* ===== ACCIONES DE TARJETA ===== */
.acciones-tarjeta {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  justify-content: flex-end;
}

/* ===== BUSCADOR ===== */
.buscador {
  position: relative;
  margin-bottom: 14px;
}

.buscador input {
  width: 100%;
  padding: 12px 14px 12px 40px;
  border: 2px solid #dde4ea;
  border-radius: 40px;
  font-size: 1rem;
  font-family: var(--fuente);
  background: var(--color-blanco);
}

.buscador input:focus { outline: none; border-color: var(--color-principal); }

.buscador .buscador-icono {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.1rem;
  color: var(--color-gris);
  pointer-events: none;
}
