/* ==========================================================================
   TUFRECUENCIA™ SAAS — COMMERCIAL DESIGN SYSTEM
   ========================================================================== */

:root {
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-subtle: #f1f5f9;
  --bg-card-hover: #ffffff;
  
  --primary-blue: #0284c7;
  --primary-blue-soft: rgba(2, 132, 199, 0.08);
  --accent-emerald: #059669;
  --accent-gold: #d97706;
  --accent-purple: #7c3aed;
  
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-subtle: #94a3b8;
  
  --border-card: #e2e8f0;
  --border-focus: #38bdf8;
  
  --shadow-soft: 0 4px 20px -2px rgba(15, 23, 42, 0.05);
  --shadow-hover: 0 10px 30px -4px rgba(2, 132, 199, 0.12);
  
  --radius-xl: 20px;
  --radius-lg: 14px;
  --radius-md: 8px;
  
  --font-heading: 'Space Grotesk', -apple-system, sans-serif;
  --font-body: 'Plus Jakarta Sans', 'Inter', -apple-system, sans-serif;
}

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

html, body {
  max-width: 100vw;
  overflow-x: hidden;
}

body {
  background-color: var(--bg-main);
  background-image: 
    radial-gradient(ellipse at 10% 0%, rgba(224, 242, 254, 0.7) 0%, transparent 50%),
    radial-gradient(ellipse at 90% 100%, rgba(240, 253, 244, 0.7) 0%, transparent 50%);
  color: var(--text-main);
  font-family: var(--font-body);
  min-height: 100vh;
  padding-bottom: 90px;
  -webkit-font-smoothing: antialiased;
}

.app-container {
  max-width: 1140px;
  margin: 0 auto;
  padding: 20px 16px;
}

/* ==========================================================================
   HEADER COMERCIAL PRINCIPAL
   ========================================================================== */
.main-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 22px;
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-soft);
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 12px;
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-badge-icon {
  font-size: 1.8rem;
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, #e0f2fe 0%, #dcfce7 100%);
  border: 1px solid #bae6fd;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.logo-area h1 {
  font-family: var(--font-heading);
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--text-main);
}

.logo-subtitle {
  font-size: 0.78rem;
  color: var(--text-muted);
  display: block;
}

.pro-tag-pill {
  background: linear-gradient(135deg, var(--primary-blue), #0284c7);
  color: #ffffff;
  font-size: 0.65rem;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 6px;
  letter-spacing: 0.5px;
}

.header-user-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.device-status-badge {
  font-size: 0.76rem;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 20px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid transparent;
}

.badge-free {
  background: #f1f5f9;
  color: #475569;
  border-color: #cbd5e1;
}

.badge-pro {
  background: #e0f2fe;
  color: #0369a1;
  border-color: #7dd3fc;
}

.badge-quantum {
  background: #f3e8ff;
  color: #6b21a8;
  border-color: #d8b4fe;
}

.btn-sound-test {
  background: #f8fafc;
  color: var(--text-main);
  border: 1px solid var(--border-card);
  cursor: pointer;
}

.btn-install-pwa {
  background: #dcfce7;
  color: #15803d;
  border: 1px solid #86efac;
  cursor: pointer;
  animation: pulseGreen 2s infinite;
}

@keyframes pulseGreen {
  0% { transform: scale(1); }
  50% { transform: scale(1.03); }
  100% { transform: scale(1); }
}

.btn-icon-link {
  background: transparent;
  border: 1px solid var(--border-card);
  padding: 6px 10px;
  border-radius: var(--radius-md);
  font-size: 0.8rem;
  cursor: pointer;
  color: var(--text-muted);
}

/* HERO CARD */
.hero-commercial-card {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  color: #ffffff;
  border-radius: var(--radius-xl);
  padding: 24px 28px;
  margin-bottom: 20px;
  box-shadow: 0 10px 25px -5px rgba(15, 23, 42, 0.2);
}

.hero-eyebrow {
  color: #38bdf8;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.hero-title {
  font-family: var(--font-heading);
  font-size: 1.6rem;
  margin: 6px 0 10px;
  font-weight: 700;
}

.hero-desc {
  color: #94a3b8;
  font-size: 0.88rem;
  line-height: 1.5;
  max-width: 720px;
  margin-bottom: 16px;
}

.hero-badges-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.hero-chip {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.74rem;
  color: #e2e8f0;
}

/* NAVEGACIÓN EN TABS */
.nav-tabs {
  display: flex;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  padding: 6px;
  border-radius: var(--radius-lg);
  margin-bottom: 24px;
  box-shadow: var(--shadow-soft);
}

.nav-tab {
  flex: 1;
  padding: 10px 14px;
  border: none;
  background: transparent;
  border-radius: var(--radius-md);
  font-family: var(--font-heading);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
}

.nav-tab.active {
  background: var(--primary-blue);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(2, 132, 199, 0.25);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* BOTONES Y FORMULARIOS */
.btn-primary {
  background: var(--primary-blue);
  color: #ffffff;
  border: none;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  font-family: var(--font-heading);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease;
}

.btn-primary:hover {
  background: #0369a1;
}

.btn-secondary {
  background: var(--bg-card-subtle);
  color: var(--text-main);
  border: 1px solid var(--border-card);
  padding: 10px 18px;
  border-radius: var(--radius-md);
  font-family: var(--font-heading);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

/* LANDING PAGE ESTILOS */
.landing-hero {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  color: #ffffff;
  padding: 48px 32px;
  border-radius: var(--radius-xl);
  text-align: center;
  margin-bottom: 32px;
}

.landing-title {
  font-family: var(--font-heading);
  font-size: 2.2rem;
  font-weight: 800;
  margin-bottom: 12px;
}

.landing-subtitle {
  color: #94a3b8;
  font-size: 1.05rem;
  max-width: 680px;
  margin: 0 auto 24px;
  line-height: 1.6;
}

.landing-cta-group {
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
}

.landing-features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  margin-bottom: 36px;
}

.feature-card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-soft);
}

.feature-icon {
  font-size: 2.2rem;
  margin-bottom: 12px;
}

/* MODAL Y FORMULARIOS */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 16px;
}

.modal-card {
  background: #ffffff;
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 480px;
  padding: 28px;
  position: relative;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
}

.auth-form-group {
  margin-bottom: 16px;
}

.auth-form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-main);
}

.auth-form-group input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border-card);
  border-radius: var(--radius-md);
  font-size: 0.9rem;
}

.auth-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #dc2626;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  font-size: 0.8rem;
  margin-bottom: 12px;
}

/* TARJETAS DE CATALOGO */
.program-card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: var(--shadow-soft);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.program-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
}

.card-locked {
  opacity: 0.85;
  background: #f8fafc;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.card-title {
  font-family: var(--font-heading);
  font-size: 1.05rem;
  margin-bottom: 6px;
}

.card-desc {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.4;
  margin-bottom: 14px;
}

.card-meta {
  display: flex;
  gap: 12px;
  font-size: 0.75rem;
  color: var(--text-subtle);
  margin-bottom: 14px;
}

.card-actions {
  display: flex;
  gap: 8px;
}

.lock-pill {
  background: #f3e8ff;
  color: #6b21a8;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
}

.hz-tag {
  background: #e0f2fe;
  color: #0369a1;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
}

.paywall-modal-card {
  max-width: 820px;
}

.paywall-plans-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.paywall-plan-card {
  background: #ffffff;
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  box-shadow: var(--shadow-soft);
}

.paywall-plan-card.plan-pro {
  border: 2px solid var(--primary-blue);
}

.popular-ribbon {
  position: absolute;
  top: -12px;
  right: 16px;
  background: var(--primary-blue);
  color: #ffffff;
  font-size: 0.65rem;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 10px;
}

.plan-card-header h3 {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  margin: 8px 0 4px;
}

.plan-price {
  font-family: var(--font-heading);
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 6px;
}

.plan-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.plan-features-list {
  list-style: none;
  margin-bottom: 20px;
}

.plan-features-list li {
  font-size: 0.78rem;
  color: var(--text-main);
  margin-bottom: 8px;
  display: flex;
  align-items: flex-start;
  gap: 6px;
  line-height: 1.35;
}

.check-icon {
  color: #10b981;
  font-weight: 800;
}

.btn-plan-action {
  width: 100%;
  padding: 10px;
  border-radius: var(--radius-md);
  font-family: var(--font-heading);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  border: none;
}

.btn-upgrade {
  background: var(--primary-blue);
  color: #ffffff;
}

.btn-coming-soon {
  background: #e2e8f0;
  color: #64748b;
  cursor: not-allowed;
}

.btn-current {
  background: #e2e8f0;
  color: #64748b;
  cursor: default;
}

.security-guarantee {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
}

.modal-close-btn {
  position: absolute;
  top: 14px;
  right: 18px;
  background: transparent;
  border: none;
  font-size: 1.8rem;
  color: var(--text-muted);
  cursor: pointer;
}

.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--border-card);
  display: flex;
  justify-content: space-around;
  padding: 8px 4px;
  z-index: 1000;
}

.bottom-nav-item {
  background: transparent;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  color: var(--text-muted);
  font-size: 0.68rem;
  font-weight: 600;
  cursor: pointer;
}

.bottom-nav-item.active {
  color: var(--primary-blue);
}

.nav-icon {
  font-size: 1.2rem;
}

.mobile-only-nav {
  display: none;
}

@media (max-width: 768px) {
  .desktop-nav { display: none; }
  .mobile-only-nav { display: flex; }
  .main-header { padding: 14px 16px; }
  .logo-area h1 { font-size: 1.15rem; }
  .hero-commercial-card { padding: 18px; }
  .hero-title { font-size: 1.3rem; }
  .landing-title { font-size: 1.6rem; }
}

.hidden { display: none !important; }

/* ===================================================================
   LOTE 1 — Correcciones de responsive y accesibilidad
   Reemplazan los estilos inline que antes quedaban fuera del alcance
   de los media queries (causa real del desbordamiento en móvil).
   =================================================================== */

.auto-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}
.auto-grid--controls {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  margin-bottom: 20px;
}
.auto-grid--stats {
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

/* Scroller horizontal de chips con indicador visual de que hay más */
.chip-scroller {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  overflow-x: auto;
  padding-bottom: 6px;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
  mask-image: linear-gradient(to right, #000 88%, transparent 100%);
}

/* Objetivo táctil mínimo accesible (44x44) */
.nav-tab,
.bottom-nav-item,
.filter-chip,
.preset-chip,
.timer-chip,
button {
  min-height: 44px;
}

/* Avisos de seguridad del modal legal */
.safety-notes {
  margin: 14px 0 0;
  padding-left: 18px;
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.6;
}
.safety-notes li { margin-bottom: 6px; }

/* --- Móvil mediano: los grids pasan a una sola columna --- */
@media (max-width: 620px) {
  .auto-grid,
  .auto-grid--controls,
  .landing-features-grid,
  .paywall-plans-grid {
    grid-template-columns: 1fr;
  }
  .auto-grid--stats {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* --- Móvil pequeño (320-400px): faltaba por completo --- */
@media (max-width: 400px) {
  .app-container { padding: 16px 12px; }
  .main-header { flex-direction: column; align-items: flex-start; gap: 12px; }
  .header-user-actions { width: 100%; flex-wrap: wrap; gap: 8px; }
  .landing-title { font-size: 1.5rem; line-height: 1.25; }
  .landing-cta-group { display: flex; flex-direction: column; gap: 10px; }
  .landing-cta-group button { width: 100%; }
  .modal-card { padding: 20px 16px; }
  .plan-price { font-size: 1.25rem; }
  .auto-grid--stats { grid-template-columns: 1fr; }
}

/* Respetar la preferencia de movimiento reducido del sistema */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
