﻿/* ── Overlay ──────────────────────────────────── */
.cart-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(4px);
  z-index: 1999;
  opacity: 0; visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}
.cart-overlay.active { opacity: 1; visibility: visible; }

/* ── Modal base ───────────────────────────────── */
.cart-sidebar {
  position: fixed;
  z-index: 2000;
  background: #fff;
  display: flex; flex-direction: column;
  overflow: hidden;
  opacity: 0; visibility: hidden;
  transition:
    transform 0.4s cubic-bezier(0.22,1,0.36,1),
    opacity 0.3s ease,
    visibility 0s linear 0.4s;
}

/* ── Mobile: pantalla completa ────────────────── */
@media (max-width: 768px) {
  .cart-sidebar {
    top: 0; right: 0;
    width: 100vw; height: 100dvh;
    border-radius: 0; transform: translateX(100%);
  }
  .cart-sidebar.active {
    transform: translateX(0); opacity: 1; visibility: visible;
    transition: transform 0.4s cubic-bezier(0.22,1,0.36,1), opacity 0.25s ease, visibility 0s;
  }
}

/* ── Desktop: modal centrado ──────────────────── */
@media (min-width: 769px) {
  .cart-sidebar {
    top: 50%; left: 50%;
    width: min(580px, 96vw);
    height: min(92vh, 820px);
    border-radius: 22px;
    box-shadow: 0 40px 100px rgba(0,0,0,0.24), 0 8px 24px rgba(0,0,0,0.10);
    transform: translate(-50%,-50%) scale(0.94);
  }
  .cart-sidebar.active {
    transform: translate(-50%,-50%) scale(1);
    opacity: 1; visibility: visible;
    transition: transform 0.38s cubic-bezier(0.22,1,0.36,1), opacity 0.25s ease, visibility 0s;
  }
}

/* ── Brand Header ─────────────────────────────── */
.cart-brand-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid #f0f0f0;
  flex-shrink: 0;
  background: #fff;
}
.cart-brand-img {
  height: 56px; width: auto;
  object-fit: contain; display: block;
}

/* ── Close ────────────────────────────────────── */
.cart-close {
  width: 34px; height: 34px; border-radius: 50%;
  background: #f5f5f5; border: none;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: #666; flex-shrink: 0;
  transition: background 0.2s, color 0.2s;
}
.cart-close:hover { background: #eee; color: #111; }

/* ── Steps wrapper ────────────────────────────── */
.cart-steps-wrapper {
  display: flex; width: 200%; flex: 1; min-height: 0;
  transition: transform 0.42s cubic-bezier(0.22,1,0.36,1);
}
.cart-steps-wrapper.show-step-2 { transform: translateX(-50%); }

.cart-step {
  width: 50%; flex-shrink: 0;
  display: flex; flex-direction: column;
  min-height: 0; overflow: hidden;
}

/* ── Step headers ─────────────────────────────── */
.cart-step-header {
  display: flex; align-items: center;
  padding: 12px 18px 10px;
  border-bottom: 1px solid #f0f0f0;
  flex-shrink: 0;
}
.cart-step-header--back { justify-content: space-between; }

.cart-header-left { display: flex; flex-direction: column; gap: 1px; }
.cart-title { font-size: 15px; font-weight: 800; color: #111; margin: 0; }
.cart-header-count { font-size: 11px; color: #aaa; font-weight: 500; }
.cart-step-label { font-size: 11px; color: #bbb; font-weight: 600; }

.cart-back-btn {
  display: flex; align-items: center; gap: 4px;
  background: none; border: none; cursor: pointer;
  font-size: 13px; font-weight: 600; color: #555;
  padding: 5px 8px; border-radius: 8px;
  transition: background 0.2s, color 0.2s;
}
.cart-back-btn:hover { background: #f5f5f5; color: #111; }

/* ── Progress bar (step 2) ────────────────────── */
.cart-progress-bar {
  height: 3px; background: #f0f0f0; flex-shrink: 0; overflow: hidden;
}
.cart-progress-fill {
  height: 100%; width: 100%;
  background: linear-gradient(90deg, #16a34a, #22c55e);
}

/* ── Step 1: Cart items ───────────────────────── */
.cart-items {
  flex: 1; overflow-y: auto;
  padding: 10px 14px;
  display: flex; flex-direction: column; gap: 8px;
  scrollbar-width: thin; scrollbar-color: #e0e0e0 transparent;
}

.cart-empty {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 10px; height: 100%; color: #bbb; text-align: center; padding: 30px 0;
}
.cart-empty svg { opacity: 0.22; }
.cart-empty-title { font-size: 14px; font-weight: 700; color: #888; margin: 0; }
.cart-empty-sub { font-size: 11px; color: #bbb; margin: 0; }

.cart-item {
  display: grid; grid-template-columns: 62px 1fr 24px;
  gap: 10px; align-items: start;
  padding: 10px; background: #fafafa;
  border: 1px solid #f0f0f0; border-radius: 12px;
  transition: border-color 0.2s;
}
.cart-item:hover { border-color: #e0e0e0; }

.cart-item-img {
  width: 62px; height: 62px;
  object-fit: contain; border-radius: 8px; background: #fff; display: block;
}
.cart-item-info { display: flex; flex-direction: column; gap: 2px; }
.cart-item-name {
  font-size: 12px; font-weight: 700; color: #111; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.cart-item-unit-price { font-size: 10px; color: #aaa; }
.cart-item-subtotal { font-size: 13px; font-weight: 800; color: #111; }

.cart-qty { display: flex; align-items: center; gap: 6px; margin-top: 5px; }
.cart-qty-btn {
  width: 24px; height: 24px; border-radius: 50%;
  border: 1.5px solid #e0e0e0; background: #fff;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 14px; font-weight: 700; color: #333;
  line-height: 1; flex-shrink: 0;
  transition: border-color 0.2s, background 0.2s, color 0.2s;
}
.cart-qty-btn:hover:not(:disabled) { border-color: #111; background: #111; color: #fff; }
.cart-qty-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.cart-qty-num { font-size: 13px; font-weight: 700; color: #111; min-width: 14px; text-align: center; }
.cart-qty-max { font-size: 10px; color: #d97706; }

.cart-item-remove {
  background: none; border: none; cursor: pointer;
  color: #ccc; padding: 2px; border-radius: 5px;
  display: flex; align-items: center; justify-content: center;
  transition: color 0.2s, background 0.2s; margin-top: 2px;
}
.cart-item-remove:hover { color: #dc2626; background: #fff1f1; }

/* ── Cart footer ──────────────────────────────── */
.cart-footer {
  padding: 10px 14px 16px;
  border-top: 1px solid #f0f0f0; flex-shrink: 0;
  display: flex; flex-direction: column; gap: 8px;
}

.cart-shipping-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 12px; background: #f0fdf4; border-radius: 10px;
  font-size: 11px; color: #15803d; font-weight: 600;
}
.cart-shipping-bar.achieved { background: #dcfce7; }
.cart-shipping-icon {
  width: 24px; height: 24px; border-radius: 50%;
  background: #dcfce7;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}

.cart-summary { display: flex; flex-direction: column; gap: 1px; }
.cart-summary-row {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 12px; color: #888; padding: 2px 0;
}
.cart-summary-total {
  font-size: 16px; font-weight: 800; color: #111;
  border-top: 1px solid #f0f0f0; margin-top: 4px; padding-top: 8px;
}

/* ── Buttons ──────────────────────────────────── */
.cart-checkout-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 14px;
  background: #111; color: #fff; border: none; border-radius: 12px;
  font-size: 15px; font-weight: 700; cursor: pointer;
  transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
  letter-spacing: 0.1px;
}
.cart-checkout-btn:hover { background: #222; transform: translateY(-1px); box-shadow: 0 4px 16px rgba(0,0,0,0.18); }
.cart-checkout-btn:active { transform: translateY(0); box-shadow: none; }

.cart-checkout-btn--confirm {
  background: linear-gradient(135deg, #16a34a 0%, #15803d 100%);
  font-size: 16px; padding: 15px;
  box-shadow: 0 4px 20px rgba(22,163,74,0.3);
}
.cart-checkout-btn--confirm:hover {
  background: linear-gradient(135deg, #15803d 0%, #14532d 100%);
  box-shadow: 0 6px 24px rgba(22,163,74,0.4);
}
.cart-checkout-btn--confirm:disabled {
  background: #d1d5db; box-shadow: none; cursor: not-allowed; transform: none;
}

.cart-security {
  display: flex; align-items: center; justify-content: center;
  gap: 5px; font-size: 10px; color: #bbb; margin: 0;
}

/* ── Step 2: Shipping Form ────────────────────── */
.cart-form-scroll {
  flex: 1; overflow-y: auto;
  padding: 20px 22px 20px;
  scrollbar-width: thin; scrollbar-color: #e0e0e0 transparent;
}

.cart-form-header { margin-bottom: 18px; }
.cart-form-title {
  font-size: 24px; font-weight: 900; color: #111;
  margin: 0; letter-spacing: -0.4px;
}

/* Form layout */
.form-row {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px;
}
.form-field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.form-field:last-child { margin-bottom: 0; }

.form-label {
  font-size: 12px; font-weight: 600; color: #555;
  letter-spacing: 0.1px;
}

/* Input wrapper */
.form-input-wrap {
  position: relative; display: flex;
}

/* SVG valid checkmark */
.form-valid-check {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  color: #16a34a; opacity: 0; transition: opacity 0.2s;
  pointer-events: none; display: flex; align-items: center;
}
.form-valid-check--phone { right: 12px; }

/* Inputs */
.form-input, .form-select {
  width: 100%; padding: 11px 38px 11px 14px;
  border: 1.5px solid #e2e2e2; border-radius: 10px;
  font-family: inherit; font-size: 14px; color: #111;
  background: #fff; box-sizing: border-box;
  transition: border-color 0.2s, box-shadow 0.2s;
  appearance: none; -webkit-appearance: none;
}
.form-input::placeholder { color: #b0b0b0; }
.form-input:focus, .form-select:focus {
  outline: none; border-color: #111;
  box-shadow: 0 0 0 3px rgba(0,0,0,0.07);
}
.form-input.error, .form-select.error {
  border-color: #e53e3e;
  box-shadow: 0 0 0 3px rgba(229,62,62,0.09);
}
.form-input.valid, .form-select.valid {
  border-color: #22c55e;
}
.form-input.valid + .form-valid-check,
.form-select.valid + .form-valid-check { opacity: 1; }

/* Select arrow */
.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='11' height='11' viewBox='0 0 24 24' fill='none' stroke='%23aaa' stroke-width='2.5' stroke-linecap='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 13px center;
  cursor: pointer;
}
.form-select:disabled { opacity: 0.4; cursor: not-allowed; }

/* Phone wrap */
.form-phone-wrap {
  display: flex; align-items: center; position: relative;
  border: 1.5px solid #e2e2e2; border-radius: 10px;
  background: #fff; overflow: hidden;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.form-phone-wrap:focus-within {
  border-color: #111;
  box-shadow: 0 0 0 3px rgba(0,0,0,0.07);
}
.form-phone-wrap.error {
  border-color: #e53e3e;
  box-shadow: 0 0 0 3px rgba(229,62,62,0.09);
}
.form-phone-wrap.valid { border-color: #22c55e; }
.form-phone-wrap.valid .form-valid-check--phone { opacity: 1; }

.form-phone-prefix {
  display: flex; align-items: center; gap: 7px;
  padding: 11px 13px;
  font-size: 13px; font-weight: 600; color: #444;
  border-right: 1.5px solid #ebebeb;
  white-space: nowrap; background: #f7f7f7; flex-shrink: 0;
  line-height: 1;
}
.form-input--phone {
  border: none; border-radius: 0; background: transparent;
  flex: 1; padding: 11px 38px 11px 13px;
  font-family: inherit; font-size: 14px; color: #111;
}
.form-input--phone:focus { outline: none; }

/* Error messages */
.form-error {
  font-size: 11px; color: #e53e3e; font-weight: 500;
  overflow: hidden; max-height: 0;
  transition: max-height 0.15s ease;
  padding-left: 2px;
}
.form-error:not(:empty) { max-height: 30px; }

/* Order summary */
.cart-order-summary {
  background: #f8f9fa; border-radius: 12px;
  border: 1px solid #f0f0f0;
  padding: 11px 13px; margin-bottom: 10px; margin-top: 4px;
}
.cart-order-summary-title {
  font-size: 9px; font-weight: 700; letter-spacing: 1.5px;
  color: #bbb; text-transform: uppercase; margin-bottom: 7px;
}
.cart-order-summary-item {
  display: flex; justify-content: space-between;
  font-size: 12px; color: #666; padding: 2px 0;
}
.cart-order-summary-item span:last-child { font-weight: 700; color: #111; }
.cart-order-summary-shipping {
  background: #f0fdf4; border-radius: 7px;
  padding: 4px 6px; margin: 4px 0;
}
.cart-order-summary-shipping span:first-child { color: #15803d; font-weight: 600; }

.cart-order-summary-total {
  display: flex; justify-content: space-between;
  font-size: 15px; font-weight: 900; color: #111;
  border-top: 1px solid #e8e8e8; margin-top: 7px; padding-top: 8px;
}

/* ── Mobile ───────────────────────────────────── */
@media (max-width: 480px) {
  .form-row { grid-template-columns: 1fr; gap: 0; }
  .cart-form-scroll { padding: 12px 14px 14px; }
  .cart-form-title { font-size: 18px; }
}
