/* ============================================================
   DulceVaso Premium — Design System v4
   Inspiración: Apple Fitness + Revolut + YNAB
   Modo oscuro como predeterminado
   ============================================================ */

/* ---------- TOKENS ---------- */
:root {
  /* Paleta light (fallback) */
  --primary: #FF3F8E;
  --primary-2: #FF7BB7;
  --primary-light: rgba(255,63,142,0.10);
  --primary-glow: rgba(255,63,142,0.22);
  --accent: #D98E32;
  --danger: #EF4444;
  --ok: #22C55E;

  --bg-color: #F5F0F7;
  --bg-2: #EDE6F0;
  --card-bg: #FFFFFF;
  --card-bg-2: #F9F5FB;
  --text-main: #1A0F1E;
  --text-muted: #7A6882;
  --border: rgba(0,0,0,0.08);
  --glass-bg: rgba(255,255,255,0.78);
  --glass-border: rgba(255,255,255,0.6);

  --shadow-sm: 0 2px 8px rgba(26,15,30,0.06);
  --shadow: 0 4px 16px rgba(26,15,30,0.08);
  --shadow-lg: 0 12px 32px rgba(26,15,30,0.12);

  --radius-sm: 12px;
  --radius-md: 18px;
  --radius-lg: 26px;
}

/* ---------- MODO OSCURO (predeterminado del app) ---------- */
[data-theme="dark"] {
  --bg-color: #120912;
  --bg-2: #1B1020;
  --card-bg: #1B1020;
  --card-bg-2: #221528;
  --text-main: #F0EAF4;
  --text-muted: #B9AFC1;
  --border: rgba(255,255,255,0.08);
  --glass-bg: rgba(27,16,32,0.85);
  --glass-border: rgba(255,255,255,0.07);

  --primary-light: rgba(255,63,142,0.12);
  --primary-glow: rgba(255,63,142,0.18);
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.3);
  --shadow: 0 4px 16px rgba(0,0,0,0.4);
  --shadow-lg: 0 12px 32px rgba(0,0,0,0.55);
}

/* ---------- RESET & BASE ---------- */
*, *::before, *::after {
  margin: 0; padding: 0; box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}
html { color-scheme: dark light; }
body {
  font-family: -apple-system, 'Inter', system-ui, sans-serif;
  background: var(--bg-color);
  color: var(--text-main);
  font-size: 16px;
  line-height: 1.5;
  transition: background .3s, color .3s;
  -webkit-font-smoothing: antialiased;
}
.title-serif { font-family: Georgia, 'Times New Roman', serif; font-weight: 700; letter-spacing: -.3px; }
.font-number { font-variant-numeric: tabular-nums; letter-spacing: -.5px; }
.mb-2 { margin-bottom: 16px; } .mt-4 { margin-top: 32px; } .hidden { display: none !important; }

/* ---------- AUTH ---------- */
.auth-screen {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: center; padding: 24px;
  background: var(--bg-color);
}
[data-theme="dark"] .auth-screen { background: radial-gradient(ellipse at 50% 0%, #2A1030 0%, #120912 60%); }
.auth-overlay { position: absolute; inset: 0; background: radial-gradient(circle at 60% 15%, rgba(255,63,142,0.10), transparent 55%); }
.auth-content { position: relative; width: 100%; max-width: 420px; text-align: center; }
.auth-subtitle { color: var(--text-muted); font-size: 15px; margin-bottom: 24px; font-weight: 500; }

/* ---------- LAYOUT ---------- */
.app-container {
  max-width: 560px; margin: 0 auto; min-height: 100vh;
  padding-bottom: calc(88px + env(safe-area-inset-bottom));
}

/* ---------- HEADER ---------- */
header {
  position: sticky; top: 0; z-index: 40;
  display: grid; grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 8px 20px env(safe-area-inset-top);
  padding-top: max(8px, env(safe-area-inset-top));
  background: var(--glass-bg);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
}
.header-left { display: flex; flex-direction: column; justify-content: center; }
.header-saudacao { font-size: 14px; font-weight: 700; color: var(--text-main); line-height: 1.2; }
.header-data { font-size: 11px; font-weight: 600; color: var(--text-muted); margin-top: 1px; }
.header-logo { justify-self: center; }
.header-logo img { height: 44px; width: auto; object-fit: contain; border-radius: 10px; }
.header-actions { display: flex; justify-content: flex-end; align-items: center; gap: 8px; }
.btn-icon {
  width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--border);
  background: var(--card-bg); color: var(--text-main); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: transform .15s;
}
.btn-icon:active { transform: scale(.92); }

main { padding: 16px 20px; }
.vista { display: none; }
.vista.activa { display: block; animation: entrar .18s ease-out; }
@keyframes entrar { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .vista.activa { animation: none; } }

/* ---------- DASH HERO ---------- */
.dash-hero {
  position: relative; overflow: hidden;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px 22px 0;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
}
[data-theme="dark"] .dash-hero {
  background: linear-gradient(160deg, #1E1128 0%, #150D1C 100%);
}
.dash-label {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 1.8px; color: var(--text-muted); text-align: center;
}
.dash-value {
  font-size: 46px; font-weight: 800; color: var(--text-main);
  margin: 2px 0 10px; text-align: center; line-height: 1.1;
}
.dash-meta-pct {
  text-align: center; font-size: 13px; font-weight: 700;
  color: var(--text-muted); margin-bottom: 4px;
}
.dash-meta-pct b { color: var(--primary); }
.dash-progress-wrap {
  height: 5px; background: var(--border); border-radius: 99px;
  overflow: hidden; margin: 6px 0 14px;
}
.dash-progress-bar {
  height: 100%; width: 0%; border-radius: 99px;
  background: linear-gradient(90deg, var(--primary), var(--primary-2));
  transition: width .6s cubic-bezier(.4,0,.2,1);
}

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px; font-weight: 700; padding: 4px 11px;
  border-radius: 99px; background: var(--primary-light); color: var(--primary);
}
.badge-accent { background: rgba(217,142,50,0.12); color: var(--accent); }
/* Glow SOLO en celebraciones/logros */
.badge-glow { box-shadow: 0 0 16px var(--primary-glow); }

/* ---------- CARDS ---------- */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 14px;
}
.card-glass {
  background: var(--glass-bg);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--glass-border);
}
/* Premium: borde sutil, sin glow en reposo */
.card-premium {
  border: 1px solid rgba(255,63,142,0.18);
  background: var(--card-bg-2);
}
[data-theme="dark"] .card-premium {
  background: linear-gradient(135deg, #1E1028 0%, #180D20 100%);
  border-color: rgba(255,63,142,0.14);
}
.item-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 0; border-bottom: 1px solid var(--border);
}
.item-row:last-child { border-bottom: none; }
.item-row .title { font-weight: 700; font-size: 15px; }
.item-row .subtitle, .subtitle { font-size: 13px; color: var(--text-muted); font-weight: 600; }
.item-row .amount, .amount { font-weight: 800; }
.amount.pos { color: var(--ok); }

/* ---------- SEMANA CARD ---------- */
.semana-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 10px; margin-top: 10px;
}
.semana-stat { text-align: center; }
.semana-stat .val { font-size: 18px; font-weight: 800; color: var(--text-main); }
.semana-stat .lbl { font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .8px; margin-top: 2px; }

/* ---------- MOVIMENTOS ---------- */
.mov-row {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 0; border-bottom: 1px solid var(--border);
}
.mov-row:last-child { border-bottom: none; }
.mov-emoji {
  width: 38px; height: 38px; border-radius: 12px;
  background: var(--primary-light); font-size: 18px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.mov-info { flex: 1; min-width: 0; }
.mov-nome { font-weight: 700; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mov-data { font-size: 12px; color: var(--text-muted); font-weight: 600; margin-top: 1px; }
.mov-valor { font-weight: 800; color: var(--ok); font-size: 15px; white-space: nowrap; }
.mov-actions { display: flex; gap: 2px; }
.mov-btn {
  background: none; border: none; cursor: pointer; font-size: 16px;
  padding: 8px; opacity: .55; min-width: 44px; min-height: 44px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 12px; transition: all .15s;
}
.mov-btn:hover { opacity: .85; background: var(--primary-light); }
.mov-btn:active { opacity: 1; transform: scale(.88); background: var(--primary-light); }

/* ---------- INPUTS / BOTONES ---------- */
.input-group { margin-bottom: 14px; text-align: left; }
.input-group label {
  display: block; font-size: 11.5px; font-weight: 700;
  color: var(--text-muted); margin-bottom: 6px;
  text-transform: uppercase; letter-spacing: .7px;
}
.input-group input, .input-group select, .input-group textarea {
  width: 100%; padding: 13px 14px; font-size: 16px; font-weight: 600;
  font-family: inherit; color: var(--text-main);
  background: var(--bg-color); border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); transition: border .15s, background .15s;
}
.input-group input:focus, .input-group textarea:focus {
  outline: none; border-color: var(--primary); background: var(--card-bg);
}
.input-costo input { border-left: 4px solid var(--accent); }
.input-venta input { border-left: 4px solid var(--ok); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.btn {
  display: block; width: 100%; min-height: 52px;
  padding: 14px 20px; border: none; border-radius: var(--radius-sm);
  font-family: inherit; font-size: 16px; font-weight: 800;
  cursor: pointer; transition: transform .12s, box-shadow .15s, opacity .15s;
  letter-spacing: .2px;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: .5; cursor: wait; }

/* CTA principal — Venta Rápida: ÚNICO con glow */
.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, #E0307A 100%);
  color: #FFF;
  box-shadow: 0 4px 18px var(--primary-glow);
  animation: pulso 2.8s ease-in-out infinite;
}
.btn-primary:active {
  animation: none;
  box-shadow: 0 2px 8px var(--primary-glow);
}
@keyframes pulso {
  0%, 100% { box-shadow: 0 4px 18px var(--primary-glow); }
  50% { box-shadow: 0 4px 28px rgba(255,63,142,0.38); }
}
.btn-secondary {
  background: var(--card-bg); color: var(--text-main);
  border: 1.5px solid var(--border);
  box-shadow: var(--shadow-sm);
}

/* ---------- CHIPS ---------- */
.chips-container {
  display: flex; gap: 8px; overflow-x: auto;
  padding-bottom: 10px; margin-bottom: 8px; scrollbar-width: none;
}
.chips-container::-webkit-scrollbar { display: none; }
.chip {
  flex-shrink: 0; padding: 8px 16px; border-radius: 99px;
  border: 1.5px solid var(--border); background: var(--card-bg);
  color: var(--text-muted); font-weight: 700; font-size: 13.5px;
  font-family: inherit; cursor: pointer; transition: all .15s;
}
.chip.active {
  background: var(--primary); border-color: var(--primary);
  color: #FFF; box-shadow: none; /* sin glow en chips */
}

/* ---------- RECETA CARDS ---------- */
.receta-card { display: flex; gap: 14px; align-items: center; cursor: pointer; transition: transform .12s; }
.receta-card:active { transform: scale(.98); }
.receta-card img { width: 80px; height: 80px; border-radius: 14px; object-fit: cover; flex-shrink: 0; background: var(--border); }
.receta-card .info { flex: 1; min-width: 0; }
.receta-card h3 { font-size: 16px; margin-bottom: 2px; }
.receta-card .meta { font-size: 13px; color: var(--text-muted); font-weight: 600; margin-bottom: 6px; }
.receta-card .lucro-pill {
  display: inline-block; font-size: 12px; font-weight: 800; color: var(--ok);
  background: rgba(34,197,94,0.12); padding: 3px 9px; border-radius: 99px;
}

/* ---------- VIEW FULL (receta) ---------- */
.view-full {
  position: fixed; inset: 0; z-index: 200;
  background: var(--bg-color); overflow-y: auto;
  transform: translateY(100%); transition: transform .26s cubic-bezier(.32,.72,.35,1);
  visibility: hidden;
}
.view-full.open { transform: translateY(0); visibility: visible; }
.hero-image { width: 100%; height: 280px; object-fit: cover; display: block; }
.view-content { padding: 22px 20px 80px; max-width: 560px; margin: 0 auto; }
.btn-close {
  position: fixed; top: max(16px, env(safe-area-inset-top)); left: 16px;
  z-index: 210; width: 44px; height: 44px; border-radius: 50%; border: none;
  background: var(--glass-bg); backdrop-filter: blur(12px);
  color: var(--text-main); display: flex; align-items: center;
  justify-content: center; cursor: pointer; box-shadow: var(--shadow);
}
.btn-close:active { transform: scale(.92); }
.check-item {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 11px 0; border-bottom: 1px dashed var(--border);
  cursor: pointer; font-size: 14.5px; color: var(--text-muted); font-weight: 600;
}
.check-item:last-child { border-bottom: none; }
.check-item .box {
  flex-shrink: 0; width: 24px; height: 24px; border-radius: 8px;
  border: 2px solid var(--border); display: flex; align-items: center;
  justify-content: center; color: transparent; font-size: 14px; margin-top: 1px;
  transition: all .15s;
}
.check-item.done { color: var(--text-muted); text-decoration: line-through; opacity: .6; }
.check-item.done .box { background: var(--ok); border-color: var(--ok); color: #FFF; }
.roteiro-card {
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: 14px; padding: 14px 16px; margin-bottom: 10px;
  font-size: 14px; color: var(--text-muted); font-weight: 500;
}
.roteiro-card b {
  color: var(--text-main); display: block; margin-bottom: 4px;
  font-size: 12px; text-transform: uppercase; letter-spacing: .8px;
}

/* ---------- NAV INFERIOR ---------- */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 90;
  display: flex;
  background: var(--glass-bg);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
  padding: 4px 8px calc(6px + env(safe-area-inset-bottom));
}
.nav-item {
  flex: 1; min-height: 58px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; background: none; border: none; border-radius: 14px;
  font-family: inherit; font-size: 11px; font-weight: 700;
  color: var(--text-muted); cursor: pointer; transition: color .15s;
  padding: 8px 4px;
}
.nav-item svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.nav-item.active { color: var(--primary); }
.nav-item.active svg { stroke: var(--primary); }
.nav-item:active { background: var(--primary-light); }

/* ---------- TOAST / MODAL ---------- */
.toast {
  position: fixed; left: 50%; bottom: 110px;
  transform: translateX(-50%) translateY(16px);
  z-index: 500; display: flex; gap: 8px; align-items: center;
  background: var(--text-main); color: var(--bg-color);
  font-weight: 700; font-size: 14px; padding: 12px 20px;
  border-radius: 99px; opacity: 0; pointer-events: none;
  transition: all .22s; box-shadow: var(--shadow-lg);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.modal-overlay {
  position: fixed; inset: 0; z-index: 400;
  background: rgba(10,5,14,0.65); backdrop-filter: blur(6px);
  display: flex; align-items: flex-end; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
.modal-overlay.open { opacity: 1; pointer-events: auto; }
.modal-sheet {
  width: 100%; max-width: 560px;
  background: var(--card-bg); border-radius: 26px 26px 0 0;
  padding: 24px 20px calc(24px + env(safe-area-inset-bottom));
  transform: translateY(40px); transition: transform .25s cubic-bezier(.32,.72,.35,1);
}
.modal-overlay.open .modal-sheet { transform: translateY(0); }
.modal-sheet h3 { margin-bottom: 16px; font-size: 19px; }

/* ---------- INVENTARIO ---------- */
.inv-item { display: flex; justify-content: space-between; align-items: center; padding: 11px 0; border-bottom: 1px solid var(--border); }
.inv-item:last-child { border-bottom: none; }
.inv-item .nome { font-weight: 700; font-size: 14.5px; }
.inv-item .low { color: var(--danger); font-size: 12px; font-weight: 800; }
.inv-qty { display: flex; gap: 10px; align-items: center; }
.inv-qty button { width: 34px; height: 34px; border-radius: 10px; border: 1.5px solid var(--border); background: var(--bg-color); color: var(--text-main); font-size: 18px; font-weight: 800; cursor: pointer; }
.inv-qty .q { min-width: 30px; text-align: center; font-weight: 800; }

/* ---------- GRÁFICO ---------- */
#grafico-meta { display: block; width: 100%; }
#grafico-tooltip {
  position: absolute; pointer-events: none; opacity: 0;
  transition: opacity .12s;
  background: var(--text-main); color: var(--bg-color);
  font-size: 11px; font-weight: 700; padding: 4px 9px;
  border-radius: 8px; white-space: nowrap; transform: translate(-50%, -130%);
}

/* ---------- CELEBRACIÓN (meta alcanzada) ---------- */
@keyframes celebrar {
  0% { transform: scale(1); }
  40% { transform: scale(1.08); box-shadow: 0 0 40px var(--primary-glow); }
  100% { transform: scale(1); }
}
.celebrando { animation: celebrar .5s ease-out; }

/* Estilos huérfanos mantenidos para no romper nada */
.progress-container { height: 10px; background: var(--border); border-radius: 99px; overflow: hidden; margin-bottom: 18px; }
.progress-bar { height: 100%; width: 0%; background: linear-gradient(90deg,var(--primary),var(--primary-2)); border-radius: 99px; transition: width .5s ease; }
.sparkline { display: none; }

/* ---------- BANNER PWA ---------- */
@keyframes subirBanner {
  from { transform: translateY(100%); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
#pwa-banner { animation: subirBanner .32s cubic-bezier(.32,.72,.35,1); }

/* ---------- BARRA DE BÚSQUEDA ---------- */
.search-bar {
  position: relative;
}
.search-bar input {
  width: 100%; padding: 13px 14px 13px 44px; font-size: 15px; font-weight: 600;
  font-family: inherit; color: var(--text-main);
  background: var(--card-bg); border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); transition: border .15s, background .15s, box-shadow .15s;
}
.search-bar input:focus {
  outline: none; border-color: var(--primary); background: var(--card-bg);
  box-shadow: 0 0 0 3px var(--primary-light);
}
.search-bar input::placeholder { color: var(--text-muted); font-weight: 500; }
.search-icon {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  color: var(--text-muted); pointer-events: none;
}
