/* =========================
   Formulare & filtre – Clean Listings (vechi / generic)
   ========================== */

.filters{
  margin:5px 0 16px 0;
}

.filters-toolbar{
  display:flex;
  align-items:center;
  gap:8px;
}

/* zona scrollabilă cu inputurile (folosită în alte forme) */
.filters-scroll{
  flex:1 1 auto;
  display:flex;
  gap:8px;
  overflow-x:auto;
  overflow-y:hidden;
  padding-bottom:4px;
  scroll-behavior:smooth;
}

/* scrollbar subțire pe desktop */
.filters-scroll::-webkit-scrollbar{ height:6px; }
.filters-scroll::-webkit-scrollbar-track{ background:transparent; }
.filters-scroll::-webkit-scrollbar-thumb{
  background:rgba(148,163,184,.7);
  border-radius:999px;
}

/* săgeți stânga/dreapta */
.filters-arrow{
  flex:0 0 auto;
  align-self:center;
  width:32px;
  height:32px;
  border-radius:999px;
  border:1px solid var(--border);
  background:#fff;
  cursor:pointer;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  font-size:16px;
  padding:0;
  transition:background .15s ease, border-color .15s ease, opacity .15s ease;
}

.filters-arrow:hover:not(.is-disabled){
  background:#f3f4f6;
  border-color:#cbd5e1;
}

.filters-arrow.is-disabled{
  opacity:.35;
  cursor:default;
}

/* butonul Search */
.filters-submit{
  flex:0 0 auto;
  white-space:nowrap;
}

/* inputuri/select pentru filtre */
.filters input,
.filters select{
  padding:8px 10px;
  border:1px solid var(--border);
  border-radius:10px;
  background:#fff;
  font:inherit;
  min-width:30px;
}

/* ============================
   Chips (summary) + Save search
   - Save search apare DOAR când există filtre active (chips)
   - JS trebuie să pună .has-filters pe .filters-summary când chips.length > 0
   ============================ */

/* ascuns implicit (când nu există filtre) */
.filters-summary{
  margin-top: 8px;
  display: none;
  align-items: center;
  gap: 8px;
}

/* devine vizibil doar când există filtre active */
.filters-summary.has-filters{
  display: flex;
}

html[lang="he"] .filters-summary.has-filters{
  flex-direction:row-reverse;
}

/* host pentru chips (JS rescrie doar aici) */
.filters-summary-chips{
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
}

html[lang="he"] .filters-summary-chips{
  flex-direction:row-reverse;
  justify-content: flex-start;
}

/* butonul rămâne la capăt */
.filter-btn--save{
  white-space: nowrap;
}

/* ========= Chips ========= */

.filter-chip{
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;

  /* muted look */
  background: rgba(148,163,184,.14);     /* slate-ish */
  border: 1px solid rgba(148,163,184,.28);
  color: rgba(15,23,42,.72);

  font-size: .85rem;
  max-width: 100%;
}

.filter-chip .chip-label{
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  max-width: 360px;
}

.filter-chip .chip-x{
  border: 0;
  background: transparent;
  cursor: pointer;
  padding: 0;
  line-height: 1;

  /* muted X */
  color: rgba(15,23,42,.55);
  font-size: 14px;
  opacity: .9;
}

.filter-chip .chip-x:hover{
  color: rgba(15,23,42,.85);
  opacity: 1;
}

/* chips hover */
.filter-chip:hover{
  background: rgba(148,163,184,.18);
  border-color: rgba(148,163,184,.38);
}


/* =========================
   Mobile (generic filters)
   ========================== */

@media (max-width:767.98px){
  .filters-toolbar{
    flex-wrap:wrap;
  }

  .filters{
    margin:15px 0 16px 0;
  }

  .filters-submit{
    width:100%;
    justify-content:center;
    margin-top:5px !important;
  }

  /* pe mobil ascundem săgețile, filtrarea se face cu swipe */
  .filters-arrow{
    display:none;
  }
}

/* =====================================================
   MEGA FILTERS (noua versiune cu For/Type/City/More)
   Scope: .filters-mega
   ===================================================== */

.filters-mega{
  background:#f9fafb;
  border-radius:14px;
  border:1px solid var(--border);
  padding:8px 12px 10px;
}

/* ✅ NO WRAP + ratio primary:actions = 1 : 0.5 */
.filters-mega .filters-toolbar{
  display:flex;
  justify-content:space-between;
  align-items:center;
  flex-wrap:nowrap;
  gap:8px;
}

html[lang="he"] .filters-mega .filters-toolbar{
  flex-direction: row-reverse;
}

/* grupuri de butoane */
.filters-group{
  display:flex;
  flex-wrap:nowrap;
  gap:8px;
  min-width:0;
}

/* ✅ primary = 1 */
.filters-group--primary{
  flex:1 1 auto;
  display:flex;
  align-items:center;
  gap:8px;
  min-width:0;
}

html[lang="he"] .filters-group--primary{
  flex-direction: row-reverse;
}

/* ✅ actions = 0.5 */
.filters-group--actions{
  flex:1 1 0;
  display:flex;
  align-items:center;
  gap:8px;
  min-width:0;
}

html[lang="he"] .filters-group--actions{
  flex-direction: row-reverse;
}

/* ✅ butonul reset rămâne fix */
.filters-group--primary .filter-btn--clearall{
  flex:0 0 auto;
}

/* ✅ FOR / TYPE / CITY umplu spațiul rămas în primary */
.filters-group--primary .filter-btn[data-filter-open]{
  flex:1 1 0;
  width:0;
  justify-content:space-between;
  display:inline-flex;
  align-items:center;

  min-width:0;
  overflow:hidden;
  white-space:nowrap;
  text-overflow:ellipsis;
}

/* ✅ în actions: butoanele acoperă tot div-ul (egale) */
.filters-group--actions .filter-btn{
  flex:1 1 0;
  width:0;
  justify-content:center;
  min-width:0;
  overflow:hidden;
  white-space:nowrap;
  text-overflow:ellipsis;
}

/* varianta roșie (Make request) */
.filter-btn.is-primary{
  background:var(--primary);
  border-color:var(--primary);
  color:#fff;
}

.filter-btn.is-primary:hover{
  background:var(--primary-strong);
  border-color:var(--primary-strong);
}

/* Sort select styled like filter button */
.filter-sort {
  display: inline-flex;
  align-items: center;
}

.filter-sort select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;

  /* match .filter-btn look */
  height: 40px;               /* ajustează dacă ai altă înălțime la butoane */
  padding: 0 38px 0 12px;
  border-radius: 12px;        /* ajustează după designul tău */
  border: 1px solid rgba(0,0,0,0.15);
  background: #fff;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

/* small caret */
.filter-sort {
  position: relative;
}
.filter-sort::after {
  content: "▾";
  position: absolute;
  right: 12px;
  pointer-events: none;
  opacity: 0.8;
}

/* container pentru panouri */
.filters-mega .filters-panels{
  margin-top:6px;
}

/* =========================
   FIX: panel height + vertical scroll
   ========================== */

/* Desktop: înălțime fixă + scroll vertical */
.filter-panel{
  display:none;
  margin-top:6px;
  padding:12px 14px 14px;
  border-radius:14px;
  border:1px solid var(--border);
  background:#fff;
  box-shadow:0 18px 50px rgba(15,23,42,.16);

  height:320px;            /* ✅ fix (poți schimba) */
  overflow-y:auto;         /* ✅ scroll vertical */
  overscroll-behavior:contain;
}

/* panel vizibil */
.filter-panel.is-open{
  display:block;
}

/* scrollbar mai fin (opțional) */
.filter-panel::-webkit-scrollbar{ width:10px; }
.filter-panel::-webkit-scrollbar-track{ background:transparent; }
.filter-panel::-webkit-scrollbar-thumb{
  background:rgba(148,163,184,.55);
  border-radius:999px;
}

/* header-ul panelului */
.filter-panel .panel-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  margin-bottom:10px;
  position:sticky;         /* ✅ header sticky când dai scroll */
  top:0;
  background:#fff;
  padding-top:2px;
  padding-bottom:8px;
  z-index:2;
}

html[lang="he"] .filter-panel .panel-head{
  flex-direction:row-reverse;
}

.filter-panel .panel-title{
  font-weight:600;
  font-size:0.95rem;
}

.filter-panel .panel-actions{
  display:flex;
  flex-wrap:wrap;
  gap:6px;
}

/* micșorăm butoanele Clear / Apply */
.filter-panel .panel-actions .btn{
  padding:6px 10px;
  border-radius:999px;
  font-size:0.8rem;
}

/* grid intern */
.panel-grid{
  display:grid;
  gap:10px;
  margin-bottom:6px;
}

.panel-grid.cols-2{
  grid-template-columns:repeat(2, minmax(0,1fr));
}

.panel-grid.cols-3{
  grid-template-columns:repeat(3, minmax(0,1fr));
}

/* opțiuni Sell/Rent și type/city pills */
.filter-panel .opt{
  display:flex;
  align-items:center;
  gap:6px;
  padding:6px 10px;
  border-radius:999px;
  border:1px solid var(--border);
  background:#f9fafb;
  font-size:0.9rem;
  cursor:pointer;
  user-select:none;
}

.filter-panel .opt input{
  margin:0;
}

.filter-panel .opt:hover{
  background:#eff6ff;
  border-color:#bfdbfe;
}

/* Hint sub-panou */
.hint-mini{
  font-size:0.78rem;
  color:#6b7280;
}

/* câmpuri (More: price, rooms, area, sort) */
.filter-panel .field{
  display:flex;
  flex-direction:column;
  gap:4px;
}

.filter-panel .field label{
  font-size:0.8rem;
  font-weight:500;
}

.filter-panel .field input,
.filter-panel .field select{
  width:100%;
  padding:7px 10px;
  border-radius:10px;
  border:1px solid var(--border);
  font:inherit;
}

/* reset icon */
.filter-btn--clearall .icon--reset{
  width:18px;
  height:18px;
  display:block;
  pointer-events:none;
}

/* =========================
   Mega filters – MOBILE
   ========================== */

@media (max-width:767.98px){
  .filters-mega{
    padding:8px 8px 10px;
    border-radius:12px;
  }

  .filters-mega .filters-toolbar{
    flex-direction:column;
    align-items:stretch;
    flex-wrap:nowrap;
  }

  .filters-group{
    width:100%;
    justify-content:flex-start;
  }

  .filters-group--actions{
    width:100%;
    justify-content:space-between;
  }

  .filters-group--actions .filter-btn{
    justify-content:center;
  }

  .panel-grid.cols-2,
  .panel-grid.cols-3{
    grid-template-columns:1fr;
  }

  /* ✅ Mobile: panelul nu depășește marginea de jos a ecranului */
  .filter-panel{
    height:auto;                      /* nu fix pe mobil */
    max-height:calc(100dvh - 220px);  /* ✅ nu trece de bottom; ajustează 220px dacă ai alt header */
    overflow-y:auto;
    -webkit-overflow-scrolling:touch;
  }

  .filter-panel{
    padding:12px 10px 12px;
  }
}
