/* =========================================================
   CARRITO + MODAL DE CHECKOUT - COMARCAAPP / YA-IA
   ========================================================= */

/* ---------- Overlay del modal ---------- */

.checkout-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 9999;
}

/* ---------- Caja principal del modal ---------- */

.checkout-modal {
  background: #ffffff;
  border-radius: 18px;
  max-width: 420px;
  width: 100%;
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.25);
  padding: 1.75rem 1.9rem;
  position: relative;
  font-family: inherit;
  animation: checkoutFadeUp 0.22s ease-out;
}

/* Animación suave de entrada */
@keyframes checkoutFadeUp {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ---------- Botón de cerrar (X) ---------- */

.checkout-modal-close {
  position: absolute;
  top: 10px;
  right: 12px;
  border: none;
  background: transparent;
  font-size: 1.4rem;
  cursor: pointer;
  color: #64748b;
  line-height: 1;
  padding: 4px;
  transition: transform 0.12s ease, color 0.12s ease;
}

.checkout-modal-close:hover {
  color: #0f172a;
  transform: scale(1.08);
}

/* ---------- Títulos ---------- */

.checkout-modal h2 {
  font-size: 1.3rem;
  margin: 0 0 0.75rem 0;
  color: #0f172a;
}

.checkout-modal h3 {
  font-size: 0.95rem;
  margin: 1rem 0 0.35rem 0;
  color: #1e293b;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* ---------- Secciones internas ---------- */

.checkout-section {
  margin-bottom: 0.9rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid #e2e8f0;
}

.checkout-section.resumen {
  border-bottom: none;
  margin-bottom: 1.2rem;
}

/* ---------- Opciones de pago y dirección ---------- */

.pago-option,
.direccion-option {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 0.95rem;
  padding: 0.45rem 0.6rem;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s ease, box-shadow 0.15s ease;
  color: #0f172a;
}

.pago-option:hover,
.direccion-option:hover {
  background: #f8fafc;
  box-shadow: 0 0 0 1px #e2e8f0;
}

.pago-option input,
.direccion-option input {
  margin-top: 2px;
}

/* ---------- Dirección guardada ---------- */

.direccion-guardada {
  font-size: 0.82rem;
  color: #475569;
  margin-top: 3px;
}

.direccion-guardada.vacia {
  color: #ef4444;
}

/* ---------- Textarea de “otra dirección” ---------- */

.checkout-textarea {
  width: 100%;
  margin-top: 0.45rem;
  min-height: 70px;
  resize: vertical;
  font-size: 0.9rem;
  padding: 0.5rem 0.6rem;
  border-radius: 10px;
  border: 1px solid #cbd5f5;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.checkout-textarea:focus {
  border-color: #0ea5e9;
  box-shadow: 0 0 0 1px rgba(14, 165, 233, 0.45);
}

/* ---------- Total y textos ---------- */

.checkout-section.resumen p {
  margin: 0;
  font-size: 0.95rem;
  color: #0f172a;
}

/* ---------- Botones del modal ---------- */

.checkout-actions {
  display: flex;
  gap: 0.6rem;
  justify-content: flex-end;
}

.checkout-modal .btn-primary,
.checkout-modal .btn-secondary {
  border-radius: 999px;
  padding: 0.5rem 1.15rem;
  font-size: 0.95rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease,
    background-color 0.12s ease, color 0.12s ease;
  white-space: nowrap;
}

/* Primario (Confirmar) */
.checkout-modal .btn-primary {
  background: linear-gradient(135deg, #0ea5e9, #2563eb);
  color: #ffffff;
  box-shadow: 0 10px 20px rgba(37, 99, 235, 0.35);
}

.checkout-modal .btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 26px rgba(37, 99, 235, 0.45);
}

/* Secundario (Cancelar) */
.checkout-modal .btn-secondary {
  background: #e2e8f0;
  color: #0f172a;
}

.checkout-modal .btn-secondary:hover {
  background: #cbd5f5;
}

/* ---------- RESPONSIVE ---------- */
@media (min-width: 640px) {
  .checkout-modal {
    max-width: 460px;
  }
}

/* =======================================================
   ESTILOS DEL CARRITO (Modern Glassmorphism)
   ======================================================= */

/* Contenedor de la lista */
.lista-carrito {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Tarjeta de cada producto */
.carrito-item {
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.03); /* Fondo muy sutil */
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  padding: 1rem;
  transition: transform 0.2s, background 0.2s;
  position: relative;
  overflow: hidden;
}

.carrito-item:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.15);
}

/* Imagen del producto */
.carrito-img {
  width: 70px;
  height: 70px;
  flex-shrink: 0;
  border-radius: 12px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.05);
  display: flex;
  align-items: center;
  justify-content: center;
}

.carrito-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.carrito-img span {
  font-size: 1.5rem; /* Icono cámara por defecto */
}

/* Info del producto (Nombre y Precio Unitario) */
.carrito-info {
  flex: 1;
  padding: 0 1rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.carrito-info h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.2rem;
  color: #fff;
}

.precio-unit {
  font-size: 0.85rem;
  color: #9ca3af; /* Gris claro */
}

/* Controles (Cantidad, Subtotal, Borrar) */
.carrito-control {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.5rem;
}

/* Selector de Cantidad (+ 1 -) */
.qty-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(0, 0, 0, 0.2); /* Fondo un poco más oscuro para contraste */
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 50px; /* Bordes totalmente redondos */
  padding: 4px; /* Espacio interno para que los botones respiren */
  width: 120px;
  margin-bottom: 10px;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3); /* Sombra interna (profundidad) */
}

/* Botones (+ y -) */
.btn-qty {
  width: 34px; /* Un poquito más grandes */
  height: 34px;
  border: none;
  border-radius: 50%; /* Círculo perfecto */
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-size: 1.2rem;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;

  /* Animación Elástica Suave */
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);

  line-height: 1;
  padding-bottom: 3px; /* Ajuste óptico del texto */
}

/* Animación al pasar el mouse (Hover) */
.btn-qty:hover {
  background: #4da3ff; /* Azul brillante */
  box-shadow: 0 0 15px rgba(77, 163, 255, 0.6); /* Resplandor */
  transform: scale(1.1) rotate(90deg); /* Crece y rota sutilmente (solo si es +) */
}

/* Corrección para que el menos (-) no rote raro, o rotarlo también si quieres */
.btn-qty.btn-qty-minus:hover {
  transform: scale(1.1); /* El menos solo crece */
}
.btn-qty.btn-qty-plus:hover {
  transform: scale(1.1) rotate(90deg); /* El más gira divertido */
}

/* Animación al hacer Clic (Active) - Efecto "Pulsar" */
.btn-qty:active {
  transform: scale(0.85); /* Se achica rápido */
  background: #2563eb;
  transition: transform 0.1s ease; /* Reacción instantánea */
}

/* Número del centro */
.carrito-cantidad {
  font-size: 1.2rem;
  font-weight: 800;
  color: #fff;
  min-width: 30px;
  text-align: center;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}
.carrito-cantidad {
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0 8px;
  min-width: 20px;
  text-align: center;
}

/* Subtotal destacado */
.subtotal {
  font-size: 1rem;
  font-weight: 700;
  color: #2ecc71; /* Verde dinero */
  margin: 0;
}

/* Botón Eliminar (Tachito rojo) */
.btn-remove-item {
  background: transparent;
  border: none;
  color: #ef4444; /* Rojo */
  font-size: 1.1rem;
  cursor: pointer;
  padding: 5px;
  border-radius: 8px;
  transition: all 0.2s;
  opacity: 0.7;
}

.btn-remove-item:hover {
  background: rgba(239, 68, 68, 0.15);
  opacity: 1;
  transform: scale(1.1);
}

/* Footer del carrito (Total y Botón Confirmar) */
.carrito-footer {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.total-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  font-size: 1.3rem;
}

.total-row span {
  color: #9ca3af;
}

.total-row strong {
  color: #fff;
  font-size: 1.5rem;
  text-shadow: 0 0 10px rgba(255, 255, 255, 0.1);
}

/* Botón Confirmar Grande */
.carrito-footer .btn-primary {
  width: 100%;
  padding: 14px;
  font-size: 1.1rem;
  border-radius: 12px;
  background: linear-gradient(135deg, #ff3b3b 0%, #ff8a3d 100%);
  box-shadow: 0 4px 20px rgba(255, 59, 59, 0.4);
  border: none;
  color: white;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.2s;
}

.carrito-footer .btn-primary:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 25px rgba(255, 59, 59, 0.6);
}

/* --- MODAL DE CHECKOUT (Estilos) --- */
.checkout-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(5px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 2000;
  padding: 1rem;
  animation: fadeIn 0.3s;
}

.checkout-modal {
  background: #1a1c29;
  width: 100%;
  max-width: 500px;
  border-radius: 24px;
  padding: 2rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
  position: relative;
  animation: slideUp 0.3s;
}

.checkout-modal h2 {
  margin-top: 0;
  margin-bottom: 1.5rem;
  font-size: 1.6rem;
  color: #fff;
}

.checkout-modal-close {
  position: absolute;
  top: 1.5rem;
  right: 1.5rem;
  background: none;
  border: none;
  color: #9ca3af;
  font-size: 1.5rem;
  cursor: pointer;
}

.checkout-section {
  margin-bottom: 1.5rem;
}

.checkout-section h3 {
  font-size: 0.95rem;
  color: #9ca3af;
  margin-bottom: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Inputs del modal */
.pago-option,
.direccion-option {
  display: flex;
  align-items: center; /* Alinea radio y texto */
  gap: 10px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  margin-bottom: 8px;
  cursor: pointer;
  color: #fff;
  transition: background 0.2s;
}

.pago-option:hover,
.direccion-option:hover {
  background: rgba(255, 255, 255, 0.08);
}

.pago-option input,
.direccion-option input {
  accent-color: #ff3b3b;
  width: 18px;
  height: 18px;
}

/* Dirección guardada destacada */
.direccion-guardada {
  margin-top: 5px;
  margin-left: 28px; /* Indentación */
  font-size: 0.9rem;
  color: #ccc;
  font-style: italic;
}
.direccion-guardada.vacia {
  color: #ef4444;
}

/* Textarea */
.checkout-textarea {
  width: 100%;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(0, 0, 0, 0.3);
  color: #fff;
  font-family: inherit;
  margin-top: 10px;
  resize: none;
  height: 80px;
}

/* Botones Modal */
.checkout-actions {
  display: flex;
  gap: 1rem;
  margin-top: 2rem;
}

.checkout-actions button {
  flex: 1;
  padding: 12px;
  border-radius: 12px;
  font-weight: 600;
  cursor: pointer;
  border: none;
}

#btnCancelar {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
}

#btnFinalizar {
  background: #2ecc71;
  color: #fff;
  box-shadow: 0 4px 15px rgba(46, 204, 113, 0.4);
}

#btnFinalizar:hover {
  background: #27ae60;
}

/* Animaciones */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
@keyframes slideUp {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* Responsive */
@media (max-width: 600px) {
  .carrito-img {
    width: 60px;
    height: 60px;
  }
  .carrito-item {
    flex-wrap: wrap;
    gap: 1rem;
  }
  .carrito-info {
    min-width: 100%;
    order: -1;
    margin-bottom: 0.5rem;
    padding: 0;
  }
  .carrito-control {
    flex-direction: row;
    justify-content: space-between;
    width: 100%;
    align-items: center;
  }
  .btn-remove-item {
    margin-left: auto;
  }
}

/* ---------- Botón ELIMINAR ---------- */

.btn-remove-item {
  margin-top: 6px;
  border-radius: 999px;
  padding: 0.18rem 0.8rem;
  font-size: 0.75rem;
  border: 1px solid #f87171;
  background: transparent;
  color: #f97373;
  cursor: pointer;
  line-height: 1;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease,
    transform 0.12s ease;
}

.btn-remove-item:hover {
  background: rgba(239, 68, 68, 0.08);
  border-color: #ef4444;
  color: #ef4444;
  transform: translateY(-1px);
}

/* ---------- Total del carrito ---------- */

.carrito-total {
  margin-top: 0.5rem;
  padding: 0.75rem 0.5rem 0.1rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.carrito-total p {
  margin: 0;
  font-size: 0.95rem;
  color: #0f172a;
}

/* Botón confirmar pedido en la vista carrito */
.carrito-total #btnConfirmarPedido {
  margin-top: 0.3rem;
  width: 100%;
  border-radius: 999px;
  padding: 0.6rem 1rem;
  font-size: 0.98rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  background: linear-gradient(135deg, #22c55e, #16a34a);
  color: #ffffff;
  box-shadow: 0 12px 24px rgba(22, 163, 74, 0.35);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.carrito-total #btnConfirmarPedido:hover {
  transform: translateY(-1px);
  box-shadow: 0 15px 30px rgba(22, 163, 74, 0.45);
}

/* ---------- Responsive carrito ---------- */

@media (min-width: 640px) {
  .carrito-item {
    grid-template-columns: 80px 1.5fr 1.1fr;
    grid-template-rows: auto;
    grid-template-areas: "img info importe";
    align-items: center;
  }

  .carrito-importe {
    align-items: flex-end;
  }
}
