/* ========================================
   PRODUCTS PAGE STYLES - UZ CASNIC & INDUSTRIAL
   Modern filters sidebar and product cards
   ======================================== */

/* Products Section - adjusted for sidebar filters and category bar */
.products-section {
  padding: 2rem 1.5rem;
  min-height: 400px;
  margin-right: 0;
  margin-top: var(--total-header-height, 137px); /* Uses global CSS variable */
  transition: margin-right 0.3s ease, margin-top 0.3s ease;
}

/* When sidebar is expanded */
body:has(.filters-sidebar.expanded) .products-section {
  margin-right: var(--sidebar-width, 280px);
}

/* Responsive adjustments for products section */
@media (max-width: 992px) {
  .products-section {
    margin-top: var(--total-header-height, 107px);
  }
}

@media (max-width: 768px) {
  .products-section {
    margin-top: var(--total-header-height, 54px);
    padding: 1.5rem 1rem;
  }
}

.products-grid,
#productsGrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.5rem;
  max-width: 1600px;
  margin: 0 auto;
}

/* Product Cards - Clean & Compact Design */
.product-card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  overflow: hidden;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  max-width: 100%;
}

.product-card:hover {
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
  border-color: var(--bs-primary);
}

.product-image-container {
  position: relative;
  width: 100%;
  height: 250px;
  overflow: hidden;
  background: var(--bg-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.image-placeholder {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  opacity: 0.3;
}

.product-image {
  max-width: 90%; /* Uniform size for all images */
  max-height: 90%;
  width: auto;
  height: auto;
  object-fit: contain; /* Show full image without cropping */
  transition: opacity 0.3s ease;
  opacity: 0;
  z-index: 2;
  position: absolute; /* Absolute positioning for perfect centering */
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%); /* Center perfectly */
}

.product-image.loaded {
  opacity: 1;
}

.product-card:hover .product-image {
  /* No zoom on hover to keep image quality */
}

.product-card-body {
  padding: 1rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.product-brand {
  color: var(--bs-primary);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.25rem;
}

.product-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: auto;
}

.product-description {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 0.75rem;
}

.product-footer {
  margin-top: auto;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.product-price {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--bs-primary);
}

.product-btn {
  padding: 0.35rem 0.75rem;
  background: var(--bs-primary);
  color: #ffffff !important;
  border: none;
  border-radius: 6px;
  font-weight: 500;
  font-size: 0.7rem;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none !important;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  white-space: nowrap;
}

.product-btn:hover {
  background: #c01818;
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(224, 32, 32, 0.2);
  color: #ffffff !important;
}

.product-btn i {
  font-size: 0.75rem;
}

/* Loading State */
.loading-state {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 2rem;
  min-height: 400px;
}

.spinner {
  width: 50px;
  height: 50px;
  border: 4px solid var(--border-color);
  border-top-color: var(--bs-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 1rem;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-state p {
  color: var(--text-secondary);
  font-size: 1rem;
  margin-top: 1rem;
}

/* No Results */
.no-results {
  grid-column: 1 / -1;
  text-align: center;
  padding: 4rem 2rem;
  color: var(--text-secondary);
}

.no-results i {
  font-size: 4rem;
  color: var(--border-color);
  margin-bottom: 1.5rem;
}

.no-results h3 {
  font-size: 1.5rem;
  color: var(--text-primary);
  margin-bottom: 0.75rem;
}

.no-results p {
  font-size: 1rem;
  color: var(--text-secondary);
}

/* Responsive - Desktop & Large Tablets */
@media (max-width: 1400px) {
  .products-grid,
  #productsGrid {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  }
}

/* ========================================
   CATEGORY GROUPED PRODUCTS - MODERN HORIZONTAL LAYOUT
   ======================================== */

/* Products container when grouped - stack categories vertically */
.products-grid.grouped-view {
  display: flex !important;
  flex-direction: column !important;
  gap: 2.5rem !important;
}

/* Category Section - clean card-like container */
.category-section {
  width: 100% !important;
  display: block !important;
  background: var(--card-bg, #fff);
  border-radius: 16px;
  padding: 1.25rem;
  border: 1px solid var(--border-color, rgba(0,0,0,0.08));
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.category-section:last-child {
  margin-bottom: 0;
}

/* Category Header - sleek design */
.category-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-color, rgba(0,0,0,0.08));
}

.category-header i {
  font-size: 1.25rem;
  color: var(--bs-primary, #e02020);
  background: linear-gradient(135deg, rgba(224, 32, 32, 0.12), rgba(224, 32, 32, 0.04));
  padding: 0.5rem;
  border-radius: 8px;
  flex-shrink: 0;
}

.category-header h2 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary, #1a1a2e);
  margin: 0;
  flex-grow: 1;
}

.category-header .product-count {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-secondary, #6c757d);
  background: var(--bg-secondary, #f8f9fa);
  padding: 0.25rem 0.625rem;
  border-radius: 12px;
  flex-shrink: 0;
}

/* Category Navigation Buttons */
.category-nav-buttons {
  display: flex;
  gap: 0.5rem;
  margin-left: 0.5rem;
  flex-shrink: 0;
}

.category-nav-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border-color, rgba(0,0,0,0.1));
  background: var(--card-bg, #fff);
  color: var(--text-primary, #1a1a2e);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  padding: 0;
}

.category-nav-btn:hover {
  background: var(--bs-primary, #e02020);
  border-color: var(--bs-primary, #e02020);
  color: #fff;
  transform: scale(1.05);
}

.category-nav-btn:active {
  transform: scale(0.95);
}

.category-nav-btn i {
  font-size: 1rem;
  background: none;
  padding: 0;
  color: inherit;
}

/* Category Products - HORIZONTAL SCROLL SLIDER */
.category-products {
  display: flex !important;
  flex-wrap: nowrap !important;
  gap: 1rem !important;
  overflow-x: auto !important;
  overflow-y: hidden !important;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--bs-primary, #e02020) transparent;
  padding: 0.5rem 0 1rem 0;
  /* IMPORTANT: Prevent horizontal page overflow */
  max-width: 100%;
}

/* Custom scrollbar for webkit browsers */
.category-products::-webkit-scrollbar {
  height: 6px;
}

.category-products::-webkit-scrollbar-track {
  background: var(--bg-secondary, #f1f1f1);
  border-radius: 3px;
}

.category-products::-webkit-scrollbar-thumb {
  background: var(--bs-primary, #e02020);
  border-radius: 3px;
}

.category-products::-webkit-scrollbar-thumb:hover {
  background: #c01818;
}

/* Product cards inside category slider - LARGER for better visibility */
.category-products .product-card,
.category-section .category-products .product-card,
#productsGrid .category-section .category-products .product-card,
.grouped-view .category-section .category-products .product-card {
  flex: 0 0 280px !important;
  min-width: 280px !important;
  max-width: 280px !important;
  width: 280px !important;
  display: flex !important;
  flex-direction: column !important;
  height: auto;
}

/* Adjust image container for slider cards */
.category-products .product-card .product-image-container {
  height: 220px;
}

/* Text styles for slider cards */
.category-products .product-card .product-title {
  font-size: 1rem;
  -webkit-line-clamp: 2;
  font-weight: 600;
}

.category-products .product-card .product-description {
  font-size: 0.85rem;
  -webkit-line-clamp: 2;
}

.category-products .product-card .product-footer {
  flex-direction: column;
  align-items: stretch;
  gap: 0.75rem;
  padding-top: 1rem;
}

.category-products .product-card .product-price {
  font-size: 1.1rem;
  text-align: center;
  line-height: 1.3;
  font-weight: 700;
  color: var(--bs-primary);
}

/* Handle discount price display */
.category-products .product-card .product-price span {
  display: inline;
  font-size: 0.9rem;
}

.category-products .product-card .product-btn {
  padding: 0.4rem 0.875rem;
  font-size: 0.75rem;
  white-space: nowrap;
  width: auto;
  justify-content: center;
  text-align: center;
  align-self: center;
}

/* "Vezi mai multe" button for category */
.category-view-more {
  display: flex;
  justify-content: center;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color, rgba(0,0,0,0.08));
}

.category-view-more-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  background: transparent;
  border: 2px solid var(--bs-primary, #e02020);
  border-radius: 10px;
  color: var(--bs-primary, #e02020);
  font-size: 0.95rem;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.2s ease;
  cursor: pointer;
}

.category-view-more-btn:hover {
  background: var(--bs-primary, #e02020);
  color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(224, 32, 32, 0.25);
}

.category-view-more-btn i {
  font-size: 1rem;
}

/* Responsive adjustments */
@media (max-width: 1400px) {
  .category-products .product-card,
  .category-section .category-products .product-card {
    flex: 0 0 260px !important;
    min-width: 260px !important;
    max-width: 260px !important;
    width: 260px !important;
  }

  .category-products .product-card .product-image-container {
    height: 200px;
  }
}

/* Mobile styles are handled in products-page-mobile.css */