/* Controles móviles: Filters y Búsqueda */
.mobile-controls {
  display: none; /* Oculto por defecto, se muestra en móvil */
  flex-direction: row;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  background-color: white;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
  position: sticky;
  top: 0;
  z-index: 110; /* Mayor que el header para que se mantenga visible */
  border: 1px solid #f0f0f0;
  transition: top 0.3s ease;
}

/* Cuando el header está oculto, los controles móviles van arriba del todo */
body.header-hidden .mobile-controls {
  top: 0;
}

/* Botón de filtros móvil - 30% del ancho */
.mobile-filters-btn {
  display: none;
  align-items: center;
  gap: 0.5rem;
  background: var(--primary-color);
  color: white;
  border: none;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  position: relative;
  box-shadow: 0 2px 8px rgba(230, 57, 70, 0.3);
  transition: all 0.3s ease;
  width: 30%;
  flex-shrink: 0;
  justify-content: center;
  min-width: 90px;
}

.mobile-filters-btn:hover {
  background: #d63384;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(230, 57, 70, 0.4);
}

.mobile-filters-btn i {
  font-size: 1rem;
}

.filters-count {
  background: white;
  color: var(--primary-color);
  border-radius: 50%;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  position: absolute;
  top: -5px;
  right: -5px;
  border: 2px solid var(--primary-color);
}

/* Modal de filtros */
.filters-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.filters-modal.open {
  display: flex;
  opacity: 1;
  align-items: stretch; /* Asegurar que el modal se estire completamente */
}

.filters-modal-content {
  background: white;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  animation: slideInRight 0.3s ease-out;
  overflow: hidden; /* Prevenir scroll horizontal */
}

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

.filters-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid #e9ecef;
  background: var(--primary-color);
  color: white;
}

.filters-modal-header h3 {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 600;
}

.close-filters-modal {
  background: none;
  border: none;
  color: white;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 4px;
  transition: background-color 0.3s;
}

.close-filters-modal:hover {
  background: rgba(255, 255, 255, 0.1);
}

.filters-modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
}

.filters-modal-footer {
  display: flex;
  gap: 1rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid #e9ecef;
  background: #f8f9fa;
}

.clear-filters-mobile,
.apply-filters-mobile {
  flex: 1;
  padding: 0.875rem 1rem;
  border: none;

/* --- Código de bulto en cards --- */
.product-bulk-code, .product-code-badge {
  margin: 4px 0 4px 0;
  font-size: 0.68rem;
  font-weight: 700; /* bold */
  letter-spacing: 0.5px;
  color: var(--primary-color);
  background: rgba(230,57,70,0.08);
  padding: 3px 6px;
  border-radius: 4px;
  display: inline-block;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.1;
}

  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.clear-filters-mobile {
  background: #6c757d;
  color: white;
}

.clear-filters-mobile:hover {
  background: #5a6268;
  transform: translateY(-1px);
}

.apply-filters-mobile {
  background: var(--primary-color);
  color: white;
}

.apply-filters-mobile:hover {
  background: #d63384;
  transform: translateY(-1px);
}

/* Filtros Sidebar - Solo desktop */
.filters-sidebar {
  width: 280px;
  background-color: var(--card-color);
  border-radius: 8px;
  padding: 1.5rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  height: fit-content;
  top: 2rem;
}

/* Override visual para que el código (bulk/box/unit mostrado) se vea más fuerte en /tienda/ */
.products-grid .product-card .product-bulk-code {
  font-weight: 800; /* más grueso que 700 */
  color: #111; /* casi negro para mayor contraste */
  background: #ffe8ea; /* leve fondo claro rosado (opcional) */
  border: 1px solid rgba(0,0,0,0.08);
  letter-spacing: 0.6px;
  font-size: 0.72rem; /* apenas más grande */
}

.filters-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid #eee;
}

.filters-header h3 {
  margin: 0;
  color: var(--secondary-color);
  font-size: 1.2rem;
}

.clear-filters {
  background: none;
  border: 1px solid var(--primary-color);
  color: var(--primary-color);
  padding: 0.25rem 0.75rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.8rem;
  transition: all 0.3s;
}

.clear-filters:hover {
  background-color: var(--primary-color);
  color: white;
}

.filter-section {
  margin-bottom: 1.5rem;
}

.filter-title {
  color: var(--secondary-color);
  font-size: 1rem;
  margin-bottom: 1rem;
  font-weight: 600;
}

/* Headers colapsables */
.filter-header-collapsible {
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  padding: 0.75rem;
  border-radius: 6px;
  transition: background-color 0.3s;
  background-color: #f8f9fa;
  border: 1px solid #e9ecef;
  margin-bottom: 0.5rem;
}

.filter-header-collapsible:hover {
  background-color: #e9ecef;
}

.filter-header-collapsible .filter-title {
  margin-bottom: 0;
  flex: 1;
  font-size: 0.95rem;
}

.collapse-btn {
  background: none;
  border: none;
  color: var(--secondary-color);
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 4px;
  transition: all 0.3s;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
}

.collapse-btn:hover {
  background-color: rgba(0, 0, 0, 0.1);
}

.collapse-btn i {
  transition: transform 0.3s;
  font-size: 0.8rem;
}

.collapse-btn.collapsed i {
  transform: rotate(-90deg);
}

/* Contenido colapsable */
.filter-content {
  overflow: hidden;
  transition: max-height 0.3s ease-out, opacity 0.3s ease-out, padding 0.3s ease-out;
  max-height: 400px;
  opacity: 1;
  padding: 0.75rem;
  background-color: white;
  border: 1px solid #e9ecef;
  border-top: none;
  border-radius: 0 0 6px 6px;
}

.filter-content.collapsed {
  max-height: 0;
  opacity: 0;
  padding: 0 0.75rem;
  margin-bottom: 0;
}

/* Buscador de filtros */
.filter-search {
  position: relative;
  margin-bottom: 0.75rem;
}

.search-input {
  width: 100%;
  padding: 0.6rem 2.25rem 0.6rem 0.75rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 0.85rem;
  background-color: white;
  transition: border-color 0.3s, box-shadow 0.3s;
  box-sizing: border-box;
}

.search-input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px rgba(230, 57, 70, 0.1);
}

.search-input::placeholder {
  color: #999;
  font-style: italic;
  font-size: 0.8rem;
}

.search-icon {
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: #999;
  font-size: 0.8rem;
  pointer-events: none;
}

/* Filtro de Precio */
.price-filter {
  padding: 1rem;
  background-color: #f8f9fa;
  border-radius: 6px;
}

.price-range-container {
  position: relative;
  height: 30px;
  margin-bottom: 1.5rem;
}

.price-track {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  height: 4px;
  width: 100%;
  background: #ddd;
  border-radius: 2px;
}

.price-slider {
  position: absolute;
  width: 100%;
  height: 30px;
  -webkit-appearance: none;
  appearance: none;
  background: none;
  pointer-events: none;
}

.price-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  height: 18px;
  width: 18px;
  border-radius: 50%;
  background: var(--primary-color);
  border: 2px solid white;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  pointer-events: all;
  cursor: pointer;
  position: relative;
  z-index: 2;
}

.price-slider::-moz-range-thumb {
  height: 18px;
  width: 18px;
  border-radius: 50%;
  background: var(--primary-color);
  border: 2px solid white;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  pointer-events: all;
  cursor: pointer;
  position: relative;
  z-index: 2;
}

.price-inputs {
  display: grid;
  gap: 1rem;
  margin-bottom: 1rem;
}

.price-input-group label {
  display: block;
  font-size: 0.9rem;
  margin-bottom: 0.25rem;
  color: var(--text-color);
}

.price-input-group input {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 0.9rem;
}

.filter-btn {
  width: 100%;
  background-color: var(--primary-color);
  color: white;
  border: none;
  padding: 0.75rem;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 600;
  transition: background-color 0.3s;
}

.filter-btn:hover {
  background-color: #d63384;
}

/* Filtros de Categoría y Marca */
.category-filters,
.brand-filters,
.stock-filters {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 150px;
  overflow-y: auto;
  padding-right: 0.5rem;
}

/* Scrollbar personalizado */
.category-filters::-webkit-scrollbar,
.brand-filters::-webkit-scrollbar {
  width: 3px;
}

.category-filters::-webkit-scrollbar-track,
.brand-filters::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 2px;
}

.category-filters::-webkit-scrollbar-thumb,
.brand-filters::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 2px;
}

.category-filters::-webkit-scrollbar-thumb:hover,
.brand-filters::-webkit-scrollbar-thumb:hover {
  background: #999;
}

.filter-checkbox {
  display: flex;
  align-items: center;
  cursor: pointer;
  font-size: 0.85rem;
  position: relative;
  padding: 0.4rem 0.5rem 0.4rem 1.75rem;
  transition: all 0.3s;
  border-radius: 4px;
}

.filter-checkbox.hidden {
  display: none !important;
}

.filter-checkbox:hover {
  background-color: rgba(0, 0, 0, 0.05);
}

.filter-checkbox input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  cursor: pointer;
}

.checkmark {
  position: absolute;
  left: 0.25rem;
  top: 50%;
  transform: translateY(-50%);
  height: 16px;
  width: 16px;
  background-color: white;
  border: 2px solid #ddd;
  border-radius: 3px;
  transition: all 0.3s;
}

.filter-checkbox:hover input ~ .checkmark {
  border-color: var(--primary-color);
}

.filter-checkbox input:checked ~ .checkmark {
  background-color: var(--primary-color);
  border-color: var(--primary-color);
}

.checkmark:after {
  content: "";
  position: absolute;
  display: none;
  left: 4px;
  top: 1px;
  width: 3px;
  height: 7px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.filter-checkbox input:checked ~ .checkmark:after {
  display: block;
}

/* Mensaje cuando no hay resultados de búsqueda */
.no-results-message {
  text-align: center;
  color: #999;
  font-size: 0.8rem;
  padding: 0.75rem;
  font-style: italic;
  background-color: #f8f9fa;
  border-radius: 4px;
  margin-top: 0.5rem;
}

/* Header de Productos */
.products-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  padding: 1rem;
  background-color: var(--card-color);
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.results-count {
  color: var(--text-color);
  font-size: 0.9rem;
}

.products-controls {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.control-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.control-group label {
  font-size: 0.9rem;
  color: var(--text-color);
  white-space: nowrap;
}

.control-select {
  padding: 0.5rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  background-color: white;
  font-size: 0.9rem;
  cursor: pointer;
}

.view-toggle {
  display: flex;
  border: 1px solid #ddd;
  border-radius: 4px;
  overflow: hidden;
}

.view-btn {
  background-color: white;
  border: none;
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  transition: all 0.3s;
  border-right: 1px solid #ddd;
}

.view-btn:last-child {
  border-right: none;
}

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

/* Layout con filtros */
.shop-container {
  display: flex;
  gap: 2rem;
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem 1rem;
}

.products-section {
  flex: 1;
}

/* GRID DE PRODUCTOS - ALTURA UNIFORME */
.products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

/* Tarjeta de producto con altura uniforme */
.product-card {
  background: white;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  overflow: hidden;
  transition: all 0.3s ease;
  border: 1px solid #f0f0f0;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.product-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.12);
  border-color: var(--primary-color);
}

/* Image wrapper with 1:1 aspect ratio for consistent cards */
.product-image-container {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  background-color: #f8f9fa;
  display: flex;
  align-items: center;
  justify-content: center;
}

.product-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.product-info {
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.product-details {
  flex: 1;
}

.product-name {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--secondary-color);
  margin-bottom: 0.5rem;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.2rem;
}

.product-description {
  font-size: 0.85rem;
  color: #666;
  margin-bottom: 1rem;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 1rem;
}

/* Truncation utility class for preventing card expansion */
.truncate-text {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-wrap: break-word;
  hyphens: auto;
}

/* Secondary product name styling */
.product-secondary-name {
  font-size: 0.9rem;
  color: #777;
  margin-bottom: 0.25rem;
  font-weight: 500;
}

.product-meta {
  margin-bottom: 1rem;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
  font-size: 0.85rem;
}

.detail-label {
  font-weight: 500;
  color: var(--secondary-color);
}

.product-actions {
  margin-top: auto;
  padding-top: 0.75rem;
  border-top: 1px solid #f0f0f0;
}

.product-price {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary-color);
  margin-bottom: 0.75rem;
}

.stock-info {
  font-size: 0.8rem;
  color: #666;
  margin-bottom: 1rem;
  padding: 0.5rem;
  background-color: #f8f9fa;
  border-radius: 4px;
}

.add-to-cart {
  width: 100%;
  background: linear-gradient(135deg, var(--primary-color), #d63384);
  color: white;
  border: none;
  padding: 0.875rem 1rem;
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.3s ease;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.add-to-cart:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(230, 57, 70, 0.3);
}

.add-to-cart:active {
  transform: translateY(0);
}

/* Vista de lista */
.products-grid.list-view {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.products-grid.list-view .product-card {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  padding: 1.5rem;
  height: auto;
  min-height: 180px;
}

.products-grid.list-view .product-image {
  width: 160px;
  height: 160px;
  margin-right: 2rem;
  flex-shrink: 0;
  border-radius: 8px;
}

.products-grid.list-view .product-info {
  flex: 1;
  display: flex;
  flex-direction: row;
  gap: 2rem;
  padding: 0;
  align-items: stretch;
}

.products-grid.list-view .product-details {
  flex: 2;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  margin-bottom: 0;
}

.products-grid.list-view .product-actions {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem;
  margin-top: 0;
  padding-top: 0;
  border-top: none;
  min-width: 200px;
  flex-shrink: 0;
}

/* Mensaje cuando no hay productos */
.no-products {
  text-align: center;
  padding: 3rem 1rem;
  color: #666;
  font-size: 1.1rem;
  grid-column: 1 / -1;
}

/* Responsive */
@media (max-width: 1024px) {
  .shop-container {
    flex-direction: column;
  }

  .filters-sidebar {
    width: 100%;
    position: static;
    padding: 1rem;
  }

  .products-header {
    flex-direction: column;
    gap: 1rem;
    align-items: stretch;
  }

  .products-controls {
    justify-content: space-between;
    flex-wrap: wrap;
  }

  .products-grid {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  }
}

@media (max-width: 1024px) {
  .mobile-controls {
    display: flex !important;
    width: 100%;
  }

  .mobile-controls .mobile-search-container {
    display: flex !important;
    flex: 1;
  }

  .mobile-controls .mobile-filters-btn {
    display: flex !important;
  }
}

/* Media query específica para tablets (768px - 1024px) */
@media (min-width: 768px) and (max-width: 1024px) {
  .mobile-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    gap: 1rem;
  }
  
  .mobile-search-container {
    display: flex;
    flex: 1;
    width: 75%;
  }
  
  .mobile-filters-btn {
    display: flex;
    width: 25%;
    min-width: 120px;
  }
}

@media (max-width: 768px) {
  /* MÓVIL: Mostrar botón, búsqueda móvil y ocultar sidebar */
  .mobile-filters-btn {
    display: flex;
  }

  .mobile-controls {
    display: flex !important;
    flex-direction: row; /* Asegurar que se mantenga horizontal */
    align-items: center;
    gap: 0.75rem;
  }

  .mobile-search-container {
    display: flex !important;
    width: 70%;
    flex: 1;
    max-width: none;
    margin-left: 0;
  }
  
  .mobile-filters-btn {
    width: 30%;
    flex-shrink: 0;
    justify-content: center;
    min-width: 90px;
  }

  /* Asegurar que la barra de filtros se mantenga en el top cuando el header se oculta */
  body.header-hidden .mobile-controls {
    top: 0;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); /* Sombra más fuerte cuando está arriba del todo */
  }

  .mobile-search-input {
    width: 100%;
    padding: 0.75rem 2.5rem 0.75rem 1rem;
    border: 2px solid #e9ecef;
    border-radius: 25px;
    font-size: 0.9rem;
    color: var(--text-color);
    background-color: white;
    transition: all 0.3s ease;
    outline: none;
  }

  .mobile-search-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(230, 57, 70, 0.1);
  }

  .mobile-search-input::placeholder {
    color: #999;
    font-style: italic;
  }

  .filters-sidebar {
    display: none;
  }

  .shop-container {
    padding: 1rem;
    gap: 1rem;
  }

  /* MÓVIL: Ocultar controles excepto ordenamiento */
  .products-controls {
    flex-direction: column;
    gap: 0;
    align-items: stretch;
    padding: 0;
    margin: 0;
  }

  /* Ocultar contador de resultados en móvil */
  .results-count {
    display: none !important;
  }

  /* Solo mostrar el ordenamiento */
  .control-group:has(#itemsPerPage),
  .view-toggle {
    display: none !important;
  }

  /* Mejorar el estilo del ordenamiento */
  .control-group:has(#sortBy) {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 1rem;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    margin: 0;
  }

  .control-group:has(#sortBy) label {
    font-weight: 600;
    color: var(--secondary-color);
    font-size: 0.9rem;
    margin: 0;
  }

  .control-group:has(#sortBy) select {
    width: 100%;
    padding: 0.875rem 1rem;
    font-size: 1rem;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    background-color: white;
    color: var(--text-color);
    font-weight: 500;
    margin: 0;
    box-sizing: border-box;
    transition: border-color 0.3s ease;
  }

  .control-group:has(#sortBy) select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(230, 57, 70, 0.1);
  }

  .products-header {
    flex-direction: column;
    gap: 0;
    align-items: stretch;
    padding: 0;
    background: transparent;
    box-shadow: none;
    margin-bottom: 1.5rem;
  }

  .products-grid {
  grid-template-columns: repeat(2, 1fr);
   
  }

  .product-image {
  height: 100%;
  }

  .product-name {
    font-size: 1rem;
  }

  .product-price {
    font-size: 1.1rem;
  }

  /* Modal en móvil ocupa toda la pantalla */
  .filters-modal-content {
    margin: 0;
    border-radius: 0;
  }

  /* Lista view responsive */
  .products-grid.list-view .product-card {
    flex-direction: column;
    min-height: auto;
    padding: 1.5rem;
  }

  .products-grid.list-view .product-image {
    width: 100%;
    height: 200px;
    margin-right: 0;
    margin-bottom: 1.5rem;
  }

  .products-grid.list-view .product-info {
    flex-direction: column;
    gap: 1rem;
  }

  .products-grid.list-view .product-actions {
    align-items: stretch;
    min-width: auto;
  }
}

@media (max-width: 480px) {
  .mobile-controls {
    flex-direction: row; /* Mantener horizontal */
    gap: 0.5rem;
    padding: 0.5rem;
  }

  .mobile-filters-btn {
    width: 30%;
    min-width: 80px;
    font-size: 0.8rem;
    padding: 0.6rem 0.5rem;
  }
  
  .mobile-filters-btn span:not(.filters-count) {
    display: none; /* Ocultar texto "Filtros" en pantallas muy pequeñas */
  }

  .mobile-search-container {
    width: 70%;
  }

  .mobile-search-input {
    padding: 0.6rem 2rem 0.6rem 0.8rem;
    font-size: 0.85rem;
  }

  .products-grid {
    grid-template-columns: repeat(2, 1fr); /* keep two columns on very small screens */
  }

  .product-card {
    max-width: 100%;
  }

  .filters-modal-header,
  .filters-modal-footer {
    padding: 1rem;
  }

  .filters-modal-body {
    padding: 0.75rem;
  }
}

/* Media query para dispositivos móviles en modo landscape */
@media (max-width: 768px) and (orientation: landscape) {
  .mobile-controls {
    padding: 0.5rem 1rem;
    gap: 1rem;
  }
  
  .mobile-search-container {
    width: 65%;
  }
  
  .mobile-filters-btn {
    width: 35%;
    min-width: 100px;
  }
}



/* ================================================= */
/* == REFACTOR: TARJETAS DE PRODUCTO MÁS COMPACTAS == */
/* ================================================= */

@media (max-width: 768px) {

  /* Ajustamos la grilla para que las tarjetas estén un poco más juntas */
  .products-grid {
    gap: 0.75rem;
  }

  /* Hacemos la imagen del producto más pequeña */
  .product-image {
    height: 140px;
  }

  /* Reducimos el padding general de la información */
  .product-info {
    padding: 0.75rem;
  }

  /* Más compacto en móviles - mantener descripción visible */

  /* También ocultamos detalles secundarios como el código o las unidades por caja */
  .product-meta {
    display: none;
  }

  /* Ajustamos el nombre del producto */
  .product-name {
    font-size: 0.9rem;      /* Un poco más pequeño */
    min-height: 2.4em;      /* Aseguramos espacio para 2 líneas */
    line-height: 1.2em;
    margin-bottom: 0.5rem;
  }

  /* Juntamos la sección de acciones y quitamos la línea divisora */
  .product-actions {
    padding-top: 0.5rem;
    margin-top: 0.5rem;
    border-top: none;
  }

  /* Ocultamos la información de stock para simplificar la vista */
  .stock-info {
    display: none;
  }

  /* Hacemos el botón de agregar al carrito un poco más compacto */
  .add-to-cart {
    padding: 0.75rem 0.5rem;
    font-size: 0.8rem;
  }
}

/* Compact card mode: hide secondary info, smaller paddings, tighter name */
.product-card.compact .product-info {
  padding: 0.9rem;
}

.product-card.compact .product-meta,
.product-card.compact .stock-info,
.product-card.compact .quantity-info {
  display: none !important;
}

.product-card.compact .product-name {
  font-size: 1rem;
  min-height: 2.2em;
}

.product-card.compact .add-to-cart {
  padding: 0.6rem 0.75rem;
  font-size: 0.85rem;
}



/* ======================================= */
/* == WIDGETS: OFERTA Y ME GUSTA (CORAZÓN) == */
/* ======================================= */

/* Contenedor de la imagen necesario para posicionar los widgets */
/* Ensure container rules also apply from earlier definition */
.product-image-container {
  position: relative;
}

/* Estilo para la insignia de "Oferta" */
.product-offer-badge {
  position: absolute;
  top: 12px;
  right: -35px; /* Lo movemos fuera para rotarlo y que las esquinas queden perfectas */
  background-color: var(--primary-color); /* Usamos el color primario para consistencia */
  color: white;
  padding: 4px 35px;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  transform: rotate(45deg);
  z-index: 2;
  box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

/* Estilo para el botón de "Me Gusta" (corazón) */
.product-like-btn {
  position: absolute;
  top: 10px;
  left: 10px;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 50%;
  border: 1px solid #eee;
  width: 36px;
  height: 36px;
  font-size: 1rem;
  color: #555;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  transition: all 0.2s ease;
}

.product-like-btn:hover {
  transform: scale(1.1);
  background: white;
  color: #e63946; /* Color rojo para el hover */
}

/* Clase que añadiremos con JS cuando un producto tenga "me gusta" */
.product-like-btn.liked {
  background: #e63946;
  color: white;
  border-color: #e63946;
}

/* El ícono dentro del botón */
.product-like-btn i {
  transition: transform 0.2s ease;
}

/* Pequeña animación al dar "me gusta" */
.product-like-btn.liked i {
  transform: scale(1.2);
}

/* --- ESTILOS PARA LA FUNCIONALIDAD DE OFERTAS --- */

/* Etiqueta de "OFERTA" en la esquina */
.offer-badge {
    position: absolute;
    top: 10px;
    right: -8px;
    background-color: #e63946; /* Rojo para llamar la atención */
    color: white;
    padding: 4px 12px;
    font-size: 0.8rem;
    font-weight: bold;
    border-radius: 4px;
    transform: rotate(20deg);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    z-index: 2;
}

/* Contenedor para alinear precios */
.price-container {
    display: flex;
    align-items: baseline; /* Alinea los precios por su base */
    gap: 0.5rem; /* Espacio entre precios */
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
    justify-content: space-between;
}

/* Precio de oferta (más grande y prominente) */
.product-price.offer-price {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--price-color); /* Usa el color de precio principal */
}

/* Precio original (tachado y más pequeño) */
.product-price.original-price {
    font-size: 1rem;
    color: #999; /* Un color gris para que sea menos importante */
    text-decoration: line-through; /* ¡El tachado! */
}

/* Pagination Styles */
@import url("pagination.css");


/* Estilos existentes... */

/* Barra de búsqueda de productos */
.product-search {
  margin-bottom: 15px;
  position: relative; /* Añadir posición relativa al contenedor */
}

.search-input-container {
  position: relative;
  display: flex;
  align-items: center;
}

.product-search-input {
  width: 100%;
  padding: 12px 40px 12px 15px;
  border: 2px solid #e8e0dd;
  border-radius: 8px;
  font-size: 14px;
  color: #7f6f67;
  background-color: white;
  transition: all 0.3s ease;
  outline: none;
}

.product-search-input:focus {
  border-color: #be7c69;
  box-shadow: 0 0 0 3px rgba(190, 124, 105, 0.1);
}

.product-search-input::placeholder {
  color: #b6aa9d;
  font-style: italic;
}

.search-input-container .search-icon {
  position: absolute;
  right: 15px;
  color: #b6aa9d;
  font-size: 14px;
  pointer-events: none;
  z-index: 1;
}

.clear-search-btn {
  position: absolute;
  right: 40px;
  background: none;
  border: none;
  color: #b6aa9d;
  cursor: pointer;
  padding: 5px;
  border-radius: 50%;
  transition: all 0.2s ease;
  z-index: 2;
}

.clear-search-btn:hover {
  background-color: #f0f0f0;
  color: #be7c69;
}

/* Sugerencias de búsqueda - CORREGIDO */
.search-suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: white;
  border: 2px solid #e8e0dd;
  border-top: none;
  border-radius: 0 0 8px 8px;
  max-height: 200px;
  overflow-y: auto;
  z-index: 1000;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  /* Asegurar que se mantenga dentro del sidebar */
  max-width: 100%;
  width: 100%;
}

/* Asegurar que el sidebar tenga overflow visible para las sugerencias */
.filters-sidebar {
  overflow: visible;
}

.filter-section {
  overflow: visible;
}

.search-suggestion {
  padding: 8px 12px;
  cursor: pointer;
  border-bottom: 1px solid #f0f0f0;
  transition: background-color 0.2s ease;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.search-suggestion:hover {
  background-color: #f1faee;
}

.search-suggestion:last-child {
  border-bottom: none;
}

.suggestion-name {
  font-weight: 500;
  color: #7f6f67;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.suggestion-category {
  font-size: 10px;
  color: #b6aa9d;
  background-color: #f0f0f0;
  padding: 2px 4px;
  border-radius: 8px;
  white-space: nowrap;
}

.suggestion-price {
  font-weight: 600;
  color: #be7c69;
  font-size: 12px;
  white-space: nowrap;
}

/* Indicador de búsqueda activa */
.product-search-input.searching {
  border-color: #be7c69;
  background-color: #fefefe;
}

/* Mensaje de no resultados en búsqueda */
.no-search-results {
  padding: 15px;
  text-align: center;
  color: #b6aa9d;
  font-style: italic;
  font-size: 13px;
}

/* Header de productos mejorado */
.products-header {
  background: white;
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.products-header-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 20px;
}

.products-info {
  flex: 1;
}

.products-title {
  font-size: 1.5em;
  font-weight: 600;
  color: var(--secondary-color);
  margin: 0 0 8px 0;
}

.results-count {
  font-size: 0.9em;
  color: var(--text-color);
}

/* Búsqueda móvil - 70% del ancho */
.mobile-search-container {
  display: none; /* Oculto por defecto, se muestra en móvil */
  width: 70%;
  flex: 1;
  max-width: none;
  margin-left: 0;
}

.mobile-search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.mobile-search-input {
  width: 100%;
  padding: 12px 40px 12px 15px;
  border: 2px solid #e8e0dd;
  border-radius: 25px;
  font-size: 14px;
  color: #7f6f67;
  background-color: white;
  transition: all 0.3s ease;
  outline: none;
}

.mobile-search-input:focus {
  border-color: #be7c69;
  box-shadow: 0 0 0 3px rgba(190, 124, 105, 0.1);
}

.mobile-search-input::placeholder {
  color: #b6aa9d;
  font-style: italic;
}

.mobile-search-icon {
  position: absolute;
  right: 15px;
  color: #b6aa9d;
  font-size: 14px;
  pointer-events: none;
  z-index: 1;
}

.mobile-clear-search-btn {
  position: absolute;
  right: 40px;
  background: none;
  border: none;
  color: #b6aa9d;
  cursor: pointer;
  padding: 5px;
  border-radius: 50%;
  transition: all 0.2s ease;
  z-index: 2;
}

.mobile-clear-search-btn:hover {
  background-color: #f0f0f0;
  color: #be7c69;
}

/* Controles de productos */
.products-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 15px;
  flex-wrap: wrap;
}

.filters-and-search {
  display: flex;
  align-items: center;
  gap: 15px;
}

.products-controls-right {
  display: flex;
  align-items: center;
  gap: 15px;
  flex-wrap: wrap;
}

/* Botón de filtros móvil mejorado */
.mobile-filters-btn {
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background-color: var(--primary-color);
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  white-space: nowrap;
  flex-shrink: 0;
}

.mobile-filters-btn:hover {
  background-color: var(--secondary-color);
  transform: translateY(-1px);
}

.mobile-filters-btn .filters-count {
  background-color: rgba(255, 255, 255, 0.9);
  color: var(--primary-color);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 10px;
  min-width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: 4px;
}

/* Estilos para el nuevo selector de códigos en las tarjetas */
.card-code-selector-container {
    margin-bottom: 10px;
    width: 100%;
}

.card-code-options {
    display: flex;
    gap: 5px;
    justify-content: center;
}

.card-code-option-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 4px 8px;
    border: 1px solid #ccc;
    background-color: #f9f9f9;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.2s ease;
    flex-grow: 1;
}

.card-code-option-btn .code-type {
    font-weight: bold;
}

.card-code-option-btn .code-details {
    font-size: 0.7rem;
    color: #555;
}

.card-code-option-btn.selected {
    border-color: #007bff;
    background-color: #e7f1ff;
    box-shadow: 0 0 5px rgba(0, 123, 255, 0.5);
}

/* Estilos para el selector de cantidad */
.card-quantity-selector {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 10px;
}

.card-quantity-selector .quantity-btn {
    background-color: #eee;
    border: 1px solid #ccc;
    padding: 5px 10px;
    cursor: pointer;
    font-size: 1rem;
}

.card-quantity-selector .quantity-input {
    width: 40px;
    text-align: center;
    border: 1px solid #ccc;
    border-left: none;
    border-right: none;
    padding: 5px;
}

/* Estilos para el precio dinámico */
.card-dynamic-price {
    text-align: center;
    margin-bottom: 10px;
    font-weight: bold;
    font-size: 1.1rem;
    color: #333;
}
