/**
 * Jain Digital Hub - Storefront Top Product Filter Bar
 * Premium, responsive filter bar for Category, Brand, and Search pages.
 */

.jdh-top-filter-bar {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 12px 16px;
  margin-bottom: 20px;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.04);
  position: relative;
  z-index: 20;
}

.jdh-tf-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

/* Left controls: filter button + count + filter pills */
.jdh-tf-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  flex: 1 1 auto;
}

/* Right controls: sort by */
.jdh-tf-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  margin-left: auto;
}

/* Product Count Badge */
.jdh-tf-count {
  font-size: 0.88rem;
  color: #64748b;
  font-weight: 500;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  padding-right: 6px;
  border-right: 1px solid #e2e8f0;
}

.jdh-tf-count strong {
  color: #0f172a;
  font-weight: 700;
  margin-right: 4px;
}

/* Mobile Filter trigger (opens category sidebar on mobile if present) */
.jdh-tf-sidebar-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #0f172a;
  color: #ffffff !important;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 8px;
  text-decoration: none !important;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
}

.jdh-tf-sidebar-btn:hover {
  background: #1e293b;
  transform: translateY(-1px);
}

/* Filter Dropdown Trigger Button */
.jdh-tf-dropdown {
  position: relative;
  display: inline-block;
}

.jdh-tf-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #f8fafc;
  color: #334155;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 6px 13px;
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  outline: none;
  white-space: nowrap;
}

.jdh-tf-btn:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
  color: #0f172a;
}

.jdh-tf-btn .jdh-tf-arrow {
  font-size: 0.70rem;
  color: #64748b;
  transition: transform 0.2s ease;
}

.jdh-tf-dropdown.is-open .jdh-tf-btn .jdh-tf-arrow {
  transform: rotate(180deg);
}

/* Active state for filter button when filter is applied */
.jdh-tf-btn.is-active {
  background: #eff6ff;
  border-color: #3b82f6;
  color: #1d4ed8;
  font-weight: 700;
}

.jdh-tf-btn.is-active .jdh-tf-arrow {
  color: #1d4ed8;
}

/* In-Stock Toggle Chip */
.jdh-tf-toggle-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #f8fafc;
  color: #475569;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 6px 13px;
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none !important;
  transition: all 0.2s ease;
  user-select: none;
}

.jdh-tf-toggle-chip:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
  color: #0f172a;
}

.jdh-tf-toggle-chip.is-active {
  background: #ecfdf5;
  border-color: #10b981;
  color: #047857;
  font-weight: 700;
  box-shadow: 0 1px 3px rgba(16, 185, 129, 0.15);
}

.jdh-tf-toggle-chip.is-active i {
  color: #10b981;
}

/* Dropdown Menu Popover */
.jdh-tf-menu {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  box-shadow: 0 10px 25px -5px rgba(15, 23, 42, 0.12), 0 8px 10px -6px rgba(15, 23, 42, 0.08);
  padding: 10px;
  min-width: 250px;
  max-width: 320px;
  z-index: 100;
  animation: jdhTfFadeIn 0.15s ease-out;
  box-sizing: border-box;
}

.jdh-tf-menu.jdh-tf-menu-right {
  left: auto;
  right: 0;
}

.jdh-tf-dropdown.is-open .jdh-tf-menu {
  display: block;
}

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

.jdh-tf-menu-header {
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: #64748b;
  padding: 4px 8px 8px 8px;
  border-bottom: 1px solid #f1f5f9;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.jdh-tf-menu-header a {
  color: #ef4444;
  font-size: 0.75rem;
  text-decoration: none;
  font-weight: 600;
  text-transform: none;
}

.jdh-tf-menu-header a:hover {
  text-decoration: underline;
}

/* Brand Search Input */
.jdh-tf-search-wrap {
  position: relative;
  margin-bottom: 8px;
  padding: 0 2px;
}

.jdh-tf-search-input {
  width: 100%;
  box-sizing: border-box;
  padding: 6px 10px 6px 28px;
  font-size: 0.82rem;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  outline: none;
  color: #0f172a;
  background: #ffffff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.jdh-tf-search-input:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}

.jdh-tf-search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.74rem;
  color: #94a3b8;
  pointer-events: none;
}

/* Menu list container (strictly vertical column layout) */
.jdh-tf-menu-list {
  max-height: 240px;
  overflow-y: auto;
  padding: 0 !important;
  margin: 0 !important;
  list-style: none !important;
  display: flex !important;
  flex-direction: column !important;
  gap: 2px !important;
}

.jdh-tf-menu-list::-webkit-scrollbar {
  width: 5px;
}

.jdh-tf-menu-list::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

/* Reset any theme li rules */
.jdh-tf-menu-list li {
  display: block !important;
  float: none !important;
  width: 100% !important;
  margin: 0 !important;
  padding: 0 !important;
  border: none !important;
  clear: both !important;
}

/* Brand / Category Row Item */
.jdh-tf-brand-item {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  justify-content: space-between !important;
  width: 100% !important;
  box-sizing: border-box !important;
  padding: 7px 10px !important;
  border-radius: 8px !important;
  font-size: 0.85rem !important;
  color: #334155 !important;
  text-decoration: none !important;
  transition: all 0.15s ease !important;
  cursor: pointer !important;
}

.jdh-tf-brand-item:hover {
  background: #f1f5f9 !important;
  color: #0f172a !important;
}

.jdh-tf-brand-item.is-selected {
  background: #eff6ff !important;
  color: #1d4ed8 !important;
  font-weight: 700 !important;
}

.jdh-tf-brand-left {
  display: inline-flex !important;
  align-items: center !important;
  gap: 9px !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  white-space: nowrap !important;
}

.jdh-tf-brand-check {
  width: 15px;
  height: 15px;
  border-radius: 4px;
  border: 1.5px solid #94a3b8;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  color: transparent;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.jdh-tf-brand-item:hover .jdh-tf-brand-check {
  border-color: #64748b;
}

.jdh-tf-brand-item.is-selected .jdh-tf-brand-check {
  background: #2563eb;
  border-color: #2563eb;
  color: #ffffff;
}

.jdh-tf-brand-badge {
  font-size: 0.74rem;
  color: #64748b;
  background: #f1f5f9;
  padding: 2px 7px;
  border-radius: 10px;
  font-weight: 600;
  flex-shrink: 0;
}

.jdh-tf-brand-item.is-selected .jdh-tf-brand-badge {
  background: #dbeafe;
  color: #1d4ed8;
}

/* Rating Row Item */
.jdh-tf-rating-item {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  justify-content: space-between !important;
  width: 100% !important;
  box-sizing: border-box !important;
  padding: 8px 10px !important;
  border-radius: 8px !important;
  text-decoration: none !important;
  color: #334155 !important;
  transition: all 0.15s ease !important;
  cursor: pointer !important;
}

.jdh-tf-rating-item:hover {
  background: #f8fafc !important;
  color: #0f172a !important;
}

.jdh-tf-rating-item.is-selected {
  background: #eff6ff !important;
  border: 1px solid #bfdbfe !important;
  color: #1d4ed8 !important;
  font-weight: 700 !important;
}

.jdh-tf-rating-stars-wrap {
  display: inline-flex !important;
  flex-direction: row !important;
  align-items: center !important;
  gap: 3px !important;
  white-space: nowrap !important;
}

.jdh-tf-rating-stars-wrap i.fa {
  display: inline-block !important;
  font-size: 14px !important;
  line-height: 1 !important;
  width: auto !important;
  height: auto !important;
  margin: 0 !important;
}

.jdh-tf-star-filled {
  color: #f59e0b !important;
}

.jdh-tf-star-empty {
  color: #e2e8f0 !important;
}

.jdh-tf-rating-label {
  font-size: 0.84rem !important;
  font-weight: 600 !important;
  margin-left: 8px !important;
}

.jdh-tf-rating-check {
  color: #2563eb;
  font-size: 0.82rem;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.jdh-tf-rating-item.is-selected .jdh-tf-rating-check {
  opacity: 1;
}

/* Price Popover Content */
.jdh-tf-price-popover {
  width: 270px;
  padding: 10px;
}

.jdh-tf-price-presets {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-bottom: 10px;
}

.jdh-tf-price-preset-btn {
  display: block;
  text-align: left;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 0.83rem;
  color: #334155;
  background: transparent;
  border: none;
  text-decoration: none !important;
  cursor: pointer;
  transition: all 0.15s ease;
}

.jdh-tf-price-preset-btn:hover {
  background: #f1f5f9;
  color: #0f172a;
}

.jdh-tf-price-preset-btn.is-selected {
  background: #eff6ff;
  color: #1d4ed8;
  font-weight: 700;
}

.jdh-tf-price-custom-form {
  border-top: 1px solid #f1f5f9;
  padding-top: 10px;
}

.jdh-tf-price-inputs {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}

.jdh-tf-price-input {
  width: 100%;
  padding: 6px 8px;
  font-size: 0.82rem;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  color: #0f172a;
  outline: none;
  transition: border-color 0.2s ease;
}

.jdh-tf-price-input:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}

.jdh-tf-price-apply-btn {
  width: 100%;
  background: #0f172a;
  color: #ffffff;
  border: none;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s ease;
}

.jdh-tf-price-apply-btn:hover {
  background: #1e293b;
}

/* Sort Select Dropdown */
.jdh-tf-sort-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}

.jdh-tf-sort-label {
  font-size: 0.82rem;
  color: #64748b;
  font-weight: 600;
  margin: 0;
  white-space: nowrap;
}

.jdh-tf-sort-select {
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 0.84rem;
  font-weight: 600;
  color: #0f172a;
  cursor: pointer;
  outline: none;
  transition: all 0.2s ease;
}

.jdh-tf-sort-select:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}

/* Active Filter Chips Row */
.jdh-tf-active-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed #e2e8f0;
}

.jdh-tf-active-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.jdh-tf-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #f1f5f9;
  color: #334155;
  border: 1px solid #e2e8f0;
  border-radius: 20px;
  padding: 3px 10px;
  font-size: 0.78rem;
  font-weight: 600;
  text-decoration: none !important;
  transition: all 0.15s ease;
}

.jdh-tf-chip:hover {
  background: #e2e8f0;
  color: #0f172a;
}

.jdh-tf-chip-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: #cbd5e1;
  color: #475569;
  font-size: 11px;
  line-height: 1;
  transition: all 0.15s ease;
}

.jdh-tf-chip:hover .jdh-tf-chip-remove {
  background: #ef4444;
  color: #ffffff;
}

.jdh-tf-clear-all {
  font-size: 0.78rem;
  font-weight: 700;
  color: #ef4444 !important;
  text-decoration: none !important;
  margin-left: 4px;
  padding: 3px 6px;
  transition: opacity 0.2s ease;
}

.jdh-tf-clear-all:hover {
  text-decoration: underline !important;
  opacity: 0.85;
}

/* Responsive adjustments */
@media (max-width: 991px) {
  .jdh-top-filter-bar {
    padding: 10px 12px;
  }
  .jdh-tf-count {
    display: none;
  }
}

@media (max-width: 576px) {
  .jdh-tf-container {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .jdh-tf-left {
    overflow-x: auto;
    padding-bottom: 4px;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
  }
  .jdh-tf-left::-webkit-scrollbar {
    height: 3px;
  }
  .jdh-tf-right {
    margin-left: 0;
    justify-content: space-between;
    width: 100%;
    border-top: 1px solid #f1f5f9;
    padding-top: 8px;
  }
  .jdh-tf-sort-select {
    width: 100%;
  }
}
