/* ==========================================================
   Farmacia Central — UI inspirada en React Bits
   (Aurora, ShinyText, GradientText, SplitText, SpotlightCard,
    CountUp, glassmorphism) en CSS/JS puro
   ========================================================== */

:root {
  --bg: #05060f;
  --surface: rgba(255, 255, 255, 0.04);
  --surface-hover: rgba(255, 255, 255, 0.07);
  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.18);
  --text: #eef0ff;
  --muted: #8b90b0;
  --accent-1: #5eead4;   /* teal  */
  --accent-2: #818cf8;   /* indigo */
  --accent-3: #e879f9;   /* fuchsia */
  --success: #34d399;
  --warning: #fbbf24;
  --danger: #fb7185;
  --radius: 20px;
  --radius-sm: 12px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  color-scheme: dark;
}

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

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }

/* ---------- Aurora background ---------- */
.aurora {
  position: fixed;
  inset: 0;
  z-index: -2;
  overflow: hidden;
  pointer-events: none;
}
.aurora span {
  position: absolute;
  width: 60vmax;
  height: 60vmax;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.35;
  mix-blend-mode: screen;
  animation: aurora-drift 22s ease-in-out infinite alternate;
}
.aurora span:nth-child(1) { background: var(--accent-1); top: -25vmax; left: -15vmax; }
.aurora span:nth-child(2) { background: var(--accent-2); top: -10vmax; right: -20vmax; animation-delay: -7s; animation-duration: 26s; }
.aurora span:nth-child(3) { background: var(--accent-3); bottom: -35vmax; left: 20vmax; animation-delay: -12s; animation-duration: 30s; opacity: 0.22; }

@keyframes aurora-drift {
  0%   { transform: translate(0, 0) scale(1); }
  50%  { transform: translate(8vmax, 6vmax) scale(1.15); }
  100% { transform: translate(-6vmax, 10vmax) scale(0.95); }
}

/* Rejilla sutil + grano encima del aurora */
.grid-overlay {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255,255,255,0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.035) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(ellipse at 50% 0%, #000 30%, transparent 75%);
}

/* ---------- Layout ---------- */
.container {
  width: min(1200px, 100% - 2.5rem);
  margin-inline: auto;
}

/* ---------- Navbar ---------- */
.nav {
  position: sticky;
  top: 0;
  z-index: 50;
  padding-block: 14px;
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  background: rgba(5, 6, 15, 0.55);
  border-bottom: 1px solid var(--border);
}
.nav .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 1.1rem;
  letter-spacing: -0.02em;
}
.brand-logo {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--accent-1), var(--accent-2) 55%, var(--accent-3));
  box-shadow: 0 6px 24px -6px rgba(129, 140, 248, 0.7);
}
.brand-logo svg { width: 20px; height: 20px; color: #05060f; }
.nav-links { display: flex; gap: 6px; }
.nav-link {
  padding: 8px 14px;
  border-radius: 999px;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.9rem;
  transition: color .2s, background .2s;
}
.nav-link:hover,
.nav-link.active { color: var(--text); background: var(--surface-hover); }

main { padding-block: 48px 80px; }

/* ---------- Texto: GradientText / ShinyText / SplitText ---------- */
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  font-size: 0.8rem;
  font-weight: 600;
}
.eyebrow .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.7);
  animation: pulse 2s infinite;
}
@keyframes pulse {
  70%  { box-shadow: 0 0 0 9px rgba(52, 211, 153, 0); }
  100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0); }
}

.shiny-text {
  color: transparent;
  background: linear-gradient(110deg, #9aa0c3 35%, #ffffff 50%, #9aa0c3 65%);
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  animation: shine 4s linear infinite;
}
@keyframes shine { from { background-position: 100% 0; } to { background-position: -100% 0; } }

.gradient-text {
  color: transparent;
  background: linear-gradient(90deg, var(--accent-1), var(--accent-2), var(--accent-3), var(--accent-1));
  background-size: 300% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  animation: gradient-flow 8s ease infinite;
}
@keyframes gradient-flow {
  0%, 100% { background-position: 0% 50%; }
  50%      { background-position: 100% 50%; }
}

.hero { margin-bottom: 40px; }
.hero h1 {
  margin: 18px 0 12px;
  font-size: clamp(2.2rem, 5.5vw, 4rem);
  line-height: 1.05;
  font-weight: 800;
  letter-spacing: -0.045em;
}
.hero p { max-width: 560px; margin: 0; color: var(--muted); font-size: 1.05rem; }
.hero-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
}

/* SplitText: cada letra se envuelve en <span class="char"> desde JS */
.split .char {
  display: inline-block;
  opacity: 0;
  transform: translateY(0.6em) rotate(4deg);
  filter: blur(6px);
  animation: char-in .8s var(--ease) forwards;
  animation-delay: calc(var(--i) * 28ms);
}
.split .char.space { width: 0.28em; }
@keyframes char-in { to { opacity: 1; transform: none; filter: blur(0); } }

/* Elementos que aparecen al hacer scroll (AnimatedContent / FadeContent) */
.reveal {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity .7s var(--ease), transform .7s var(--ease);
  transition-delay: var(--delay, 0ms);
}
.reveal.in { opacity: 1; transform: none; }

/* ---------- Botones ---------- */
.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 20px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 700;
  font-size: 0.92rem;
  cursor: pointer;
  overflow: hidden;
  transition: transform .2s var(--ease), background .2s, border-color .2s, box-shadow .2s;
}
.btn:hover { transform: translateY(-2px); background: var(--surface-hover); }
.btn:active { transform: translateY(0) scale(0.98); }
.btn svg { width: 18px; height: 18px; }

.btn-primary {
  border-color: transparent;
  background: linear-gradient(135deg, var(--accent-1), var(--accent-2) 60%, var(--accent-3));
  color: #05060f;
  box-shadow: 0 10px 30px -10px rgba(129, 140, 248, 0.8);
}
.btn-primary:hover { background: linear-gradient(135deg, var(--accent-1), var(--accent-2) 60%, var(--accent-3)); box-shadow: 0 14px 40px -10px rgba(129, 140, 248, 1); }
/* Brillo que cruza el botón (StarBorder / shine) */
.btn-primary::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, transparent 30%, rgba(255,255,255,0.55) 50%, transparent 70%);
  transform: translateX(-120%);
  transition: transform .8s var(--ease);
}
.btn-primary:hover::after { transform: translateX(120%); }

.btn-danger {
  border-color: rgba(251, 113, 133, 0.45);
  background: rgba(251, 113, 133, 0.14);
  color: #ffd1d9;
}
.btn-danger:hover { background: rgba(251, 113, 133, 0.24); border-color: var(--danger); }

.btn-ghost { background: transparent; }
.btn-sm { padding: 7px 13px; font-size: 0.82rem; }
.btn-sm svg { width: 15px; height: 15px; }

/* ---------- Spotlight card ---------- */
.spotlight {
  --mx: 50%;
  --my: 50%;
  --spot: rgba(129, 140, 248, 0.18);
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  overflow: hidden;
  isolation: isolate;
  transition: border-color .3s, transform .4s var(--ease);
}
.spotlight::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: radial-gradient(420px circle at var(--mx) var(--my), var(--spot), transparent 60%);
  opacity: 0;
  transition: opacity .35s;
}
.spotlight:hover::before { opacity: 1; }
.spotlight:hover { border-color: var(--border-strong); }

/* ---------- Stats (CountUp) ---------- */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr));
  gap: 16px;
  margin-bottom: 36px;
}
.stat { padding: 22px; }
.stat-label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
}
.stat-icon {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--surface-hover);
}
.stat-icon svg { width: 16px; height: 16px; }
.stat-value {
  margin-top: 14px;
  font-size: 2.1rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
}
.stat.teal    { --spot: rgba(94, 234, 212, 0.18); }
.stat.teal    .stat-icon { color: var(--accent-1); }
.stat.indigo  .stat-icon { color: var(--accent-2); }
.stat.amber   { --spot: rgba(251, 191, 36, 0.16); }
.stat.amber   .stat-icon { color: var(--warning); }
.stat.rose    { --spot: rgba(251, 113, 133, 0.18); }
.stat.rose    .stat-icon { color: var(--danger); }

/* ---------- Toolbar (búsqueda + filtros) ---------- */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}
.search {
  position: relative;
  flex: 1 1 280px;
  max-width: 420px;
}
.search svg {
  position: absolute;
  left: 15px;
  top: 50%;
  width: 18px;
  height: 18px;
  color: var(--muted);
  transform: translateY(-50%);
}
.search input { padding-left: 44px; border-radius: 999px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .2s;
}
.chip:hover { color: var(--text); border-color: var(--border-strong); }
.chip.active { color: #05060f; background: var(--text); border-color: var(--text); }

/* ---------- Grid de productos ---------- */
.products {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr));
  gap: 18px;
}
.product {
  display: flex;
  flex-direction: column;
  padding: 22px;
}
.product:hover { transform: translateY(-4px); }
.product-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.product-avatar {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(94,234,212,.22), rgba(129,140,248,.22));
  border: 1px solid var(--border);
  font-weight: 800;
  font-size: 1.1rem;
}
.product h3 {
  margin: 16px 0 4px;
  font-size: 1.12rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.product-desc {
  flex: 1;
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 0.9rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.product-meta {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding: 14px 0;
  border-top: 1px solid var(--border);
}
.meta-label { display: block; color: var(--muted); font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.meta-value { font-weight: 700; font-variant-numeric: tabular-nums; }
.meta-value.low { color: var(--danger); }
.product-actions { display: flex; gap: 8px; padding-top: 14px; border-top: 1px solid var(--border); }
.product-actions .btn { flex: 1; }

/* Barra de stock */
.stock-bar {
  height: 4px;
  margin-top: 6px;
  border-radius: 99px;
  background: rgba(255,255,255,0.08);
  overflow: hidden;
}
.stock-bar i {
  display: block;
  height: 100%;
  width: var(--w, 0%);
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent-1), var(--accent-2));
}
.stock-bar.low i { background: var(--danger); }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  white-space: nowrap;
  border: 1px solid;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-ok      { color: var(--success); border-color: rgba(52,211,153,.35); background: rgba(52,211,153,.1); }
.badge-warning { color: var(--warning); border-color: rgba(251,191,36,.35); background: rgba(251,191,36,.1); }
.badge-danger  { color: var(--danger);  border-color: rgba(251,113,133,.35); background: rgba(251,113,133,.1); }

/* ---------- Estado vacío ---------- */
.empty {
  grid-column: 1 / -1;
  padding: 64px 24px;
  text-align: center;
}
.empty-icon {
  display: grid;
  place-items: center;
  width: 72px;
  height: 72px;
  margin: 0 auto 18px;
  border-radius: 22px;
  background: linear-gradient(135deg, rgba(94,234,212,.2), rgba(232,121,249,.2));
  border: 1px solid var(--border);
}
.empty-icon svg { width: 34px; height: 34px; }
.empty h3 { margin: 0 0 6px; font-size: 1.3rem; }
.empty p { margin: 0 0 22px; color: var(--muted); }
.no-results { display: none; }
.no-results.show { display: block; }

/* ---------- Formularios ---------- */
.form-shell { max-width: 640px; margin-inline: auto; }
.form-card { padding: clamp(24px, 4vw, 40px); }
.form-card h1 {
  margin: 14px 0 6px;
  font-size: clamp(1.8rem, 4vw, 2.5rem);
  font-weight: 800;
  letter-spacing: -0.04em;
}
.form-card .lead { margin: 0 0 30px; color: var(--muted); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.field { display: flex; flex-direction: column; gap: 8px; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 0.85rem; font-weight: 700; }

.input,
.field input,
.field textarea {
  width: 100%;
  padding: 13px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  font: inherit;
  outline: none;
  transition: border-color .2s, box-shadow .2s, background .2s;
}
.field textarea { min-height: 110px; resize: vertical; }
.input::placeholder,
.field input::placeholder,
.field textarea::placeholder { color: #5c6185; }
.input:focus,
.field input:focus,
.field textarea:focus {
  border-color: var(--accent-2);
  background: rgba(129, 140, 248, 0.06);
  box-shadow: 0 0 0 4px rgba(129, 140, 248, 0.18);
}
.field input[type="date"]::-webkit-calendar-picker-indicator { filter: invert(1) opacity(.6); cursor: pointer; }
.field.has-error input,
.field.has-error textarea { border-color: var(--danger); box-shadow: 0 0 0 4px rgba(251, 113, 133, 0.12); }
.field-error { color: var(--danger); font-size: 0.82rem; font-weight: 600; }
.field-help { color: var(--muted); font-size: 0.8rem; }
.form-actions {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 32px;
}

/* ---------- Confirmar eliminación ---------- */
.danger-card { --spot: rgba(251, 113, 133, 0.2); text-align: center; }
.danger-icon {
  display: grid;
  place-items: center;
  width: 76px;
  height: 76px;
  margin: 0 auto 8px;
  border-radius: 24px;
  color: var(--danger);
  background: rgba(251, 113, 133, 0.12);
  border: 1px solid rgba(251, 113, 133, 0.35);
  animation: wobble 2.4s ease-in-out infinite;
}
.danger-icon svg { width: 36px; height: 36px; }
@keyframes wobble { 0%, 100% { transform: rotate(0); } 10% { transform: rotate(-8deg); } 20% { transform: rotate(6deg); } 30% { transform: rotate(0); } }
.delete-target {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 24px 0;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.03);
  text-align: left;
}
.delete-target strong { display: block; }
.delete-target div > span { color: var(--muted); font-size: 0.88rem; }

/* ---------- Toasts (mensajes) ---------- */
.toasts {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: calc(100vw - 40px);
}
.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 280px;
  padding: 14px 16px;
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  background: rgba(15, 17, 35, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 20px 50px -15px rgba(0,0,0,.6);
  font-weight: 600;
  animation: toast-in .5s var(--ease) both;
}
.toast.hide { animation: toast-out .4s var(--ease) forwards; }
.toast-icon {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(52, 211, 153, 0.15);
  color: var(--success);
  flex-shrink: 0;
}
.toast-icon svg { width: 16px; height: 16px; }
.toast-close {
  margin-left: auto;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 1.2rem;
  cursor: pointer;
}
@keyframes toast-in  { from { opacity: 0; transform: translateY(16px) scale(.96); } }
@keyframes toast-out { to   { opacity: 0; transform: translateX(30px); } }

/* ---------- Footer ---------- */
.footer {
  padding-block: 28px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
}

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  main { padding-block: 32px 64px; }
  .form-grid { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr 1fr; gap: 12px; }
  .stat { padding: 16px; }
  .stat-value { font-size: 1.6rem; }
  .search { max-width: none; }
  .form-actions { flex-direction: column-reverse; }
  .form-actions .btn { width: 100%; }
  .hero-row .btn { width: 100%; }
}

/* ---------- Accesibilidad: menos movimiento ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .reveal, .split .char { opacity: 1; transform: none; filter: none; }
}
