/**
 * Woaly Shop Filters Styles
 * Multi-select checkbox filters with accordion dropdowns
 */

/* ==== Filter Container Styles ==== */
.woaly-filters {
  width: 100%;
  margin: 0px !important;
}

.woaly-shop-products .shop-filters {
  position: relative;
}

.woaly-filters-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.woaly-filter-group {
  position: relative;
  border-radius: 12px;
  background: #ffffff;
  border: 1px solid #EEEDEC;
  width: 100%;
}

.woaly-filter-group label {
  display: flex;
  font-family: Rethink Sans;
  font-weight: 400;
  font-size: 14px;
  margin: 0px;
  color: var(--primary-color);
}

.woaly-filter-group select,
.woaly-filter-group input[type="checkbox"] {
  width: 100%;
  padding: 10px;
  border-radius: 12px;
  border: 1px solid #ddd;
  background: #fff;
  font-size: 14px;
}

.woaly-filter-group.is-open {
  box-shadow: none;
}

.woaly-filter-toggle:hover {
  color: #6D6D6D;
  background: none !important;
  border: none;
}

.woaly-filter-toggle:focus {
  outline: none !important;
}

.woaly-filter-toggle {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-family: var(--font-text);
  font-size: 14px;
  font-weight: 500;
  color: #6D6D6D;
  text-align: left;
  transition: background-color 0.2s ease;
}

.woaly-filter-label {
  flex: 1;
}

.woaly-filter-arrow {
  transition: transform 0.3s ease;
  color: #6b7280;
}

.woaly-filter-group.is-open .woaly-filter-arrow {
  transform: rotate(180deg);
}

.woaly-filter-dropdown {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.woaly-filter-group.is-open .woaly-filter-dropdown {
  max-height: 250px;
  overflow-y: auto;
}

.woaly-filter-options {
  padding: 8px;
  border-top: 1px solid #e5e7eb;
}

/* Custom Checkboxes */
.woaly-checkbox-label {
  display: flex;
  align-items: center;
  padding: 10px 12px;
  cursor: pointer;
  border-radius: 8px;
  transition: background-color 0.15s ease;
  user-select: none;
}

.woaly-checkbox-label:hover {
  background-color: #f3f4f6;
}

.woaly-checkbox-label input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.woaly-checkbox-custom {
  display: flex;
  position: relative;
  width: 18px;
  height: 18px;
  border: 2px solid #d1d5db;
  border-radius: 4px;
  margin-right: 12px;
  flex-shrink: 0;
  transition: all 0.2s ease;
  background-color: #ffffff;
}

.woaly-checkbox-label input[type="checkbox"]:checked + .woaly-checkbox-custom {
  background-color: var(--primary-color);
  border-color: var(--primary-color);
}

.woaly-checkbox-label input[type="checkbox"]:checked + .woaly-checkbox-custom::after {
  content: '';
  position: absolute;
  left: 4px;
  top: 1px;
  width: 4px;
  height: 8px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.woaly-checkbox-text {
  font-size: 14px;
  color: #242638;
  line-height: 1.4;
}

.woaly-checkbox-label input[type="checkbox"]:checked ~ .woaly-checkbox-text {
  font-weight: 500;
  color: var(--primary-color);
}

/* Action Buttons */
.woaly-filter-actions {
  display: flex;
  flex-direction: row-reverse;
  gap: 8px;
}

.woaly-apply-filters {
  font-weight: 500;
  font-size: 16px;
  padding: 20px;
  border: none;
  border-radius: 100px;
  font-family: var(--font-text);
  cursor: pointer;
  transition: all 0.2s ease;
  width:100%;
  background-color: var(--primary-color);
  color: #ffffff;
  line-height: 11px;
}

.woaly-clear-filters {
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: transparent;
  color: #3A4151;
}

.woaly-clear-filters svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.woaly-clear-filters:hover {
  background-color: transparent;
  color: inherit;
}

.woaly-apply-filters:hover {
  background-color: #1a1d2e;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(36, 38, 56, 0.15);
}

/* Scrollbar for dropdown */
.woaly-filter-dropdown::-webkit-scrollbar {
  width: 6px;
}

.woaly-filter-dropdown::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 10px;
}

.woaly-filter-dropdown::-webkit-scrollbar-thumb {
  background: #cbd5e0;
  border-radius: 10px;
}

.woaly-filter-dropdown::-webkit-scrollbar-thumb:hover {
  background: #a0aec0;
}

/* ==== Mobile Filter Button ==== */
.woaly-mobile-filter-btn {
  display: flex; /* Hidden by default, shown on mobile */
  align-items: center;
  gap: 8px;
  padding: 4px;
  background-color: #fff;
  font-family: var(--font-text);
  font-size: 14px;
  font-weight: 500;
  color: #242638;
  cursor: pointer;
  transition: all 0.2s ease;
}

.woaly-mobile-filter-btn:hover {
  background-color: #f9f9f9;
  border-color: #d1d5db;
}

.woaly-mobile-filter-btn svg {
  flex-shrink: 0;
}

.woaly-mobile-actions {
  display: flex;
  align-items: center;
  padding: 16px;
  gap: 12px;
  width: 100%;
  justify-content: space-between;
  border-bottom: 1px solid #EEEDEC;
}

/* ==== Modal Header ==== */
.woaly-modal-header {
  display: none; /* Hidden by default, shown on mobile */
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid #EEEDEC;
  background: #ffffff;
  position: sticky;
  top: 0;
  z-index: 10;
}

.woaly-modal-header h3 {
  margin: 0;
  font-family: var(--font-text);
  font-size: 18px;
  font-weight: 600;
  color: #242638;
}

.woaly-modal-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background-color 0.2s ease;
  color: #6D6D6D;
}

.woaly-modal-close:hover {
  background-color: #f3f4f6;
}

/* ==== Mobile Ordering Dropdown ==== */
@media (max-width: 768px) {
  .woaly-results-mobile {
    display: flex;
    gap: 2px;
  }

  .woaly-dropdown-ordering svg {
    width: 24px;
    height: 24px;
  }

  h2.woocommerce-products-header__title.page-title {
    display: flex;
    flex-direction: column;
    align-items: center;
    color: #242638;
    font-family: Rethink Sans;
    font-weight: 600;
    font-size: 18px;
    margin: 0px;
  }

  /* Hide the select text in mobile, keep only icon visible */
  .woaly-dropdown-ordering .woocommerce-ordering select.orderby {
    position: absolute;
    opacity: 0;
    pointer-events: none;
    width: 0;
    height: 0;
  }

  /* Show custom dropdown that opens on icon click */
  .woaly-dropdown-ordering {
    width: auto;
    position: relative;
    cursor: pointer;
  }

  /* Custom dropdown list */
  .woaly-ordering-options {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 220px;
    background: #ffffff;
    border: 1px solid #EEEDEC;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    overflow: hidden;
  }

  .woaly-dropdown-ordering.is-open .woaly-ordering-options {
    display: block;
  }

  /* Option items in dropdown */
  .woaly-ordering-option {
    display: flex;
    align-items: center;
    padding: 14px 16px;
    cursor: pointer;
    font-family: var(--font-text);
    font-size: 14px;
    color: #242638;
    border-bottom: 1px solid #EEEDEC;
    transition: background-color 0.15s ease;
    position: relative;
    padding-left: 40px;
  }

  .woaly-ordering-option:last-child {
    border-bottom: none;
  }

  .woaly-ordering-option:hover {
    background-color: #f9f9f9;
  }

  /* Check icon for selected option */
  .woaly-ordering-option.is-selected::before {
    content: '';
    position: absolute;
    left: 16px;
    width: 16px;
    height: 16px;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 16 16' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M13.3337 4L6.00033 11.3333L2.66699 8' stroke='%23242638' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
  }

  .woaly-ordering-option.is-selected {
    font-weight: 500;
    color: var(--primary-color);
  }
}

.woaly-ordering-options {
  display: none;
}

/* ==== Responsive Styles ==== */
@media (max-width: 768px) {
  .woaly-filter-options {
    padding: 0px;
    border-top: 0px;
  }

  .woaly-filter-group {
    border: 0px;
    border-bottom: 1px solid #EEEDEC;
    border-radius: 0px;
  }

  .woaly-filters-container {
    height: 100%;
    gap: 0px;
    margin: 0px;
  }

  /* Show mobile filter button */
  /* Transform sidebar into fullscreen modal */
  .woaly-shop-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background-color: #ffffff;
    z-index: 9999;
    overflow-y: auto;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    padding: 0;
    border: none !important;
    border-radius: 0px;
  }

  .woaly-shop-sidebar.is-open {
    transform: translateX(0);
  }

  /* Show modal header in mobile */
  .woaly-modal-header {
    display: flex;
    padding: 27.5px 16px;
  }

  /* Adjust filters container padding for modal */
  .woaly-filters {
    height: 100%;
    padding: 0px;
  }

  .woaly-filter-toggle {
    padding: 26px 16px;
    font-size: 16px;
  }

  .woaly-checkbox-label {
    padding: 16px;
  }

  .woaly-filter-label {
    line-height: 11px;
    color: #242638;
  }

  .woaly-checkbox-custom {
    border: 1.33px solid #242638;
  }

  .woaly-filter-group.is-open .woaly-filter-dropdown {
    max-height: 260px;
  }

  .woaly-checkbox-text {
    font-size: 16px;
  }

  .woaly-filter-actions {
    flex-direction: row-reverse;
    position: sticky;
    bottom: 0;
    background: #fff;
    padding: 16px;
    margin-top: auto;
    border-top: 1px solid #EEEDEC;
  }

  .woaly-clear-filters,
  .woaly-apply-filters {
    width: auto;
  }

  /* Add backdrop overlay effect */
  .woaly-shop-sidebar::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: transparent;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    z-index: -1;
  }

  .woaly-shop-sidebar.is-open::before {
    opacity: 1;
    pointer-events: auto;
  }
}
