/* Custom Product Filter Styles */

.cpf-product-filter {
}

/* Filter Display */
.cpf-filter-display {
  display: flex;
  flex-direction: column;
  justify-content: center;
  font-size: 16px;
  line-height: 24px;
  font-weight: 400;
  color: #242424;
  font-family: "Lexend Deca";
}

.cpf-season-display {
  color: #242424;
}

.cpf-spec-display {
  color: #242424;
  font-size: 24px;
  font-weight: 600;
}

.cpf-filter-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.cpf-form-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 15px;
}

#filterShortcode {
  margin-right: 0;
  margin-left: auto;
  width: 100%;
}

.cpf-form-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  .select2-container {
    height: 100%;
    min-width: 180px;
    .selection {
      display: block;
      height: 100%;
      .select2-selection {
        min-height: unset;
        height: 100%;
        .select2-selection__rendered {
          height: 100%;
        }
        .cpf-selection-container {
          height: 100%;
        }
      }
    }
  }
}

.cpf-form-field label {
  font-weight: 600;
  font-size: 14px;
  color: #333;
  margin-bottom: 5px;
}

.cpf-select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 14px;
  background-color: #fff;
}

.cpf-form-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-start;
  align-items: center;
}

.cpf-submit-btn {
  padding: 10px 20px !important;
  font-size: 13px !important;
  line-height: 24px !important;
  font-weight: 700 !important;
  border: none !important;
  border-radius: 5px !important;
  cursor: pointer !important;
  transition: all 0.3s ease !important;
  background-color: #fd6011 !important;
  color: #fff !important;
  text-transform: uppercase !important;
  @media (max-width: 860px) {
    .text {
      display: none;
    }
  }
}

.cpf-submit-btn:hover {
  background-color: #e55510;
}

.cpf-submit-btn.loading {
  position: relative;
  pointer-events: none;
  opacity: 0.7;
}

.cpf-submit-btn.loading::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  top: 50%;
  left: 50%;
  margin-left: -8px;
  margin-top: -8px;
  border: 2px solid #ffffff;
  border-radius: 50%;
  border-top-color: transparent;
  animation: cpf-spinner 0.6s linear infinite;
}

@keyframes cpf-spinner {
  to {
    transform: rotate(360deg);
  }
}

/* Selection container with label and chip */
.cpf-selection-container {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.cpf-label {
  font-size: 14px;
  color: #333;
  font-weight: 400;
}

.cpf-selected-chip {
  position: absolute;
  right: 30px;
  background-color: #242424;
  border-radius: 5px;
  padding: 0px 8px;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  @media (max-width: 860px) {
    line-height: 30px;
    right: 45px;
  }
}

/* Select2 customization to ensure selected values are visible */
.cpf-product-filter .select2-container--default .select2-selection--single {
  height: auto;
  min-height: 38px;
  padding: 0px;
  border: 1px solid #ddd;
  border-radius: 4px;
  display: flex;
  align-items: center;
}

.cpf-product-filter
  .select2-container--default
  .select2-selection--single
  .select2-selection__rendered {
  line-height: 28px;
  padding-left: 8px;
  color: #333;
  font-size: 14px;
  display: flex;
  align-items: center;
}

.cpf-product-filter
  .select2-container--default
  .select2-selection--single
  .select2-selection__arrow {
  height: 100%;
  right: 10px;
  width: 12px;
}

.cpf-product-filter
  .select2-container--default
  .select2-selection--single
  .select2-selection__arrow
  b {
  display: none;
}

.cpf-product-filter
  .select2-container--default
  .select2-selection--single
  .select2-selection__arrow::after {
  content: "";
  display: block;
  width: 14px;
  height: 16px;
  background-image: url("data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTIiIGhlaWdodD0iNyIgdmlld0JveD0iMCAwIDEyIDciIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxwYXRoIGQ9Ik02LjM3NSA2LjM0Mzc1QzYuMDYyNSA2LjY1NjI1IDUuNTkzNzUgNi42NTYyNSA1LjMxMjUgNi4zNDM3NUwwLjMxMjUgMS4zNDM3NUMwIDEuMDYyNSAwIDAuNTkzNzUgMC4zMTI1IDAuMzEyNUMwLjU5Mzc1IDAgMS4wNjI1IDAgMS4zNDM3NSAwLjMxMjVMNS44MTI1IDQuNzgxMjVMMTAuMzEyNSAwLjI4MTI1QzEwLjU5MzggMCAxMS4wNjI1IDAgMTEuMzQzOCAwLjI4MTI1QzExLjY1NjIgMC41OTM3NSAxMS42NTYyIDEuMDYyNSAxMS4zNDM4IDEuMzQzNzVMNi4zNzUgNi4zNDM3NVoiIGZpbGw9IiMyNDI0MjQiLz4KPC9zdmc+");
  background-repeat: no-repeat;
  background-position: center;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  transition: 0.2s all ease-in;
}

.cpf-product-filter
  .select2-container--open
  .select2-selection--single
  .select2-selection__arrow::after {
  transform: translateY(-50%) rotate(180deg);
}

.cpf-product-filter .select2-container--focus .select2-selection--single,
.cpf-product-filter .select2-container--open .select2-selection--single {
  outline: 1px solid #fd6011;
}

.cpf-product-filter
  .select2-container--default
  .select2-selection--single
  .select2-selection__placeholder {
  color: #999;
}

/* Ensure the selected value is visible and not cut off */
.cpf-product-filter
  .select2-container--default
  .select2-selection--single
  .select2-selection__rendered {
  overflow: visible;
  text-overflow: clip;
  white-space: normal;
}

/* Dropdown styles */
.cpf-product-filter
  .select2-container--default
  .select2-results__option--highlighted[aria-selected] {
  background-color: #fd6011;
  color: white;
}

.cpf-product-filter
  .select2-container--default
  .select2-results__option[aria-selected="true"] {
  background-color: #fd6011;
  color: white;
}

.cpf-product-filter .select2-dropdown {
  border: 1px solid #ddd;
  border-radius: 4px;
}

.cpf-product-filter .cpf-label,
.cpf-product-filter .select2-selection__rendered {
  font-weight: 600;
  font-size: 14px;
  color: #242424;
}

.cpf-product-filter .select2-search--dropdown .select2-search__field {
  border: 1px solid #d3d3d3;
  border-radius: 5px;
  padding: 8px;
}

.cpf-shop-filter {
  background-color: #fff;
  z-index: 999;
  position: sticky;
  top: 90px;
  left: 0;
  padding: 30px;
  width: 100%;
  transition: 0.2s all ease-in-out;

  /* not sticky */
  position: relative;
  top: 0 !important;
  margin-top: 0;
  margin-bottom: 40px;
  width: calc(100% + 30px);
  transform: translateX(-15px);
  @media (max-width: 1230px) {
    padding: 30px 20px;
  }
}

.cpf-shop-filter::after {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100vw;
  height: 100%;
  background-color: white;
  z-index: -1;
  pointer-events: none;
  transition: height 0.3s ease-in-out;
}

.cpf-shop-filter.expanded::after {
  height: calc(100% + var(--expanded-height, 0px));
}

.cpf-shop-row {
  grid-template-columns: 1fr 1fr;
  @media (max-width: 1230px) {
    grid-template-columns: 1fr;
  }
  @media (max-width: 860px) {
    grid-template-columns: 1fr 1fr;
  }
}

.cpf-shop-row .filter {
  display: grid;
  grid-template-columns: repeat(5, 180px);
  gap: 15px;
  @media (max-width: 1230px) {
    grid-template-columns: max-content 1fr 1fr 1fr 1fr;
    margin-right: 0;
    margin-left: auto;
  }
  @media (max-width: 860px) {
    grid-template-columns: max-content max-content;
  }
}

/* Orderby button and dropdown styles */
.cpf-orderby-wrapper {
  height: 100%;
  position: relative;
  align-items: end;
  .cpf-orderby-btn {
    height: 100%;
    @media (max-width: 1024px) {
      .cpf-orderby-text {
        display: none;
      }
    }
  }
}

.cpf-orderby-btn {
  background-color: #f5f5f5 !important;
  gap: 8px !important;
  padding: 8px 16px !important;
  background: #f5f5f5 !important;
  border: 1px solid #ddd !important;
  border-radius: 4px !important;
  cursor: pointer !important;
  font-size: 14px !important;
  font-weight: 600 !important;
  color: #242424 !important;
  transition: all 0.3s ease !important;

  min-width: unset;
  width: fit-content;
  border: unset !important;
  font-family: "Lexend Deca";
  font-size: 13px !important;
  text-transform: uppercase;
}

.cpf-orderby-btn:hover {
  border-color: #fd6011;
}

.cpf-orderby-btn svg {
  flex-shrink: 0;
}

.cpf-orderby-dropdown {
  position: absolute;
  top: calc(100% + 5px);
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 4px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  z-index: 1000;
  display: none;
  max-height: 300px;
  overflow-y: auto;
}

.cpf-orderby-dropdown.active {
  display: block;
  min-width: 250px;
  @media (max-width: 860px) {
    left: unset;
    right: 0;
  }
  @media (max-width: 440px) {
    left: unset;
    right: -100%;
    width: 100%;
  }

  @media (max-width: 380px) {
    right: -200%;
  }
}

.cpf-orderby-option {
  display: block;
  padding: 10px 16px;
  font-size: 14px;
  color: #242424;
  text-decoration: none;
  transition: all 0.2s ease;
  border-bottom: 1px solid #f0f0f0;
}

.cpf-orderby-option:last-child {
  border-bottom: none;
}

.cpf-orderby-option:hover {
  background-color: #f8f8f8;
  color: #fd6011;
}

.cpf-orderby-option.active {
  background-color: #fd6011;
  color: #fff;
}

.cpf-orderby-option.active:hover {
  background-color: #e55510;
}

/* Expanded filters section - Drawer style */
#cpf-expanded-filters {
  position: fixed;
  top: 0;
  right: -400px;
  width: 400px;
  height: 100vh;
  background-color: #fff;
  box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
  z-index: 9999;
  overflow-y: auto;
  overflow-x: visible;
  padding: 30px;
  padding-top: 70px;
  transition: right 0.3s ease-in-out;
  display: grid;
  grid-template-columns: 1fr;
  gap: 15px;
  align-content: start;
}

#cpf-expanded-filters .wd-popup-close {
  position: absolute;
  top: 20px;
  right: 20px;
  z-index: 10;
  a {
    color: var(--color-gray-800);
  }
}

/* Select2 dropdown styling in drawer */
.cpf-drawer-dropdown {
  z-index: 10000 !important;
  max-height: 300px !important;
  overflow-y: auto !important;
}

.cpf-drawer-dropdown.select2-dropdown--below {
  margin-top: 2px !important;
}

.cpf-drawer-dropdown .select2-results__option {
  margin-bottom: 0 !important;
}

#cpf-expanded-filters .woocommerce-widget-layered-nav-dropdown {
  position: relative;
}

.cpf-drawer-dropdown.select2-dropdown--above {
  margin-bottom: 2px !important;
}

#cpf-expanded-filters .select2-container {
  z-index: 10 !important;
}

#cpf-expanded-filters .select2-container--open {
  z-index: 10001 !important;
  top: 0 !important;
}

#cpf-expanded-filters.active {
  right: 0;
}

#cpf-expanded-filters .widget {
  margin-bottom: 30px;
  position: relative; /* Position context for Select2 dropdown */
}

#cpf-expanded-filters .widget:last-child {
  margin-bottom: 30px;
  padding-bottom: 30px;
  border-bottom: 1px solid var(--brdcolor-gray-300);
}

/* Ensure widget containers are positioned for Select2 dropdowns */
#cpf-expanded-filters .woocommerce-widget-layered-nav,
#cpf-expanded-filters .sidebar-widget {
  position: relative;
}

/* Style Select2 dropdowns within widgets */
#cpf-expanded-filters .widget .select2-dropdown {
  position: absolute !important;
  top: 100% !important;
  left: 0 !important;
}

.cpf-drawer-main-filters {
  display: flex;
  flex-direction: column;
  gap: 20px;
  /* margin-bottom: 30px; */
  /* padding-bottom: 30px; */
  /* border-bottom: 1px solid var(--brdcolor-gray-300); */
  h5 {
    margin-bottom: 0;
  }
  .widget-title {
    margin-bottom: 30px;
  }
  /* Hide width/height/diameter filters on desktop (they're in main filter bar) */
  .cpf-form-field {
    @media (min-width: 861px) {
      display: none;
    }
  }
  .cpf-form-field.last {
    margin-bottom: 30px;
    padding-bottom: 30px;
    border-bottom: 1px solid var(--brdcolor-gray-300);
  }
}

/* Backdrop overlay for drawer */
#cpf-drawer-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 9998;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease-in-out, visibility 0.3s ease-in-out;
}

#cpf-drawer-backdrop.active {
  opacity: 1;
  visibility: visible;
}

/* Responsive design */
@media (max-width: 860px) {
  .cpf-shop-filter .cpf-shop-row .filter .cpf-form-field {
    display: none;
  }
  .cpf-orderby-wrapper {
    display: block !important;
  }

  #cpf-clear-filters .wd-entities-title {
    display: none;
  }

  #cpf-clear-filters::after {
    content: "Filtruoti";
  }
}

@media (max-width: 768px) {
  .cpf-form-row {
    grid-template-columns: 1fr 1fr;
  }

  .cpf-form-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .cpf-submit-btn {
    width: 100%;
  }
}

@media (max-width: 480px) {
  .cpf-product-filter {
    padding: 15px;
  }

  .cpf-submit-btn {
    padding: 10px 20px;
    font-size: 14px;
  }
}

@media (max-width: 420px) {
  .cpf-filter-display {
    font-size: 13px;
  }
  .cpf-spec-display {
    font-size: 16px;
  }
}
