/**
 * ============================================================
 *  Latido Familiar - style.css (DOCUMENTADO)
 * ------------------------------------------------------------
 *  Este archivo define TODO el estilo visual de la webapp:
 *  - Paleta de colores (variables CSS en :root)
 *  - Tipografías y jerarquías (títulos, subtítulos, textos)
 *  - Layout (contenedor principal, grids responsivos)
 *  - Componentes (cards, botones, avatares, mensajes)
 *  - Interacciones y animaciones (hover, fade, slide, pop, bounce)
 *  - Elementos especiales:
 *      • Composer flotante (barra fija inferior)
 *      • Acordeones (historial)
 *      • Modales (ver mensaje y responder)
 *      • “Sobre sorpresa” para mensajes no leídos
 *      • Badges de notificación
 *      • Toast flotante (mensaje de éxito)
 *
 *  Nota importante (posible bug):
 *  - En `.msg-card.compact` usas `border-left: 4px solid var(--muted);`
 *    pero `--muted` NO existe en :root.
 *    → Lo correcto sería usar `var(--text-muted)` o crear `--muted`.
 * ============================================================
 */

:root {
  /* ==========================================================
   * VARIABLES GLOBALES (Paleta, tipografías, sombras, radios)
   * ----------------------------------------------------------
   * La idea: si cambias aquí, cambia la app completa.
   * ========================================================== */

  /* Fondo general */
  --bg-gradient: radial-gradient(circle at top left, #fff1eb, #ace0f9);
  --bg-body: #fdfbf7;

  /* Color primario (marca) */
  --primary: #7C3AED;        /* Violeta vibrante */
  --primary-soft: #EDE9FE;   /* Violeta suave (fondos, bordes) */
  --primary-hover: #6D28D9;  /* Violeta para hover */

  /* Texto */
  --text-main: #1F2937;      /* Texto principal */
  --text-muted: #6B7280;     /* Texto secundario */

  /* Acentos emocionales */
  --accent-warm: #F59E0B;    /* Ámbar */
  --accent-heart: #EF4444;   /* Rojo suave */

  /* Superficies */
  --card-bg: rgba(255, 255, 255, 0.95);

  /* Bordes redondeados */
  --radius-lg: 24px;
  --radius-md: 16px;

  /* Tipografías */
  --font-heading: 'Quicksand', sans-serif;
  --font-body: 'Nunito', sans-serif;

  /* Sombras */
  --shadow-soft: 0 10px 30px -5px rgba(0, 0, 0, 0.05);
  --shadow-float: 0 20px 40px -5px rgba(124, 58, 237, 0.15);
}

/* ============================================================
 * RESET / BASE
 * ============================================================ */
* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent; /* Quita destello azul en móvil al tocar */
}

body {
  margin: 0;
  font-family: var(--font-body);

  /* Fondo: aquí hay 2 backgrounds; el segundo SOBREESCRIBE el primero */
  background: var(--bg-body);
  background: linear-gradient(135deg, #fdfbfb 0%, #ebedee 100%);

  color: var(--text-main);
  min-height: 100vh;
}

/* ============================================================
 * ANIMACIONES GENERALES
 * ============================================================ */

/* Entrada suave (aparece y sube un poquito) */
@keyframes fadeInScale {
  from { opacity: 0; transform: scale(0.98) translateY(10px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* Clase utilitaria para animar entrada */
.animate-enter {
  animation: fadeInScale 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* ============================================================
 * CONTENEDORES PRINCIPALES
 * ============================================================ */

/* Fondo general centrado (estilo app) */
.app-root {
  min-height: 100vh;
  display: flex;
  justify-content: center;
  padding: 16px;
}

/* “Tarjeta grande” que contiene toda la app */
.app-shell {
  width: 100%;
  max-width: 900px;

  background: var(--card-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);

  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-float);

  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;

  border: 1px solid rgba(255,255,255,0.6);
  position: relative;
  overflow: visible;
}

/* ============================================================
 * HEADER (LOGO + INDICADOR DE ROL)
 * ============================================================ */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.logo-block {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}

/* Círculo del logo con gradiente cálido */
.logo-circle {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-warm), var(--accent-heart));
  color: white;

  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 22px;

  display: flex;
  align-items: center;
  justify-content: center;

  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
}

.logo-text-main {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 22px;
  color: var(--text-main);
  line-height: 1.1;
}

.logo-text-sub {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
}

/* Pastillita “Modo Santiago / Modo Abuelo...” */
.role-pill {
  background: var(--primary-soft);
  color: var(--primary);
  padding: 6px 14px;
  border-radius: 99px;
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.role-pill.hidden { display: none; }

/* ============================================================
 * TEXTOS / UTILIDADES
 * ============================================================ */
.title-main {
  font-family: var(--font-heading);
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 12px;
  color: #333;
}

.subtitle {
  font-size: 16px;
  color: var(--text-muted);
  line-height: 1.5;
  max-width: 500px;
  margin: 0 auto;
}

.centered { text-align: center; }
.hidden { display: none !important; }

/* ============================================================
 * CARDS
 * ============================================================ */
.card {
  background: #fff;
  border-radius: var(--radius-md);
  padding: 20px;
  box-shadow: var(--shadow-soft);
  border: 1px solid rgba(0,0,0,0.03);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

/* Hover sólo si el dispositivo soporta hover (desktop) */
@media(hover: hover) {
  .card.interactive:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 24px rgba(0,0,0,0.08);
  }
}

.section-title {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 18px;
  color: var(--text-main);
}

.section-sub {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 4px;
  line-height: 1.4;
}

/* ============================================================
 * BOTONES
 * ============================================================ */
.btn {
  border: none;
  border-radius: 12px;
  padding: 12px 20px;

  font-family: var(--font-body);
  font-weight: 700;
  font-size: 15px;

  cursor: pointer;
  transition: all 0.2s;

  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

/* Botón principal (acción fuerte) */
.btn-primary {
  background: var(--primary);
  color: white;
  box-shadow: 0 4px 12px rgba(124, 58, 237, 0.3);
}
.btn-primary:active { transform: scale(0.97); }
.btn-primary:hover { background: var(--primary-hover); }

/* Botón outline (secundario) */
.btn-outline {
  background: transparent;
  border: 2px solid var(--primary-soft);
  color: var(--primary);
}
.btn-outline:hover { background: var(--primary-soft); }

/* Botón “soft” (relleno suave) */
.btn-soft {
  background: var(--primary-soft);
  color: var(--primary);
}

.btn-full { width: 100%; }
.btn-sm { padding: 8px 14px; font-size: 13px; border-radius: 8px; }

/* Botón de texto (sutil, sin fondo) */
.btn-text {
  background: transparent;
  color: var(--text-muted);
  padding: 8px;
  font-size: 13px;
}
.btn-text:hover { color: var(--primary); text-decoration: underline; }

/* ============================================================
 * SELECCIÓN DE ROL (NIETO / ABUELO)
 * ============================================================ */
.roles-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  margin-top: 30px;
}
@media(min-width: 600px) {
  .roles-row { grid-template-columns: 1fr 1fr; }
}

.role-card {
  text-align: center;
  border: 2px solid transparent;
  cursor: pointer;
}
.role-card:hover { border-color: var(--primary-soft); }

.emoji-lg {
  font-size: 48px;
  margin-bottom: 10px;
  display: block;
}

/* ============================================================
 * LAYOUT PRINCIPAL (dos columnas en desktop)
 * ============================================================ */
.layout-split {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}
@media(min-width: 900px) {
  .layout-split { grid-template-columns: 1.5fr 1fr; }
}

/* ============================================================
 * AVATARES
 * ============================================================ */
.avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #e5e7eb;

  display: flex;
  align-items: center;
  justify-content: center;

  font-weight: 700;
  color: #fff;
  font-size: 18px;
}

/* Avatares de abuelos (gradiente azul) */
.avatar.ab { background: linear-gradient(135deg, #818cf8, #6366f1); }

/* ============================================================
 * TIMELINE / MENSAJES (ESTILO GENERAL)
 * ============================================================ */
.timeline {
  position: relative;
  padding-left: 20px;
  margin-top: 15px;
}
.timeline::before {
  content: '';
  position: absolute;
  left: 0;
  top: 10px;
  bottom: 10px;
  width: 2px;
  background: var(--primary-soft);
  border-radius: 2px;
}

/* Tarjeta de mensaje (completa) */
.msg-card {
  background: #fff;
  border: 1px solid #f3f4f6;
  border-radius: 12px;
  padding: 12px 16px;
  margin-bottom: 12px;
  position: relative;
  box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}

/* Puntito del timeline a la izquierda */
.msg-card::after {
  content: '';
  position: absolute;
  left: -25px;
  top: 20px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: white;
  border: 2px solid var(--primary);
}

.msg-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
  font-size: 12px;
  color: var(--text-muted);
}

.msg-text {
  font-size: 15px;
  line-height: 1.5;
  color: #374151;
}

/* ============================================================
 * COMPOSITOR FLOTANTE (barra inferior)
 * ============================================================ */
#composerBar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;

  padding: 16px;
  display: flex;
  justify-content: center;

  z-index: 100;
  pointer-events: none; /* “transparente” salvo el card interno */
}

#composerBar .card {
  width: 100%;
  max-width: 600px;

  pointer-events: auto;
  box-shadow: 0 -10px 30px rgba(0,0,0,0.1);

  animation: slideUp 0.3s ease-out;

  /* “Pegado” a la parte de abajo */
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}

/* Animación del compositor entrando desde abajo */
@keyframes slideUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

/* Textarea del compositor */
.textarea {
  width: 100%;
  border: 2px solid var(--primary-soft);
  border-radius: 12px;
  padding: 12px;

  font-family: var(--font-body);
  font-size: 16px;
  outline: none;
  transition: border-color 0.2s;

  margin-top: 10px;
}
.textarea:focus { border-color: var(--primary); }

/* ============================================================
 * VISTA ABUELO (Accesibilidad: textos y botones grandes)
 * ============================================================ */
.view-abuelo-container .section-title { font-size: 22px; }
.view-abuelo-container .msg-text { font-size: 18px; }
.view-abuelo-container .btn { font-size: 18px; padding: 16px; }

/* ============================================================
 * RECOMPENSA (Reto completado)
 * ============================================================ */
.card-celebration {
  background: linear-gradient(135deg, #10B981, #34D399) !important;
  color: white !important;
  text-align: center;
  border: none !important;
  animation: popIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.card-celebration .section-title,
.card-celebration .section-sub {
  color: white !important;
}

.badge-reward {
  background: rgba(255,255,255,0.2);
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: bold;
  margin-bottom: 10px;
  display: inline-block;
}

@keyframes popIn {
  0%   { transform: scale(0.9); opacity: 0; }
  100% { transform: scale(1);   opacity: 1; }
}

/* ============================================================
 * CHIPS DE DESTINATARIO (compositor)
 * ============================================================ */
.recipient-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.chip-recipient {
  padding: 6px 12px;
  border-radius: 20px;

  border: 1px solid var(--primary-soft);
  background: white;

  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;

  cursor: pointer;
  transition: all 0.2s;

  display: flex;
  align-items: center;
  gap: 6px;
}

/* Chip seleccionado */
.chip-recipient.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  box-shadow: 0 2px 5px rgba(124, 58, 237, 0.3);
}

/* Hover chip (no seleccionado) */
.chip-recipient:hover {
  background: var(--primary-soft);
  color: var(--primary);
}

/* Hover chip seleccionado */
.chip-recipient.active:hover {
  background: var(--primary-hover);
  color: white;
}

/* ============================================================
 * BAÚL (Cards compactas)
 * ============================================================ */
.msg-card.compact {
  padding: 10px;
  background: #f9fafb;

  /* ⚠️ POSIBLE BUG: --muted no existe */
  border-left: 4px solid var(--muted);

  display: flex;
  gap: 10px;
  align-items: center;
}

.msg-card.compact .msg-header { margin-bottom: 2px; }

/* Texto en modo compacto: una sola línea con elipsis */
.msg-card.compact .msg-text {
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}

.thumb-compact {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  object-fit: cover;
  background: #eee;
}

/* ============================================================
 * ACORDEÓN (historial)
 * ============================================================ */
.accordion {
  background-color: white;
  color: var(--text-main);
  cursor: pointer;

  padding: 18px 20px;
  width: 100%;

  border: none;
  text-align: left;
  outline: none;

  font-size: 18px;
  font-family: var(--font-heading);
  font-weight: 700;

  transition: 0.3s;

  border-radius: 16px;
  margin-bottom: 12px;

  display: flex;
  justify-content: space-between;
  align-items: center;

  box-shadow: 0 4px 6px rgba(0,0,0,0.05);
  border: 1px solid rgba(0,0,0,0.05);
}

.accordion:hover { background-color: #f9fafb; }

/* Estado abierto */
.accordion.active {
  background-color: var(--primary-soft);
  color: var(--primary);
  border-color: var(--primary-soft);

  /* “Pegado” al panel de abajo */
  border-bottom-left-radius: 4px;
  border-bottom-right-radius: 4px;
  margin-bottom: 0;
}

/* Ícono + / - al final */
.accordion:after {
  content: '\002B'; /* + */
  font-size: 24px;
  font-weight: bold;
  margin-left: 10px;
}
.accordion.active:after { content: "\2212"; /* - */ }

/* Panel colapsable */
.panel {
  padding: 0 16px;
  background-color: white;

  max-height: 0;     /* cerrado */
  overflow: hidden;

  transition: max-height 0.3s ease-out;
  margin-bottom: 12px;

  border-radius: 0 0 16px 16px;
  box-shadow: 0 4px 6px rgba(0,0,0,0.05);
}

.panel-content {
  padding-top: 16px;
  padding-bottom: 16px;

  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ============================================================
 * MODALES (overlay + tarjeta)
 * ============================================================ */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;

  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);

  display: flex;
  align-items: center;
  justify-content: center;

  z-index: 1000;
  animation: fadeIn 0.2s ease-out;
}

.modal-card {
  background: white;
  width: 90%;
  max-width: 400px;

  border-radius: 24px;
  padding: 24px;

  text-align: center;
  box-shadow: 0 20px 50px rgba(0,0,0,0.3);

  animation: scaleIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Grid de reacciones emoji */
.reaction-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
  margin: 20px 0;
}

/* Botón de emoji */
.btn-reaction {
  background: #f3f4f6;
  border: 2px solid transparent;
  border-radius: 16px;

  padding: 15px 0;
  font-size: 32px;

  cursor: pointer;
  transition: transform 0.1s;
}
.btn-reaction:active {
  transform: scale(0.9);
  background: var(--primary-soft);
  border-color: var(--primary);
}

/* Badge para mostrar respuesta del abuelo dentro de msg-card */
.reply-badge {
  background: #ECFDF5;
  color: #047857;
  padding: 8px 12px;
  border-radius: 12px;
  margin-top: 10px;
  font-size: 13px;

  display: flex;
  align-items: center;
  gap: 8px;

  border: 1px solid #A7F3D0;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes scaleIn { from { transform: scale(0.8); } to { transform: scale(1); } }

/* ============================================================
 * DOBLE CHECK (WhatsApp style)
 * ============================================================ */
.double-check {
  font-size: 14px;
  margin-left: 6px;
  letter-spacing: -3px; /* Juntar las palomitas */
  font-weight: bold;
}

.check-grey { color: #d1d5db; } /* No leído */
.check-blue { color: #34B7F1; } /* Leído */

/* ============================================================
 * Z-INDEX (capas)
 * ============================================================ */
#replyModal { z-index: 2000 !important; }
#viewMsgModal { z-index: 1500 !important; }

/* Botón cerrar grande en modales */
.btn-close-big {
  background: #f3f4f6;
  color: var(--text-muted);
  border: 1px solid #e5e7eb;
  font-weight: bold;

  margin-top: 15px;
  width: 100%;

  padding: 12px;
  border-radius: 12px;
  cursor: pointer;
}
.btn-close-big:hover {
  background: #e5e7eb;
  color: var(--text-main);
}

/* ============================================================
 * “SOBRE SORPRESA” (mensaje no leído del abuelo)
 * ============================================================ */
.msg-envelope {
  background: linear-gradient(135deg, #fff 0%, #f0fdf4 100%);
  border: 2px dashed #10B981;
  border-radius: 16px;

  padding: 20px;
  text-align: center;
  cursor: pointer;

  position: relative;
  box-shadow: 0 8px 15px rgba(16, 185, 129, 0.15);
  margin-bottom: 12px;

  transition: transform 0.2s;
  animation: float 3s ease-in-out infinite;
}

.msg-envelope:active { transform: scale(0.95); }

.envelope-icon {
  font-size: 40px;
  margin-bottom: 8px;
  display: block;
}

.stamp {
  position: absolute;
  top: 10px;
  right: 10px;

  width: 40px;
  height: 40px;

  border-radius: 50%;
  background: #e5e7eb;

  display: flex;
  align-items: center;
  justify-content: center;

  font-size: 10px;
  font-weight: bold;
  color: var(--text-muted);

  transform: rotate(15deg);
  border: 1px dotted #999;
}

.wax-seal {
  color: #EF4444;
  font-size: 28px;
  margin-top: 15px; /* espacio extra */
  text-shadow: 0 2px 4px rgba(0,0,0,0.2);
  filter: drop-shadow(0 4px 3px rgba(0,0,0,0.15));
}

/* Flotación suave */
@keyframes float {
  0%   { transform: translateY(0px); }
  50%  { transform: translateY(-5px); }
  100% { transform: translateY(0px); }
}

/* ============================================================
 * BADGES DE NOTIFICACIÓN (en menú)
 * ============================================================ */
.notification-badge {
  position: absolute;
  top: -10px;
  right: -10px;

  background: white;
  border-radius: 50%;

  width: 40px;
  height: 40px;

  display: flex;
  align-items: center;
  justify-content: center;

  font-size: 24px;

  box-shadow: 0 4px 10px rgba(0,0,0,0.2);
  z-index: 10;
  border: 2px solid white;
}

/* Corazón palpitando (urgencia suave) */
.pulse-heart {
  background: #FFFBEB;
  border-color: #F59E0B;
  animation: pulse 1.5s infinite;
}

/* Sobre rebotando (novedad / alegría) */
.bounce-envelope {
  background: #ECFDF5;
  border-color: #10B981;
  animation: bounce 2s infinite;
}

@keyframes pulse {
  0%   { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.7); }
  70%  { transform: scale(1.1);  box-shadow: 0 0 0 10px rgba(245, 158, 11, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(245, 158, 11, 0); }
}

@keyframes bounce {
  0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
  40% { transform: translateY(-10px); }
  60% { transform: translateY(-5px); }
}

/* ============================================================
 * BOTÓN SUSURRO (sutil, premium)
 * ============================================================ */
.btn-whisper {
  background: white;
  border: 1px solid var(--primary-soft);
  color: var(--primary);

  padding: 8px 20px;
  border-radius: 50px;

  font-size: 15px;
  font-weight: 600;
  cursor: pointer;

  transition: all 0.2s;

  display: inline-flex;
  align-items: center;
  gap: 8px;

  box-shadow: 0 2px 5px rgba(0,0,0,0.03);
  margin-top: 10px;
}

.btn-whisper:hover {
  background: var(--primary-soft);
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0,0,0,0.08);
}
.btn-whisper:active { transform: scale(0.98); }

/* ============================================================
 * TOAST (mensaje flotante de éxito)
 * ============================================================ */
.toast-notification {
  position: fixed;
  bottom: 30px;
  left: 50%;

  /* Entra desde abajo (translateY(20px)) */
  transform: translateX(-50%) translateY(20px);

  background: #10B981;
  color: white;
  padding: 12px 24px;
  border-radius: 50px;

  box-shadow: 0 4px 15px rgba(16, 185, 129, 0.4);

  font-weight: bold;
  font-size: 16px;

  z-index: 99999 !important;
  opacity: 0;
  visibility: hidden;

  transition: all 0.4s cubic-bezier(0.68, -0.55, 0.27, 1.55);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Clase “show” para hacerlo visible */
.toast-notification.show {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}
