:root {
  --bg-main: #070b18;
  --bg-card: #11182b;
  --bg-card-soft: #151f36;
  --primary: #2f6df6;
  --primary-hover: #2359cf;
  --whatsapp: #25d366;
  --whatsapp-hover: #1eb85a;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --text-main: #ffffff;
  --text-muted: #aeb7cc;
  --border: rgba(255, 255, 255, 0.12);
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
  --radius-lg: 22px;
  --radius-md: 14px;
  --radius-sm: 10px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  font-family: Arial, Helvetica, sans-serif;
  background:
    radial-gradient(circle at top left, rgba(47, 109, 246, 0.28), transparent 35%),
    linear-gradient(135deg, #060914 0%, #0a1024 50%, #071024 100%);
  color: var(--text-main);
}

.checkout-page {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 42px 0;
}

.checkout-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  margin-bottom: 32px;
}

.checkout-kicker {
  display: inline-block;
  color: var(--primary);
  font-weight: 700;
  margin-bottom: 8px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 13px;
}

.checkout-header h1 {
  font-size: clamp(32px, 5vw, 52px);
  line-height: 1;
  margin-bottom: 12px;
}

.checkout-header p {
  color: var(--text-muted);
  max-width: 620px;
  line-height: 1.6;
}

.btn-volver {
  flex-shrink: 0;
  text-decoration: none;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
  border: 1px solid var(--border);
  padding: 13px 18px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  transition: 0.2s ease;
}

.btn-volver:hover {
  background: rgba(255, 255, 255, 0.14);
  transform: translateY(-1px);
}

.checkout-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 24px;
  align-items: start;
}

.checkout-products-card,
.checkout-summary-card {
  background: rgba(17, 24, 43, 0.92);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.checkout-products-card {
  padding: 24px;
  min-height: 360px;
}

.checkout-summary-card {
  padding: 24px;
  position: sticky;
  top: 24px;
}

.section-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 18px;
}

.section-title h2,
.checkout-summary-card h2 {
  font-size: 22px;
}

.section-title span {
  color: var(--text-muted);
  font-size: 14px;
}

.checkout-lista-productos {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.checkout-producto {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  background: var(--bg-card-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
}

.producto-imagen {
  width: 82px;
  height: 82px;
  border-radius: 14px;
  object-fit: cover;
  background: #0a1024;
  border: 1px solid var(--border);
}

.producto-info {
  min-width: 0;
}

.producto-info h3 {
  font-size: 17px;
  margin-bottom: 6px;
  line-height: 1.3;
}

.producto-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.badge {
  font-size: 12px;
  padding: 5px 9px;
  border-radius: 999px;
  font-weight: 700;
}

.badge-online {
  color: #d9ffe7;
  background: rgba(37, 211, 102, 0.16);
  border: 1px solid rgba(37, 211, 102, 0.38);
}

.badge-no-online {
  color: #ffe2e2;
  background: rgba(239, 68, 68, 0.16);
  border: 1px solid rgba(239, 68, 68, 0.38);
}

.producto-precio {
  color: var(--text-main);
  font-weight: 800;
}

.producto-controles {
  display: flex;
  align-items: center;
  gap: 10px;
}

.control-cantidad {
  display: flex;
  align-items: center;
  background: #0b1122;
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
}

.control-cantidad button {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: var(--text-main);
  cursor: pointer;
  font-size: 18px;
  font-weight: 800;
}

.control-cantidad button:hover {
  background: rgba(255, 255, 255, 0.08);
}

.control-cantidad span {
  min-width: 34px;
  text-align: center;
  font-weight: 700;
}

.btn-eliminar {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 999px;
  background: rgba(239, 68, 68, 0.16);
  color: #fecaca;
  cursor: pointer;
  font-size: 18px;
  transition: 0.2s ease;
}

.btn-eliminar:hover {
  background: rgba(239, 68, 68, 0.32);
}

.summary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}

.summary-row span {
  color: var(--text-muted);
}

.summary-row strong {
  font-size: 22px;
}

.inventory-warning {
  margin: 18px 0;
  padding: 13px;
  border-radius: var(--radius-sm);
  background: rgba(245, 158, 11, 0.14);
  border: 1px solid rgba(245, 158, 11, 0.32);
  color: #fde68a;
  line-height: 1.5;
  font-size: 14px;
}

.btn-full {
  width: 100%;
  margin-top: 12px;
}

.btn-primary,
.btn-whatsapp,
.btn-danger {
  border: none;
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  transition: 0.2s ease;
}

.btn-primary {
  display: inline-block;
  text-decoration: none;
  background: var(--primary);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

.btn-primary:disabled {
  background: #334155;
  color: #94a3b8;
  cursor: not-allowed;
  transform: none;
}

.btn-whatsapp {
  background: var(--whatsapp);
  color: #06120b;
}

.btn-whatsapp:hover {
  background: var(--whatsapp-hover);
  transform: translateY(-1px);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.14);
  color: #fecaca;
  border: 1px solid rgba(239, 68, 68, 0.36);
}

.btn-danger:hover {
  background: var(--danger-hover);
  color: white;
  transform: translateY(-1px);
}

.summary-note {
  margin-top: 16px;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.5;
}

.checkout-empty {
  text-align: center;
  padding: 48px 18px;
}

.empty-icon {
  font-size: 52px;
  margin-bottom: 14px;
}

.checkout-empty h3 {
  font-size: 24px;
  margin-bottom: 8px;
}

.checkout-empty p {
  color: var(--text-muted);
  margin-bottom: 22px;
}

.hidden {
  display: none !important;
}

@media (max-width: 900px) {
  .checkout-layout {
    grid-template-columns: 1fr;
  }

  .checkout-summary-card {
    position: static;
  }

  .checkout-header {
    flex-direction: column;
  }
}

@media (max-width: 620px) {
  .checkout-page {
    width: min(100% - 20px, 1180px);
    padding: 24px 0;
  }

  .checkout-products-card,
  .checkout-summary-card {
    padding: 18px;
  }

  .checkout-producto {
    grid-template-columns: 68px 1fr;
  }

  .producto-imagen {
    width: 68px;
    height: 68px;
  }

  .producto-controles {
    grid-column: 1 / -1;
    justify-content: space-between;
  }

  .section-title {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* =========================================================
   DATOS DEL CLIENTE EN CHECKOUT
   ========================================================= */

.checkout-customer-box {
  margin: 18px 0;
  padding: 16px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
}

.checkout-customer-box h3 {
  font-size: 17px;
  margin-bottom: 14px;
}

.checkout-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

.checkout-field:last-child {
  margin-bottom: 0;
}

.checkout-field label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
}

.checkout-field input {
  width: 100%;
  min-height: 44px;
  padding: 12px 13px;

  border-radius: 10px;
  border: 1px solid var(--border);

  background: #0b1122;
  color: var(--text-main);

  outline: none;
  font-size: 14px;
}

.checkout-field input::placeholder {
  color: #64748b;
}

.checkout-field input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(47, 109, 246, 0.18);
}

.checkout-field input.input-error {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.18);
}


/* =========================================================
   LOADER INTERNO CHECKOUT
   ========================================================= */

.checkout-page-loader {
  position: fixed;
  inset: 0;
  z-index: 99999;

  display: flex;
  align-items: center;
  justify-content: center;

  padding: 22px;

  background:
    radial-gradient(circle at top, rgba(47, 109, 246, 0.28), transparent 35%),
    radial-gradient(circle at bottom right, rgba(0, 255, 204, 0.16), transparent 35%),
    #060914;

  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.checkout-page-loader.hide {
  opacity: 0;
  visibility: hidden;
}

.checkout-page-loader-card {
  width: min(420px, 100%);
  padding: 32px 24px;

  border-radius: 24px;
  border: 1px solid rgba(47, 109, 246, 0.35);

  background:
    linear-gradient(180deg, rgba(17, 24, 43, 0.96), rgba(7, 11, 24, 0.98));

  box-shadow:
    0 25px 70px rgba(0, 0, 0, 0.55),
    0 0 45px rgba(47, 109, 246, 0.2);

  text-align: center;
  color: #ffffff;
  animation: checkoutLoaderIn 0.35s ease forwards;
}

.checkout-page-loader-logo {
  margin-bottom: 22px;

  font-size: clamp(26px, 7vw, 38px);
  font-weight: 900;
  letter-spacing: 1px;

  background: linear-gradient(90deg, #ffffff, #00aaff, #00ffcc);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;

  text-shadow:
    0 0 18px rgba(0, 170, 255, 0.35),
    0 0 35px rgba(0, 255, 204, 0.18);

  animation: checkoutLoaderLogoPulse 1.15s ease-in-out infinite;
}

.checkout-page-loader-ring {
  width: 72px;
  height: 72px;

  margin: 0 auto 20px;

  border-radius: 50%;
  padding: 5px;

  background:
    conic-gradient(from 0deg, #2f6df6, #00aaff, #00ffcc, #2f6df6);

  animation: checkoutLoaderSpin 0.9s linear infinite;
}

.checkout-page-loader-ring span {
  display: block;
  width: 100%;
  height: 100%;

  border-radius: 50%;
  background: #070b18;
}

.checkout-page-loader-card h3 {
  margin: 0 0 8px;
  font-size: 22px;
  font-weight: 900;
}

.checkout-page-loader-card p {
  max-width: 320px;
  margin: 0 auto;

  color: #aeb7cc;
  font-size: 14px;
  line-height: 1.5;
}

@keyframes checkoutLoaderIn {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.96);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes checkoutLoaderLogoPulse {
  0%, 100% {
    transform: scale(1);
    filter: drop-shadow(0 0 8px rgba(0, 170, 255, 0.2));
  }

  50% {
    transform: scale(1.04);
    filter: drop-shadow(0 0 16px rgba(0, 255, 204, 0.35));
  }
}

@keyframes checkoutLoaderSpin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 600px) {
  .checkout-page-loader {
    padding: 18px;
  }

  .checkout-page-loader-card {
    padding: 28px 18px;
    border-radius: 22px;
  }

  .checkout-page-loader-ring {
    width: 64px;
    height: 64px;
  }

  .checkout-page-loader-card h3 {
    font-size: 20px;
  }

  .checkout-page-loader-card p {
    font-size: 13px;
  }
}

/* =========================================================
   REDIRECCIÓN A WHATSAPP DESDE CHECKOUT
   ========================================================= */

.whatsapp-redirect-overlay {
  position: fixed;
  inset: 0;
  z-index: 99999;

  display: flex;
  align-items: center;
  justify-content: center;

  padding: 20px;

  background:
    radial-gradient(circle at top, rgba(37, 211, 102, 0.18), transparent 34%),
    radial-gradient(circle at bottom right, rgba(47, 109, 246, 0.22), transparent 38%),
    rgba(6, 9, 20, 0.97);

  backdrop-filter: blur(10px);

  opacity: 1;
  visibility: visible;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.whatsapp-redirect-overlay.hide {
  opacity: 0;
  visibility: hidden;
}

.whatsapp-redirect-card {
  width: min(560px, 100%);
  max-height: min(92vh, 720px);
  overflow-y: auto;

  padding: 28px 24px;
  border-radius: 24px;

  background:
    linear-gradient(180deg, rgba(17, 24, 43, 0.97), rgba(7, 11, 24, 0.99));

  border: 1px solid rgba(255, 255, 255, 0.1);

  box-shadow:
    0 25px 70px rgba(0, 0, 0, 0.55),
    0 0 45px rgba(37, 211, 102, 0.14);

  color: #ffffff;
  text-align: center;

  animation: whatsappCardIn 0.35s ease forwards;
}

.whatsapp-brand {
  margin-bottom: 10px;

  font-size: clamp(28px, 6vw, 42px);
  font-weight: 900;
  letter-spacing: 1px;
}

.whatsapp-brand span {
  background: linear-gradient(90deg, #2f6df6, #00aaff, #25d366);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.whatsapp-status-badge {
  width: fit-content;
  margin: 0 auto 16px;
  padding: 7px 14px;

  border-radius: 999px;

  background: rgba(37, 211, 102, 0.12);
  border: 1px solid rgba(37, 211, 102, 0.32);
  color: #bbf7d0;

  font-size: 12px;
  font-weight: 800;
}

.whatsapp-redirect-card h3 {
  margin: 0 0 10px;
  font-size: clamp(22px, 5vw, 30px);
  font-weight: 900;
  line-height: 1.15;
}

.whatsapp-main-text {
  max-width: 440px;
  margin: 0 auto 20px;

  color: #cbd5e1;
  font-size: 15px;
  line-height: 1.6;
}

.whatsapp-main-text strong {
  color: #ffffff;
}

.whatsapp-summary-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;

  margin-bottom: 18px;
}

.whatsapp-summary-grid div {
  padding: 14px 10px;

  border-radius: 16px;

  background: rgba(255, 255, 255, 0.045);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.whatsapp-summary-grid span {
  display: block;
  margin-bottom: 6px;

  color: #aeb7cc;
  font-size: 12px;
  font-weight: 700;
}

.whatsapp-summary-grid strong {
  color: #ffffff;
  font-size: 15px;
  font-weight: 900;
  word-break: break-word;
}

.whatsapp-products-box {
  margin-bottom: 22px;
  padding: 16px;

  border-radius: 18px;

  background: rgba(255, 255, 255, 0.045);
  border: 1px solid rgba(255, 255, 255, 0.08);

  text-align: left;
}

.whatsapp-products-box h4 {
  margin: 0 0 10px;

  color: #ffffff;
  font-size: 15px;
}

.whatsapp-products-box ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.whatsapp-products-box li {
  display: flex;
  justify-content: space-between;
  gap: 12px;

  padding: 8px 0;

  border-bottom: 1px solid rgba(255, 255, 255, 0.06);

  color: #dbe4f0;
  font-size: 14px;
}

.whatsapp-products-box li:last-child {
  border-bottom: none;
}

.whatsapp-products-box li span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.whatsapp-products-box li strong {
  flex-shrink: 0;
  color: #ffffff;
}

.whatsapp-product-extra {
  color: #94a3b8 !important;
  font-style: italic;
}

.whatsapp-animation-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;

  margin: 8px 0 14px;
}

.whatsapp-cart-icon,
.whatsapp-icon {
  width: 60px;
  height: 60px;

  display: flex;
  align-items: center;
  justify-content: center;

  border-radius: 999px;
  font-weight: 900;
}

.whatsapp-cart-icon {
  background: rgba(47, 109, 246, 0.14);
  border: 1px solid rgba(47, 109, 246, 0.3);

  font-size: 26px;

  animation: whatsappCartMove 1.2s ease-in-out infinite;
}

.whatsapp-icon {
  background: rgba(37, 211, 102, 0.16);
  border: 1px solid rgba(37, 211, 102, 0.36);

  color: #25d366;
  font-size: 18px;
  letter-spacing: 1px;

  box-shadow: 0 0 24px rgba(37, 211, 102, 0.16);
}

.whatsapp-path {
  position: relative;

  height: 7px;
  overflow: hidden;

  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}

.whatsapp-path span {
  position: absolute;
  top: 0;
  left: -35%;

  width: 35%;
  height: 100%;

  border-radius: 999px;

  background: linear-gradient(90deg, #2f6df6, #00aaff, #25d366);

  animation: whatsappPathMove 1.2s linear infinite;
}

.whatsapp-small-note {
  margin: 0;

  color: #86efac;
  font-size: 14px;
  font-weight: 800;
}

@keyframes whatsappCardIn {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.96);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes whatsappPathMove {
  from {
    left: -35%;
  }

  to {
    left: 100%;
  }
}

@keyframes whatsappCartMove {
  0%, 100% {
    transform: translateX(0);
  }

  50% {
    transform: translateX(7px);
  }
}

@media (max-width: 640px) {
  .whatsapp-redirect-overlay {
    padding: 14px;
    align-items: center;
  }

  .whatsapp-redirect-card {
    padding: 22px 16px;
    border-radius: 22px;
    max-height: 92vh;
  }

  .whatsapp-summary-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .whatsapp-main-text {
    font-size: 14px;
  }

  .whatsapp-products-box {
    padding: 14px;
  }

  .whatsapp-products-box li {
    font-size: 13px;
  }

  .whatsapp-cart-icon,
  .whatsapp-icon {
    width: 52px;
    height: 52px;
  }

  .whatsapp-cart-icon {
    font-size: 22px;
  }

  .whatsapp-icon {
    font-size: 15px;
  }
}


/* =========================================================
   SECUENCIA WHATSAPP: CONTADOR + CARRITO
   ========================================================= */

.whatsapp-animation-row {
  opacity: 0.45;
}

.whatsapp-animation-row .whatsapp-cart-icon {
  animation: none;
}

.whatsapp-animation-row .whatsapp-path span {
  animation: none;
}

.whatsapp-animation-row.active {
  opacity: 1;
}

.whatsapp-animation-row.active .whatsapp-cart-icon {
  animation: whatsappCartMove 0.9s ease-in-out infinite;
}

.whatsapp-animation-row.active .whatsapp-path span {
  animation: whatsappPathMove 0.9s linear infinite;
}

/* =========================================================
   CONFIRMACIÓN FINAL DESPUÉS DE WHATSAPP
   ========================================================= */

.whatsapp-final-card {
  animation: whatsappCardIn 0.28s ease forwards;
}

.whatsapp-final-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 18px 0 14px;
}

.whatsapp-final-actions button {
  min-height: 44px;
  border: none;
  border-radius: 12px;
  cursor: pointer;

  font-size: 14px;
  font-weight: 900;
  transition: 0.2s ease;
}

.whatsapp-final-actions button:first-child {
  background: linear-gradient(135deg, #2f6df6, #00aaff);
  color: #ffffff;
}

.whatsapp-final-actions button:last-child {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.whatsapp-final-actions button:hover {
  transform: translateY(-1px);
}

@media (max-width: 640px) {
  .whatsapp-final-actions {
    grid-template-columns: 1fr;
  }
}