/* Products page specific styles */

/* Category sidebar styles */
.category-list,
.subcategory-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.category-item {
  position: relative;
  padding: 8px 0;
  border-bottom: 1px solid #eee;
}

.category-item:last-child {
  border-bottom: none;
}

.category-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.category-left input[type="checkbox"] {
  margin: 0;
}

.category-left span {
  font-size: 14px;
  color: #333;
}

/* Category count styling */
.category-count {
  color: #777;
  font-weight: normal;
  font-size: 0.9em;
}

/* Category level indicator */
.category-level-indicator {
  width: 8px;
  height: 8px;
  display: inline-block;
  border-radius: 50%;
  background-color: #eaeaea;
  margin-right: 4px;
  flex-shrink: 0;
}

.subcategory-list .subcategory-list .category-level-indicator {
  width: 6px;
  height: 6px;
  background-color: #f0f0f0;
}

/* Category hierarchy styling */
.category-list > .category-item > .category-left > span {
  font-weight: 700;
  color: #222;
  font-size: 16px;
}

.has-children > .category-left > span {
  font-weight: 600;
}

/* Indentation and visual hierarchy */
.subcategory-list {
  padding-left: 20px;
  margin-top: 5px;
  border-left: 2px solid #f0f0f0;
  margin-left: 10px;
  position: relative;
}

/* Add vertical line for subcategories */
.subcategory-list::before {
  content: '';
  position: absolute;
  top: 0;
  left: -2px;
  height: 100%;
  width: 2px;
  background-color: #f0f0f0;
}

.subcategory-list .category-item {
  padding: 6px 0;
  border-bottom: 1px dashed #eee;
  position: relative;
}

/* Add horizontal connector line */
.subcategory-list .category-item::before {
  content: '';
  position: absolute;
  top: 50%;
  left: -20px;
  width: 10px;
  height: 1px;
  background-color: #f0f0f0;
}

.subcategory-list .category-item:last-child {
  border-bottom: none;
}

/* Toggle button styling */
.category-toggle {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: #666;
  cursor: pointer;
  padding: 5px;
  transition: all 0.2s ease;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background-color: rgba(0, 0, 0, 0.03);
}

.category-toggle:hover {
  color: var(--primary-color);
  background-color: rgba(0, 0, 0, 0.08);
}

.category-toggle.expanded {
  transform: translateY(-50%) rotate(180deg);
}

/* Level indicators */
.subcategory-list .subcategory-list {
  border-left-style: dotted;
}

/* Active category styling */
.category-item.active > .category-left > span {
  color: var(--primary-color);
  font-weight: 600;
}

.category-item.active > .category-left > .category-level-indicator {
  background-color: var(--primary-color);
}

/* Active filters */
.active-filters {
  margin-bottom: 15px;
}

.active-filters .badge {
  margin-right: 5px;
  margin-bottom: 5px;
  padding: 6px 10px;
  font-weight: normal;
}

.active-filters .btn-close {
  font-size: 10px;
  margin-left: 5px;
}

/* Products grid */
.products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 20px;
}

/* Product card image area - consistent size, no cropping */
.product-card .product-image {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3; /* keep all cards same height */
  background-color: #fafafa;
  border-radius: 6px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.product-card .product-image img {
  width: 100%;
  height: 100%;
  object-fit: contain; /* avoid cropping */
  object-position: center center;
  transition: opacity 0.3s ease;
  visibility: hidden; /* prevent alt text showing while loading */
  position: relative;
  z-index: 0;
}

/* Skeleton loader overlay shown while image loading */
.product-card .product-image .image-loader {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, #f2f2f2 25%, #e6e6e6 37%, #f2f2f2 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
  z-index: 1;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Hide loader once image is ready */
.product-card .product-image.ready .image-loader {
  display: none;
}

.product-card .product-image.ready img {
  visibility: visible;
}

/* Keep titles to two lines for uniform card heights */
.product-card .card-title {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  line-clamp: 2;
  overflow: hidden;
  min-height: 2.6em; /* ~2 lines */
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  background-color: #f9f9f9;
  border-radius: 8px;
  margin-top: 20px;
}

.empty-state i {
  font-size: 48px;
  color: #ccc;
  margin-bottom: 15px;
}

.empty-state h3 {
  margin-bottom: 10px;
  color: #666;
}

.empty-state p {
  color: #888;
  max-width: 400px;
  margin: 0 auto;
}

/* Responsive */
@media (max-width: 768px) {
  .products-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 15px;
  }
  
  .category-left span {
    font-size: 13px;
  }
  
  .category-list > .category-item > .category-left > span {
    font-size: 14px;
  }
}

@media (max-width: 480px) {
  .products-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
  }
  .product-card .product-image { aspect-ratio: 1 / 1; }
}

/* Rating stars styles - prevent wrapping - УСИЛЕННАЯ ЗАЩИТА */
.rating-container {
  display: flex !important;
  flex-direction: row !important;
  flex-wrap: nowrap !important;
  .product-card .product-image { aspect-ratio: 1 / 1; }
  white-space: nowrap !important;
  align-items: center !important;
  gap: 0.25rem !important;
  overflow: hidden !important;
  min-width: 0 !important;
}

.rating-container > * {
  white-space: nowrap !important;
  flex-shrink: 0 !important;
  overflow: hidden !important;
}

/* Ensure stars container doesn't wrap - МАКСИМАЛЬНАЯ ЗАЩИТА */
.rating-stars {
  white-space: nowrap !important;
  display: inline-flex !important;
  flex-direction: row !important;
  align-items: center !important;
  flex-shrink: 0 !important;
  flex-wrap: nowrap !important;
  overflow: hidden !important;
  min-width: auto !important;
  width: auto !important;
  max-width: none !important;
}

/* Individual star icons - НИКОГДА НЕ ПЕРЕНОСЯТСЯ */
.rating-stars i {
  display: inline-block !important;
  margin-right: 1px !important;
  margin-left: 0 !important;
  flex-shrink: 0 !important;
  flex-grow: 0 !important;
  white-space: nowrap !important;
  overflow: visible !important;
  line-height: 1 !important;
  width: auto !important;
  height: auto !important;
}

/* Rating text elements - БЕЗ ПЕРЕНОСА */
.rating-text {
  white-space: nowrap !important;
  flex-shrink: 0 !important;
  flex-grow: 0 !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  max-width: none !important;
}

/* ========== ДОПОЛНИТЕЛЬНАЯ ЗАЩИТА ДЛЯ КАРТОЧЕК ПРОДУКТОВ ========== */
.product-card .rating-container {
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  overflow: hidden !important;
  text-overflow: clip !important;
  box-sizing: border-box !important;
}

.product-card .rating-stars {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: flex-start !important;
  flex-shrink: 0 !important;
  flex-grow: 0 !important;
  width: auto !important;
  min-width: fit-content !important;
}

.product-card .rating-stars i {
  font-style: normal !important;
  font-variant: normal !important;
  text-rendering: auto !important;
  -webkit-font-smoothing: antialiased !important;
}

.product-card .rating-text {
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  max-width: none !important;
  min-width: 0 !important;
}

/* ========== КРИТИЧЕСКАЯ ЗАЩИТА ДЛЯ CARD-BODY ========== */
.product-card .card-body {
  overflow: hidden !important;
  word-break: normal !important;
  word-wrap: normal !important;
  hyphens: none !important;
  -webkit-hyphens: none !important;
  -moz-hyphens: none !important;
}

/* ========== ФИНАЛЬНАЯ ЗАЩИТА - ПРИОРИТЕТ НАД ВСЕМИ СТИЛЯМИ ========== */
.rating-container,
.rating-stars,
.rating-stars i,
.rating-text {
  white-space: nowrap !important;
  word-break: keep-all !important;
  word-wrap: normal !important;
  overflow-wrap: normal !important;
  hyphens: none !important;
  -webkit-hyphens: none !important;
  -moz-hyphens: none !important;
}