/**
 * ═══════════════════════════════════════════════════════════════
 * CART MODAL CSS - Estilos para el modal lateral de carrito
 * ═══════════════════════════════════════════════════════════════
 *
 * Estructura:
 * - Badge del carrito en navbar
 * - Modal lateral (drawer) desde la derecha
 * - Lista de productos con imagen, nombre, precio, cantidad
 * - Footer con totales y botones de acción
 * - Toast de notificaciones
 * - Responsive para mobile y desktop
 * - Dark mode compatible
 */

/* ═══════════════════════════════════════════════════════════════
   BADGE DEL CARRITO EN NAVBAR
   ═══════════════════════════════════════════════════════════════ */

.cart-icon-wrapper {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 8px;
  transition: background-color 0.2s;
}

.cart-icon-wrapper:hover {
  background-color: var(--bg-hover, rgba(0, 0, 0, 0.05));
}

.cart-icon-wrapper svg {
  width: 24px;
  height: 24px;
  stroke: var(--text-primary, #1a1a1a);
}

.cart-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  background: var(--primary-color, #0066cc);
  color: white;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
  display: none; /* Oculto por defecto, se muestra cuando hay productos */
  align-items: center;
  justify-content: center;
  line-height: 1;
}

/* ═══════════════════════════════════════════════════════════════
   MODAL PRINCIPAL
   ═══════════════════════════════════════════════════════════════ */

.cart-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 9999;
  display: flex;
  justify-content: flex-end;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.cart-modal.active {
  opacity: 1;
  visibility: visible;
}

.cart-modal-content {
  width: 100%;
  max-width: 420px;
  height: 100%;
  background: var(--bg-primary, #ffffff);
  box-shadow: -4px 0 20px rgba(0, 0, 0, 0.15);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.cart-modal.active .cart-modal-content {
  transform: translateX(0);
}

/* ═══════════════════════════════════════════════════════════════
   HEADER DEL MODAL
   ═══════════════════════════════════════════════════════════════ */

.cart-modal-header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border-color, #e5e7eb);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.cart-modal-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary, #1a1a1a);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
}

.cart-modal-title svg {
  width: 24px;
  height: 24px;
  stroke: var(--primary-color, #0066cc);
}

.btn-close-cart-modal {
  width: 36px;
  height: 36px;
  border: none;
  background: var(--bg-secondary, #f3f4f6);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-close-cart-modal:hover {
  background: var(--bg-hover, #e5e7eb);
  transform: scale(1.05);
}

.btn-close-cart-modal svg {
  width: 20px;
  height: 20px;
  stroke: var(--text-secondary, #6b7280);
}

/* ═══════════════════════════════════════════════════════════════
   BODY DEL MODAL - LISTA DE PRODUCTOS
   ═══════════════════════════════════════════════════════════════ */

.cart-modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
}

/* Scrollbar personalizado */
.cart-modal-body::-webkit-scrollbar {
  width: 8px;
}

.cart-modal-body::-webkit-scrollbar-track {
  background: var(--bg-secondary, #f3f4f6);
}

.cart-modal-body::-webkit-scrollbar-thumb {
  background: var(--border-color, #d1d5db);
  border-radius: 4px;
}

.cart-modal-body::-webkit-scrollbar-thumb:hover {
  background: var(--text-tertiary, #9ca3af);
}

/* Estado vacío */
.cart-modal-empty {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 1rem;
  text-align: center;
  min-height: 300px;
}

.cart-modal-empty svg {
  width: 80px;
  height: 80px;
  stroke: var(--text-tertiary, #9ca3af);
  margin-bottom: 1rem;
}

.cart-modal-empty h3 {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-primary, #1a1a1a);
  margin: 0 0 0.5rem 0;
}

.cart-modal-empty p {
  font-size: 0.875rem;
  color: var(--text-secondary, #6b7280);
  margin: 0 0 1.5rem 0;
}

.btn-continue-shopping {
  padding: 0.75rem 1.5rem;
  background: var(--primary-color, #0066cc);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-continue-shopping:hover {
  background: var(--primary-hover, #0052a3);
  transform: translateY(-1px);
}

/* ═══════════════════════════════════════════════════════════════
   ITEMS DEL CARRITO
   ═══════════════════════════════════════════════════════════════ */

.cart-modal-items {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.cart-modal-item {
  display: flex;
  gap: 1rem;
  padding: 1rem;
  background: var(--bg-secondary, #f9fafb);
  border-radius: 12px;
  border: 1px solid var(--border-color, #e5e7eb);
  transition: all 0.2s;
}

.cart-modal-item:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  border-color: var(--primary-color, #0066cc);
}

/* Imagen del producto */
.cart-item-image {
  width: 80px;
  height: 80px;
  flex-shrink: 0;
  border-radius: 8px;
  overflow: hidden;
  background: white;
  border: 1px solid var(--border-color, #e5e7eb);
}

.cart-item-image img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Información del producto */
.cart-item-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.cart-item-name {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-primary, #1a1a1a);
  margin: 0;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.cart-item-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.cart-item-brand {
  font-size: 0.8125rem;
  color: var(--text-secondary, #6b7280);
}

.cart-item-badge-event,
.cart-item-badge-discount {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
}

.cart-item-badge-event {
  background: #fee;
  color: #c00;
}

.cart-item-badge-discount {
  background: #e0f2fe;
  color: #0284c7;
}

/* Precios */
.cart-item-pricing {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.cart-item-price-original {
  font-size: 0.8125rem;
  color: var(--text-tertiary, #9ca3af);
  text-decoration: line-through;
}

.cart-item-price {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--primary-color, #0066cc);
}

.cart-item-savings {
  font-size: 0.8125rem;
  font-weight: 600;
  color: #10b981;
}

/* Acciones (cantidad + eliminar) */
.cart-item-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: auto;
}

.cart-item-quantity {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  background: white;
  border: 1px solid var(--border-color, #e5e7eb);
  border-radius: 8px;
  padding: 2px;
}

.btn-qty-decrease,
.btn-qty-increase {
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.2s;
}

.btn-qty-decrease:hover,
.btn-qty-increase:hover {
  background: var(--bg-secondary, #f3f4f6);
}

.btn-qty-decrease:active,
.btn-qty-increase:active {
  transform: scale(0.95);
}

.btn-qty-decrease svg,
.btn-qty-increase svg {
  stroke: var(--text-secondary, #6b7280);
}

.cart-item-qty-input {
  width: 40px;
  height: 28px;
  border: none;
  background: transparent;
  text-align: center;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-primary, #1a1a1a);
}

.cart-item-qty-input:focus {
  outline: none;
}

/* Botón eliminar */
.btn-remove-item {
  width: 32px;
  height: 32px;
  border: none;
  background: #fee;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-remove-item:hover {
  background: #fdd;
  transform: scale(1.05);
}

.btn-remove-item svg {
  stroke: #c00;
}

/* ═══════════════════════════════════════════════════════════════
   FOOTER DEL MODAL - TOTALES Y BOTONES
   ═══════════════════════════════════════════════════════════════ */

.cart-modal-footer {
  padding: 1.5rem;
  border-top: 1px solid var(--border-color, #e5e7eb);
  background: var(--bg-secondary, #f9fafb);
  flex-shrink: 0;
  display: none; /* Oculto cuando no hay productos */
}

/* Resumen de totales */
.cart-modal-totals {
  margin-bottom: 1rem;
}

.cart-total-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0;
  font-size: 0.9375rem;
}

.cart-total-row.subtotal {
  color: var(--text-secondary, #6b7280);
}

.cart-total-row.savings {
  color: #10b981;
  font-weight: 600;
}

.cart-total-row.shipping .cart-total-value.free {
  color: #10b981;
  font-weight: 700;
}

.cart-total-row.total {
  padding-top: 1rem;
  border-top: 2px solid var(--border-color, #e5e7eb);
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text-primary, #1a1a1a);
}

.cart-total-label {
  font-weight: 500;
}

.cart-total-value {
  font-weight: 600;
}

/* Botones de acción */
.cart-modal-actions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.btn-checkout-modal,
.btn-view-full-cart {
  width: 100%;
  padding: 1rem;
  border: none;
  border-radius: 10px;
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.btn-checkout-modal {
  background: var(--primary-color, #0066cc);
  color: white;
}

.btn-checkout-modal:hover {
  background: var(--primary-hover, #0052a3);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 102, 204, 0.3);
}

.btn-view-full-cart {
  background: white;
  color: var(--primary-color, #0066cc);
  border: 2px solid var(--primary-color, #0066cc);
}

.btn-view-full-cart:hover {
  background: var(--primary-color, #0066cc);
  color: white;
}

/* ═══════════════════════════════════════════════════════════════
   TOAST DE NOTIFICACIONES
   ═══════════════════════════════════════════════════════════════ */

.cart-toast {
  position: fixed;
  top: 90px;
  right: 20px;
  min-width: 280px;
  max-width: 400px;
  padding: 1rem 1.25rem;
  background: var(--bg-primary, #ffffff);
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  z-index: 10000;
  transform: translateX(150%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border-left: 4px solid var(--primary-color, #0066cc);
}

.cart-toast.show {
  transform: translateX(0);
}

.cart-toast-icon {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
  flex-shrink: 0;
}

.cart-toast-message {
  flex: 1;
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text-primary, #1a1a1a);
}

/* Variantes de toast */
.cart-toast-success {
  border-left-color: #10b981;
}

.cart-toast-success .cart-toast-icon {
  background: #d1fae5;
  color: #10b981;
}

.cart-toast-error {
  border-left-color: #ef4444;
}

.cart-toast-error .cart-toast-icon {
  background: #fee2e2;
  color: #ef4444;
}

.cart-toast-warning {
  border-left-color: #f59e0b;
}

.cart-toast-warning .cart-toast-icon {
  background: #fef3c7;
  color: #f59e0b;
}

.cart-toast-info {
  border-left-color: #3b82f6;
}

.cart-toast-info .cart-toast-icon {
  background: #dbeafe;
  color: #3b82f6;
}

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════════ */

@media (max-width: 480px) {
  .cart-modal-content {
    max-width: 100%;
  }

  .cart-modal-header {
    padding: 1rem;
  }

  .cart-modal-title {
    font-size: 1.125rem;
  }

  .cart-modal-body {
    padding: 0.75rem;
  }

  .cart-modal-item {
    padding: 0.75rem;
    gap: 0.75rem;
  }

  .cart-item-image {
    width: 70px;
    height: 70px;
  }

  .cart-item-name {
    font-size: 0.875rem;
  }

  .cart-item-price {
    font-size: 1rem;
  }

  .cart-modal-footer {
    padding: 1rem;
  }

  .cart-toast {
    right: 10px;
    left: 10px;
    min-width: auto;
  }
}

/* ═══════════════════════════════════════════════════════════════
   DARK MODE
   ═══════════════════════════════════════════════════════════════ */

@media (prefers-color-scheme: dark) {
  .cart-modal {
    background: rgba(0, 0, 0, 0.7);
  }

  .cart-modal-item {
    background: var(--bg-hover, rgba(255, 255, 255, 0.05));
  }

  .cart-item-image {
    background: rgba(255, 255, 255, 0.05);
  }

  .cart-item-quantity {
    background: var(--bg-hover, rgba(255, 255, 255, 0.05));
  }

  .btn-remove-item {
    background: rgba(239, 68, 68, 0.15);
  }

  .btn-remove-item:hover {
    background: rgba(239, 68, 68, 0.25);
  }
}

/* ═══════════════════════════════════════════════════════════════
   ANIMACIONES
   ═══════════════════════════════════════════════════════════════ */

@media (prefers-reduced-motion: reduce) {
  .cart-modal,
  .cart-modal-content,
  .cart-toast,
  .btn-checkout-modal,
  .btn-view-full-cart,
  .btn-qty-decrease,
  .btn-qty-increase,
  .btn-remove-item {
    transition: none;
  }
}
