/**
 * 🛒 Estilos del Carrito de Compras
 */

/* ========================================
   BADGE DEL CARRITO
   ======================================== */

/* Badge integrado en la navegación */
.nav__link--cart {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  text-decoration: none;
}

/* Wrapper del icono del carrito */
.cart-icon-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  background: #2a2a2a;
  border-radius: 16px;
  border: 2px solid #404040;
  transition: all 0.3s ease;
  flex-shrink: 0;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.nav__link--cart:hover .cart-icon-wrapper {
  background: #353535;
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  border-color: #505050;
}

/* Icono SVG del carrito */
.cart-icon {
  width: 32px;
  height: 32px;
  color: #ffffff;
  flex-shrink: 0;
  stroke-width: 2.5;
}

/* Badge contador */
.cart-badge__count {
  position: absolute;
  top: -8px;
  right: -8px;
  background: #ff3b30;
  color: white;
  border-radius: 50%;
  min-width: 26px;
  height: 26px;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  font-weight: 700;
  padding: 0 0.45rem;
  box-shadow: 0 3px 10px rgba(255, 59, 48, 0.5);
  border: 3px solid #1a1a1a;
  line-height: 1;
}

/* Mostrar badge cuando hay items */
.cart-badge__count:not(:empty) {
  display: inline-flex;
}

/* Estilos legacy para compatibilidad */
.cart-badge-container {
  position: relative;
  margin-left: auto;
}

.cart-badge {
  background: var(--primary-color, #4CAF50);
  color: white;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 25px;
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.3s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.cart-badge:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.cart-badge .cart-badge__count {
  background: white;
  color: var(--primary-color, #4CAF50);
}

/* Badge flotante (fallback) */
.cart-badge-floating {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 999;
}

.cart-badge-floating .cart-badge {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

/* ========================================
   MODAL DEL CARRITO - DARK THEME
   ======================================== */

.cart-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1000;
  display: none;
}

.cart-modal--open {
  display: block;
}

.cart-modal__overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(4px);
  animation: fadeIn 0.3s ease;
}

.cart-modal__content {
  position: absolute;
  top: 0;
  right: 0;
  width: 100%;
  max-width: 500px;
  height: 100%;
  background: #1a1a1a;
  box-shadow: -4px 0 32px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  animation: slideInRight 0.3s ease;
  overflow: hidden; /* Prevenir scroll en el contenedor principal */
}

/* ========================================
   HEADER DEL MODAL - DARK THEME
   ======================================== */

.cart-modal__header {
  padding: 1.5rem;
  border-bottom: 1px solid #2a2a2a;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(135deg, #2a2a2a 0%, #1f1f1f 100%);
  color: white;
}

.cart-modal__header h2 {
  margin: 0;
  font-size: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--primary-color, #4CAF50);
  font-weight: 600;
}

.cart-modal__close {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: white;
  font-size: 2rem;
  cursor: pointer;
  padding: 0;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.3s ease;
}

.cart-modal__close:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
  transform: rotate(90deg);
}

/* ========================================
   BODY DEL MODAL - DARK THEME
   ======================================== */

.cart-modal__body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 1rem;
  background: #1a1a1a;
  min-height: 0; /* Importante para que flex funcione correctamente */
}

/* Scrollbar personalizado */
.cart-modal__body::-webkit-scrollbar {
  width: 8px;
}

.cart-modal__body::-webkit-scrollbar-track {
  background: #1a1a1a;
}

.cart-modal__body::-webkit-scrollbar-thumb {
  background: #404040;
  border-radius: 4px;
}

.cart-modal__body::-webkit-scrollbar-thumb:hover {
  background: #505050;
}

#cart-items-container {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Carrito vacío */
.cart-empty {
  text-align: center;
  padding: 3rem 1rem;
  color: #888;
}

.cart-empty p:first-child {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
  color: #aaa;
}

/* ========================================
   ITEMS DEL CARRITO - DARK THEME
   ======================================== */

.cart-item {
  display: flex;
  gap: 1rem;
  padding: 1rem;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  transition: all 0.3s ease;
}

.cart-item:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.12);
  transform: translateY(-2px);
}

.cart-item__image {
  width: 80px;
  height: 80px;
  flex-shrink: 0;
}

.cart-item__image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.cart-item__details {
  flex: 1;
  min-width: 0;
}

.cart-item__details h4 {
  margin: 0 0 0.5rem 0;
  font-size: 1rem;
  color: #ffffff;
  font-weight: 500;
}

.cart-item__variant {
  font-size: 0.85rem;
  color: #999;
  margin: 0 0 0.5rem 0;
}

.cart-item__price {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.cart-item__original-price {
  text-decoration: line-through;
  color: #666;
  font-size: 0.9rem;
}

.cart-item__current-price {
  font-weight: 600;
  color: var(--primary-color, #4CAF50);
  font-size: 1.1rem;
}

.cart-item__controls {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.5rem;
}

.cart-item__quantity {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 0.25rem;
}

.cart-item__quantity button {
  background: rgba(255, 255, 255, 0.05);
  border: none;
  color: var(--primary-color, #4CAF50);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  transition: all 0.3s ease;
  border-radius: 6px;
}

.cart-item__quantity button:hover {
  background: rgba(255, 255, 255, 0.1);
  transform: scale(1.1);
}

.cart-item__quantity span {
  min-width: 30px;
  text-align: center;
  font-weight: 600;
  color: #ffffff;
}

.cart-item__subtotal {
  font-weight: 600;
  font-size: 1.1rem;
  color: #ffffff;
}

.cart-item__remove {
  background: rgba(244, 67, 54, 0.1);
  border: 1px solid rgba(244, 67, 54, 0.2);
  color: #ff5252;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  transition: all 0.3s ease;
  border-radius: 6px;
}

.cart-item__remove:hover {
  background: rgba(244, 67, 54, 0.2);
  border-color: rgba(244, 67, 54, 0.3);
  transform: scale(1.05);
}

/* ========================================
   FOOTER DEL MODAL - DARK THEME
   ======================================== */

.cart-modal__footer {
  padding: 1.5rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  background: linear-gradient(180deg, #1a1a1a 0%, #151515 100%);
  flex-shrink: 0; /* No permitir que se comprima */
  max-height: 50vh; /* Máximo 50% de la altura de la ventana */
  overflow-y: auto; /* Scroll si el contenido es muy largo */
  overflow-x: hidden;
}

/* Scrollbar para el footer */
.cart-modal__footer::-webkit-scrollbar {
  width: 8px;
}

.cart-modal__footer::-webkit-scrollbar-track {
  background: #1a1a1a;
}

.cart-modal__footer::-webkit-scrollbar-thumb {
  background: #404040;
  border-radius: 4px;
}

.cart-modal__footer::-webkit-scrollbar-thumb:hover {
  background: #505050;
}

.cart-modal__total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 1rem;
  padding: 1rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  color: #ffffff;
}

.cart-modal__total span:last-child {
  color: var(--primary-color, #4CAF50);
  font-weight: 700;
}

.cart-modal__clear {
  width: 100%;
  padding: 0.75rem;
  background: rgba(244, 67, 54, 0.15);
  color: #ff5252;
  border: 1px solid rgba(244, 67, 54, 0.3);
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  margin-bottom: 1rem;
  transition: all 0.3s ease;
}

.cart-modal__clear:hover {
  background: rgba(244, 67, 54, 0.25);
  border-color: rgba(244, 67, 54, 0.4);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(244, 67, 54, 0.2);
}

/* ========================================
   FORMULARIO - DARK THEME PREMIUM
   ======================================== */

.cart-modal__form {
  margin: 1.5rem 0;
}

.cart-modal__form h3 {
  margin: 0 0 1rem 0;
  font-size: 1.1rem;
  color: #ffffff;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Inputs y textarea con estilo dark premium */
.cart-modal__form input,
.cart-modal__form textarea {
  width: 100%;
  padding: 0.875rem 1rem;
  margin-bottom: 0.875rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  font-size: 1rem;
  font-family: inherit;
  color: #ffffff;
  transition: all 0.3s ease;
}

/* Placeholder styling */
.cart-modal__form input::placeholder,
.cart-modal__form textarea::placeholder {
  color: #888;
  opacity: 1;
}

/* Focus states con efecto premium */
.cart-modal__form input:focus,
.cart-modal__form textarea:focus {
  outline: none;
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--primary-color, #4CAF50);
  box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.1);
  transform: translateY(-1px);
}

/* Textarea específico */
.cart-modal__form textarea {
  resize: vertical;
  min-height: 90px;
  line-height: 1.5;
}

/* Botón principal de WhatsApp - destacado y premium */
.cart-modal__checkout {
  width: 100%;
  padding: 1rem 1.5rem;
  background: linear-gradient(135deg, var(--primary-color, #4CAF50) 0%, #45a049 100%);
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 16px rgba(76, 175, 80, 0.3);
  position: relative;
  overflow: hidden;
  margin-top: 1rem; /* Separación del formulario */
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

/* Efecto hover premium */
.cart-modal__checkout:hover {
  background: linear-gradient(135deg, #45a049 0%, #3d8b40 100%);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(76, 175, 80, 0.4);
}

/* Efecto activo */
.cart-modal__checkout:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(76, 175, 80, 0.3);
}

/* Efecto de brillo sutil */
.cart-modal__checkout::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: left 0.5s ease;
}

.cart-modal__checkout:hover::before {
  left: 100%;
}

/* ========================================
   NOTIFICACIÓN
   ======================================== */

.cart-notification {
  position: fixed;
  top: 20px;
  right: 20px;
  background: var(--primary-color, #4CAF50);
  color: white;
  padding: 1rem 1.5rem;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  z-index: 1001;
  transform: translateX(400px);
  transition: transform 0.3s ease;
}

.cart-notification--show {
  transform: translateX(0);
}

/* ========================================
   ANIMACIONES
   ======================================== */

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

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

/* ========================================
   RESPONSIVE
   ======================================== */

@media (max-width: 768px) {
  .cart-modal__content {
    max-width: 100%;
  }

  .cart-item {
    flex-direction: column;
  }

  .cart-item__controls {
    flex-direction: row;
    justify-content: space-between;
    width: 100%;
  }

  .cart-badge {
    padding: 0.4rem 0.8rem;
    font-size: 1rem;
  }

  /* Asegurar que el icono del carrito se mantenga en su lugar */
  .nav__link--cart {
    position: relative;
    margin-left: auto; /* Forzar a la derecha */
  }

  .cart-icon-wrapper {
    width: 48px;
    height: 48px;
    border-radius: 14px;
  }

  .cart-icon {
    width: 28px;
    height: 28px;
  }

  .cart-badge__count {
    min-width: 24px;
    height: 24px;
    font-size: 0.85rem;
    top: -6px;
    right: -6px;
    border-width: 2.5px;
  }

  /* Asegurar que header__actions mantenga el carrito a la derecha */
  .header__actions {
    display: flex;
    justify-content: flex-end !important;
    align-items: center;
    gap: var(--spacing-md, 1rem);
  }
}

@media (max-width: 480px) {
  .cart-modal__header {
    padding: 1rem;
  }

  .cart-modal__header h2 {
    font-size: 1.2rem;
  }

  .cart-modal__footer {
    padding: 1rem;
  }

  .cart-modal__total {
    font-size: 1.2rem;
  }

  .cart-modal__checkout {
    font-size: 1rem;
    padding: 0.875rem 1.25rem;
  }

  /* Icono más pequeño en móviles */
  .cart-icon-wrapper {
    width: 44px;
    height: 44px;
    border-radius: 12px;
  }

  .cart-icon {
    width: 24px;
    height: 24px;
  }

  .cart-badge__count {
    min-width: 22px;
    height: 22px;
    font-size: 0.8rem;
    top: -5px;
    right: -5px;
    border-width: 2px;
  }
}


/* ========================================
   ESTILOS ADICIONALES PARA CARDS
   ======================================== */

.card__actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.card__actions .btn {
  flex: 1;
}

.search-card__add-to-cart {
  width: 100%;
  margin-top: 0.5rem;
}

/* Estilos para botones en product page */
.product__actions {
  display: flex;
  gap: 1rem;
  margin-top: 1.5rem;
}

.product__actions .btn {
  flex: 1;
}

.btn--add-to-cart {
  background: var(--primary-color, #4CAF50);
}

.btn--buy-now {
  background: #FF9800;
}

.btn--buy-now:hover {
  background: #F57C00;
}
