/* ==========================================================================
   1. DESIGN TOKENS (Variables Semánticas)
   ========================================================================== */
:root {
  /* Superficies y Fondos */
  --color-bg: #f4f0ff;
  --color-surface: #ffffff;
  --color-border: #ded6f7;

  /* Tipografía */
  --color-text-main: #1d1640;
  --color-text-muted: #6b6490;
  --font-sans: 'Poppins', system-ui, sans-serif;
  --font-display: 'Press Start 2P', monospace;

  /* Colores de Marca y Acentos (antes --a, --b, --c) */
  --color-primary: #ff2e93;       /* Rosa neón */
  --color-secondary: #7c3aed;     /* Violeta */
  --color-accent: #00b8d9;        /* Cian */
  --color-on-accent: #06202a;     /* Texto sobre fondo cian */

  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --color-bg: #0e0a22;
    --color-surface: #1a1438;
    --color-text-main: #f2eeff;
    --color-text-muted: #a79fd0;
    --color-primary: #ff4fa8;
    --color-secondary: #9b6bff;
    --color-accent: #22e3ff;
    --color-border: #33295f;
  }
}

:root[data-theme="dark"] {
  --color-bg: #0e0a22;
  --color-surface: #1a1438;
  --color-text-main: #f2eeff;
  --color-text-muted: #a79fd0;
  --color-primary: #ff4fa8;
  --color-secondary: #9b6bff;
  --color-accent: #22e3ff;
  --color-border: #33295f;
}

/* ==========================================================================
   2. BASE & RESET
   ========================================================================== */
html {
  scroll-padding-top: env(safe-area-inset-top, 0px);
}

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

body {
  background-color: var(--color-bg);
  color: var(--color-text-main);
  font-family: var(--font-sans);
  min-height: 100vh;
  background-image: 
    radial-gradient(circle at 15% 0, color-mix(in srgb, var(--color-secondary) 25%, transparent), transparent 40%),
    radial-gradient(circle at 90% 10%, color-mix(in srgb, var(--color-primary) 20%, transparent), transparent 35%);
}

/* ==========================================================================
   3. LAYOUT & NAVEGACIÓN
   ========================================================================== */
.site-header,
header {
  position: sticky;
  top: env(safe-area-inset-top, 0px);
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 5vw;
  backdrop-filter: blur(12px);
  background: color-mix(in srgb, var(--color-bg) 80%, transparent);
  border-bottom: 1px solid var(--color-border);
}

.site-logo,
.logo {
  font-family: var(--font-display);
  font-size: clamp(0.7rem, 3vw, 1rem);
  background: linear-gradient(90deg, var(--color-primary), var(--color-accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-decoration: none;
}

.site-nav,
nav {
  display: flex;
  gap: 8px;
}

.nav-tab,
nav button {
  font: 600 0.9rem var(--font-sans);
  border: 2px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text-main);
  padding: 8px 16px;
  border-radius: 99px;
  cursor: pointer;
  position: relative;
  transition: 0.2s ease;
}

/* Soporta clase semántica, atributo ARIA de accesibilidad o tu clase antigua */
.nav-tab.is-active,
.nav-tab[aria-current="page"],
.nav-tab[aria-selected="true"],
nav button.on {
  background: linear-gradient(90deg, var(--color-secondary), var(--color-primary));
  border-color: transparent;
  color: #ffffff;
}

.cart-badge,
#badge {
  position: absolute;
  top: -8px;
  right: -6px;
  background: var(--color-accent);
  color: var(--color-on-accent);
  font-size: 0.72rem;
  min-width: 22px;
  height: 22px;
  border-radius: 99px;
  display: grid;
  place-items: center;
  font-weight: 700;
}

.main-content,
main {
  padding: 28px 5vw 60px;
  max-width: 1150px;
  margin: auto;
}

/* ==========================================================================
   4. HERO BANNER
   ========================================================================== */
.hero {
  text-align: center;
  padding: 20px 0 30px;
}

.hero-title,
.hero h1 {
  font-family: var(--font-display);
  font-size: clamp(1rem, 4.5vw, 2rem);
  line-height: 1.5;
  animation: pulse-glow 2.5s infinite alternate;
}

.hero-subtitle,
.hero p {
  color: var(--color-text-muted);
  margin-top: 12px;
}

/* ==========================================================================
   5. CATÁLOGO Y TARJETAS DE PRODUCTO
   ========================================================================== */
.product-grid,
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 20px;
}

.product-card,
.card {
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: 20px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: 0.25s ease;
  animation: fade-in-up 0.5s both;
}

.product-card:hover,
.card:hover {
  transform: translateY(-8px) rotate(-1deg);
  border-color: var(--color-primary);
  box-shadow: 0 14px 30px color-mix(in srgb, var(--color-primary) 30%, transparent);
}

.product-media,
.art {
  height: 130px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-size: 4rem;
  position: relative;
  overflow: hidden;
}

.product-media-icon,
.art span {
  animation: float-idle 3s ease-in-out infinite;
  display: inline-block;
}

.product-category,
.tag {
  font-size: 0.7rem;
  color: var(--color-accent);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.product-title,
.card h3 {
  font-size: 1rem;
}

.product-description,
.card small {
  color: var(--color-text-muted);
  font-size: 0.85rem;
}

.product-footer,
.row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: auto;
  padding-top: 8px;
}

.product-price,
.price {
  font-family: var(--font-display);
  font-size: 0.8rem;
  color: var(--color-primary);
}

/* ==========================================================================
   6. BOTONES
   ========================================================================== */
.btn {
  font: 600 0.85rem var(--font-sans);
  border: 0;
  color: #ffffff;
  background: linear-gradient(90deg, var(--color-secondary), var(--color-primary));
  padding: 10px 14px;
  border-radius: 12px;
  cursor: pointer;
  transition: 0.2s ease;
}

.btn:hover {
  filter: brightness(1.15);
  transform: scale(1.05);
}

.btn:active {
  transform: scale(0.94);
}

.btn--success,
.btn.ok {
  background: var(--color-accent);
  color: var(--color-on-accent);
}

/* ==========================================================================
   7. CARRITO DE COMPRAS / PANEL
   ========================================================================== */
.cart-panel,
.panel {
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: 20px;
  padding: 20px;
  animation: fade-in-up 0.4s;
}

.cart-item,
.item {
  display: grid;
  grid-template-columns: 56px 1fr auto auto;
  gap: 14px;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px dashed var(--color-border);
  animation: fade-in-up 0.35s;
}

.cart-item.is-removing,
.item.out {
  animation: slide-out-right 0.35s forwards;
}

.cart-item-thumbnail,
.ico {
  font-size: 2rem;
  width: 56px;
  height: 56px;
  border-radius: 12px;
  display: grid;
  place-items: center;
}

.quantity-selector,
.qty {
  display: flex;
  align-items: center;
  gap: 8px;
}

.quantity-btn,
.qty button {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 2px solid var(--color-border);
  background: none;
  color: var(--color-text-main);
  cursor: pointer;
  font-size: 1rem;
}

.quantity-btn:hover,
.qty button:hover {
  border-color: var(--color-primary);
}

.btn-remove,
.x {
  background: none;
  border: 0;
  cursor: pointer;
  font-size: 1.2rem;
}

.cart-summary,
.total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 18px;
  font-size: 1.1rem;
}

.cart-total-amount,
.total b,
.total output {
  font-family: var(--font-display);
  font-size: 1rem;
  color: var(--color-primary);
}

.cart-empty-state,
.empty {
  text-align: center;
  padding: 40px 10px;
  color: var(--color-text-muted);
}

.cart-empty-icon,
.empty div {
  font-size: 3.5rem;
  animation: float-idle 3s infinite;
}

/* ==========================================================================
   8. FEEDBACK, MODALES Y EFECTOS (Toast, Loader, Confetti)
   ========================================================================== */
.toast-notification,
#toast {
  position: fixed;
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translate(-50%, 120px);
  background: var(--color-surface);
  border: 2px solid var(--color-accent);
  padding: 12px 20px;
  border-radius: 14px;
  transition: 0.4s ease;
  z-index: 50;
}

.toast-notification.is-visible,
#toast.show {
  transform: translate(-50%, 0);
}

.flying-item,
.fly {
  position: fixed;
  z-index: 60;
  font-size: 2rem;
  pointer-events: none;
}

.modal-overlay,
.overlay {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: rgba(10, 6, 30, 0.85);
  display: grid;
  place-items: center;
  text-align: center;
  color: #ffffff;
  padding: 20px;
}

.loading-spinner,
.spin {
  width: 60px;
  height: 60px;
  border: 6px solid #ffffff33;
  border-top-color: var(--color-accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 20px;
}

.progress-bar,
.bar {
  width: 240px;
  height: 10px;
  background: #ffffff22;
  border-radius: 9px;
  margin: 16px auto;
  overflow: hidden;
}

.progress-bar-fill,
.bar i {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--color-primary), var(--color-accent));
  transition: width 1s ease;
}

.confetti-piece,
.conf {
  position: fixed;
  top: -20px;
  width: 10px;
  height: 14px;
  z-index: 80;
  animation: confetti-fall linear forwards;
}

/* ==========================================================================
   9. UTILIDADES Y ANIMACIONES
   ========================================================================== */
.is-hidden,
.hidden,
[hidden] {
  display: none !important;
}

.animate-bump,
.bump {
  animation: bump-scale 0.4s ease;
}

@keyframes bump-scale {
  50% { transform: scale(1.5); }
}

@keyframes pulse-glow {
  to { text-shadow: 0 0 18px var(--color-primary), 0 0 36px var(--color-secondary); }
}

@keyframes fade-in-up {
  from { opacity: 0; transform: translateY(25px); }
}

@keyframes float-idle {
  50% { transform: translateY(-8px) scale(1.08); }
}

@keyframes slide-out-right {
  to { opacity: 0; transform: translateX(60px); height: 0; padding: 0; }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes confetti-fall {
  to { transform: translateY(110vh) rotate(720deg); }
}

/* ==========================================================================
   10. MEDIA QUERIES
   ========================================================================== */
@media (max-width: 520px) {
  .cart-item,
  .item {
    grid-template-columns: 48px 1fr auto;
  }
  .cart-item .btn-remove,
  .item .x {
    grid-column: 3;
    grid-row: 1;
  }
  .cart-item .quantity-selector,
  .item .qty {
    grid-column: 2 / 4;
  }
}