/* ============================================================
   TIENDA DISTRIBUIDORA — store.css
   Paleta: Onyx #0e0c0a + Rojo #D42B2B · Space Grotesk + Inter
   Mobile first
   ============================================================ */

:root {
  --bg:           #0e0c0a;
  --surface:      #1a1815;
  --surface-2:    #242119;
  --primary:      #D42B2B;
  --primary-h:    #E83535;
  --primary-dim:  rgba(212,43,43,.12);
  --text:         #ffffff;
  --text-muted:   #9e9890;
  --text-dim:     #6b6560;
  --border:       rgba(255,255,255,.08);
  --border-gold:  rgba(212,43,43,.3);
  --success:      #4caf7d;
  --warning:      #f0a500;
  --danger:       #e05252;
  --radius-s:     8px;
  --radius:       12px;
  --radius-l:     16px;
  --shadow:       0 4px 24px rgba(0,0,0,.4);
  --shadow-gold:  0 0 20px rgba(212,43,43,.2);
  --f-title:      'Space Grotesk', sans-serif;
  --f-body:       'Inter', sans-serif;
  --header-h:     64px;
  --cart-w:       380px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: var(--f-body);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}
img { display: block; max-width: 100%; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
input, select, textarea { font-family: inherit; font-size: 1rem; }
h1, h2, h3 { font-family: var(--f-title); font-weight: 600; }

/* ── HEADER ────────────────────────────────────────────────── */
.header {
  position: sticky; top: 0; z-index: 100;
  height: var(--header-h);
  background: rgba(14,12,10,.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  max-width: 1200px; margin: 0 auto; padding: 0 16px;
  height: 100%; display: flex; align-items: center;
  justify-content: space-between; gap: 12px;
}
.header-logo { height: 44px; width: auto; display: block; }
.header-actions { display: flex; align-items: center; gap: 8px; }

.tipo-toggle {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: 999px;
  border: 1px solid var(--border-gold);
  color: var(--text-muted); font-size: .8rem; font-weight: 500;
  transition: all .2s; background: transparent;
}
.tipo-toggle:hover        { border-color: var(--primary); color: var(--primary); }
.tipo-toggle.mayorista    { background: var(--primary-dim); border-color: var(--primary); color: var(--primary); }

.cart-btn {
  position: relative; display: flex; align-items: center; gap: 8px;
  padding: 10px 16px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text); font-size: .9rem; font-weight: 500;
  min-height: 44px; transition: all .2s;
}
.cart-btn:hover { border-color: var(--primary); box-shadow: var(--shadow-gold); }

.cart-count {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 20px; height: 20px; padding: 0 5px;
  background: var(--primary); color: var(--bg);
  border-radius: 999px; font-size: .72rem; font-weight: 700;
  font-family: var(--f-title);
}
.cart-count.hidden { display: none; }

/* ── MAIN / CATALOG ────────────────────────────────────────── */
.main { max-width: 1200px; margin: 0 auto; padding: 20px 16px 100px; }

/* ── FILTERS ───────────────────────────────────────────────── */
.filters {
  display: flex; gap: 8px; overflow-x: auto;
  padding-bottom: 12px; margin-bottom: 20px; scrollbar-width: none;
}
.filters::-webkit-scrollbar { display: none; }
.filter-btn {
  flex-shrink: 0; padding: 8px 16px; border-radius: 999px;
  border: 1px solid var(--border); color: var(--text-muted);
  font-size: .85rem; font-weight: 500; white-space: nowrap;
  transition: all .2s; background: transparent;
}
.filter-btn:hover         { border-color: var(--primary); color: var(--primary); }
.filter-btn.active        { background: var(--primary); border-color: var(--primary); color: var(--bg); font-weight: 600; }

/* ── PRODUCT GRID ──────────────────────────────────────────── */
.productos-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}
@media (min-width: 600px)  { .productos-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1000px) { .productos-grid { grid-template-columns: repeat(4, 1fr); } }

/* ── PRODUCT CARD ──────────────────────────────────────────── */
.producto-card {
  background: var(--surface); border-radius: var(--radius-l);
  border: 1px solid var(--border); overflow: hidden;
  display: flex; flex-direction: column;
  transition: transform .2s, box-shadow .2s, border-color .2s;
  animation: fadeUp .3s ease;
}
.producto-card:hover { transform: translateY(-2px); border-color: var(--border-gold); box-shadow: var(--shadow-gold); }
.producto-card.sin-stock { opacity: .55; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.producto-img { width: 100%; aspect-ratio: 4/3; background: var(--surface-2); overflow: hidden; }
.producto-img img { width: 100%; height: 100%; object-fit: cover; transition: transform .3s; }
.producto-card:hover .producto-img img { transform: scale(1.04); }
.producto-img-ph {
  width: 100%; height: 100%; display: flex;
  align-items: center; justify-content: center;
  font-size: 2.4rem; color: var(--text-dim);
}

.producto-body { padding: 12px; flex: 1; display: flex; flex-direction: column; gap: 5px; }
.cat-badge   { font-size: .7rem; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--primary); opacity: .8; }
.prod-nombre { font-family: var(--f-title); font-size: .95rem; font-weight: 600; line-height: 1.3; }
.prod-unidad { font-size: .75rem; color: var(--text-muted); }
.prod-precio { font-family: var(--f-title); font-size: 1.15rem; font-weight: 700; color: var(--primary); margin-top: auto; }

.stock-badge {
  font-size: .72rem; font-weight: 600;
  padding: 3px 8px; border-radius: 999px;
  display: inline-flex; align-items: center; gap: 4px; width: fit-content;
}
.s-ok   { background: rgba(76,175,125,.15); color: var(--success); }
.s-poco { background: rgba(240,165,0,.15);  color: var(--warning); }
.s-cero { background: rgba(224,82,82,.15);  color: var(--danger);  }

.btn-agregar {
  margin: 0 12px 12px;
  padding: 10px; border-radius: var(--radius-s);
  background: var(--primary); color: var(--bg);
  font-weight: 600; font-size: .9rem; font-family: var(--f-title);
  min-height: 44px; transition: all .2s;
}
.btn-agregar:hover:not(:disabled) { background: var(--primary-h); box-shadow: 0 4px 12px rgba(212,43,43,.3); }
.btn-agregar:disabled { background: var(--surface-2); color: var(--text-dim); cursor: not-allowed; }

/* ── SKELETON ──────────────────────────────────────────────── */
.skeleton-card {
  background: var(--surface); border-radius: var(--radius-l);
  border: 1px solid var(--border); aspect-ratio: 3/4; position: relative; overflow: hidden;
}
.skeleton-card::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,.04) 50%, transparent 100%);
  background-size: 200% 100%; animation: shimmer 1.5s infinite;
}
@keyframes shimmer { 0% { background-position: -200% 0; } 100% { background-position: 200% 0; } }

/* ── EMPTY STATE ───────────────────────────────────────────── */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }

/* ── OVERLAY ───────────────────────────────────────────────── */
.overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 200; backdrop-filter: blur(2px); }
.overlay.active { display: block; }

/* ── CART SIDEBAR ──────────────────────────────────────────── */
.cart-sidebar {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: min(100vw, var(--cart-w));
  background: var(--surface); border-left: 1px solid var(--border);
  z-index: 300; display: flex; flex-direction: column;
  transform: translateX(100%);
  transition: transform .3s cubic-bezier(.4,0,.2,1);
}
.cart-sidebar.open { transform: translateX(0); }

.cart-hd {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px; border-bottom: 1px solid var(--border);
}
.cart-hd h2 { font-size: 1.1rem; }
.close-btn {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--surface-2); color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem; transition: all .2s;
}
.close-btn:hover { background: var(--border); color: var(--text); }

.cart-items { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.cart-empty  { text-align: center; color: var(--text-muted); padding: 40px 20px; }

.cart-item {
  display: flex; gap: 12px;
  background: var(--surface-2); border-radius: var(--radius);
  padding: 12px; border: 1px solid var(--border);
}
.cart-item-img {
  width: 56px; height: 56px; border-radius: var(--radius-s);
  overflow: hidden; flex-shrink: 0; background: var(--bg);
  display: flex; align-items: center; justify-content: center; font-size: 1.4rem;
}
.cart-item-img img { width: 100%; height: 100%; object-fit: cover; }
.cart-item-info { flex: 1; min-width: 0; }
.cart-item-nom  { font-size: .9rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cart-item-sub  { font-size: .85rem; color: var(--primary); font-weight: 600; margin-top: 2px; }
.cart-item-ctrl { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.qty-btn {
  width: 28px; height: 28px; border-radius: 6px;
  background: var(--bg); border: 1px solid var(--border);
  color: var(--text); font-size: 1rem;
  display: flex; align-items: center; justify-content: center; transition: all .15s;
}
.qty-btn:hover { border-color: var(--primary); color: var(--primary); }
.qty-num { font-weight: 600; min-width: 24px; text-align: center; font-family: var(--f-title); }
.btn-quitar { margin-left: auto; color: var(--text-dim); font-size: .8rem; transition: color .15s; }
.btn-quitar:hover { color: var(--danger); }

.cart-ft { padding: 16px 20px; border-top: 1px solid var(--border); }
.cart-total {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 12px; font-weight: 600;
}
.cart-total span:last-child { font-family: var(--f-title); font-size: 1.25rem; color: var(--primary); }

.btn-go-checkout {
  width: 100%; padding: 14px; border-radius: var(--radius);
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-h) 100%);
  color: var(--bg); font-weight: 700; font-size: 1rem;
  font-family: var(--f-title); min-height: 52px; transition: all .2s;
}
.btn-go-checkout:hover { box-shadow: 0 6px 20px rgba(212,43,43,.4); transform: translateY(-1px); }

/* ── CHECKOUT SECTION ──────────────────────────────────────── */
.checkout-section { min-height: 100vh; padding-top: var(--header-h); }
.checkout-inner { max-width: 600px; margin: 0 auto; padding: 24px 16px 80px; }

.back-btn {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--text-muted); font-size: .9rem;
  margin-bottom: 20px; transition: color .2s;
}
.back-btn:hover { color: var(--primary); }
.checkout-inner h2 { font-size: 1.5rem; margin-bottom: 20px; }

.checkout-summary {
  background: var(--surface); border-radius: var(--radius-l);
  border: 1px solid var(--border); padding: 16px; margin-bottom: 24px;
}
.summary-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 0; font-size: .9rem;
  border-bottom: 1px solid var(--border);
}
.summary-row:last-child { border-bottom: none; }
.summary-qty  { color: var(--text-muted); font-size: .8rem; }
.summary-sub  { font-weight: 600; color: var(--primary); }

.checkout-form { display: flex; flex-direction: column; gap: 16px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label {
  font-size: .82rem; font-weight: 600;
  color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em;
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%; padding: 12px 14px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text); font-size: .95rem;
  min-height: 48px; transition: border-color .2s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-dim); }
.form-group select { appearance: none; cursor: pointer; }
.form-group textarea { min-height: 80px; resize: vertical; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 440px) { .form-row { grid-template-columns: 1fr; } }

.total-box {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px; background: var(--primary-dim);
  border: 1px solid var(--border-gold); border-radius: var(--radius);
}
.total-box span:first-child { font-weight: 600; color: var(--text-muted); }
.total-amount { font-family: var(--f-title); font-size: 1.4rem; font-weight: 700; color: var(--primary); }

.btn-confirm {
  width: 100%; padding: 16px; border-radius: var(--radius);
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-h) 100%);
  color: var(--bg); font-weight: 700; font-size: 1.05rem;
  font-family: var(--f-title); min-height: 56px; transition: all .2s;
}
.btn-confirm:hover:not(:disabled) { box-shadow: 0 6px 20px rgba(212,43,43,.4); transform: translateY(-1px); }
.btn-confirm:disabled { opacity: .6; cursor: not-allowed; }

.checkout-nota { text-align: center; font-size: .83rem; color: var(--text-muted); }

/* ── SUCCESS SECTION ───────────────────────────────────────── */
.success-section {
  min-height: 100vh; display: flex;
  align-items: center; justify-content: center; padding: 20px;
}
.success-inner {
  max-width: 460px; width: 100%;
  text-align: center; display: flex; flex-direction: column;
  gap: 16px; align-items: center;
}
.success-icon {
  width: 80px; height: 80px; border-radius: 50%;
  background: rgba(76,175,125,.15); border: 2px solid var(--success);
  color: var(--success); font-size: 2rem;
  display: flex; align-items: center; justify-content: center;
}
.success-inner h2 { font-size: 1.6rem; }
.success-inner > p { color: var(--text-muted); }

.success-details {
  width: 100%; background: var(--surface);
  border-radius: var(--radius); border: 1px solid var(--border);
  padding: 16px; text-align: left;
}
.detail-row {
  display: flex; justify-content: space-between;
  padding: 6px 0; font-size: .9rem;
  border-bottom: 1px solid var(--border);
}
.detail-row:last-child { border-bottom: none; }
.detail-row span:first-child { color: var(--text-muted); }

.btn-wa {
  width: 100%; padding: 14px; border-radius: var(--radius);
  background: #25d366; color: white;
  font-weight: 700; font-size: 1rem; font-family: var(--f-title);
  min-height: 52px; transition: all .2s;
}
.btn-wa:hover { background: #1ebe5c; box-shadow: 0 4px 12px rgba(37,211,102,.3); }

.btn-sec {
  width: 100%; padding: 12px; border-radius: var(--radius);
  border: 1px solid var(--border); color: var(--text-muted);
  font-weight: 600; font-size: .95rem; min-height: 48px; transition: all .2s;
}
.btn-sec:hover { border-color: var(--primary); color: var(--primary); }

/* ── TOAST ─────────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 24px; left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--surface); border: 1px solid var(--border-gold);
  border-radius: var(--radius); padding: 12px 20px;
  color: var(--text); font-size: .9rem; font-weight: 500;
  z-index: 1000; box-shadow: var(--shadow); white-space: nowrap;
  transition: transform .3s cubic-bezier(.4,0,.2,1);
}
.toast.show { transform: translateX(-50%) translateY(0); }

/* ── SPINNER ───────────────────────────────────────────────── */
.spinner {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid var(--border); border-top-color: var(--primary);
  animation: spin .7s linear infinite; display: inline-block; vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }
