/* static/css/gp-filters.css
 * Filter system: search bar, chips, modals
 * Brand green: #3F622A / Dark: #334F22
 */

/* ========================================
   SEARCH BAR (restored from old inline)
   ======================================== */

.gp-search-bar-wrapper {
  background: #fff;
  padding: 15px 0 0;
}
.gp-search-bar-wrapper .gp-search__form {
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
  border: 1px solid #e0e0e0;
}


/* ========================================
   FILTER CHIPS BAR (sticky)
   ======================================== */

/* Alto real de la barra: 12px + 12px de padding + 40px del chip + 2px del
   raíl de scroll + borde. Se expone como token porque el mapa sticky de la
   landing necesita descontarlo para no quedar tapado. */
:root { --gp-filterbar-h: 67px; }

.gp-filter-bar {
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  position: sticky;
  top: 0;
  z-index: 999;
  padding: 12px 0;
  /* al pegarse arriba, el contenido pasa por debajo: la sombra lo separa */
  box-shadow: 0 4px 10px -8px rgba(15,30,26,.4);
}

.gp-filter-chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  align-items: center;
  padding-bottom: 2px;
}
.gp-filter-chips::-webkit-scrollbar { display: none; }

/* Circular "all filters" button */
.gp-chip-all {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  min-width: 40px;
  border-radius: 50%;
  background: #3F622A;
  color: #fff;
  border: none;
  cursor: pointer;
  position: relative;
  transition: background 0.15s ease;
  flex-shrink: 0;
}
.gp-chip-all:hover { background: #334F22; }
.gp-chip-all svg { width: 18px; height: 18px; }

/* Badge on all-filters button */
.gp-chip-all__badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #dc2626;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.gp-chip-all__badge:empty { display: none; }

/* Pill chips (toggle + dropdown) */
.gp-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid #e5e7eb;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 500;
  color: #1a1a1a;
  background: #fff;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.15s ease;
  line-height: 1.4;
  text-decoration: none;
  user-select: none;
  flex-shrink: 0;
}
.gp-chip:hover {
  background: #f9fafb;
  border-color: #d1d5db;
  text-decoration: none;
  color: #1a1a1a;
}
.gp-chip--active {
  border: 2px solid #3F622A;
  background: #ecf5e7;
  color: #3F622A;
  padding: 7px 15px; /* compensate 2px border */
}
.gp-chip--active:hover {
  background: #dcebd4;
  color: #3F622A;
}

.gp-chip__icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}
.gp-chip__chevron {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
  transition: transform 0.15s ease;
}

/* Clear all chip */
.gp-chip--clear {
  border-color: #dc2626;
  color: #dc2626;
}
.gp-chip--clear:hover {
  background: #dc2626;
  color: #fff;
}


/* ========================================
   FILTER MODALS — Redesigned
   ======================================== */

/* Overlay */
.gp-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 99999999;
  display: none;
  align-items: flex-end;
  justify-content: center;
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}
.gp-modal-overlay--open {
  display: flex;
}
@media (min-width: 768px) {
  .gp-modal-overlay { align-items: center; }
}

/* Modal card */
.gp-modal {
  background: #fff;
  width: 100%;
  max-height: 90vh;
  border-radius: 20px 20px 0 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 -4px 40px rgba(0, 0, 0, 0.15);
  animation: gpSlideUp 0.3s cubic-bezier(0.32, 0.72, 0, 1);
}
@media (min-width: 768px) {
  .gp-modal {
    max-width: 520px;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    animation: gpScaleIn 0.25s cubic-bezier(0.32, 0.72, 0, 1);
  }
}

/* Full modal (wider) */
.gp-modal--full { max-width: 100%; }
@media (min-width: 768px) {
  .gp-modal--full { max-width: 640px; }
}

@keyframes gpSlideUp {
  from { transform: translateY(100%); opacity: 0.5; }
  to { transform: translateY(0); opacity: 1; }
}
@keyframes gpScaleIn {
  from { transform: scale(0.92) translateY(20px); opacity: 0; }
  to { transform: scale(1) translateY(0); opacity: 1; }
}

/* --- Modal header --- */
.gp-modal__header {
  display: flex;
  align-items: center;
  padding: 20px 24px 16px;
  border-bottom: 1px solid #f0f0f0;
  flex-shrink: 0;
}
.gp-modal__close {
  background: #f5f5f5;
  border: none;
  cursor: pointer;
  padding: 6px;
  color: #666;
  display: flex;
  border-radius: 50%;
  transition: all 0.15s ease;
}
.gp-modal__close:hover {
  color: #1a1a1a;
  background: #eaeaea;
}
.gp-modal__close svg { width: 18px; height: 18px; }
.gp-modal__title {
  flex: 1;
  text-align: center;
  font-size: 17px;
  font-weight: 700;
  color: #1a1a1a;
  margin: 0;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.gp-modal__title-icon {
  width: 20px;
  height: 20px;
  color: #3F622A;
  flex-shrink: 0;
}

/* --- Modal search --- */
.gp-modal__search {
  padding: 12px 24px 8px;
  flex-shrink: 0;
}
.gp-modal__search-input {
  width: 100%;
  padding: 11px 16px 11px 42px;
  border: 1.5px solid #e5e7eb;
  border-radius: 12px;
  font-size: 14px;
  color: #1a1a1a;
  background: #fafafa url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E") 14px center no-repeat;
  outline: none;
  transition: all 0.15s ease;
}
.gp-modal__search-input:focus {
  border-color: #3F622A;
  background-color: #fff;
  box-shadow: 0 0 0 3px rgba(63, 98, 42, 0.08);
}
.gp-modal__search-input::placeholder { color: #aaa; }

/* --- Modal body (scrollable) --- */
.gp-modal__body {
  flex: 1;
  overflow-y: auto;
  padding: 4px 24px 8px;
  -webkit-overflow-scrolling: touch;
}
/* Custom scrollbar */
.gp-modal__body::-webkit-scrollbar { width: 4px; }
.gp-modal__body::-webkit-scrollbar-track { background: transparent; }
.gp-modal__body::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 4px;
}

/* --- Sections container --- */
.gp-modal__section {
  padding: 4px 0;
}

/* --- Section headings with icon --- */
.gp-modal__section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
  color: #444;
  text-transform: none;
  letter-spacing: 0;
  padding: 12px 0 10px;
  margin: 0;
}
.gp-modal__section-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: #3F622A;
  stroke-width: 2;
}

/* --- Section divider --- */
.gp-modal__divider {
  border: none;
  border-top: 1px solid #eee;
  margin: 4px 0;
}

/* --- 2-column grid for checkbox rows --- */
.gp-modal__grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px 8px;
}
@media (max-width: 480px) {
  .gp-modal__grid { grid-template-columns: 1fr; }
}

/* --- Toggle "ver más" button --- */
.gp-modal__toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  color: #3F622A;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  padding: 8px 0 4px;
  transition: color 0.15s ease;
}
.gp-modal__toggle-btn:hover { color: #334F22; text-decoration: underline; }
.gp-modal__toggle-chevron {
  width: 14px;
  height: 14px;
  transition: transform 0.2s ease;
}
.gp-modal__toggle-btn--expanded .gp-modal__toggle-chevron {
  transform: rotate(180deg);
}

/* --- Checkbox rows --- */
.gp-modal__row {
  display: flex;
  align-items: center;
  padding: 11px 8px;
  margin: 0 -8px;
  border-radius: 10px;
  cursor: pointer;
  gap: 12px;
  transition: background 0.1s ease;
  border-bottom: none;
}
.gp-modal__row:hover {
  background: #f7f7f7;
}
.gp-modal__row--checked {
  background: #f0f7ec;
}
.gp-modal__row--checked:hover {
  background: #e6f0e0;
}

/* Custom checkbox */
.gp-modal__checkbox {
  width: 22px;
  height: 22px;
  border: 2px solid #ccc;
  border-radius: 6px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  background: #fff;
}
.gp-modal__row--checked .gp-modal__checkbox {
  background: #3F622A;
  border-color: #3F622A;
  box-shadow: 0 1px 3px rgba(63, 98, 42, 0.3);
}
.gp-modal__checkbox svg {
  width: 14px;
  height: 14px;
  stroke: #fff;
  fill: none;
  display: none;
}
.gp-modal__row--checked .gp-modal__checkbox svg { display: block; }

.gp-modal__label {
  font-size: 15px;
  color: #333;
  flex: 1;
  font-weight: 450;
}
.gp-modal__row--checked .gp-modal__label {
  color: #2a4a1d;
  font-weight: 550;
}

.gp-modal__count {
  font-size: 13px;
  color: #aaa;
  font-weight: 400;
}

/* --- Price range pills (card style) --- */
.gp-modal__price-pills {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  padding: 8px 0 4px;
}
.gp-modal__price-pill {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 12px 8px 10px;
  border: 1.5px solid #e5e7eb;
  border-radius: 12px;
  background: #fff;
  cursor: pointer;
  transition: all 0.15s ease;
}
.gp-modal__price-pill:hover {
  border-color: #bbb;
  background: #fafafa;
}
.gp-modal__price-symbol {
  font-size: 16px;
  font-weight: 700;
  color: #333;
  letter-spacing: 0.5px;
}
.gp-modal__price-label {
  font-size: 11px;
  font-weight: 500;
  color: #888;
}
.gp-modal__price-pill--active {
  border: 2px solid #3F622A;
  background: #f0f7ec;
  padding: 11px 7px 9px;
  box-shadow: 0 1px 3px rgba(63, 98, 42, 0.15);
}
.gp-modal__price-pill--active .gp-modal__price-symbol { color: #3F622A; }
.gp-modal__price-pill--active .gp-modal__price-label { color: #3F622A; }

/* Hidden rows — MUST come after .gp-modal__row to win cascade */
.gp-modal__row.gp-modal__row--hidden { display: none; }
.gp-modal__grid--expanded .gp-modal__row--hidden { display: flex; }

/* --- Modal footer (sticky CTA) --- */
.gp-modal__footer {
  padding: 16px 24px;
  border-top: 1px solid #f0f0f0;
  flex-shrink: 0;
  display: flex;
  gap: 16px;
  align-items: center;
  background: #fff;
}
.gp-modal__clear-btn {
  background: none;
  border: none;
  color: #888;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  padding: 8px 4px;
  text-decoration: none;
  transition: color 0.15s ease;
  white-space: nowrap;
}
.gp-modal__clear-btn:hover { color: #333; text-decoration: underline; }

.gp-modal__apply-btn {
  flex: 1;
  background: #3F622A;
  color: #fff;
  border: none;
  border-radius: 14px;
  height: 50px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
  letter-spacing: 0.01em;
  box-shadow: 0 2px 8px rgba(63, 98, 42, 0.25);
}
.gp-modal__apply-btn:hover {
  background: #334F22;
  box-shadow: 0 4px 12px rgba(63, 98, 42, 0.35);
  transform: translateY(-1px);
}
.gp-modal__apply-btn:active {
  transform: translateY(0);
  box-shadow: 0 1px 4px rgba(63, 98, 42, 0.2);
}


/* ========================================
   LOADING STATE
   ======================================== */

.gp-listing-panel--loading {
  opacity: 0.5;
  pointer-events: none;
  transition: opacity 0.2s ease;
}


/* ========================================
   RESPONSIVE
   ======================================== */

@media (max-width: 767px) {
  .gp-filter-chips { padding: 0 16px; }
  .gp-modal__body { padding: 4px 16px 8px; }
  .gp-modal__header { padding: 20px 16px 16px; }
  .gp-modal__footer { padding: 16px; }
  .gp-modal__search { padding: 12px 16px 8px; }
  .gp-modal__row { padding: 12px 10px; margin: 0 -10px; }

  /* Landing pages: hide search bar on scroll, sticky filter bar only */
  body.gp-landing-map .gp-search-bar-wrapper {
    transition: transform 0.25s ease, opacity 0.2s ease;
  }
  body.gp-landing-map .gp-search-bar-wrapper.gp-hidden-scroll {
    transform: translateY(-100%);
    opacity: 0;
    height: 0;
    overflow: hidden;
    padding: 0;
    margin: 0;
  }
  body.gp-landing-map .gp-filter-bar {
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  }

  /* Hide header on landing pages when scrolled */
  body.gp-landing-map header.header {
    transition: transform 0.25s ease;
  }
  body.gp-landing-map header.header.gp-header-hidden {
    transform: translateY(-100%);
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .gp-modal-overlay,
  .gp-modal,
  .gp-chip,
  .gp-chip-all,
  .gp-modal__apply-btn,
  .gp-listing-panel--loading {
    animation: none !important;
    transition: none !important;
  }
}
