/* Override styles for listing images (added by assistant) */
/* Improvement pass: balance list view image vs details so image doesn't squeeze text */

/* List view wrapper: force horizontal flex layout if not already */
.rtcl.rtcl-listings.rtcl-list-view .listing-item.listing-layout-2 {
  display: flex;
  align-items: stretch; /* allow equal height columns */
}

/* Image container sizing: keep it moderate width on desktop */
.rtcl .rtcl-list-view .listing-item.listing-layout-2 .item-img {
  flex: 0 0 280px; /* fixed column width */
  max-width: 280px;
  position: relative;
}

/* Allow easy tweak with CSS variable */
.rtcl .rtcl-list-view .listing-item.listing-layout-2 {
  --listing-thumb-width: 240px; /* was 280px */
}
.rtcl .rtcl-list-view .listing-item.listing-layout-2 .item-img { flex-basis: var(--listing-thumb-width); max-width: var(--listing-thumb-width); }

/* Keep image full inside its box while preserving aspect ratio */
.rtcl .rtcl-list-view .listing-item.listing-layout-2 .listing-thumb a,
.rtcl .rtcl-list-view .listing-item.listing-layout-2 .listing-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  aspect-ratio: 5/4; /* consistent shape */
  border-radius: 12px;
}

/* Content area grows */
.rtcl .rtcl-list-view .listing-item.listing-layout-2 .item-content {
  flex: 1 1 auto;
  min-width: 0; /* allow flexbox text wrap */
  padding: 8px 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Title spacing refinement */
.rtcl .rtcl-list-view .listing-item.listing-layout-2 h3.listing-title { margin: 0 0 6px; font-size: 1.15rem; line-height: 1.3; }

/* Clamp long description to 3 lines for uniform blocks; can remove if undesired */
.rtcl .rtcl-list-view .listing-item.listing-layout-2 .listing-info-text p {
  margin: 0 0 6px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-clamp: 3; /* standard property (supported partially) */
}

/* Meta info layout: distribute left/right cleanly */
.rtcl .rtcl-list-view .listing-item.listing-layout-2 .all-meta-info-box {
  margin-top: auto; /* push to bottom */
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}
.rtcl .rtcl-list-view .listing-item.listing-layout-2 .all-meta-info-box-left { flex: 1 1 auto; }
.rtcl .rtcl-list-view .listing-item.listing-layout-2 .all-meta-info-box-right { flex: 0 0 auto; }

/* Reduce heart icon overlap */
.rtcl .rtcl-list-view .listing-item.listing-layout-2 .meta-item.meta-favourite a { font-size: 18px; }

/* Responsive adjustments */
@media (max-width: 991.98px) {
  .rtcl.rtcl-listings.rtcl-list-view .listing-item.listing-layout-2 { flex-direction: row; }
  .rtcl .rtcl-list-view .listing-item.listing-layout-2 { --listing-thumb-width: 220px; }
}
@media (max-width: 767.98px) {
  .rtcl.rtcl-listings.rtcl-list-view .listing-item.listing-layout-2 { flex-direction: column; }
  .rtcl .rtcl-list-view .listing-item.listing-layout-2 .item-img { width: 100%; max-width: 100%; flex: 0 0 auto; }
  .rtcl .rtcl-list-view .listing-item.listing-layout-2 .listing-thumb a { aspect-ratio: 16/10; }
  .rtcl .rtcl-list-view .listing-item.listing-layout-2 .all-meta-info-box { margin-top: 4px; }
}
@media (min-width: 1400px) {
  .rtcl .rtcl-list-view .listing-item.listing-layout-2 { --listing-thumb-width: 260px; }
}

/* Fallback if some inline styles inflate image: force containment */
.rtcl .rtcl-list-view .listing-item.listing-layout-2 .item-img img { max-width: 100%; height: 100%; }

/* Slight card styling enhancement */
.rtcl.rtcl-listings.rtcl-list-view .listing-item.listing-layout-2 {
  background: #fff;
  border: 1px solid #e6e6e6;
  border-radius: 16px;
  padding: 18px 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,.06);
}
.rtcl.rtcl-listings.rtcl-list-view .listing-item.listing-layout-2:hover { box-shadow: 0 4px 18px rgba(0,0,0,.09); }

/* Remove any previous max-width forcing full row for thumbnail */
.rtcl .rtcl-list-view .listing-item .listing-thumb { max-width: none; }

/* 1. List view thumbnails full width */
.rtcl .rtcl-list-view .listing-item .listing-thumb {
  flex: 1 1 auto;
  max-width: 100%;
}
.rtcl .rtcl-list-view .listing-item .listing-thumb a,
.rtcl .rtcl-list-view .listing-item .listing-thumb img {
  display: block;
  width: 100%;
  height: auto;
}

/* 2. Optional common aspect ratio for archive grid (can be removed if not wanted) */
.rtcl .rtcl-grid-view .listing-item .listing-thumb a {
  display: block;
  width: 100%;
  aspect-ratio: 16/9;
  overflow: hidden;
}
.rtcl .rtcl-grid-view .listing-item .listing-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* 3. Responsive gallery on single listing */
.listingDetails-header .page-header .photo-swip-gallery-wrap {
  display: grid;
  gap: 10px;
  /* Автоматично запълване на реда с минимална ширина */
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  align-items: stretch;
}
@media (max-width: 991.98px) {
  .listingDetails-header .page-header .photo-swip-gallery-wrap { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 575.98px) {
  .listingDetails-header .page-header .photo-swip-gallery-wrap { grid-template-columns: 1fr; }
}
/* Remove explicit min-heights & fixed row height behavior from original; rely on aspect ratio */
.listingDetails-header .page-header .photo-swip-gallery-wrap .listing-gallery-item { display: block; }
.listingDetails-header .page-header .photo-swip-gallery-wrap .listing-gallery-item a {
  display: block;
  overflow: hidden;
  aspect-ratio: 16/10; /* adjust if you prefer 4/3 */
  border-radius: 8px;
}
.listingDetails-header .page-header .photo-swip-gallery-wrap .listing-gallery-item a img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
/* Keep larger first image style (optional) */
/* Премахваме специалните първи големи клетки за да е равномерно */
.photo-swip-gallery-wrap.items-five .listing-gallery-item:nth-child(1) a,
.photo-swip-gallery-wrap.items-four .listing-gallery-item:nth-child(1) a,
.photo-swip-gallery-wrap.items-three .listing-gallery-item:nth-child(1) a,
.photo-swip-gallery-wrap.items-five .listing-gallery-item:not(:nth-child(1)) a { aspect-ratio: unset; }

/* 4. Universal safe rule to prevent overflow */
.rtcl .rtcl-listings .listing-item .listing-thumb img, 
.listingDetails-header img { max-width: 100%; height: auto; }

/* 5. Guard against legacy max-width leftover */
.rtcl .rtcl-list-view .listing-item .listing-thumb { max-width: 100% !important; }

/* Hover zoom restored: no override here so original main.css transform applies */

/* ==== Bigger listing images & optional white crescent adjustments ==== */
/* Grid view: make thumbnails taller / larger */
/* Малко по-широки миниатюри за grid */
.rtcl .rtcl-grid-view .listing-item .listing-thumb a { aspect-ratio: 5/4; }
@media (min-width: 1400px) { /* a bit wider on large screens */
  .rtcl .rtcl-grid-view.columns-3 .listing-item .listing-thumb a { aspect-ratio: 3/2; }
}
/* Ensure the img fills new ratio */
.rtcl .rtcl-grid-view .listing-item .listing-thumb a img { width: 100%; height: 100%; object-fit: cover; }

/* List view: enlarge thumbnail area */
.rtcl .rtcl-list-view .listing-item .listing-thumb a { aspect-ratio: 3/2; min-height: 260px; }
.rtcl .rtcl-list-view .listing-item .listing-thumb a img { width: 100%; height: 100%; object-fit: cover; }

/* Optional: reduce size of white circular background ("полумесец") so it doesn't visually eat the image */
.rtcl .rtcl-grid-view .listing-item .item-content::before {
  width: 600px; /* was 800px */
  height: 600px; /* was 800px */
  top: -10px; /* bring closer so it sits behind text only */
}
/* If you prefer to remove it entirely, uncomment the next rule */
/* .rtcl .rtcl-grid-view .listing-item .item-content::before { display: none !important; } */

/* Related / slider thumbnails (keep consistent) */
.rtcl .rtcl-related-listing .listing-thumb .rtcl-thumbnail { aspect-ratio: 4/3; }
.rtcl .rtcl-related-listing .listing-thumb .rtcl-thumbnail img { width: 100%; height: 100%; object-fit: cover; }

/* Safety: avoid tiny heights if lazy-loading sets intrinsic size */
.rtcl .listing-item .listing-thumb img { min-height: 100%; }

/* ===== Listing Status Badge (Намерено / Върнато на стопанина / Осиновено) ===== */
.rtcl .listing-item .listing-thumb { position: relative; overflow: visible; }

.petslist-status-badge {
  position: absolute;
  top: 10px;
  right: 10px; /* keep away from left-side action buttons */
  z-index: 5;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  font-size: 12px;
  line-height: 1;
  font-weight: 700;
  color: #fff;
  background: rgba(0,0,0,.65);
  border-radius: 999px;
  box-shadow: 0 6px 18px rgba(0,0,0,.15);
  pointer-events: none; /* do not block thumbnail link */
  text-shadow: 0 1px 0 rgba(0,0,0,.15);
}
.petslist-status-badge i { font-size: 12px; line-height: 1; }

/* Specific colors by status */
.petslist-status-badge.status-found   { background: #1e9e55; } /* Намерено */
.petslist-status-badge.status-rehomed { background: #1e88e5; } /* Върнато на стопанина */
.petslist-status-badge.status-adopted { background: #d81b60; } /* Осиновено */

@media (max-width: 575.98px){
  .petslist-status-badge{ font-size: 11px; padding: 5px 9px; }
}

/* ===================================================
   MOBILE FLOATING FILTER BAR — .rtcl-ajax-filter-floating-mobile
   Overrides the plain plugin defaults (2px radius, no shadow, hidden text)
   and aligns the bar to the Petslist theme palette.
   =================================================== */
@media screen and (max-width: 767px) {

  /* ── Outer bar ── */
  .rtcl-widget-ajax-filter-wrapper .rtcl-ajax-filter-floating-mobile {
    display: flex;
    align-items: center;
    justify-content: space-between;
    /* Gradient: theme teal → vivid blue */
    background: linear-gradient(
      135deg,
      var(--petslist-primary-color, #02c5bd) 0%,
      #0284c7 55%,
      #1d4ed8 100%
    );
    padding: 14px 18px;
    border-radius: 14px;
    margin-bottom: 14px;
    box-shadow:
      0 4px 20px rgba(29, 78, 216, .35),
      0 1px 4px rgba(0, 0, 0, .12),
      0 0 0 1px rgba(255,255,255,.08) inset;
    position: relative;
    overflow: hidden;
    transition: box-shadow .25s ease, transform .2s ease;
  }

  /* Subtle shimmer overlay */
  .rtcl-widget-ajax-filter-wrapper .rtcl-ajax-filter-floating-mobile::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
      110deg,
      rgba(255,255,255,.14) 0%,
      rgba(255,255,255,0) 55%
    );
    border-radius: 14px;
    pointer-events: none;
  }

  /* Subtle decorative circle (right side) */
  .rtcl-widget-ajax-filter-wrapper .rtcl-ajax-filter-floating-mobile::after {
    content: '';
    position: absolute;
    right: -30px;
    top: -30px;
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: rgba(255,255,255,.07);
    pointer-events: none;
  }

  .rtcl-widget-ajax-filter-wrapper .rtcl-ajax-filter-floating-mobile:hover {
    box-shadow:
      0 6px 28px rgba(29, 78, 216, .45),
      0 2px 6px rgba(0, 0, 0, .14);
    transform: translateY(-1px);
  }

  /* ── Left heading ── */
  .rtcl-widget-ajax-filter-wrapper .rtcl-ajax-filter-floating-mobile h4 {
    font-size: 17px;
    font-weight: 700;
    color: #ffffff;
    margin: 0;
    letter-spacing: .2px;
    line-height: 1.2;
    text-shadow: 0 1px 3px rgba(0,0,0,.18);
    position: relative;
    flex: 1 1 auto;
  }

  /* ── Right trigger button ── */
  .rtcl-widget-ajax-filter-wrapper .rtcl-ajax-filter-floating-mobile .rtcl-ajax-filter-open-filter {
    margin-left: 12px;
    flex: 0 0 auto;
    cursor: pointer;
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 16px 8px 12px;
    background: rgba(255,255,255,.2);
    border: 1.5px solid rgba(255,255,255,.45);
    border-radius: 999px;
    backdrop-filter: blur(4px);
    transition: background .2s ease, border-color .2s ease, transform .15s ease;
  }

  .rtcl-widget-ajax-filter-wrapper .rtcl-ajax-filter-floating-mobile .rtcl-ajax-filter-open-filter:hover {
    background: rgba(255,255,255,.3);
    border-color: rgba(255,255,255,.7);
    transform: scale(1.04);
  }

  .rtcl-widget-ajax-filter-wrapper .rtcl-ajax-filter-floating-mobile .rtcl-ajax-filter-open-filter:active {
    transform: scale(.97);
    background: rgba(255,255,255,.15);
  }

  /* SVG icon inside the pill */
  .rtcl-widget-ajax-filter-wrapper .rtcl-ajax-filter-floating-mobile .rtcl-ajax-filter-open-filter svg {
    width: 20px;
    height: 14px;
    flex-shrink: 0;
    filter: drop-shadow(0 1px 1px rgba(0,0,0,.15));
  }

  /* ── Show the "Филтър" text ── */
  .rtcl-widget-ajax-filter-wrapper .rtcl-ajax-filter-floating-mobile .rtcl-ajax-filter-open-filter strong {
    display: inline !important;
    font-size: 14px;
    font-weight: 700;
    color: #ffffff;
    letter-spacing: .3px;
    white-space: nowrap;
    text-shadow: 0 1px 2px rgba(0,0,0,.15);
    line-height: 1;
  }

  /* ── Pulse animation ── */
  @keyframes pl-filter-pulse {
    0%   { box-shadow: 0 4px 20px rgba(29,78,216,.35), 0 1px 4px rgba(0,0,0,.12); }
    50%  { box-shadow: 0 4px 28px rgba(29,78,216,.55), 0 1px 4px rgba(0,0,0,.12); }
    100% { box-shadow: 0 4px 20px rgba(29,78,216,.35), 0 1px 4px rgba(0,0,0,.12); }
  }
  .rtcl-widget-ajax-filter-wrapper .rtcl-ajax-filter-floating-mobile {
    animation: pl-filter-pulse 2.8s ease-in-out 0.6s 3;
  }
}
/* ===== /MOBILE FLOATING FILTER BAR ===== */

/* ===================================================
   FIX: My Account mobile sidebar navigation overlap
   =================================================== */
@media screen and (max-width: 991px) {
  .rtcl-MyAccount-wrap .rtcl-MyAccount-navigation {
    flex: 0 0 220px !important;
    max-width: 220px !important;
    width: 220px !important;
  }
}

/* ===== keyword-and-button-wrap layout fix ===== */
.keyword-and-button-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 auto;
  min-width: 0;
}
.keyword-and-button-wrap .rtin-key-space {
  flex: 1 1 auto;
  min-width: 0;
}
.keyword-and-button-wrap .rtin-btn-holder {
  flex: 0 0 auto;
}
.rtin-search-btn {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  overflow: hidden;
}
.rtin-search-btn .fas {
  font-size: 16px;
  line-height: 1;
  pointer-events: none;
}

/* ===== Typeahead autocomplete ===== */
.petslist-location-typeahead,
.petslist-category-typeahead,
.petslist-adtype-typeahead {
  position: relative;
  width: 100%;
}
.petslist-location-input,
.petslist-category-input,
.petslist-adtype-input {
  width: 100%;
}
.petslist-location-suggestions,
.petslist-category-suggestions,
.petslist-adtype-suggestions {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 9999;
  background: #fff;
  border: 1px solid #d8dee8;
  border-radius: 10px;
  margin: 4px 0 0;
  padding: 6px 0;
  box-shadow: 0 10px 30px rgba(15, 23, 42, .12);
  list-style: none;
  max-height: 260px;
  overflow-y: auto;
}
.petslist-location-suggestions li,
.petslist-category-suggestions li,
.petslist-adtype-suggestions li {
  padding: 10px 14px;
  cursor: pointer;
  font-size: 14px;
  color: #1f2937;
  line-height: 1.35;
}
.petslist-location-suggestions li:hover,
.petslist-location-suggestions li.active,
.petslist-category-suggestions li:hover,
.petslist-category-suggestions li.active,
.petslist-adtype-suggestions li:hover,
.petslist-adtype-suggestions li.active {
  background: #f0f9ff;
  color: #0ea5e9;
}
@media (max-width: 767.98px) {
  .petslist-location-suggestions,
  .petslist-category-suggestions,
  .petslist-adtype-suggestions {
    border-radius: 8px;
    max-height: 200px;
  }
}

/* ===================================================
   SINGLE LISTING GALLERY FIX
   =================================================== */
body.single-rtcl_listing .listingDetails-header .page-header .photo-swip-gallery-wrap {
  display: grid !important;
  grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
  grid-auto-rows: 140px !important;
  gap: 8px !important;
  align-items: stretch;
}
body.single-rtcl_listing .listingDetails-header .page-header .photo-swip-gallery-wrap .listing-gallery-item {
  display: block !important;
  position: relative;
  overflow: hidden;
  min-height: 0 !important;
  border-radius: 10px;
}
body.single-rtcl_listing .listingDetails-header .page-header .photo-swip-gallery-wrap .listing-gallery-item a,
body.single-rtcl_listing .listingDetails-header .page-header .photo-swip-gallery-wrap .listing-gallery-item img,
body.single-rtcl_listing .listingDetails-header .page-header .photo-swip-gallery-wrap .listing-gallery-item .rtcl-lightbox-iframe {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
}
@media (min-width: 992px) {
  body.single-rtcl_listing .listingDetails-header .page-header .photo-swip-gallery-wrap.items-three .listing-gallery-item:nth-child(1),
  body.single-rtcl_listing .listingDetails-header .page-header .photo-swip-gallery-wrap.items-four .listing-gallery-item:nth-child(1),
  body.single-rtcl_listing .listingDetails-header .page-header .photo-swip-gallery-wrap.items-five .listing-gallery-item:nth-child(1) {
    grid-column: span 2 !important;
    grid-row: span 2 !important;
  }
}
@media (max-width: 991.98px) {
  body.single-rtcl_listing .listingDetails-header .page-header .photo-swip-gallery-wrap {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    grid-auto-rows: 220px !important;
    gap: 6px !important;
  }
  body.single-rtcl_listing .listingDetails-header .page-header .photo-swip-gallery-wrap .listing-gallery-item {
    grid-column: auto !important;
    grid-row: auto !important;
  }
}
@media (max-width: 575.98px) {
  body.single-rtcl_listing .listingDetails-header .page-header .photo-swip-gallery-wrap {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    grid-auto-rows: 160px !important;
    gap: 4px !important;
  }
  body.single-rtcl_listing .listingDetails-header .page-header .photo-swip-gallery-wrap .listing-gallery-item,
  body.single-rtcl_listing .listingDetails-header .page-header .photo-swip-gallery-wrap .listing-gallery-item img,
  body.single-rtcl_listing .listingDetails-header .page-header .photo-swip-gallery-wrap .listing-gallery-item a {
    border-radius: 8px;
  }
}
@media (max-width: 380px) {
  body.single-rtcl_listing .listingDetails-header .page-header .photo-swip-gallery-wrap {
    grid-template-columns: 1fr !important;
    grid-auto-rows: 220px !important;
  }
}

/* ===================================================
   FIX: Homepage Interactive Map - collapsed/shrunk map
   The map needs both explicit height AND full width on all wrappers.
   =================================================== */
.rtcl-map-section,
.zoospace-home-classified-map__section {
  width: 100% !important;
  max-width: 100% !important;
}

.rtcl-map-section .rtcl-search-map,
.zoospace-home-classified-map__section .rtcl-search-map {
  width: 100% !important;
  max-width: 100% !important;
}

.rtcl-map-section .rtcl-map-view,
.zoospace-home-classified-map__section .rtcl-map-view,
.rtcl-map-section .rtcl-map-view.leaflet-container,
.zoospace-home-classified-map__section .rtcl-map-view.leaflet-container {
  width: 100% !important;
  max-width: 100% !important;
  height: 480px !important;
  min-height: 400px;
  border-radius: 16px;
  overflow: hidden;
}

@media (max-width: 991.98px) {
  .rtcl-map-section .rtcl-map-view,
  .zoospace-home-classified-map__section .rtcl-map-view,
  .rtcl-map-section .rtcl-map-view.leaflet-container,
  .zoospace-home-classified-map__section .rtcl-map-view.leaflet-container {
    height: 400px !important;
    min-height: 350px;
  }
}

@media (max-width: 575.98px) {
  .rtcl-map-section .rtcl-map-view,
  .zoospace-home-classified-map__section .rtcl-map-view,
  .rtcl-map-section .rtcl-map-view.leaflet-container,
  .zoospace-home-classified-map__section .rtcl-map-view.leaflet-container {
    height: 320px !important;
    min-height: 280px;
    border-radius: 12px;
  }
}