/* ====== BOTÓN FLOTANTE DEL CARRITO ====== */
.carrito-float {
  position: fixed;
  bottom: 100px; /* Arriba del botón de WhatsApp */
  right: 30px;
  width: 60px;
  height: 60px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border: none;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  color: white;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  transition: all 0.3s;
  z-index: 999;
}

.carrito-float:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5);
}

.carrito-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  background: #ef4444;
  color: white;
  font-size: 0.75rem;
  font-weight: 700;
  min-width: 22px;
  height: 22px;
  border-radius: 11px;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* ====== BOTÓN AGREGAR AL CARRITO EN PRODUCTOS ====== */
.producto-carrito {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  align-items: center;
}

.cantidad-input {
  width: 60px;
  padding: 8px;
  border: 2px solid var(--border-color);
  border-radius: 6px;
  text-align: center;
  font-size: 1rem;
  font-weight: 600;
}

.cantidad-input:focus {
  outline: none;
  border-color: var(--primary-color);
}

.btn-agregar-carrito {
  flex: 1;
  padding: 10px 16px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn-agregar-carrito:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-agregar-carrito:active {
  transform: translateY(0);
}

/* ====== NOTIFICACIÓN FLOTANTE ====== */
.carrito-notificacion {
  position: fixed;
  top: 20px;
  right: 20px;
  background: white;
  padding: 16px 24px;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  border-left: 4px solid #10b981;
  z-index: 10000;
  opacity: 0;
  transform: translateX(400px);
  transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.carrito-notificacion.show {
  opacity: 1;
  transform: translateX(0);
}

.carrito-notificacion span {
  font-weight: 600;
  color: var(--text-primary);
}

.carrito-notificacion small {
  color: var(--text-secondary);
  font-size: 0.85rem;
}

/* ====== MODAL DEL CARRITO ====== */
.modal-carrito {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 9999;
  justify-content: flex-end;
  align-items: stretch;
  animation: fadeIn 0.2s;
}

.modal-carrito-content {
  background: white;
  width: 100%;
  max-width: 500px;
  height: 100%;
  display: flex;
  flex-direction: column;
  animation: slideInRight 0.3s;
  box-shadow: -4px 0 20px rgba(0, 0, 0, 0.2);
}

@keyframes slideInRight {
  from {
    transform: translateX(100%);
  }
  to {
    transform: translateX(0);
  }
}

.modal-carrito-header {
  padding: 24px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-carrito-header h2 {
  margin: 0;
  font-size: 1.5rem;
}

.modal-carrito-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  max-height: calc(100vh - 250px);
  -webkit-overflow-scrolling: touch;
  touch-action: auto;
}
.modal-carrito-body::-webkit-scrollbar {
  width: 8px;
}


.carrito-items-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Item del carrito */
.carrito-item {
  display: grid;
  grid-template-columns: 70px 1fr auto auto;
  gap: 12px;
  padding: 16px;
  background: var(--bg-color);
  border-radius: 12px;
  align-items: center;
  position: relative;
}

.carrito-item-imagen {
  width: 70px;
  height: 70px;
  border-radius: 8px;
  overflow: hidden;
  background: white;
}

.carrito-item-imagen img {
  width: 100%;
  height: 100%;
  object-fit: scale-down;
}

.carrito-item-info h4 {
  margin: 0 0 4px 0;
  font-size: 1rem;
  color: var(--text-primary);
}

.carrito-item-precio {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin: 0;
}

.carrito-item-cantidad {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-cantidad {
  width: 32px;
  height: 32px;
  border: 2px solid var(--border-color);
  background: white;
  border-radius: 6px;
  cursor: pointer;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--primary-color);
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-cantidad:hover {
  background: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}

.input-cantidad {
  width: 50px;
  height: 32px;
  text-align: center;
  border: 2px solid var(--border-color);
  border-radius: 6px;
  font-size: 1rem;
  font-weight: 600;
}

.carrito-item-subtotal {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary-color);
}

.btn-eliminar-item {
  background: none;
  border: none;
  font-size: 1.3rem;
  cursor: pointer;
  color: var(--danger-color);
  transition: transform 0.2s;
}

.btn-eliminar-item:hover {
  transform: scale(1.2);
}

/* Carrito vacío */
.carrito-vacio {
  text-align: center;
  padding: 60px 20px;
}

.carrito-vacio p {
  font-size: 1.2rem;
  color: var(--text-secondary);
  margin-bottom: 24px;
}

/* Footer del modal */
.modal-carrito-footer {
  padding: 20px;
  border-top: 2px solid var(--border-color);
  background: white;
}

.carrito-total-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding: 16px;
  background: var(--bg-color);
  border-radius: 8px;
}

.carrito-total-label {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text-primary);
}

.carrito-total-monto {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--primary-color);
}

.carrito-acciones {
  display: flex;
  gap: 12px;
}

.carrito-acciones .btn {
  flex: 1;
}

/* ====== MODAL DE CHECKOUT ====== */
.modal-checkout {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 10000;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.2s;
}

.modal-checkout-content {
  background: white;
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  border-radius: 16px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: zoomIn 0.3s;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

@keyframes zoomIn {
  from {
    transform: scale(0.9);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

.modal-checkout-header {
  padding: 24px;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: white;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-checkout-header h2 {
  margin: 0;
  font-size: 1.5rem;
}

.modal-checkout-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  max-height: calc(90vh - 200px);
  -webkit-overflow-scrolling: touch;
  touch-action: auto;
}

.checkout-resumen {
  background: var(--bg-color);
  padding: 20px;
  border-radius: 12px;
  margin-bottom: 24px;
}

.checkout-resumen h4 {
  margin: 0 0 12px 0;
  color: var(--text-primary);
}

.checkout-resumen ul {
  list-style: none;
  padding: 0;
  margin: 0 0 12px 0;
}

.checkout-resumen li {
  padding: 8px 0;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-secondary);
}

.checkout-resumen li:last-child {
  border-bottom: none;
}

.checkout-total {
  font-size: 1.3rem;
  color: var(--primary-color);
  margin: 12px 0 0 0;
}

.checkout-form h3 {
  margin: 0 0 16px 0;
  color: var(--text-primary);
}

.recaptcha-container {
  margin-top: 16px;
}

.modal-checkout-footer {
  padding: 20px;
  border-top: 2px solid var(--border-color);
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

/* ====== RESPONSIVE ====== */
@media (max-width: 768px) {
  .carrito-float {
    bottom: 90px;
    right: 20px;
    width: 55px;
    height: 55px;
  }

  .modal-carrito-content {
    max-width: 100%;
  }

  .carrito-item {
    grid-template-columns: 60px 1fr;
    gap: 10px;
  }

  .carrito-item-cantidad {
    grid-column: 1 / -1;
    justify-content: center;
  }

  .carrito-item-subtotal {
    grid-column: 1 / -1;
    text-align: center;
  }

  .btn-eliminar-item {
    position: absolute;
    top: 8px;
    right: 8px;
  }

  .producto-carrito {
    flex-direction: column;
  }

  .cantidad-input {
    width: 100%;
  }
}

@media (max-width: 480px) {
  .modal-checkout-content {
    max-width: 100%;
    border-radius: 0;
  }

  .carrito-notificacion {
    right: 10px;
    left: 10px;
  }
}

.modal-checkout-body::-webkit-scrollbar {
  width: 8px;
}

.modal-checkout-body::-webkit-scrollbar-track {
  background: #f1f5f9;
}

.modal-checkout-body::-webkit-scrollbar-thumb {
  background: #cbd5e0;
  border-radius: 4px;
}
.modal-checkout-body::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* Responsive móvil: */
@media (max-width: 768px) {
  .modal-checkout-content {
    max-width: 100%;
    /* Restar el padding del contenedor (.modal-checkout tiene 20px arriba + abajo) */
    max-height: calc(100vh - 40px);
    border-radius: 0;
    display: flex;
    flex-direction: column;
  }

  .modal-checkout-body {
    /* Hacer que el body ocupe el espacio disponible y sea scrollable dentro
       del modal. `min-height:0` es importante para que el flex item pueda
       reducir su altura y permitir el scroll en móviles. */
    flex: 1 1 auto;
    min-height: 0;
    padding: 16px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
}
