/* Estilos profesionales para la sección de productos con diseño innovador */

/* Variables de colores para productos */
:root {
  --product-primary: #ab8e75;
  --product-secondary: #c0a18b;
  --product-accent: #e9c3b0;
  --product-gold: #d4af37;
  --product-dark: #2c2c2c;
  --product-light: #f8f6f3;
  --product-shadow: rgba(171, 142, 117, 0.15);
  --product-shadow-hover: rgba(171, 142, 117, 0.25);
}

/* Hero Section para productos */
.products-hero {
  background: linear-gradient(
    135deg,
    var(--product-primary) 0%,
    var(--product-secondary) 50%,
    var(--product-accent) 100%
  );
  color: white;
  text-align: center;
  padding: 8rem 0 6rem;
  position: relative;
  overflow: hidden;
}

.products-hero::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><pattern id="grain" width="100" height="100" patternUnits="userSpaceOnUse"><circle cx="25" cy="25" r="1" fill="white" opacity="0.1"/><circle cx="75" cy="75" r="1" fill="white" opacity="0.1"/><circle cx="50" cy="10" r="0.5" fill="white" opacity="0.05"/></pattern></defs><rect width="100" height="100" fill="url(%23grain)"/></svg>');
  opacity: 0.3;
}

.products-hero h1 {
  font-size: 3.5rem;
  font-weight: 700;
  margin-bottom: 1rem;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
  position: relative;
  z-index: 2;
}

.products-hero p {
  font-size: 1.3rem;
  opacity: 0.9;
  position: relative;
  z-index: 2;
}

/* Categorías de productos */
.products-categories {
  padding: 4rem 0;
  background: var(--product-light);
}

.products-categories h2 {
  text-align: center;
  font-size: 2.5rem;
  color: var(--product-dark);
  margin-bottom: 3rem;
  position: relative;
}

.products-categories h2::after {
  content: "";
  position: absolute;
  bottom: -10px;
  left: 50%;
  transform: translateX(-50%);
  width: 80px;
  height: 3px;
  background: linear-gradient(90deg, var(--product-primary), var(--product-gold));
  border-radius: 2px;
}

.category-filters {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 2rem;
}

.category-filter {
  background: white;
  border: 2px solid var(--product-primary);
  color: var(--product-primary);
  padding: 0.8rem 1.5rem;
  border-radius: 50px;
  cursor: pointer;
  transition: all 0.3s ease;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  box-shadow: 0 4px 15px var(--product-shadow);
}

.category-filter:hover,
.category-filter.active {
  background: var(--product-primary);
  color: white;
  transform: translateY(-2px);
  box-shadow: 0 8px 25px var(--product-shadow-hover);
}

/* Toolbar de productos */
.products-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 3rem;
  padding: 1.5rem;
  background: white;
  border-radius: 15px;
  box-shadow: 0 4px 20px var(--product-shadow);
}

.search-bar {
  display: flex;
  align-items: center;
  background: var(--product-light);
  border-radius: 50px;
  padding: 0.5rem;
  flex: 1;
  max-width: 400px;
}

.search-bar input {
  border: none;
  background: none;
  padding: 0.8rem 1.2rem;
  font-size: 1rem;
  flex: 1;
  outline: none;
  color: var(--product-dark);
}

.search-bar button {
  background: var(--product-primary);
  border: none;
  color: white;
  padding: 0.8rem 1.2rem;
  border-radius: 50px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.search-bar button:hover {
  background: var(--product-secondary);
  transform: scale(1.05);
}

.view-options {
  display: flex;
  gap: 0.5rem;
}

.view-btn {
  background: var(--product-light);
  border: none;
  padding: 0.8rem;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.3s ease;
  color: var(--product-dark);
}

.view-btn.active,
.view-btn:hover {
  background: var(--product-primary);
  color: white;
}

/* Grid de productos */
.products-showcase {
  padding: 4rem 0;
  background: linear-gradient(135deg, #f8f6f3 0%, #ffffff 50%, #f8f6f3 100%);
}

.products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 2rem;
  margin-top: 2rem;
  align-items: start;
}

/* Card de producto */
.product-card {
  background: white;
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 8px 30px var(--product-shadow);
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  position: relative;
  cursor: pointer;
  max-width: 400px;
  width: 100%;
  margin: 0 auto;
  height: fit-content;
  border: 1px solid #eee;
}

.product-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, var(--product-primary), var(--product-gold));
  opacity: 0;
  transition: opacity 0.3s ease;
  z-index: 1;
}

.product-card:hover {
  transform: translateY(-10px) scale(1.02);
  box-shadow: 0 20px 50px var(--product-shadow-hover);
}

.product-card:hover::before {
  opacity: 0.05;
}

.product-image-container {
    position: relative;
    width: 100%;
    height: 300px;
    overflow: hidden;
    background: linear-gradient(45deg, var(--product-accent), var(--product-light));
}

.product-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
    padding: 10px;
    transition: all 0.4s ease;
    background: white;
}

.product-card:hover .product-image {
  transform: scale(1.05);
}

.product-badge {
  position: absolute;
  top: 15px;
  left: 15px;
  background: var(--product-gold);
  color: white;
  padding: 0.4rem 0.8rem;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  z-index: 3;
  box-shadow: 0 2px 10px rgba(212, 175, 55, 0.3);
}

.favorite-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  background: white;
  border: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.favorite-btn.active {
  color: #e74c3c;
}

.product-badge.best-seller {
  background: #e74c3c;
}

.product-badge.new {
  background: #27ae60;
}

.product-badge.premium {
  background: linear-gradient(45deg, var(--product-gold), #f39c12);
}

.product-content {
  padding: 1.5rem;
  position: relative;
  z-index: 2;
}

.product-title {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--product-dark);
  margin-bottom: 0.5rem;
  line-height: 1.3;
}

.product-description {
  color: #666;
  font-size: 0.9rem;
  line-height: 1.5;
  margin-bottom: 1rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.product-rating {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.stars {
  display: flex;
  gap: 2px;
}

.star {
  color: var(--product-gold);
  font-size: 0.9rem;
}

.star.empty {
  color: #ddd;
}

.rating-text {
  font-size: 0.8rem;
  color: #666;
}

.product-pricing {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  margin-bottom: 1.5rem;
}

.product-price {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--product-primary);
}

.original-price {
  font-size: 1rem;
  color: #999;
  text-decoration: line-through;
  margin-left: 8px;
}

.discount-badge {
  background: #e74c3c;
  color: white;
  padding: 0.2rem 0.5rem;
  border-radius: 10px;
  font-size: 0.7rem;
  font-weight: 600;
  margin-left: 8px;
}

.stock-indicator {
  font-size: 0.8rem;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
}

.stock-indicator i {
  margin-right: 5px;
}

.stock-indicator.low {
  color: #e74c3c;
  font-weight: 600;
}

.stock-indicator.medium {
  color: #f39c12;
}

.stock-indicator.high {
  color: #27ae60;
}

.product-actions {
    display: flex;
    justify-content: center;
    width: 100%;
    margin-top: 1rem;
}

.add-to-cart-btn {
  flex: 1;
  background-color: #ab8e75;
  color: white;
  border: none;
  padding: 10px;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background-color 0.3s ease;
}

.add-to-cart-btn:hover {
  background-color: #8c6f57;
}


/* Productos destacados */
.featured-products {
  padding: 4rem 0;
  background: var(--product-dark);
  color: white;
}

.featured-products h2 {
  text-align: center;
  font-size: 2.5rem;
  margin-bottom: 3rem;
  color: white;
}

.featured-carousel {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 2rem;
}

/* Loading state */
.loading-message {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--product-dark);
}

.loading-message i {
  font-size: 3rem;
  color: var(--product-primary);
  margin-bottom: 1rem;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* ===================================================================
   INICIO: SISTEMA DEL CARRITO DE COMPRAS (CÓDIGO CORREGIDO Y COMPLETO)
   =================================================================== */

.body-no-scroll {
    overflow: hidden !important;
}

.cart-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.cart-overlay.visible {
    opacity: 1;
    visibility: visible;
}

/* --- Botón Flotante del Carrito (POSICIÓN CORREGIDA) --- */
.cart-floating-icon {
    position: fixed;
    bottom: 95px; /* <-- CORRECCIÓN: Elevado para no chocar con el botón de "subir" del footer */
    right: 25px;
    width: 60px;
    height: 60px;
    background: var(--product-primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    z-index: 999; /* <-- CORRECCIÓN: z-index ligeramente inferior al del botón de "subir" */
    transition: all 0.3s ease;
}

.cart-floating-icon:hover {
    transform: scale(1.08);
    background: var(--product-secondary);
}

.cart-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background-color: #e74c3c;
    color: white;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    border: 2px solid white;
}

/* --- Estructura principal de la barra lateral (REFORZADA) --- */
.cart-sidebar {
    position: fixed;
    top: 0;
    right: 0;
    width: 380px;
    max-width: 90vw;
    height: 100vh;
    background-color: white;
    box-shadow: -5px 0 25px rgba(0, 0, 0, 0.15);
    z-index: 1001;
    transform: translateX(100%);
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex !important;
    flex-direction: column !important;
}

.cart-sidebar.visible {
    transform: translateX(0);
}

/* --- Cabecera de la barra (RESTAURADA) --- */
.cart-sidebar-header {
    padding: 1rem 1.5rem;
    background: var(--product-primary);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.cart-sidebar-header h3 {
    margin: 0;
    font-size: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.cart-sidebar-header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.clear-cart-btn, .cart-close-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    cursor: pointer;
    border-radius: 50%;
    font-size: 1rem;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
}

.clear-cart-btn:hover, .cart-close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* --- Contenido de la barra (SCROLL CORREGIDO) --- */
.cart-sidebar-content {
    flex: 1 1 auto !important;
    overflow-y: auto !important;
    padding: 1rem;
    background-color: #f9f9f9;
}

.cart-empty-message {
    text-align: center;
    padding: 4rem 1rem;
    color: #888;
}

/* --- Ítems dentro del carrito --- */
.cart-item {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 1rem;
    background: white;
    border-radius: 8px;
    margin-bottom: 1rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.cart-item-image {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 8px;
    flex-shrink: 0;
}

.cart-item-details {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.cart-item-title {
    font-weight: 600;
    margin: 0;
    font-size: 0.95rem;
    line-height: 1.3;
}

.cart-item-quantity-controls {
    display: flex;
    align-items: center;
}

.quantity-btn {
    background: #f1f1f1;
    border: 1px solid #ddd;
    width: 28px;
    height: 28px;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s ease;
}
.quantity-btn:hover {
    background: #e0e0e0;
}
.cart-item-quantity {
    padding: 0 0.75rem;
    font-weight: 500;
}

.cart-item-price-section {
    text-align: right;
}

.cart-item-price {
    font-weight: bold;
    color: var(--product-dark);
    font-size: 1rem;
    display: block;
    margin-bottom: 0.5rem;
}

.cart-item-remove {
    background: none;
    border: none;
    color: #999;
    cursor: pointer;
    font-size: 0.9rem;
    transition: color 0.2s ease;
}

.cart-item-remove:hover {
    color: #dc3545;
}


/* --- Pie de página de la barra (POSICIÓN CORREGIDA) --- */
.cart-sidebar-footer {
    padding: 1.5rem;
    background: white;
    border-top: 1px solid #eee;
    box-shadow: 0 -4px 15px rgba(0, 0, 0, 0.05);
    flex-shrink: 0;
}

.cart-total {
    display: flex;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    font-weight: 700;
    font-size: 1.2rem;
    color: var(--product-dark);
}

.checkout-btn {
    width: 100%;
    background: var(--product-primary);
    color: white;
    border: none;
    padding: 1rem;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 1rem;
    transition: background 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.checkout-btn:hover {
    background: var(--product-secondary);
}

/* ===================================================================
   FIN: SISTEMA DEL CARRITO DE COMPRAS
   =================================================================== */

/* Animaciones adicionales */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(30px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Efectos de hover mejorados */
.product-card:hover .product-title {
  color: var(--product-primary);
  transition: color 0.3s ease;
}

.product-card:hover .add-to-cart-btn {
  background: linear-gradient(135deg, var(--product-gold), var(--product-primary));
}

/* Estilos de la tarjeta de servicio */
.service-card {
    background-color: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    transition: all 0.3s ease;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.service-image {
    position: relative;
    height: 300px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
}

.service-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 10px;
    transition: transform 0.4s ease;
}

/* Fallback para imágenes que no cargan */
.product-image.error,
.service-image img.error {
    object-fit: contain;
    padding: 20px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
}

/* Estilos para el modal de pedido de productos */
.modal {
  display: none;
  position: fixed;
  z-index: 2000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
}

.modal-content {
  background-color: #fefefe;
  margin: 5% auto;
  padding: 20px;
  border: 1px solid #888;
  border-radius: 8px;
  position: relative;
  animation: modalFadeIn 0.3s;
  width: 90%;
  max-width: 500px;
}

@keyframes modalFadeIn {
  from {opacity: 0; transform: translateY(-50px);}
  to {opacity: 1; transform: translateY(0);}
}

.close {
  color: #aaa;
  float: right;
  font-size: 28px;
  font-weight: bold;
  position: absolute;
  right: 15px;
  top: 10px;
  cursor: pointer;
}

.close:hover,
.close:focus {
  color: black;
  text-decoration: none;
}

.form-group {
  margin-bottom: 15px;
}

.form-group label {
  display: block;
  margin-bottom: 5px;
  font-weight: bold;
}

.form-group input {
  width: 100%;
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 16px;
}

.form-group input:focus {
  outline: none;
  border-color: #ab8e75;
}

#order-summary {
  max-height: 150px;
  overflow-y: auto;
  padding: 10px;
  background: #f9f9f9;
  border-radius: 4px;
  border: 1px solid #eee;
  margin-bottom: 15px;
}

.order-item {
  display: flex;
  justify-content: space-between;
  padding: 5px 0;
  border-bottom: 1px solid #eee;
}

.submit-btn {
  width: 100%;
  padding: 12px;
  background: #ab8e75;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 16px;
  transition: background 0.3s ease;
}

.submit-btn:hover {
  background: #8c6f57;
}

.submit-btn:disabled {
  background: #ccc;
  cursor: not-allowed;
}

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

@media (max-width: 768px) {
  .products-hero h1 {
    font-size: 2.5rem;
  }

  .products-toolbar {
    flex-direction: column;
    gap: 1.5rem;
    align-items: stretch;
  }

  .search-bar {
    max-width: 100%;
  }

  .products-grid {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }
  
  .product-card {
    max-width: 400px;
  }

  .category-filters {
    justify-content: flex-start;
    overflow-x: auto;
    padding-bottom: 1rem;
    -webkit-overflow-scrolling: touch;
  }

  .category-filter {
    white-space: nowrap;
    flex-shrink: 0;
  }
}

@media (max-width: 480px) {
  .products-hero {
    padding: 6rem 0 4rem;
  }

  .products-hero h1 {
    font-size: 2rem;
  }

  .product-actions {
    flex-direction: column;
  }

  .products-toolbar {
    padding: 1rem;
  }

  .cart-sidebar {
      width: 100% !important;
      max-width: 100vw !important;
  }
}