/**
 * Jare Product Filters - Nike Inspired Minimalist Design
 * High-performance, clean CSS with seamless responsiveness
 */

:root {
  --jpf-primary: #111111;
  --jpf-accent: #FD9800;
  --jpf-text: #111111;
  --jpf-text-muted: #757575;
  --jpf-bg: #FFFFFF;
  --jpf-surface: #F5F5F5;
  --jpf-border: #E5E5E5;
  --jpf-border-hover: #111111;
  --jpf-radius: 4px;
  --jpf-transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  --jpf-sidebar-width: 260px;
}

/* Hide default WooCommerce result count & catalog ordering if we replace them */
.woocommerce-result-count,
.woocommerce-ordering,
.astra-shop-thumbnail-wrap + .ast-woocommerce-container .woocommerce-ordering,
.woocommerce.archive #secondary,
.woocommerce.archive .sidebar-main {
  display: none !important;
}

/* Ensure WooCommerce main content container takes 100% width */
.woocommerce.archive #primary,
.woocommerce.archive .content-area {
  width: 100% !important;
  max-width: 100% !important;
  float: none !important;
}

/* Ensure Astra / WooCommerce shop page container uses full width for our layout */
.woocommerce .jpf-shop-wrapper ul.products,
.jpf-products-container ul.products {
  margin: 0 !important;
  display: grid !important;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)) !important;
  gap: 24px !important;
  width: 100% !important;
}

.woocommerce .jpf-shop-wrapper ul.products::before,
.woocommerce .jpf-shop-wrapper ul.products::after,
.jpf-products-container ul.products::before,
.jpf-products-container ul.products::after {
  content: none !important;
  display: none !important;
}

.woocommerce .jpf-shop-wrapper ul.products li.product,
.jpf-products-container ul.products li.product {
  width: 100% !important;
  margin: 0 !important;
  float: none !important;
}

/* --- 1. Top Header Controls Bar --- */
.jpf-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 0 20px 0;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--jpf-border);
  position: relative;
  z-index: 10;
  width: 100%;
}

.jpf-top-bar-left {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.jpf-page-title {
  font-size: 26px;
  font-weight: 700;
  color: var(--jpf-text);
  margin: 0;
  line-height: 1.2;
  letter-spacing: -0.02em;
  font-family: inherit;
}

.jpf-items-count {
  font-size: 16px;
  font-weight: 400;
  color: var(--jpf-text-muted);
}

.jpf-top-bar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

/* Desktop Toggle Filters Button */
.jpf-btn-toggle-filters {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: none;
  font-size: 14px;
  font-weight: 500;
  color: var(--jpf-text);
  cursor: pointer;
  padding: 8px 12px;
  border-radius: var(--jpf-radius);
  transition: var(--jpf-transition);
}

.jpf-btn-toggle-filters:hover {
  background-color: var(--jpf-surface);
}

.jpf-btn-toggle-filters .jpf-icon {
  transition: transform 0.2s ease;
}

/* Mobile Filter Trigger Button */
.jpf-btn-mobile-filter {
  display: none;
  align-items: center;
  gap: 8px;
  background: #ffffff;
  border: 1px solid var(--jpf-border);
  padding: 8px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  color: var(--jpf-text);
  cursor: pointer;
}

.jpf-filter-badge {
  background: var(--jpf-primary);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  border-radius: 10px;
  padding: 1px 6px;
}

/* Sort Dropdown */
.jpf-sort-wrapper {
  position: relative;
}

.jpf-sort-select {
  appearance: none;
  -webkit-appearance: none;
  background: #ffffff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23111111' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 12px center;
  border: 1px solid var(--jpf-border);
  padding: 8px 36px 8px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  color: var(--jpf-text);
  cursor: pointer;
  transition: var(--jpf-transition);
}

.jpf-sort-select:hover,
.jpf-sort-select:focus {
  border-color: var(--jpf-border-hover);
  outline: none;
}

/* --- 2. Active Filter Chips --- */
.jpf-active-chips-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 12px 0;
  margin-bottom: 16px;
  border-bottom: 1px dashed var(--jpf-border);
}

.jpf-chips-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.jpf-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background-color: var(--jpf-surface);
  border: 1px solid var(--jpf-border);
  border-radius: 16px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 500;
  color: var(--jpf-text);
  cursor: pointer;
  transition: var(--jpf-transition);
}

.jpf-chip:hover {
  background-color: #e5e5e5;
  border-color: #ccc;
}

.jpf-chip-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  font-size: 12px;
  line-height: 1;
  color: var(--jpf-text-muted);
}

.jpf-chip:hover .jpf-chip-remove {
  color: var(--jpf-text);
}

.jpf-clear-all-btn {
  background: none;
  border: none;
  font-size: 12px;
  font-weight: 600;
  color: var(--jpf-text-muted);
  text-decoration: underline;
  cursor: pointer;
  padding: 4px 8px;
  margin-left: 6px;
  transition: var(--jpf-transition);
}

.jpf-clear-all-btn:hover {
  color: #d9534f;
}

/* --- 3. Shop Layout Wrapper & Sidebar --- */
.jpf-shop-wrapper {
  display: flex;
  gap: 32px;
  align-items: flex-start;
  width: 100%;
  position: relative;
  transition: var(--jpf-transition);
}

/* Desktop Sidebar */
.jpf-sidebar {
  width: var(--jpf-sidebar-width);
  min-width: var(--jpf-sidebar-width);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
}

.jpf-sidebar.is-hidden {
  width: 0 !important;
  min-width: 0 !important;
  opacity: 0;
  margin-right: -32px;
  pointer-events: none;
}

.jpf-sidebar-inner {
  padding-right: 8px;
}

/* Products Container */
.jpf-products-container {
  flex: 1;
  min-width: 0;
  position: relative;
  transition: var(--jpf-transition);
}

/* Loading Overlay & Spinner */
.jpf-loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.7);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding-top: 100px;
  z-index: 20;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
  backdrop-filter: blur(1px);
}

.jpf-loading-overlay.is-active {
  opacity: 1;
  visibility: visible;
}

.jpf-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid #e0e0e0;
  border-top-color: var(--jpf-primary);
  border-radius: 50%;
  animation: jpf-spin 0.8s linear infinite;
}

@keyframes jpf-spin {
  to { transform: rotate(360deg); }
}

/* --- 4. Accordion Groups --- */
.jpf-filter-group {
  border-bottom: 1px solid var(--jpf-border);
  padding: 16px 0;
}

.jpf-filter-group:first-child {
  padding-top: 0;
}

.jpf-accordion-header {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  text-align: left;
}

.jpf-filter-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--jpf-text);
  letter-spacing: -0.01em;
}

.jpf-chevron {
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--jpf-text);
  border-bottom: 2px solid var(--jpf-text);
  transform: rotate(45deg);
  transition: transform 0.25s ease;
  margin-right: 4px;
}

.jpf-filter-group.active .jpf-chevron {
  transform: rotate(-135deg);
}

.jpf-accordion-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s ease;
  opacity: 0;
}

.jpf-filter-group.active .jpf-accordion-content {
  max-height: 450px;
  opacity: 1;
  margin-top: 14px;
  overflow-y: auto;
}

/* Custom Scrollbar for lists */
.jpf-accordion-content::-webkit-scrollbar {
  width: 4px;
}
.jpf-accordion-content::-webkit-scrollbar-thumb {
  background: #ddd;
  border-radius: 4px;
}

/* --- 5. Option List & Minimalist Checkbox (Nike Style) --- */
.jpf-options-list {
  list-style: none;
  padding: 0;
  padding-right: 6px;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.jpf-option-item {
  margin: 0;
  padding: 0;
}

.jpf-checkbox-label {
  display: flex;
  align-items: center;
  cursor: pointer;
  font-size: 13.5px;
  color: var(--jpf-text);
  position: relative;
  user-select: none;
  line-height: 1.3;
}

.jpf-checkbox-label input {
  position: absolute;
  opacity: 0;
  cursor: pointer;
  height: 0;
  width: 0;
}

.jpf-checkbox-custom {
  height: 18px;
  width: 18px;
  background-color: #fff;
  border: 1.5px solid #ccc;
  border-radius: 3px;
  margin-right: 10px;
  flex-shrink: 0;
  position: relative;
  transition: var(--jpf-transition);
}

.jpf-checkbox-label:hover .jpf-checkbox-custom {
  border-color: var(--jpf-text);
}

.jpf-checkbox-label input:checked ~ .jpf-checkbox-custom {
  background-color: var(--jpf-primary);
  border-color: var(--jpf-primary);
}

.jpf-checkbox-label input:checked ~ .jpf-checkbox-custom:after {
  content: "";
  position: absolute;
  left: 5px;
  top: 2px;
  width: 4px;
  height: 8px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.jpf-option-name {
  flex: 1;
  font-weight: 400;
}

.jpf-checkbox-label input:checked ~ .jpf-option-name {
  font-weight: 600;
}

.jpf-option-count {
  font-size: 12px;
  color: var(--jpf-text-muted);
  margin-left: 6px;
  margin-right: 4px;
  white-space: nowrap;
}

/* --- 6. Calibre Grid (Nike Pill Box Style) --- */
.jpf-pill-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.jpf-pill-label {
  cursor: pointer;
  user-select: none;
}

.jpf-pill-label input {
  position: absolute;
  opacity: 0;
  height: 0;
  width: 0;
}

.jpf-pill-box {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 6px;
  border: 1px solid var(--jpf-border);
  border-radius: 4px;
  background: #fff;
  text-align: center;
  transition: var(--jpf-transition);
}

.jpf-pill-text {
  font-size: 12px;
  font-weight: 500;
  color: var(--jpf-text);
  line-height: 1.2;
}

.jpf-pill-label:hover .jpf-pill-box {
  border-color: var(--jpf-text);
}

.jpf-pill-label input:checked ~ .jpf-pill-box {
  border-color: var(--jpf-primary);
  background-color: var(--jpf-primary);
}

.jpf-pill-label input:checked ~ .jpf-pill-box .jpf-pill-text {
  color: #ffffff;
  font-weight: 600;
}

/* --- 7. Price Filter --- */
.jpf-price-filter {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.jpf-price-inputs {
  display: flex;
  align-items: center;
  gap: 8px;
}

.jpf-price-field {
  display: flex;
  align-items: center;
  border: 1px solid var(--jpf-border);
  border-radius: 4px;
  padding: 4px 8px;
  background: #fff;
  flex: 1;
}

.jpf-currency {
  font-size: 12px;
  color: var(--jpf-text-muted);
  margin-right: 4px;
}

.jpf-price-field input {
  width: 100%;
  border: none;
  background: none;
  font-size: 13px;
  font-weight: 500;
  color: var(--jpf-text);
  outline: none;
  padding: 0;
}

.jpf-price-separator {
  color: var(--jpf-text-muted);
  font-size: 14px;
}

.jpf-price-slider-track {
  position: relative;
  height: 24px;
}

.jpf-price-slider-track input[type="range"] {
  position: absolute;
  width: 100%;
  pointer-events: none;
  appearance: none;
  background: transparent;
  outline: none;
}

.jpf-price-slider-track input[type="range"]::-webkit-slider-thumb {
  pointer-events: auto;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--jpf-primary);
  cursor: pointer;
  border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

/* --- 8. No Products Found State --- */
.jpf-no-products {
  text-align: center;
  padding: 60px 20px;
  background: #fff;
  border-radius: 8px;
  margin: 20px 0;
}

.jpf-no-icon {
  color: #bbb;
  margin-bottom: 16px;
}

.jpf-no-products h3 {
  font-size: 18px;
  font-weight: 700;
  color: var(--jpf-text);
  margin: 0 0 8px 0;
}

.jpf-no-products p {
  font-size: 14px;
  color: var(--jpf-text-muted);
  margin: 0;
}

/* --- 9. Mobile Drawer (Off-Canvas) --- */
.jpf-drawer-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 99998;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.jpf-drawer-backdrop.is-open {
  opacity: 1;
  visibility: visible;
}

.jpf-mobile-drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 320px;
  max-width: 85vw;
  background: #fff;
  z-index: 99999;
  transform: translateX(-100%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15);
}

.jpf-mobile-drawer.is-open {
  transform: translateX(0);
}

.jpf-drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 20px;
  border-bottom: 1px solid var(--jpf-border);
}

.jpf-drawer-title {
  font-size: 18px;
  font-weight: 700;
  margin: 0;
  color: var(--jpf-text);
}

.jpf-drawer-close {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  color: var(--jpf-text);
}

.jpf-drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
}

.jpf-drawer-footer {
  display: flex;
  gap: 12px;
  padding: 16px 20px;
  border-top: 1px solid var(--jpf-border);
  background: #fff;
}

.jpf-btn-drawer-clear {
  flex: 1;
  background: var(--jpf-surface);
  border: 1px solid var(--jpf-border);
  border-radius: 24px;
  padding: 12px;
  font-size: 14px;
  font-weight: 600;
  color: var(--jpf-text);
  cursor: pointer;
}

.jpf-btn-drawer-apply {
  flex: 2;
  background: var(--jpf-primary);
  border: none;
  border-radius: 24px;
  padding: 12px;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  cursor: pointer;
}

/* --- 10. Responsive Breakpoints --- */
@media (max-width: 991px) {
  .jpf-sidebar-desktop {
    display: none !important;
  }
  
  .jpf-btn-toggle-filters {
    display: none;
  }

  .jpf-btn-mobile-filter {
    display: inline-flex;
  }

  .jpf-shop-wrapper {
    gap: 0;
  }
}
