/* ===================================
   Archive Product Enhancements CSS
   - Infinity Scroll Styles
   - Auto-Collapse Category Styles
   =================================== */

/* ===================
   Infinity Scroll
   =================== */

/* Loading indicator */
.infinity-loading {
  padding: 30px 0;
  text-align: center;
  color: #666;
}

.infinity-loading .spinner-border {
  width: 1.5rem;
  height: 1.5rem;
  border-width: 0.15em;
}

/* Hide Show More button when infinity scroll is active */
.infinity-scroll-active .btn-show-more {
  display: none !important;
}

/* End of products message */
.product-content > .text-center.text-muted {
  padding: 20px 0;
  margin-top: 20px;
  border-top: 1px solid #eee;
  font-size: 14px;
}

/* Error message styling */
.product-content > .text-center.text-danger {
  padding: 20px 0;
  margin-top: 20px;
}

/* Smooth animation for new products */
.product-item-ajax {
  transition: opacity 0.3s ease-in-out;
  animation: fadeInUp 0.5s ease-out;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Loading overlay adjustment for infinity scroll */
.product-content.loading-more {
  position: relative;
}

.product-content.loading-more::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 100px;
  background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.9));
  pointer-events: none;
}

/* ======================
   Auto-Collapse Category
   ====================== */

/* Smooth transitions for collapse */
#filter-category .collapse {
  transition: height 0.35s ease;
}

#filter-category .collapse-items {
  margin-bottom: 10px;
}

/* Button styling and transitions */
#filter-category .btn-collapse {
  transition: all 0.2s ease;
  width: 100%;
  text-align: left;
  padding: 12px 15px;
  border: 1px solid #e0e0e0;
  background: #fff;
  color: #333;
  font-weight: 500;
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

#filter-category .btn-collapse:hover {
  background: #f8f9fa;
  border-color: #212d65;
}

#filter-category .radio-items:has(#product-category-0) {
  border: 1px solid #e0e0e0 !important;
}

/* Active/Expanded state */
#filter-category .btn-collapse:not(.collapsed) {
  font-weight: 600;
  color: #212d65;
  background: #f0f4ff;
  border-color: #212d65;
}

/* Plus/Minus indicators */
/* SVG Chevron Icon untuk Category Filter */
#filter-category .btn-collapse::after {
  content: "";
  display: inline-block;
  width: 14px;
  height: 14px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23666'%3E%3Cpath d='M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  transition: transform 0.3s ease;
  margin-left: auto;
}

#filter-category .btn-collapse:not(.collapsed)::after {
  transform: rotate(180deg);
}

/* Hover state */
#filter-category .btn-collapse:hover::after {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23212D65'%3E%3Cpath d='M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z'/%3E%3C/svg%3E");
}

#filter-category .btn-collapse:not(.collapsed)::after {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23212D65'%3E%3Cpath d='M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z'/%3E%3C/svg%3E");
}

/* Collapse content styling */
#filter-category .collapse {
  border: 1px solid #e0e0e0;
  border-top: none;
  background: #ffffff;
  margin-top: -10px;
  padding: 20px;
  border-radius: 10px;
  -webkit-border-radius: 10px;
  -moz-border-radius: 10px;
  -ms-border-radius: 10px;
  -o-border-radius: 10px;
}

#filter-category .collapse.show {
  animation: slideDown 0.3s ease-out;
}

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

/* Radio items in collapsed content */
#filter-category .radio-items {
  padding: 8px 0;
  transition: all 0.2s ease;
}

#filter-category .radio-items:hover {
  background: #fff;
  padding-left: 5px;
}

/* Category search field enhancement */
#filter-category .cate-search {
  margin-bottom: 15px;
}

#filter-category .cate-search input {
  padding-right: 35px;
}

#filter-category .btn-searchcate {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  padding: 5px;
  background: none;
  border: none;
  color: #212d65;
}

/* All Categories special styling */
#filter-category .radio-items:has(#product-category-0) {
  background: #fff;
  padding: 10px;
  margin-top: 10px;
  border: 1px solid #212d65;
  border-radius: 4px;
}

#filter-category .radio-items:has(#product-category-0):hover {
  background: #f0f4ff;
}

/* ======================
   Mobile Responsive
   ====================== */

@media (max-width: 768px) {
  /* Infinity scroll - smaller loading indicator on mobile */
  .infinity-loading {
    padding: 20px 0;
  }

  .infinity-loading .spinner-border {
    width: 1.2rem;
    height: 1.2rem;
  }

  /* Category filter - better mobile UX */
  #filter-category .btn-collapse {
    padding: 15px;
    font-size: 16px; /* Prevent zoom on iOS */
  }

  #filter-category .collapse {
    padding: 10px;
  }

  #filter-category .radio-items {
    padding: 10px 5px;
  }
}

/* ======================
   Loading States
   ====================== */

/* General loading overlay enhancement */
.LoadingOverlay {
  background: rgba(255, 255, 255, 0.95) !important;
}

.LoadingOverlay_progress {
  color: #212d65 !important;
}

/* Filter loading state */
#filter-brand.loading,
#filter-category.loading {
  opacity: 0.6;
  pointer-events: none;
}

/* ======================
   Animation Classes
   ====================== */

.fade-in {
  animation: fadeIn 0.3s ease-in;
}

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

.slide-up {
  animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ======================
   Utility Classes
   ====================== */

.no-products-message {
  padding: 40px 20px;
  text-align: center;
  color: #666;
  font-style: italic;
}

.filter-active-indicator {
  display: inline-block;
  width: 8px;
  height: 8px;
  background: #212d65;
  border-radius: 50%;
  margin-left: 5px;
}

/* ======================
   Sort Container & Dropdown Styling
   ====================== */

/* Parent container for sort section */
.col-lg-5.col-xl-4 {
  flex: 0 0 auto;
  width: 45%; /* Lebih lebar dari 33.33% (col-4) */
  max-width: 400px; /* Batas maksimal */
}

/* Container yang memuat text + dropdown */
.d-flex.justify-content-end.gap-2.align-items-center {
  min-width: 280px; /* Minimum width untuk container */
}

/* Text "Urutkan berdasarkan" */
.d-flex.justify-content-end .text-xs.color-gray {
  white-space: nowrap;
  margin-right: 10px;
  font-size: 14px; /* Slightly larger for better readability */
}

/* Form container */
#product-sort-form {
  flex: 1;
  min-width: 180px;
}

/* Main dropdown - wider */
.custom-select.sources {
  min-width: 180px;
  width: 100%;
  max-width: 220px;
}

/* Trigger button */
.custom-select.sources .custom-select-trigger {
  padding: 10px 35px 10px 15px;
  font-size: 14px;
  white-space: nowrap;
}

/* Dropdown options container */
.custom-select.sources .custom-options {
  min-width: 180px;
  width: 100%;
}

/* Individual options */
.custom-select.sources .custom-option {
  padding: 10px 15px;
  white-space: nowrap;
  font-size: 14px;
}

/* Mobile responsive */
@media (max-width: 991px) {
  .col-lg-5.col-xl-4 {
    width: 100%;
    max-width: none;
  }

  .d-flex.justify-content-end.gap-2.align-items-center {
    justify-content: flex-start !important;
  }
}

@media (max-width: 768px) {
  .custom-select.sources {
    min-width: 150px;
  }

  /* Stack on very small screens */
  .d-flex.justify-content-end.gap-2.align-items-center {
    flex-wrap: wrap;
    min-width: auto;
  }

  .d-flex.justify-content-end .text-xs.color-gray {
    width: 100%;
    margin-bottom: 8px;
    margin-right: 0;
  }
}

/* Optional: Adjust search box width to balance */
.wrapper-prod-search {
  max-width: 400px; /* Balance with sort container */
}

/* ======================
   Dynamic Brand Filter Styles
   ====================== */

/* Brand filter loading state */
#filter-brand.loading {
  position: relative;
  opacity: 0.7;
}

#filter-brand.loading .brand-list {
  pointer-events: none;
}

/* Brand filter button with selection indicator */
#filter-brand .btn-collapse.has-selection {
  background: #f0f4ff;
  border-color: #212d65;
  font-weight: 600;
}

#filter-brand .btn-collapse.has-selection span {
  color: #212d65;
}

/* Selection badge/indicator */
#filter-brand .btn-collapse.has-selection::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  background: #212d65;
  border-radius: 50%;
  margin-right: 8px;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(33, 45, 101, 0.7);
  }
  70% {
    box-shadow: 0 0 0 6px rgba(33, 45, 101, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(33, 45, 101, 0);
  }
}

/* No brands message styling */
.brand-list .no-brands-message {
  padding: 15px;
  text-align: center;
  color: #999;
  font-style: italic;
  background: #f9f9f9;
  border-radius: 4px;
  margin: 10px 0;
}

/* Brand list disabled state */
.brand-list input[type="checkbox"]:disabled + label {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Brand count in button */
#filter-brand .btn-collapse span {
  font-weight: 500;
  transition: all 0.3s ease;
}

/* Visual feedback for brand update */
.brand-list {
  transition: opacity 0.3s ease;
}

.brand-list.updating {
  opacity: 0.5;
}

/* Brand checkbox hover effect */
.brand-list .checkbox-items:hover {
  background: #f0f4ff;
  padding-left: 5px;
  transition: all 0.2s ease;
}

/* Loading overlay specific to brand filter */
#filter-brand .LoadingOverlay {
  background: rgba(255, 255, 255, 0.9) !important;
}

/* Brand filter expanded state */
#filter-brand .collapse.show {
  max-height: 300px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #212d65 #f0f0f0;
}

#filter-brand .collapse.show::-webkit-scrollbar {
  width: 6px;
}

#filter-brand .collapse.show::-webkit-scrollbar-track {
  background: #f0f0f0;
  border-radius: 3px;
}

#filter-brand .collapse.show::-webkit-scrollbar-thumb {
  background: #212d65;
  border-radius: 3px;
}

#filter-brand .collapse.show::-webkit-scrollbar-thumb:hover {
  background: #1a2454;
}

/* Error message in brand filter */
.brand-list .text-danger {
  padding: 15px;
  text-align: center;
  background: #fee;
  border: 1px solid #fcc;
  border-radius: 4px;
  margin: 10px 0;
}

/* Smooth transition for brand list updates */
.brand-list > * {
  animation: fadeIn 0.3s ease-in;
}

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

/* Mobile responsive for brand filter */
@media (max-width: 768px) {
  #filter-brand .collapse.show {
    max-height: 200px;
  }

  .brand-list .no-brands-message,
  .brand-list .text-danger {
    font-size: 12px;
    padding: 10px;
  }
}
