/* ==========================================================================
   Tappy — Design System "Organic Tech Narrative"
   Fuente de verdad visual: proyecto Google Stitch "Tappy NFC Business Platform"
   Rebranding de color:
     · Modo claro  → "Butter cream" (crema #FFF8E7 · naranja #FF6B35 · mostaza
       #F5C842 · chocolate #3D2000).
     · Modo oscuro / admin / franquicia → "Sunset neon" (fondo #1A0A00 ·
       naranja neón #FF6B35 · amarillo #FFAD00 · coral #FF3D6B · crema #FFF5E0).
   Tipografía Be Vietnam Pro + Inter.
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Be+Vietnam+Pro:wght@400;500;600;700&family=Inter:wght@400;500;600;700&display=swap');

:root {
  /* ---- Colores: superficies (Butter cream) ---- */
  --surface: #fff8e7;              /* fondo crema principal */
  --surface-dim: #f0e4c4;
  --surface-bright: #fffdf7;
  --surface-container-lowest: #ffffff;   /* tarjetas */
  --surface-container-low: #fef7e4;
  --surface-container: #fbf0d6;
  --surface-container-high: #f6e8c4;
  --surface-container-highest: #f1e0b4;

  /* ---- Colores: texto / contenido (chocolate) ---- */
  --on-surface: #3d2000;           /* chocolate (texto principal) */
  --on-surface-variant: #6b4a28;   /* texto secundario */
  --outline: #a9885e;              /* texto tenue / bordes fuertes */
  --outline-variant: #e7d3a6;      /* bordes suaves / divisores */

  /* ---- Colores: marca (Butter cream) ---- */
  --primary: #c4471a;              /* naranja quemado (texto/acento sobre crema) */
  --primary-container: #ff6b35;    /* naranja CTA (topbars, botones) */
  --on-primary: #ffffff;
  --on-primary-container: #ffe2d0;
  --primary-hover: #e2551f;        /* estado :active más oscuro */
  --secondary: #c79a1e;            /* mostaza oscura */
  --secondary-container: #fdefc0;  /* chips / badges suaves */
  --on-secondary-container: #5c3a00;
  --light-sage: #f5c842;           /* acento mostaza (nombre heredado) */
  --sage-tint: #fdf3d4;            /* fondo mostaza muy claro */

  /* ---- Acento cálido (mostaza) ---- */
  --accent-gold: #f5c842;          /* celebración: taps exitosos, logros */
  --accent-gold-soft: #fdefc0;

  /* ---- Gráficos (estilo Apple Stocks + escala de intensidad) ---- */
  --chart-line: #ff6b35;                     /* línea naranja */
  --chart-area-top: rgba(255, 107, 53, 0.2); /* relleno gradiente arriba */
  --chart-area-bottom: rgba(255, 107, 53, 0);/* relleno gradiente abajo */
  --chart-grid: rgba(61, 32, 0, 0.06);       /* grid horizontal tenue */
  --chart-grid-soft: rgba(61, 32, 0, 0.05);
  --chart-caption: #9a8767;                  /* fecha bajo el valor */
  --bar-high: #e2551f;                       /* barras: más taps = más intenso */
  --bar-mid-high: #ff6b35;
  --bar-mid: #f5a05a;
  --bar-low: #fadfa8;
  --toggle-bg: #f1e4c2;                      /* pista del selector de rango */
  --hm-empty: #f6ecce;                        /* celda vacía del heatmap */

  /* ---- Navegación inferior ---- */
  --border: #efe1be;                         /* borde sutil (nav, divisores) */
  --nav-active: #ff6b35;                     /* tab activo (naranja) */
  --nav-inactive: #9a8767;                   /* tab inactivo (texto secundario) */

  /* ---- Estados ---- */
  --success: #3e8e41;
  --success-container: #e3f2e0;
  --on-success-container: #245127;
  --error: #ba1a1a;
  --error-container: #fbeeec;
  --on-error-container: #93000a;

  /* ---- Radios (Soft Geometricism) ---- */
  --radius-sm: 8px;
  --radius: 12px;
  --radius-md: 16px;
  --radius-lg: 20px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  /* ---- Sombras (Tonal / tinte chocolate, difusas) ---- */
  --shadow-sm: 0 1px 4px rgba(61, 32, 0, 0.06);
  --shadow-md: 0 4px 16px rgba(61, 32, 0, 0.08);
  --shadow-lg: 0 20px 60px rgba(61, 32, 0, 0.12);

  /* ---- Tipografía ---- */
  --font-display: 'Be Vietnam Pro', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  /* ---- Espaciado (ritmo 8px) ---- */
  --space-unit: 8px;
  --space-gutter: 16px;
  --container-margin: 20px;

  /* ---- Transiciones ---- */
  --transition-fast: 0.15s ease;
  --transition: 0.25s ease;
}

/* --------------------------------------------------------------------------
   Aplicación global de tipografía del design system.
   Usa !important para ganar sobre los <style> embebidos de cada pantalla.
   -------------------------------------------------------------------------- */
body {
  font-family: var(--font-body) !important;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Roles de titular → Be Vietnam Pro (nombres de clase compartidos en la app) */
h1, h2, h3,
.topbar-title, .card-title, .stat-value, .nivel-name, .success-title,
.logo-name, .logo-letter, .section-title, .chart-title, .notif-title,
.topbar-title * {
  font-family: var(--font-display) !important;
}

/* Titulares con letra apretada y peso alto = confianza premium */
.topbar-title, .stat-value, .nivel-name, .success-title, .logo-name {
  letter-spacing: -0.01em;
}

/* Interacción táctil: los elementos presionables se "hunden" al tocarse */
button:active,
.btn:active, .btn-primary:active, .nfc-area:active,
.menu-item:active, .chip-card:active, .nav-item:active {
  transform: scale(0.985);
}

/* --------------------------------------------------------------------------
   Toques del design system (aplican por nombres de clase compartidos).
   -------------------------------------------------------------------------- */

/* Tarjetas: borde 1px mostaza al ~22% sobre la crema (Ambient Depth) */
.card, .stat-card, .chart-card, .menu-card, .info-card, .notif-card, .chip-card {
  border: 1px solid rgba(245, 200, 66, 0.22);
}

/* Anillo de foco naranja en inputs y selects */
input:focus, select:focus, textarea:focus {
  box-shadow: 0 0 0 3px rgba(255, 107, 53, 0.14);
}

/* Mostaza: resalta el progreso/logro (uso escaso, celebratorio) */
.nivel-bar {
  background: var(--accent-gold) !important;
}

/* --------------------------------------------------------------------------
   Navegación inferior — 3 tabs con íconos SVG (estilo Stitch).
   Centralizada aquí; las pantallas solo aportan el markup.
   -------------------------------------------------------------------------- */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  width: 100%;
  background: var(--surface-container-lowest, #ffffff);
  border-top: 1px solid var(--border, #efe1be);
  display: flex;
  padding: 8px 0 env(safe-area-inset-bottom, 8px);
  z-index: 50;
}
.bottom-nav .nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 4px 0;
  text-decoration: none;
  color: var(--nav-inactive, #9a8767);
  cursor: pointer;
}
.bottom-nav .nav-item svg {
  width: 24px;
  height: 24px;
  display: block;
}
.bottom-nav .nav-label {
  font-size: 11px;
  font-weight: 500;
}
.bottom-nav .nav-item.active {
  color: var(--nav-active, #ff6b35);
}

/* --------------------------------------------------------------------------
   Banner "Modo franquicia" — visible al ver una sede desde franchise.html.
   -------------------------------------------------------------------------- */
.franchise-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: linear-gradient(135deg, var(--primary-container, #ff6b35), var(--primary, #c4471a));
  color: #fff;
  padding: 10px 16px;
  font-size: 13px;
}
.franchise-banner strong { font-weight: 700; }
.franchise-banner button {
  background: rgba(255,255,255,0.2);
  border: none;
  color: #fff;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  font-family: inherit;
}

/* --------------------------------------------------------------------------
   Streak tracker (racha estilo Duolingo) — adaptado a la paleta sage.
   -------------------------------------------------------------------------- */
.streak-card {
  background: var(--surface-container-lowest, #fff);
  border-radius: var(--radius-md, 16px);
  padding: 18px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm, 0 1px 4px rgba(61,32,0,0.06));
}
.streak-main { display: flex; align-items: center; gap: 14px; }
.streak-flame { font-size: 40px; line-height: 1; }
.streak-number {
  font-size: 26px;
  font-weight: 700;
  color: var(--on-surface, #3d2000);
  font-family: var(--font-display, sans-serif);
  line-height: 1.1;
}
.streak-best { font-size: 13px; color: var(--chart-caption, #9a8767); margin-top: 2px; }
.streak-week {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  margin-top: 16px;
}
.streak-day { flex: 1; text-align: center; }
.streak-dot {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  margin: 0 auto 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: #fff;
}
.streak-dot.on { background: var(--success, #3e8e41); }
.streak-dot.off { background: var(--surface-container-highest, #f1e0b4); }
.streak-day-label { font-size: 10px; color: var(--chart-caption, #9a8767); }

/* ==========================================================================
   MODO OSCURO "Sunset neon" — activado con la clase html.tappy-dark (toggle
   en Cuenta) y por defecto en admin.html / franchise.html.
   Claro es el default; aquí solo se re-mapean superficies, texto y acentos.
   Fondo cálido casi negro + naranja neón / amarillo / coral.
   ========================================================================== */
html.tappy-dark {
  --surface: #1a0a00;
  --surface-container-lowest: #2a1200;
  --surface-container-low: #200d00;
  --surface-container: #200d00;
  --surface-container-high: #331a05;
  --surface-container-highest: #3d1f0a;
  --on-surface: #fff5e0;
  --on-surface-variant: #e0c4a0;
  --outline: #c9a88a;
  --outline-variant: #3d1f0a;
  --border: #3d1f0a;
  --nav-inactive: #c9a88a;
  --nav-active: #ff6b35;
  --toggle-bg: #3d1f0a;
  --primary: #ff6b35;
  --primary-container: #ff6b35;
  --on-primary: #1a0a00;
  --on-primary-container: #ffe2d0;
  --primary-hover: #ffad00;
  --secondary: #ffad00;
  --secondary-container: #3d1f0a;
  --on-secondary-container: #fff5e0;
  --light-sage: #ff6b35;
  --sage-tint: #331a05;
  --accent-gold: #ffad00;
  --accent-gold-soft: #331a05;
  --chart-line: #ff6b35;
  --chart-area-top: rgba(255, 107, 53, 0.28);
  --chart-area-bottom: rgba(255, 107, 53, 0);
  --chart-grid: rgba(255, 245, 224, 0.06);
  --chart-grid-soft: rgba(255, 245, 224, 0.05);
  --chart-caption: #c9a88a;
  --bar-high: #ff6b35;
  --bar-mid-high: #ff8c42;
  --bar-mid: #ffad00;
  --bar-low: #3d1f0a;
  --success: #4ade80;
  --error: #ff3d6b;
  --hm-empty: #4a2810;   /* más claro que la tarjeta (#2a1200) para que la celda vacía se vea */
}

/* Fondo y texto base */
html.tappy-dark body { background: #1a0a00 !important; color: #fff5e0; }

/* Tarjetas: blanco -> superficie oscura cálida */
html.tappy-dark .stat-card,
html.tappy-dark .chart-card,
html.tappy-dark .menu-card,
html.tappy-dark .info-card,
html.tappy-dark .notif-card,
html.tappy-dark .chip-card,
html.tappy-dark .streak-card,
html.tappy-dark .save-bar {
  background: #2a1200 !important;
  border-color: #3d1f0a !important;
  box-shadow: none !important;
}

/* Texto principal */
html.tappy-dark .stat-value,
html.tappy-dark .chart-title,
html.tappy-dark .menu-label,
html.tappy-dark .info-value,
html.tappy-dark .streak-number,
html.tappy-dark .notif-title,
html.tappy-dark .chip-slug,
html.tappy-dark .empty-text {
  color: #fff5e0 !important;
}

/* Texto secundario / tenue */
html.tappy-dark .stat-label,
html.tappy-dark .menu-sub,
html.tappy-dark .info-label,
html.tappy-dark .chip-url,
html.tappy-dark .loading,
html.tappy-dark .empty,
html.tappy-dark .empty-sub,
html.tappy-dark .streak-best,
html.tappy-dark .notif-sub,
html.tappy-dark .section-title,
html.tappy-dark .chart-subtitle,
html.tappy-dark .field-label {
  color: #c9a88a !important;
}

/* Navegación inferior */
html.tappy-dark .bottom-nav { background: #200d00 !important; border-top-color: #3d1f0a !important; }

/* Selector de rango (pill activo) */
html.tappy-dark .range-pill.active { background: #3d1f0a !important; color: #ff6b35 !important; }

/* Inputs / selects / textareas */
html.tappy-dark input,
html.tappy-dark select,
html.tappy-dark textarea,
html.tappy-dark select.styled-select {
  background: #200d00 !important;
  border-color: #3d1f0a !important;
  color: #fff5e0 !important;
}

/* Divisores internos */
html.tappy-dark .menu-item { border-bottom-color: #3d1f0a !important; }
html.tappy-dark .info-row { border-bottom-color: #3d1f0a !important; }

/* Íconos de chip */
html.tappy-dark .chip-icon.activo { background: #3d1f0a !important; }
html.tappy-dark .chip-icon.inactivo { background: #200d00 !important; }

/* Estilo iOS del switch de tema en Cuenta */
.theme-switch { position: relative; display: inline-block; width: 46px; height: 27px; flex-shrink: 0; }
.theme-switch input { opacity: 0; width: 0; height: 0; }
.theme-slider {
  position: absolute; cursor: pointer; inset: 0;
  background: var(--outline-variant, #e7d3a6); border-radius: 34px;
  transition: background 0.25s ease;
}
.theme-slider::before {
  content: ""; position: absolute; height: 23px; width: 23px; left: 2px; top: 2px;
  background: #fff; border-radius: 50%; transition: transform 0.25s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.theme-switch input:checked + .theme-slider { background: var(--primary-container, #ff6b35); }
.theme-switch input:checked + .theme-slider::before { transform: translateX(19px); }

/* --------------------------------------------------------------------------
   Pull-to-refresh — indicador circular con spinner sage.
   -------------------------------------------------------------------------- */
.ptr-indicator {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translate(-50%, -50px);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--surface-container-lowest, #fff);
  box-shadow: 0 2px 8px rgba(61, 32, 0, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  opacity: 0;
  pointer-events: none;
}
.ptr-indicator svg { width: 20px; height: 20px; color: var(--primary-container, #ff6b35); }
.ptr-indicator.spinning svg { animation: ptr-spin 0.8s linear infinite; }
@keyframes ptr-spin { to { transform: rotate(360deg); } }
