/* ================================
   VARIABLES / TEMAS
================================ */
:root {
  --primary: #22a3b8;
  --primary-dark: #1b4f58;
  --bg: #f5f7f9;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: rgba(0,0,0,.08);
  --chip: #e5e7eb;
}

[data-theme="dark"] {
  --bg: #0b1220;
  --card: #0f172a;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --border: rgba(255,255,255,.08);
  --chip: #1f2937;
}

/* ================================
   RESET
================================ */
* {
  box-sizing: border-box;
}

a {
  text-decoration: none;
  color: inherit;
}

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: Inter, system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
}

/* ================================
   HEADER
================================ */
.topbar {
  background: linear-gradient(135deg, #0f3c46, #1f2e30);
  color: white;
}

.topbar-inner {
  max-width: 1200px;
  margin: auto;
  padding: 48px 24px;
  text-align: center;
}

.logo {
  height: 44px;
  margin-bottom: 12px;
}

.actions {
  margin-top: 28px;
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

.actions input {
  min-width: 260px;
  padding: 12px 18px;
  border-radius: 24px;
  border: none;
}

.actions button {
  padding: 12px 18px;
  border-radius: 24px;
  border: none;
  cursor: pointer;
  background: var(--primary);
  color: white;
}

/* ================================
   CATEGORÍAS (LIGHT + DARK OK)
================================ */
.categories {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.categories-inner {
  max-width: 1200px;
  margin: auto;
  padding: 12px 16px;
  display: flex;
  gap: 10px;
  overflow-x: auto;
}

.cat {
  padding: 8px 16px;
  border-radius: 999px;
  background: var(--chip);
  font-size: 14px;
  white-space: nowrap;
  transition: background .2s ease, color .2s ease;
}

.cat:hover {
  background: var(--primary);
  color: white;
}

.cat.active {
  background: var(--primary);
  color: white;
}

/* ================================
   CONTENT / GRID
================================ */
.content {
  max-width: 1200px;
  margin: auto;
  padding: 32px 24px 80px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 28px;
}

/* ================================
   CARD (SIN ANIMACIONES)
================================ */
.card {
  background: var(--card);
  border-radius: 20px;
  padding: 18px;
  box-shadow: 0 14px 35px rgba(0,0,0,.15);
  position: relative;
  display: flex;
  flex-direction: column;
  text-align: center;
}

/* ================================
   IMAGEN
================================ */
.img-wrap {
  height: 180px;
  margin-bottom: 14px;
  background: rgba(0,0,0,.04);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

[data-theme="dark"] .img-wrap {
  background: rgba(255,255,255,.04);
}

.img-wrap img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

/* ================================
   TEXTO
================================ */
.card h3 {
  font-size: 15px;
  line-height: 1.4;
  margin: 0 0 8px;
}

.sku {
  font-size: 12px;
  color: var(--muted);
}

.price {
  margin-top: 8px;
  font-size: 22px;
  font-weight: bold;
  color: var(--primary);
}

.hide-prices .price {
  display: none;
}

/* ================================
   BADGE PREVENTA (FIJO)
================================ */
.badge {
  position: absolute;
  top: 14px;
  left: 14px;
  background: var(--primary);
  color: white;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 11px;
}

/* ================================
   PAGINACIÓN
================================ */
.pagination {
  margin-top: 48px;
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

.pagination a {
  padding: 8px 14px;
  border-radius: 12px;
  background: var(--chip);
  font-size: 14px;
}

.pagination a.active {
  background: var(--primary);
  color: white;
}

/* ================================
   FOOTER
================================ */
footer {
  text-align: center;
  padding: 40px 0;
}

.watermark {
  height: 40px;
  opacity: .15;
}

/* ================================
   MOBILE
================================ */
@media (max-width: 640px) {
  .topbar-inner {
    padding: 32px 16px;
  }

  .content {
    padding: 24px 16px;
  }

  .actions input {
    min-width: 100%;
  }
}

.price-usd {
  margin-top: 10px;
  font-size: 22px;
  font-weight: 700;
  color: var(--primary);
}

.price-pvp {
  margin-top: 4px;
  font-size: 13px;
  color: var(--muted);
}

/* ===== CARRITO FIXED ARRIBA ===== */
.cart {
  position: fixed;
  top: 80px;
  right: 20px;
  width: 320px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 20px 40px rgba(0,0,0,.2);
  padding: 16px;
  z-index: 9999;
}

.cart.hidden {
  display: none;
}

#cart-items {
  max-height: 300px;
  overflow-y: auto;
  margin-bottom: 12px;
}

/* badge del carrito */
#cart-count {
  background: #16b5c5;
  color: #fff;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 12px;
}

.pagination {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin: 40px 0;
  flex-wrap: wrap;
}

.pagination a,
.pagination span {
  padding: 8px 12px;
  border-radius: 10px;
  background: #eee;
  text-decoration: none;
  color: #333;
}

.pagination a.active {
  background: #16b5c5;
  color: white;
}

/* ============================= */
/*  ADD TO CART – UI PROLIGA     */
/* ============================= */

.card input.qty,
.card input[type="number"] {
  width: 100%;
  height: 42px;
  margin-top: 8px;
  margin-bottom: 6px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid #d0d7de;
  font-size: 15px;
  text-align: center;
  transition: border .2s, box-shadow .2s;
}

.card input.qty:focus,
.card input[type="number"]:focus {
  outline: none;
  border-color: #16b5c5;
  box-shadow: 0 0 0 3px rgba(22,181,197,.15);
}

/* BOTÓN AGREGAR */
.card .add-cart,
.card button.add-cart,
.card button {
  width: 100%;
  height: 44px;
  border-radius: 12px;
  border: none;
  background: linear-gradient(135deg, #16b5c5, #0fa1b2);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease, background .2s;
}

/* hover */
.card .add-cart:hover,
.card button:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(22,181,197,.35);
  background: linear-gradient(135deg, #18c4d6, #12b3c6);
}

/* click */
.card .add-cart:active,
.card button:active {
  transform: scale(.98);
  box-shadow: 0 6px 14px rgba(22,181,197,.25);
}

/* ============================= */
/*  MINI FEEDBACK VISUAL         */
/* ============================= */

.card .add-cart::after {
  content: "✓";
  position: absolute;
  right: 14px;
  opacity: 0;
  transition: opacity .2s ease;
}

.card .add-cart:focus::after {
  opacity: 1;
}

/* ============================= */
/*  ESPACIADO CORRECTO           */
/* ============================= */

.card {
  position: relative;
}

.card .price-usd {
  margin-bottom: 6px;
}

.card .price-pvp {
  margin-bottom: 10px;
}

/* =======================
   CARRITO
======================= */
.cart-panel {
  position: fixed;
  top: 90px;
  right: 24px;
  width: 360px;
  max-height: 75vh;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 20px 40px rgba(0,0,0,.25);
  padding: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
}

.cart-panel.hidden {
  display: none;
}

.cart-close {
  position: absolute;
  top: 10px;
  right: 12px;
  border: none;
  background: none;
  font-size: 22px;
  cursor: pointer;
}

#cart-items {
  margin-top: 12px;
  overflow-y: auto;
  flex: 1;
}

.cart-row {
  border-bottom: 1px solid #eee;
  padding: 8px 0;
  font-size: 14px;
}

.cart-row strong {
  display: block;
  font-size: 14px;
}

.cart-footer {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cart-total {
  font-size: 16px;
  text-align: right;
}

.cart-footer select,
.cart-footer button {
  padding: 8px;
  border-radius: 8px;
  font-size: 14px;
}

.cart-footer button {
  background: #12b6c0;
  color: #fff;
  border: none;
  cursor: pointer;
}

.cart-footer button:hover {
  background: #0ea1aa;
}

.order-success {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  color: white;
  z-index: 10000;
  animation: fadeIn .4s ease;
}

.order-success.hidden {
  display: none;
}

.order-success .check {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  background: #12b6c0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
  margin-bottom: 16px;
  animation: pop .4s ease;
}

@keyframes pop {
  from { transform: scale(0); }
  to { transform: scale(1); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.card h3,
.card .title,
.card .description {
  word-break: break-word;
  overflow-wrap: anywhere;
  hyphens: auto;
}

.card {
  display: flex;
  flex-direction: column;
}

.card h3 {
  line-height: 1.25;
}

/* ===== CART VISUAL ===== */

.cart-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid #eee;
  align-items: center;
}

.cart-info strong {
  display: block;
  font-size: 14px;
  line-height: 1.2;
}

.cart-info small {
  color: #777;
  font-size: 12px;
}

.cart-qty {
  font-weight: bold;
}

.cart-subtotal {
  font-weight: bold;
  color: #0aa;
}

.empty-cart {
  text-align: center;
  color: #777;
}

/* ===== SUCCESS ANIMATION ===== */

/* ===== SUCCESS ===== */

.order-success {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 10000;
}

.order-success.hidden {
  display: none;
}

.order-success .check {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  background: #12b6c0;
  color: #fff;
  font-size: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
  animation: pop .4s ease;
}

@keyframes pop {
  from { transform: scale(0); }
  to { transform: scale(1); }
}


.fade-in {
  animation: fadeInUp .4s ease-out;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===== BADGE PULSE ===== */

.pulse {
  animation: pulse .3s ease;
}

@keyframes pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.3); }
  100% { transform: scale(1); }
}

/* ===== FIX TEXT OVERFLOW EN CARDS ===== */

.card h3,
.card p {
  word-break: break-word;
  hyphens: auto;
}

.buyer-form {
  display: grid;
  gap: 8px;
  margin: 10px 0;
}

.buyer-form input {
  padding: 8px;
  border-radius: 6px;
  border: 1px solid #ccc;
}

.order-success {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 10000;
}

.order-success.hidden {
  display: none;
}

.order-success .check {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  background: #12b6c0;
  color: #fff;
  font-size: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
  animation: pop .4s ease;
}

@keyframes pop {
  from { transform: scale(0); }
  to { transform: scale(1); }
}

.order-success {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.order-success.hidden {
  display: none;
}

.order-success > div,
.order-success {
  animation: pop 0.35s ease-out;
}

.order-success .check {
  font-size: 64px;
  color: #1bcfb4;
  margin-bottom: 10px;
}

@keyframes pop {
  from { transform: scale(.8); opacity: 0 }
  to { transform: scale(1); opacity: 1 }
}

/* ================== CARRITO ================== */

.cart-panel {
  position: fixed;
  top: 80px;
  right: 24px;
  width: 360px;
  max-height: calc(100vh - 120px);
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
  padding: 20px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
}

.cart-panel.hidden {
  display: none;
}

/* Header */
.cart-panel h3 {
  font-size: 20px;
  margin-bottom: 16px;
  color: #0f172a;
}

.cart-close {
  position: absolute;
  top: 14px;
  right: 14px;
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: #64748b;
}

.cart-close:hover {
  color: #0f172a;
}

/* Items */
#cart-items {
  flex: 1;
  overflow-y: auto;
  padding-right: 4px;
}

.cart-row {
  padding: 12px 0;
  border-bottom: 1px solid #e5e7eb;
}

.cart-row:last-child {
  border-bottom: none;
}

.cart-row strong {
  display: block;
  font-size: 14px;
  color: #0f172a;
}

.cart-row small {
  color: #64748b;
  font-size: 12px;
}

.cart-row .price {
  margin-top: 4px;
  font-weight: 600;
  color: #0ea5a4;
}

/* Footer */
.cart-footer {
  margin-top: 16px;
  border-top: 1px solid #e5e7eb;
  padding-top: 16px;
}

/* Total */
.cart-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 14px;
  color: #0f172a;
}

/* Inputs */
.cart-footer input,
.cart-footer select {
  width: 100%;
  margin-bottom: 8px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid #d1d5db;
  font-size: 14px;
  transition: border .2s, box-shadow .2s;
}

.cart-footer input:focus,
.cart-footer select:focus {
  outline: none;
  border-color: #0ea5a4;
  box-shadow: 0 0 0 2px rgba(14,165,164,.15);
}

/* Button */
.cart-footer button {
  margin-top: 8px;
  width: 100%;
  padding: 12px;
  border-radius: 12px;
  border: none;
  background: linear-gradient(135deg,#0ea5a4,#0891b2);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease;
}

.cart-footer button:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 20px rgba(14,165,164,.35);
}

/* Scrollbar suave */
#cart-items::-webkit-scrollbar {
  width: 6px;
}

#cart-items::-webkit-scrollbar-thumb {
  background: #cbd5f5;
  border-radius: 6px;
}

#cart-panel {
  animation: slideIn .3s ease;
}

#cart-panel.success {
  box-shadow: 0 0 0 2000px rgba(0,0,0,.5);
}

.cart-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid #eee;
}

.cart-total {
  font-size: 18px;
  font-weight: bold;
  margin: 12px 0;
}

@keyframes slideIn {
  from { transform: translateX(20px); opacity: 0 }
  to { transform: translateX(0); opacity: 1 }
}

.order-success {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  animation: fadeIn .3s ease;
}

.order-box {
  background: white;
  padding: 30px;
  border-radius: 14px;
  width: 360px;
  text-align: center;
  animation: pop .35s ease;
}

.order-box h2 {
  color: #16b6c1;
  margin-bottom: 10px;
}

.order-box button {
  margin-top: 15px;
  background: #16b6c1;
  color: white;
  border: none;
  padding: 10px 18px;
  border-radius: 8px;
  cursor: pointer;
}

@keyframes pop {
  from { transform: scale(.8); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
