/* ============================================================
   Biodata Listing — Filter flyout panel + pill-style BEF links
   ============================================================ */

/* ── 1. Filter bar (trigger row) ────────────────────────────── */
.biodata-filter-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px 0 16px;
}

/* ── 1b. Search wrap (inline in the main filter bar) ─────────── */
.biodata-search-wrap {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  max-width: 320px;
  min-width: 160px;
}

.biodata-search-input {
  flex: 1;
  width: 100%;
  min-width: 0;
  padding: 8px 12px;
  border: 1.5px solid #d0cec8;
  border-radius: 9999px;
  background: #fff;
  color: #1a1a2e;
  font-size: 0.875rem;
  box-sizing: border-box;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.07);
}

.biodata-search-input:focus {
  border-color: #1a1a2e;
  box-shadow: 0 0 0 2px rgba(26,26,46,0.1);
}

/* Chrome clears button */
.biodata-search-input::-webkit-search-cancel-button {
  cursor: pointer;
}

.biodata-search-submit {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: #1a1a2e;
  color: #fff;
  cursor: pointer;
  transition: background 0.15s;
}

.biodata-search-submit:hover {
  background: #2e2e48;
}

.biodata-search-submit svg {
  width: 16px;
  height: 16px;
}

.biodata-filter-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 18px 8px 14px;
  border: 1.5px solid #d0cec8;
  border-radius: 9999px;
  background: #fff;
  color: #1a1a2e;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.07);
}

.biodata-filter-trigger:hover {
  background: #f5f4f0;
  border-color: #9e9b94;
}

.biodata-filter-trigger[aria-expanded="true"] {
  background: #1a1a2e;
  border-color: #1a1a2e;
  color: #fff;
  box-shadow: 0 2px 8px rgba(26,26,46,0.18);
}

.biodata-filter-trigger__icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.biodata-filter-trigger__count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 9999px;
  background: #f04e37;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
}

.biodata-filter-trigger[aria-expanded="true"] .biodata-filter-trigger__count {
  background: rgba(255,255,255,0.25);
}

/* ── 2. Backdrop overlay ────────────────────────────────────── */
.biodata-filter-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.38);
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.biodata-filter-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

/* ── 3. Flyout panel (slides in from the right) ─────────────── */
.biodata-filter-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 680px;
  max-width: 92vw;
  background: #fff;
  box-shadow: -4px 0 24px rgba(0,0,0,0.15);
  z-index: 1001;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

.biodata-filter-panel.is-open {
  transform: translateX(0);
}

/* ── 3b. Drag handle (visible only on the mobile bottom sheet) ── */
.biodata-filter-panel__drag-handle {
  display: none;
  flex-shrink: 0;
}

/* ── 4. Panel header ────────────────────────────────────────── */
.biodata-filter-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 16px;
  border-bottom: 1px solid #eeece8;
  flex-shrink: 0;
}

.biodata-filter-panel__title {
  font-size: 1rem;
  font-weight: 700;
  color: #1a1a2e;
  letter-spacing: 0.01em;
}

.biodata-filter-panel__close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: #555;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.biodata-filter-panel__close:hover {
  background: #f0ede8;
  color: #1a1a2e;
}

.biodata-filter-panel__close svg {
  width: 16px;
  height: 16px;
}

/* ── 5. Panel body (scrollable filter content) ──────────────── */
.biodata-filter-panel__body {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0 24px;
  overscroll-behavior: contain;
}

/* BEF wraps everything in .bef-exposed-form */
.biodata-filter-panel__body .bef-exposed-form,
.biodata-filter-panel__body .views-exposed-form {
  padding: 0;
  margin: 0;
  display: flex !important;
  flex-direction: column;
}

/* ── 6a. Fulltext search input (hidden — search is in the filter bar) */
.biodata-filter-panel__body .form-item-search-api-fulltext {
  display: none;
}


/* ── 6. Per-filter group ────────────────────────────────────── */
.biodata-filter-panel__body .js-form-item,
.biodata-filter-panel__body .form-item {
  padding: 16px 20px 12px;
  border-bottom: 1px solid #f0ede8;
  margin: 0;
}

.biodata-filter-panel__body .js-form-item:last-of-type,
.biodata-filter-panel__body .form-item:last-of-type {
  border-bottom: none;
}

/* Filter group label */
.biodata-filter-panel__body .js-form-item label,
.biodata-filter-panel__body .form-item label,
.biodata-filter-panel__body .form-item__label {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #888;
  margin-bottom: 10px;
}

/* ── 7. BEF links list reset ────────────────────────────────── */
.biodata-filter-panel__body .bef-links ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex !important;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 7px;
}

.biodata-filter-panel__body .bef-links ul li {
  margin: 0;
  padding: 0;
}

/* ── 8. Pill links (inactive) ───────────────────────────────── */
.biodata-filter-panel__body .bef-link {
  display: inline-block;
  padding: 5px 14px;
  border-radius: 9999px;
  border: 1.5px solid #d5d3cd;
  background: #faf9f7;
  color: #333;
  font-size: 0.8rem;
  font-weight: 500;
  text-decoration: none;
  line-height: 1.4;
  transition: background 0.13s, border-color 0.13s, color 0.13s;
  white-space: nowrap;
}

.biodata-filter-panel__body .bef-link:hover {
  background: #eee9e2;
  border-color: #b5b1a9;
  color: #1a1a2e;
}

/* ── 9. Pill links (selected / active) ─────────────────────── */
.biodata-filter-panel__body .bef-link--selected {
  background: #1a1a2e;
  border-color: #1a1a2e;
  color: #fff;
  font-weight: 600;
}

.biodata-filter-panel__body .bef-link--selected:hover {
  background: #2e2e48;
  border-color: #2e2e48;
  color: #fff;
}

/* ── 10. BEF action buttons (Apply / Clear All) ─────────────── */
.biodata-filter-panel__body .views-exposed-form .form-actions {
  display: flex;
  gap: 10px;
  padding: 16px 20px 8px;
  border-top: 1px solid #f0ede8;
  flex-wrap: wrap;
}

/* Every exposed filter self-applies on click (bef-link navigation) or via
   the debounced/Enter-key search handlers — the Apply submit does nothing. */
.biodata-filter-panel__body .form-actions .button--primary,
.biodata-filter-panel__body .form-actions [data-drupal-selector="edit-submit-biodata-listing"] {
  display: none;
}

.biodata-filter-panel__body .form-actions .button--secondary,
.biodata-filter-panel__body .form-actions [data-drupal-selector="edit-reset"] {
  flex: 1;
  padding: 9px 16px;
  border-radius: 9999px;
  background: transparent;
  color: #555;
  border: 1.5px solid #d0cec8;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.biodata-filter-panel__body .form-actions .button--secondary:hover,
.biodata-filter-panel__body .form-actions [data-drupal-selector="edit-reset"]:hover {
  background: #f5f4f0;
  border-color: #9e9b94;
}

/* ── 11. Active-filter summary badges in the filter bar ─────── */
.biodata-active-filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.biodata-active-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px 4px 12px;
  border-radius: 9999px;
  background: #1a1a2e;
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
  text-decoration: none;
}

.biodata-active-chip__remove {
  display: inline-flex;
  width: 14px;
  height: 14px;
  align-items: center;
  justify-content: center;
  opacity: 0.75;
}

.biodata-clear-all-link {
  color: #555;
  font-size: 0.8rem;
  font-weight: 600;
  text-decoration: underline;
  margin-left: 4px;
  transition: color 0.15s;
}

.biodata-clear-all-link:hover {
  color: #1a1a2e;
}

/* ── 12. Mobile adjustments ─────────────────────────────────────────
   Below 640px the filter bar becomes an always-visible bottom bar
   (Search + Filters buttons) and the flyout panel becomes a bottom
   sheet instead of a right-hand drawer. ─────────────────────────── */
@media (max-width: 640px) {
  /* Reserve room so the fixed bar never covers the last row of cards. */
  .biodata-listing-view-wrapper {
    padding-bottom: 72px;
  }

  .biodata-filter-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 998;
    margin: 0;
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
    background: #fff;
    border-top: 1px solid #eeece8;
    box-shadow: 0 -2px 14px rgba(0,0,0,0.1);
  }

  .biodata-filter-bar .biodata-search-wrap {
    max-width: none;
  }

  .biodata-filter-bar .biodata-filter-trigger {
    flex: 0 0 auto;
  }

  .biodata-active-filter-chips {
    padding: 0 2px 10px;
  }

  /* Panel becomes a bottom sheet. */
  .biodata-filter-panel {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: 100%;
    height: 85vh;
    max-height: 85vh;
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -4px 24px rgba(0,0,0,0.18);
    transform: translateY(100%);
  }

  .biodata-filter-panel.is-open {
    transform: translateY(0);
  }

  .biodata-filter-panel__drag-handle {
    display: block;
    width: 36px;
    height: 4px;
    border-radius: 9999px;
    background: #d5d3cd;
    margin: 10px auto 0;
  }

  .biodata-filter-panel__body {
    padding-bottom: max(24px, env(safe-area-inset-bottom));
  }
}
