/* ── Reset & Base ─────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --c-primary:    #74ACDF;   /* celeste AFA */
  --c-primary-d:  #4a8ec2;   /* celeste oscuro */
  --c-primary-l:  #EBF5FB;   /* celeste muy suave */
  --c-bg:         #F0F7FC;   /* fondo celeste suavísimo */
  --c-white:      #FFFFFF;
  --c-text:       #1A1A1A;
  --c-muted:      #6B7280;
  --c-border:     #C8DFF0;
  --c-success:    #2E7D32;
  --c-mp:         #009EE3;
  --header-h:     70px;
  --banner-h:     38px;
  --cart-w:       340px;
  --radius:       10px;
  --shadow:       0 2px 10px rgba(0,0,0,.07);
  --shadow-lg:    0 8px 28px rgba(0,0,0,.13);
}

html { font-family: 'Inter', system-ui, sans-serif; font-size: 15px; }
body { background: var(--c-bg); color: var(--c-text); min-height: 100vh; }

/* ── Header ───────────────────────────────────────── */
.header {
  position: sticky; top: 0; z-index: 100;
  background: linear-gradient(135deg, #74ACDF 0%, #5a9fd4 50%, #3d8cbf 100%);
  border-bottom: 3px solid #F6B40E;
  height: var(--header-h);
  box-shadow: 0 2px 16px rgba(74,142,194,.35);
}
.header-inner {
  max-width: 1280px; margin: 0 auto;
  padding: 0 24px;
  height: 100%;
  display: flex; align-items: center; gap: 20px;
}

.logo {
  display: flex; align-items: center; gap: 10px;
  text-decoration: none; flex-shrink: 0;
}
.logo img { height: 52px; width: auto; filter: drop-shadow(0 2px 6px rgba(0,0,0,0.2)); }
.logo-text { display: flex; flex-direction: column; }
.logo-name { font-size: 17px; font-weight: 800; color: #fff; line-height: 1.1; text-shadow: 0 1px 3px rgba(0,0,0,0.2); }
.logo-sub  { font-size: 10px; font-weight: 700; color: #F6B40E; letter-spacing: .08em; text-transform: uppercase; }

.header-center { flex: 1; }
.search-wrap { position: relative; }
.search-wrap svg {
  position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; color: #74ACDF; pointer-events: none;
}
.search-input {
  width: 100%; padding: 9px 14px 9px 36px;
  border: 1.5px solid rgba(255,255,255,0.4); border-radius: 8px;
  font-size: 14px; font-family: inherit;
  background: rgba(255,255,255,0.92); outline: none;
  transition: border-color .15s, background .15s;
  color: #1a1a1a;
}
.search-input:focus { border-color: #F6B40E; background: #fff; }
.search-input::placeholder { color: #6b7280; }

.cart-btn {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 18px; border-radius: 8px;
  background: #F6B40E; color: #1a1a1a;
  border: none; cursor: pointer; font-family: inherit;
  font-size: 14px; font-weight: 700; flex-shrink: 0;
  position: relative; transition: background .15s;
  box-shadow: 0 2px 8px rgba(246,180,14,0.4);
}
.cart-btn svg { width: 19px; height: 19px; stroke: #1a1a1a; fill: none; }
.cart-btn:hover { background: #e6a800; }
.cart-label { display: none; }
.cart-badge {
  position: absolute; top: -7px; right: -7px;
  background: #1a3a6e; color: white;
  font-size: 10px; font-weight: 700;
  width: 19px; height: 19px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid white;
}

/* ── Banner ───────────────────────────────────────── */
.banner {
  background: #1a3a6e;
  height: var(--banner-h);
  border-bottom: 2px solid #F6B40E;
}
.banner-inner {
  max-width: 1280px; margin: 0 auto;
  padding: 0 24px; height: 100%;
  display: flex; align-items: center; gap: 28px;
  background: #1a3a6e;
}
.banner-pill {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600; color: #F6B40E; white-space: nowrap;
}
.banner-pill svg { width: 14px; height: 14px; flex-shrink: 0; stroke: #74ACDF; }

/* ── Layout ───────────────────────────────────────── */
.layout {
  max-width: 1280px; margin: 0 auto;
  padding: 24px;
  display: grid;
  grid-template-columns: 1fr var(--cart-w);
  gap: 24px;
  align-items: start;
}

/* ── Catalog ──────────────────────────────────────── */
.catalog { min-width: 0; }

.loading-state {
  display: flex; flex-direction: column; align-items: center;
  gap: 14px; padding: 80px 20px; color: var(--c-muted);
  font-size: 14px;
}
.spinner {
  width: 34px; height: 34px;
  border: 3px solid var(--c-border);
  border-top-color: var(--c-primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.section { margin-bottom: 32px; }
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px; padding-bottom: 10px;
  border-bottom: 2px solid var(--c-border);
}
.section-title { font-size: 17px; font-weight: 800; }
.section-count { font-size: 12px; color: var(--c-muted); font-weight: 500; }

.products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(158px, 1fr));
  gap: 12px;
}

/* Card */
.product-card {
  background: var(--c-white);
  border-radius: var(--radius);
  border: 1.5px solid var(--c-border);
  overflow: hidden; cursor: pointer;
  transition: box-shadow .18s, transform .18s, border-color .18s;
  display: flex; flex-direction: column;
}
.product-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
  border-color: #ccc;
}
.product-card.in-cart { border-color: var(--c-primary); }

.product-img-wrap {
  aspect-ratio: 1; background: #fafafa;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; border-bottom: 1px solid var(--c-border);
}
.product-img { width: 100%; height: 100%; object-fit: contain; padding: 12px; }
.product-img-placeholder {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
}

.product-info { padding: 10px 12px 12px; flex: 1; display: flex; flex-direction: column; gap: 5px; }
.product-name {
  font-size: 12.5px; font-weight: 600; line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  color: var(--c-text);
}
.product-price { font-size: 15px; font-weight: 800; color: var(--c-text); }

.product-add-btn {
  margin-top: auto; width: 100%; padding: 7px;
  background: var(--c-primary); color: white;
  border: none; border-radius: 6px; cursor: pointer;
  font-family: inherit; font-size: 13px; font-weight: 700;
  transition: background .15s;
}
.product-add-btn:hover { background: var(--c-primary-d); }

.product-counter {
  margin-top: auto;
  display: flex; align-items: center; justify-content: space-between;
  background: var(--c-primary); border-radius: 6px; overflow: hidden;
}
.product-counter button {
  background: none; border: none; color: white;
  font-size: 20px; font-weight: 700; cursor: pointer;
  width: 36px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  transition: background .1s;
}
.product-counter button:hover { background: rgba(0,0,0,.18); }
.product-counter span { color: white; font-weight: 700; font-size: 14px; }

/* ── Cart Panel (desktop) ─────────────────────────── */
.cart-panel {
  position: sticky;
  top: calc(var(--header-h) + var(--banner-h) + 24px);
  background: var(--c-white);
  border-radius: var(--radius);
  border: 1.5px solid var(--c-border);
  box-shadow: var(--shadow);
  overflow: hidden;
  max-height: calc(100vh - var(--header-h) - var(--banner-h) - 48px);
  display: flex; flex-direction: column;
}
.cart-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--c-border);
  background: var(--c-white);
}
.cart-header h2 { font-size: 15px; font-weight: 800; }

.cart-empty {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 36px 20px; gap: 8px; text-align: center;
}
.cart-empty svg { opacity: .18; }
.cart-empty p { font-size: 14px; font-weight: 600; color: var(--c-muted); }
.cart-empty span { font-size: 12px; color: var(--c-muted); }

.cart-items { flex: 1; overflow-y: auto; }

.cart-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--c-border);
}
.cart-item:last-child { border-bottom: none; }
.cart-item-thumb {
  width: 42px; height: 42px; border-radius: 7px;
  object-fit: contain; background: #f5f5f5;
  flex-shrink: 0; padding: 4px;
  border: 1px solid var(--c-border);
}
.cart-item-thumb-placeholder {
  width: 42px; height: 42px; border-radius: 7px;
  background: #f5f5f5; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; border: 1px solid var(--c-border);
}
.cart-item-info { flex: 1; min-width: 0; }
.cart-item-name { font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cart-item-price { font-size: 12px; color: var(--c-muted); margin-top: 2px; }

.cart-item-controls { display: flex; align-items: center; gap: 5px; flex-shrink: 0; }
.cart-item-controls button {
  width: 25px; height: 25px; border-radius: 50%;
  border: 1.5px solid var(--c-border);
  background: white; cursor: pointer; font-size: 16px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  line-height: 1; transition: border-color .1s, background .1s;
}
.cart-item-controls button:hover { border-color: var(--c-primary); background: var(--c-primary-l); }
.cart-item-qty { font-size: 13px; font-weight: 700; min-width: 16px; text-align: center; }

.cart-footer { padding: 14px 18px; border-top: 1.5px solid var(--c-border); }
.cart-total-row {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 12px; font-size: 14px; font-weight: 600;
}
.cart-total-price { font-size: 20px; font-weight: 900; color: var(--c-primary); }

.btn-checkout {
  width: 100%; padding: 12px;
  background: var(--c-primary); color: white;
  border: none; border-radius: 8px; cursor: pointer;
  font-family: inherit; font-size: 14px; font-weight: 700;
  transition: background .15s;
}
.btn-checkout:hover { background: var(--c-primary-d); }

/* ── Cart Drawer (mobile) ─────────────────────────── */
.cart-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,.5);
  display: flex; align-items: flex-end;
}
.cart-drawer {
  width: 100%; background: var(--c-white);
  border-radius: 18px 18px 0 0;
  max-height: 85vh; display: flex; flex-direction: column;
  animation: slideUp .22s ease;
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.drawer-header {
  padding: 14px 18px;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--c-border);
}
.drawer-header h2 { font-size: 15px; font-weight: 800; }
.drawer-close {
  background: #f0f0f0; border: none; cursor: pointer;
  width: 28px; height: 28px; border-radius: 50%;
  font-size: 13px; font-weight: 700; color: var(--c-text);
}

/* ── Modal Checkout ───────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(0,0,0,.5);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal-box {
  background: var(--c-white);
  border-radius: 14px; width: 100%; max-width: 420px;
  padding: 26px 26px 22px;
  position: relative; box-shadow: var(--shadow-lg);
  animation: fadeIn .18s ease;
  max-height: 90vh; overflow-y: auto;
}
@keyframes fadeIn { from { opacity: 0; transform: scale(.97); } to { opacity: 1; transform: scale(1); } }
.modal-close {
  position: absolute; top: 13px; right: 14px;
  background: #f0f0f0; border: none; cursor: pointer;
  width: 28px; height: 28px; border-radius: 50%;
  font-size: 13px; font-weight: 700; color: var(--c-text);
}
.modal-title { font-size: 18px; font-weight: 800; margin-bottom: 16px; }

.checkout-summary {
  background: var(--c-bg); border-radius: 8px;
  padding: 12px 14px; margin-bottom: 16px;
  max-height: 140px; overflow-y: auto;
}
.checkout-item { display: flex; justify-content: space-between; font-size: 13px; padding: 3px 0; }
.checkout-item-name { color: var(--c-muted); }
.checkout-total {
  display: flex; justify-content: space-between;
  font-size: 14px; font-weight: 800;
  border-top: 1px solid var(--c-border);
  padding-top: 8px; margin-top: 6px;
}

.form-group { margin-bottom: 13px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; color: var(--c-text); }
.form-group input {
  width: 100%; padding: 10px 12px;
  border: 1.5px solid var(--c-border); border-radius: 7px;
  font-size: 14px; font-family: inherit; outline: none;
  transition: border-color .15s;
}
.form-group input:focus { border-color: var(--c-primary); }

.checkout-info {
  display: flex; align-items: flex-start; gap: 7px;
  background: #EFF6FF; border-radius: 7px;
  padding: 10px 12px; font-size: 12px;
  color: #1D4ED8; margin-bottom: 14px; line-height: 1.4;
}
.checkout-info svg { width: 15px; height: 15px; flex-shrink: 0; margin-top: 1px; }

.btn-pay {
  width: 100%; padding: 13px;
  background: var(--c-mp); color: white;
  border: none; border-radius: 8px; cursor: pointer;
  font-family: inherit; font-size: 14px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: background .15s;
}
.btn-pay:hover { background: #007BB5; }
.btn-pay:disabled { background: #9CA3AF; cursor: not-allowed; }
.btn-spinner {
  width: 17px; height: 17px;
  border: 2px solid rgba(255,255,255,.4);
  border-top-color: white; border-radius: 50%;
  animation: spin .7s linear infinite;
}

/* ── Status Page ──────────────────────────────────── */
.status-page {
  position: fixed; inset: 0; z-index: 400;
  background: var(--c-bg);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.status-card {
  background: white; border-radius: 18px;
  padding: 40px 32px; max-width: 400px; width: 100%;
  text-align: center; box-shadow: var(--shadow-lg);
}
.status-icon { margin-bottom: 14px; }
.status-icon svg { width: 64px; height: 64px; }
.status-card h2 { font-size: 20px; font-weight: 800; margin-bottom: 8px; }
.status-card p { color: var(--c-muted); font-size: 14px; margin-bottom: 22px; line-height: 1.5; }

.codigo-box {
  background: var(--c-bg); border-radius: 12px;
  padding: 20px; margin-bottom: 22px;
  border: 2px dashed var(--c-primary);
}
.codigo-label { display: block; font-size: 11px; font-weight: 700; color: var(--c-muted); text-transform: uppercase; letter-spacing: .07em; margin-bottom: 8px; }
.codigo-value { display: block; font-size: 38px; font-weight: 900; letter-spacing: .14em; color: var(--c-primary); }
.codigo-hint { display: block; font-size: 12px; color: var(--c-muted); margin-top: 6px; }

.btn-volver {
  padding: 11px 24px;
  background: var(--c-primary); color: white;
  border: none; border-radius: 8px; cursor: pointer;
  font-family: inherit; font-size: 14px; font-weight: 700;
  transition: background .15s;
}
.btn-volver:hover { background: var(--c-primary-d); }

/* ── Sin resultados ───────────────────────────────── */
.no-results {
  text-align: center; padding: 60px 20px; color: var(--c-muted);
}
.no-results p { font-size: 16px; font-weight: 600; margin-bottom: 5px; }
.no-results span { font-size: 13px; }

/* ── Responsive ───────────────────────────────────── */
@media (min-width: 900px) {
  .cart-label { display: inline; }
}
@media (max-width: 899px) {
  .layout { grid-template-columns: 1fr; padding: 16px; }
  .cart-panel { display: none; }
  .banner-pill:not(:first-child) { display: none; }
  .products-grid { grid-template-columns: repeat(auto-fill, minmax(145px, 1fr)); gap: 10px; }
}
@media (max-width: 480px) {
  .header-inner { padding: 0 14px; gap: 10px; }
  .logo-text { display: none; }
  .products-grid { grid-template-columns: repeat(2, 1fr); }
}
