/**
 * HICB Project Filter Styles
 * ====================================================
 * Filter bar styling with dropdown menus and checkboxes
 * Responsive design with mobile breakpoint at 782px
 */

/* ====================================================
 * 1. Main Filter Container
 * ==================================================== */
.hicb-projects-filter {
  display: -webkit-box;
  display: -webkit-flex;
  display: -moz-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-align: center;
  -webkit-align-items: center;
  -moz-box-align: center;
  -ms-flex-align: center;
  align-items: center;
  gap: 16px;
  -webkit-flex-wrap: wrap;
  -ms-flex-wrap: wrap;
  flex-wrap: wrap;
  margin-bottom: 24px;
  position: relative;
  z-index: 50;
  -webkit-box-pack: end;
  -webkit-justify-content: flex-end;
  -moz-box-pack: end;
  -ms-flex-pack: end;
  justify-content: flex-end;
}

.hicb-filter-clear.is-active-filters:hover {
  background-color: transparent;
}

/* ====================================================
 * 2. Filter Groups Layout
 * ==================================================== */
.hicb-filter-groups {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.hicb-filter-dropdown {
  position: relative;
  flex: 1;
  min-width: 160px;
}

/* ====================================================
 * 3. Filter Trigger Button
 * ==================================================== */
.hicb-filter-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: transparent;
  border: 1px solid #c1c8ce;
  padding: 12px 16px;
  cursor: pointer;
  font-size: 16px;
  color: #000;
  font-weight: 500;
  transition: border-color 0.2s ease;
}

.hicb-filter-trigger:hover {
  border-color: #999;
}

.hicb-filter-trigger span {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Active state when filter is selected */
/* .hicb-filter-dropdown.has-active .hicb-filter-trigger {
  border-color: #da101d;
} */

/* ====================================================
 * 4. Chevron Icon Rotate
 * ==================================================== */
.hicb-filter-chevron {
  width: 10px;
  height: 10px;
  border-right: 2px solid #111;
  border-bottom: 2px solid #111;
  transform: rotate(45deg);
  transition: transform 0.2s ease;
  flex-shrink: 0;
  margin-left: 8px;
}

.hicb-filter-dropdown.is-open .hicb-filter-chevron {
  transform: rotate(-135deg);
}

/* ====================================================
 * 5. Filter Menu (Dropdown Content)
 * ==================================================== */
.hicb-filter-menu {
  display: none;
  position: absolute;
  left: 0;
  width: 100%;
  background: #f5f5f5;
  border-radius: 0;
  overflow: hidden;
  z-index: 100;
}

.hicb-filter-dropdown.is-open .hicb-filter-menu {
  display: block;
  border: 1px solid #c1c8ce;
  border-top-width: 1px;
}

/* ====================================================
 * 6. Filter Options (Checkboxes)
 * ==================================================== */
.hicb-filter-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  cursor: pointer;
  font-size: 16px;
  font-weight: 500;
  border-bottom: 1px solid #c1c8ce;
  transition: background-color 0.15s ease;
}

.hicb-filter-option:last-child {
  border-bottom: none;
}

.hicb-filter-option:hover {
  background: #ececec;
}

/* Hide native checkbox */
.hicb-filter-option input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

/* ====================================================
 * 7. Custom Checkbox Styling
 * ==================================================== */
.hicb-filter-checkbox {
  width: 18px;
  height: 18px;
  background: #e0e3e7;
  flex-shrink: 0;
  position: relative;
  border-radius: 2px;
  transition: background-color 0.2s ease;
}

.hicb-filter-option input[type="checkbox"]:checked + .hicb-filter-checkbox {
  background: #4a9f5f;
}

/* Checkmark (horizontal line) */
.hicb-filter-option
  input[type="checkbox"]:checked
  + .hicb-filter-checkbox::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 10px;
  height: 2px;
  background: #fff;
  transform: translate(-50%, -50%);
}

/* Checkmark (vertical line) */
.hicb-filter-option
  input[type="checkbox"]:checked
  + .hicb-filter-checkbox::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 2px;
  height: 10px;
  background: #fff;
  transform: translate(-50%, -50%);
}

/* ====================================================
 * 8. Clear Filter Button
 * ==================================================== */
.hicb-filter-clear,
.hicb-filter-clear-link {
  visibility: hidden;
  background: none;
  border: none;
  text-decoration: underline;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  color: #111;
  padding: 0;
  transition: color 0.2s ease;
}

.hicb-filter-clear:hover,
.hicb-filter-clear-link:hover {
  background: #4a9f5f;
}

/* Show only when filters are active */
.hicb-filter-clear.is-active-filters,
.hicb-filter-clear-link.is-active-filters {
  visibility: visible;
}

/* ====================================================
 * 9. Topbar (Mobile)
 * ==================================================== */
.hicb-projects-filter-topbar {
  display: none;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 12px;
}

.hicb-projects-filter-topbar-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.hicb-projects-filter-title {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #9a9a9a;
}

.hicb-filter-mobile-toggle {
  background: none;
  border: none;
  text-decoration: underline;
  font-weight: 500;
  font-size: 16px;
  cursor: pointer;
  color: #000;
  padding: 0;
}

/* ====================================================
 * 10. Loading State with Spinner
 * ==================================================== */
.listing.listing-projects.is-loading,
.wh-projects-list.is-loading {
  opacity: 0.6;
  pointer-events: none;
  transition: opacity 0.2s ease;
  position: relative;
  min-height: 200px;
}

/* Spinner animation */
@keyframes hicb-spinner-spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* Spinner element */
.listing.listing-projects.is-loading::after,
.wh-projects-list.is-loading::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 50px;
  height: 50px;
  margin: -25px 0 0 -25px;
  border: 4px solid #e0e0e0;
  border-top-color: #418b53;
  border-radius: 50%;
  animation: hicb-spinner-spin 0.8s linear infinite;
  z-index: 1000;
}

/* ====================================================
 * 11. Empty State
 * ==================================================== */
.hicb-projects-empty {
  width: 100%;
  text-align: center;
  padding: 48px 16px;
}

.hicb-projects-empty__title {
  font-size: 18px;
  font-weight: 600;
  color: #111;
  margin: 0 0 8px;
}

.hicb-projects-empty__desc {
  font-size: 14px;
  color: #767676;
  margin: 0;
}

/* ====================================================
 * 12. Responsive - Tablet & Mobile (max-width: 900px)
 * ==================================================== */
@media all and (max-width: 900px) {
  .hicb-filter-groups {
    flex-wrap: wrap;
  }

  .hicb-filter-dropdown {
    flex: 0 1 calc(50% - 8px);
  }
}

/* ====================================================
 * 13. Responsive - Mobile (max-width: 782px)
 * ==================================================== */
@media (max-width: 782px) {
  .hicb-projects-filter {
    flex-direction: column;
    align-items: stretch;
    gap: 0;
  }

  /* Show topbar on mobile */
  .hicb-projects-filter-topbar {
    display: flex;
  }

  /* Hide desktop clear button */
  .hicb-filter-clear {
    display: none;
  }

  /* Mobile clear button styling */
  .hicb-filter-clear-link {
    display: none;
    visibility: hidden;
  }

  .hicb-filter-clear-link.is-active-filters {
    display: block;
  }

  /* Hide filter groups until opened */
  .hicb-filter-groups {
    display: none;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    margin-top: 20px;
  }

  /* Show filter groups when mobile panel is open */
  .hicb-projects-filter.is-mobile-open .hicb-filter-groups {
    display: flex;
    position: relative;
    width: 50%;
    left: 50%;
  }

  .hicb-projects-filter-topbar > * {
    flex: 1;
  }

  body .hicb-projects-filter-topbar {
    justify-content: flex-start;
  }

  .panel-heading-filters {
    display: none;
  }

  /* Make dropdown full width on mobile */
  .hicb-filter-dropdown {
    width: 100%;
    min-width: unset;
    flex: none;
  }

  /* Dropdown menu positioning on mobile */
  .hicb-filter-menu {
    position: static;
    border-top: none;
    border-radius: 0 0 8px 8px;
    margin-top: -1px;
  }

  .hicb-filter-trigger {
    background: #fff;
    width: 100%;
  }
}

/* ====================================================
 * 14. Responsive - Small Mobile (max-width: 600px)
 * ==================================================== */
@media all and (max-width: 600px) {
  .hicb-filter-trigger span {
    font-size: 14px;
  }

  .hicb-filter-option {
    font-size: 14px;
    padding: 10px 12px;
  }
}

/* ====================================================
 * 15. Load More Button Styling
 * ==================================================== */
.wh-projects-loadmore-wrap {
  text-align: center;
  margin-top: 32px;
  padding: 16px 0;
}

.wh-projects-loadmore-btn {
  display: inline-block;
  padding: 12px 32px;
  font-size: 16px;
  font-weight: 500;
  color: #418b53;
  background-color: #f5f5f5;
  border: 2px solid #418b53;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.wh-projects-loadmore-btn:hover {
  background-color: #418b53;
  color: #f5f5f5;
}

.wh-projects-loadmore-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
