/* ── Cart icon ─────────────────────────────────────── */
.cart-toggle {
  position: relative;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.4rem;
  color: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.5rem;
  transition: background 0.2s;
}
.cart-toggle:hover { background: rgba(0,0,0,0.06); }
.cart-count {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--primary, #0284c7);
  color: #fff;
  border-radius: 999px;
  min-width: 18px;
  height: 18px;
  font-size: 0.68rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
}

/* ── Cart drawer ────────────────────────────────────── */
.cart-drawer { position: fixed; inset: 0; z-index: 1100; pointer-events: none; }
.cart-drawer.open { pointer-events: all; }
.cart-drawer__overlay {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0);
  transition: background 0.3s;
}
.cart-drawer.open .cart-drawer__overlay { background: rgba(0,0,0,0.45); }
.cart-drawer__panel {
  position: absolute; top: 0; right: 0; bottom: 0;
  width: min(420px, 100vw);
  background: #fff;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(.4,0,.2,1);
  display: flex; flex-direction: column;
  box-shadow: -4px 0 24px rgba(0,0,0,0.12);
}
.cart-drawer.open .cart-drawer__panel { transform: translateX(0); }
.cart-drawer__header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.1rem 1.25rem;
  border-bottom: 1px solid #e2e8f0;
  font-size: 1.05rem; font-weight: 700;
}
.cart-drawer__header button {
  background: none; border: none; cursor: pointer;
  font-size: 1.25rem; color: #64748b;
  width: 2rem; height: 2rem; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.2s;
}
.cart-drawer__header button:hover { background: #f1f5f9; }
.cart-drawer__items { flex: 1; overflow-y: auto; padding: 0.5rem 0; }
.cart-empty { padding: 3rem 1.25rem; text-align: center; color: #94a3b8; font-size: 0.95rem; }
.cart-item {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid #f1f5f9;
}
.cart-item__info { flex: 1; min-width: 0; }
.cart-item__name { font-weight: 600; font-size: 0.88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cart-item__price { font-size: 0.78rem; color: #64748b; margin-top: 0.1rem; }
.cart-item__qty {
  display: flex; align-items: center; gap: 0.35rem;
  background: #f8fafc; border-radius: 0.5rem; padding: 0.2rem 0.4rem;
}
.cart-item__qty button {
  width: 1.4rem; height: 1.4rem; background: none; border: none;
  cursor: pointer; font-size: 1rem; display: flex; align-items: center;
  justify-content: center; border-radius: 0.3rem; color: #334155;
  transition: background 0.15s;
}
.cart-item__qty button:hover { background: #e2e8f0; }
.cart-item__qty span { min-width: 1.5rem; text-align: center; font-size: 0.88rem; font-weight: 600; }
.cart-item__subtotal { font-size: 0.88rem; font-weight: 700; white-space: nowrap; }
.cart-item__remove {
  background: none; border: none; cursor: pointer; color: #94a3b8;
  font-size: 0.9rem; width: 1.5rem; height: 1.5rem; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  transition: color 0.15s, background 0.15s;
}
.cart-item__remove:hover { color: #ef4444; background: #fee2e2; }
.cart-drawer__footer {
  padding: 1.1rem 1.25rem;
  border-top: 1px solid #e2e8f0;
  background: #f8fafc;
}
.cart-total {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 1.05rem; font-weight: 700; margin-bottom: 0.5rem;
}
.cart-shipping {
  display: flex; align-items: center; gap: 0.4rem;
  font-size: 0.8rem; color: #64748b; margin-bottom: 1rem;
}
.cart-checkout-btn {
  width: 100%; justify-content: center; gap: 0.4rem;
  padding: 0.75rem; font-size: 0.95rem; font-weight: 600;
}
.cart-added-btn {
  background: #16a34a !important;
}

/* ── Checkout modal ──────────────────────────────────── */
.checkout-modal {
  position: fixed; inset: 0; z-index: 1200;
  display: flex; align-items: center; justify-content: center;
  padding: max(0.75rem, env(safe-area-inset-top)) max(0.75rem, env(safe-area-inset-right)) max(0.75rem, env(safe-area-inset-bottom)) max(0.75rem, env(safe-area-inset-left));
}
.checkout-overlay {
  position: absolute; inset: 0; background: rgba(0,0,0,0.5);
}
.checkout-panel {
  position: relative; z-index: 1;
  background: #fff; border-radius: 1rem;
  width: min(600px, 100%);
  max-width: 100%;
  max-height: min(92vh, calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 1.5rem));
  min-height: 0;
  display: flex; flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  animation: checkoutSlideIn 0.25s ease;
}
@keyframes checkoutSlideIn {
  from { opacity: 0; transform: translateY(24px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.checkout-header {
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid #e2e8f0;
  gap: 0.75rem;
}
.checkout-header h2 { font-size: clamp(1rem, 4vw, 1.15rem); font-weight: 700; margin: 0; line-height: 1.3; }
.checkout-header button {
  background: none; border: none; cursor: pointer; color: #64748b;
  font-size: 1.25rem; min-width: 44px; min-height: 44px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.checkout-header button:hover { background: #f1f5f9; }
.checkout-panel > form {
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.checkout-body {
  /* Altura máxima explícita: sin esto, flex:1+ basis 0 colapsaba el formulario entero */
  max-height: min(72vh, calc(100dvh - 11.5rem));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 1rem 1.25rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.checkout-body h4 { font-size: 0.88rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: #64748b; margin: 0.75rem 0 0.25rem; }
.checkout-body h4:first-child { margin-top: 0; }
.checkout-summary {
  background: #f8fafc; border-radius: 0.65rem;
  padding: 0.9rem 1rem; display: flex; flex-direction: column; gap: 0.4rem;
  border: 1px solid #e2e8f0;
}
.checkout-item-row { display: flex; justify-content: space-between; font-size: 0.85rem; color: #475569; }
.checkout-total-row {
  display: flex; justify-content: space-between; font-size: 0.95rem;
  font-weight: 700; padding-top: 0.4rem;
  border-top: 1px solid #e2e8f0; margin-top: 0.25rem;
}
.checkout-shipping-row {
  display: flex; justify-content: space-between; font-size: 0.8rem; color: #64748b;
}
.checkout-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.checkout-field { display: flex; flex-direction: column; gap: 0.3rem; }
.checkout-field label { font-size: 0.8rem; font-weight: 600; color: #475569; }
.checkout-field input, .checkout-field select {
  padding: 0.6rem 0.75rem;
  min-height: 44px;
  border: 1px solid #cbd5e1; border-radius: 0.4rem;
  font-size: 16px;
  background: #fff;
  transition: border-color 0.15s;
}
.checkout-field input:focus, .checkout-field select:focus {
  outline: none; border-color: var(--primary, #0284c7);
  box-shadow: 0 0 0 3px rgba(2,132,199,0.1);
}
.checkout-toggle-field { flex-direction: row; align-items: center; }
.checkout-toggle-label {
  display: flex; align-items: center; gap: 0.5rem;
  cursor: pointer; font-size: 0.88rem; font-weight: 500; color: #334155;
  padding: 0.5rem 0;
}
.checkout-toggle-label input[type=checkbox] { width: 1.1rem; height: 1.1rem; cursor: pointer; }
/* display:flex gana a [hidden] del UA si va después — forzar oculto cuando aplique */
.checkout-invoice-block[hidden] {
  display: none !important;
}
.checkout-invoice-block:not([hidden]) {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  margin: 0.15rem 0 0.35rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 0.65rem;
}
.checkout-invoice-intro {
  margin: 0;
  font-size: 0.8rem;
  color: #64748b;
  line-height: 1.45;
}
.checkout-opt { font-weight: 500; color: #94a3b8; }
/* Payment methods */
.payment-methods { display: flex; flex-direction: column; gap: 0.6rem; }
.payment-method {
  display: flex; align-items: flex-start; gap: 0.75rem;
  border: 2px solid #e2e8f0; border-radius: 0.65rem;
  padding: 0.85rem 1rem; cursor: pointer; transition: border-color 0.15s;
  min-height: 52px;
}
.payment-method:has(input:checked) { border-color: var(--primary, #0284c7); background: rgba(2,132,199,0.04); }
.payment-method.disabled { opacity: 0.5; cursor: not-allowed; }
.payment-method input[type=radio] { margin-top: 0.15rem; cursor: pointer; }
.payment-method__body { flex: 1; }
.payment-method__logo {
  display: flex; align-items: center; gap: 0.5rem;
  font-weight: 700; font-size: 0.92rem; margin-bottom: 0.2rem;
}
.payment-method__desc { font-size: 0.8rem; color: #64748b; }
.payment-method__note { font-size: 0.75rem; color: #f59e0b; margin-top: 0.2rem; }
.mp-logo { color: #009EE3; }
.checkout-footer {
  flex-shrink: 0;
  padding: 0.85rem 1.25rem max(0.85rem, env(safe-area-inset-bottom));
  border-top: 1px solid #e2e8f0;
  display: flex; justify-content: space-between; gap: 0.65rem;
}
.checkout-footer .btn {
  flex: 1;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.75rem 0.85rem;
  min-height: 48px;
  font-size: 0.92rem;
}

/* Bank info block */
.bank-info {
  background: #f0fdf4; border: 1px solid #bbf7d0;
  border-radius: 0.65rem; padding: 1rem 1.25rem;
  text-align: left; margin-top: 0.75rem;
}
.bank-info h4 { font-size: 0.88rem; font-weight: 700; color: #166534; margin-bottom: 0.5rem; }
.bank-info p { font-size: 0.82rem; color: #166534; margin-bottom: 0.5rem; }
.bank-detail { display: flex; gap: 0.5rem; font-size: 0.85rem; margin-bottom: 0.25rem; }
.bank-detail span { color: #64748b; min-width: 80px; }

@media (max-width: 640px) {
  .checkout-modal {
    align-items: flex-end;
    padding: 0;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .checkout-panel {
    width: 100%;
    max-height: min(94dvh, calc(100dvh - env(safe-area-inset-top)));
    border-radius: 1rem 1rem 0 0;
  }
  .checkout-item-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.15rem;
  }
}
@media (max-width: 480px) {
  .checkout-grid-2 { grid-template-columns: 1fr; }
  .checkout-footer { flex-direction: column-reverse; }
  .payment-methods { gap: 0.5rem; }
}
