/* ============================================
   V2 TOP-OF-PAGE — breadcrumb + heading + filter controls + category chips
   Replaces the legacy .filters-bar block above the listing grid.

   IMPORTANT: style.css has aggressive bare-element rules (`select`, `h1`,
   `button`) that override class-level styling. All critical v2 properties
   below use !important to defeat them.
   ============================================ */

/* Page-wide container width — match Lovable's 1400px max-width and reset the
   global `.container-fluid { width: 95% !important }` to a sane cap on this page. */
.dogs-for-sale .container-fluid {
    width: 100% !important;
    max-width: 1400px !important;
    margin-left: auto !important;
    margin-right: auto !important;
    padding-left: 16px;
    padding-right: 16px;
}

.dfs-breadcrumb {
    padding: 24px 0 0;
    font-family: var(--v2-font) !important;
    font-size: 14px;
    color: var(--v2-muted);
}

.dfs-breadcrumb .container {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 16px;
}

.dfs-breadcrumb a {
    color: var(--v2-muted);
    text-decoration: none;
    transition: color 0.2s ease;
}

.dfs-breadcrumb a:hover {
    color: var(--v2-primary);
}

.dfs-breadcrumb-sep {
    margin: 0 8px;
}

.dfs-breadcrumb-current {
    color: var(--v2-fg);
    font-weight: 500;
}

/* --- Heading + controls row --- */
.dfs-heading-row {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin: 16px 0 24px;
}

@media (min-width: 768px) {
    .dfs-heading-row {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }
}

/* Override bare `h1 { font-size: 2em; margin: 0.67em 0 }` from style.css:108 */
.dfs-heading {
    font-family: var(--v2-font) !important;
    font-weight: 700 !important;
    font-size: 24px !important;
    color: var(--v2-fg) !important;
    margin: 0 !important;
    line-height: 1.25 !important;
    letter-spacing: normal !important;
}

@media (min-width: 640px) {
    .dfs-heading {
        font-size: 30px !important;
    }
}

.dfs-result-count {
    font-family: var(--v2-font);
    font-size: 14px;
    color: var(--v2-muted);
    margin: 4px 0 0;
    letter-spacing: normal;
}

.dfs-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

/* --- Filter / Map / View buttons (outline style) ---
   Override bare `button { appearance: button }` and `body { font-family: Inter }` */
.dfs-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 36px;
    padding: 0 12px;
    font-family: var(--v2-font) !important;
    font-size: 14px !important;
    font-weight: 500;
    color: var(--v2-fg) !important;
    background: var(--v2-bg-card) !important;
    border: 1px solid var(--v2-border) !important;
    border-radius: 8px !important;
    cursor: pointer;
    transition:
        background 0.2s ease,
        color 0.2s ease,
        border-color 0.2s ease;
    white-space: nowrap;
    letter-spacing: normal;
    appearance: none;
    -webkit-appearance: none;
}

.dfs-btn:hover {
    background: hsl(var(--v2-secondary)) !important;
    color: var(--v2-fg) !important;
}

.dfs-btn svg {
    width: 16px;
    height: 16px;
    display: block;
    flex-shrink: 0;
}

/* Mobile-only Filters button — opens the existing #filterModal */
.dfs-filters-mobile {
    display: inline-flex;
}

/* Filters button stays visible up to 1200px — sidebar is a slide-out drawer
   below that breakpoint so the listings grid gets full width and isn't
   squished beside a 256px inline sidebar. */
@media (min-width: 1200px) {
    .dfs-filters-mobile {
        display: none;
    }
}

/* --- Sort select --- override style.css:310 bare `select` rules (border-radius:5px,
   min-height:38px, width:calc(100%-30px), font-size:15px, letter-spacing:1px, Inter) */
.dfs-sort-form {
    margin: 0;
    display: inline-block;
}

.dfs-sort-select {
    appearance: none !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    width: auto !important;
    min-height: 0 !important;
    height: 36px !important;
    padding: 0 36px 0 12px !important;
    font-family: var(--v2-font) !important;
    font-size: 14px !important;
    color: var(--v2-fg) !important;
    background-color: var(--v2-bg-card) !important;
    border: 1px solid var(--v2-border) !important;
    border-radius: 8px !important;
    cursor: pointer;
    outline: none;
    letter-spacing: normal !important;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8' fill='none'><path d='M1 1l5 5 5-5' stroke='%236b7280' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/></svg>") !important;
    background-repeat: no-repeat !important;
    background-position: right 12px center !important;
    background-size: 12px 8px !important;
}

.dfs-sort-select:focus {
    border-color: var(--v2-primary) !important;
}

/* --- Grid/list view toggle (desktop only) --- */
.dfs-view-toggle {
    display: none;
    align-items: stretch;
    border: 1px solid var(--v2-border);
    border-radius: 8px;
    overflow: hidden;
    background: var(--v2-bg-card);
}

@media (min-width: 768px) {
    .dfs-view-toggle {
        display: inline-flex;
    }
}

.dfs-view-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent !important;
    border: none !important;
    border-radius: 0 !important;
    color: var(--v2-muted) !important;
    cursor: pointer;
    padding: 0 !important;
    appearance: none;
    -webkit-appearance: none;
    transition:
        background 0.2s ease,
        color 0.2s ease;
}

.dfs-view-btn:hover {
    color: var(--v2-fg) !important;
}

.dfs-view-btn.is-active {
    background: hsl(var(--v2-secondary)) !important;
    color: var(--v2-fg) !important;
}

.dfs-view-btn svg {
    width: 16px;
    height: 16px;
    display: block;
}

/* --- Category chip row --- override bare `a { background-color: transparent }` (style.css:124) */
.dfs-chip-row {
    display: flex;
    gap: 8px;
    margin: 0 0 24px;
    padding: 0 0 4px;
    overflow-x: auto;
    scrollbar-width: thin;
    /* Without these, the flex container sizes to its content (max-content) and
       overflows the page at mobile widths (~393px at 375vw) instead of becoming
       horizontally scrollable. */
    min-width: 0;
    max-width: 100%;
}

.dfs-chip-row::-webkit-scrollbar {
    height: 6px;
}

/* Wraps the chip row and hosts the left/right scroll-arrow buttons. JS toggles
   .has-scroll-left / .has-scroll-right when the row has more content to scroll
   in that direction (see dogs-for-sale.blade.php DOMContentLoaded). */
.dfs-chip-row-wrap {
    position: relative;
    min-width: 0;
    max-width: 100%;
    display: block;
}

.dfs-chip-scroll-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 30px;
    height: 30px;
    padding: 0;
    border-radius: 50%;
    border: 1px solid var(--v2-border);
    background: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
    align-items: center;
    justify-content: center;
    color: var(--v2-fg);
    cursor: pointer;
    z-index: 2;
    display: none;
}

/* Hide the chip-row scrollbar when arrow buttons are present — the arrows are
   now the only scroll affordance, and the scrollbar gutter would push the
   chip-row taller than the chips so the arrows wouldn't sit centered on them. */
.dfs-chip-row-wrap .dfs-chip-row {
    padding-bottom: 0;
    scrollbar-width: none;
}

.dfs-chip-row-wrap .dfs-chip-row::-webkit-scrollbar {
    display: none;
}

.dfs-chip-scroll-btn svg {
    width: 16px;
    height: 16px;
    display: block;
}

.dfs-chip-scroll-left {
    left: 2px;
}

.dfs-chip-scroll-right {
    right: 2px;
}

.dfs-chip-row-wrap.has-scroll-left .dfs-chip-scroll-left,
.dfs-chip-row-wrap.has-scroll-right .dfs-chip-scroll-right {
    display: inline-flex;
}

.dfs-chip {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    padding: 8px 16px;
    font-family: var(--v2-font) !important;
    font-size: 14px !important;
    font-weight: 500;
    color: var(--v2-fg) !important;
    background-color: hsl(var(--v2-secondary)) !important;
    border-radius: 9999px;
    text-decoration: none !important;
    letter-spacing: normal;
    transition:
        background-color 0.2s ease,
        color 0.2s ease;
}

.dfs-chip:hover {
    background-color: hsl(40, 20%, 88%) !important;
    color: var(--v2-fg) !important;
    text-decoration: none !important;
}

.dfs-chip.is-active {
    background-color: var(--v2-primary) !important;
    color: #fff !important;
}

.dfs-chip.is-active:hover {
    background-color: var(--v2-primary-hover) !important;
    color: #fff !important;
}

/* ============================================
   CHIP ROW + MAP FILTER BAR WRAPPER
   Desktop (>=768px): chips left, map dropdowns right, single row.
   Mobile (<768px):  chips top (horizontal scroll), dropdowns below, stacked.
   ============================================ */

.dfs-chip-and-filter-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    margin: 0 0 24px;
}

/* Chip row wrap inside the wrapper expands to take leftover space — pushes the
   map dropdowns to the right on desktop. min-width:0 lets overflow-x kick in. */
.dfs-chip-and-filter-row .dfs-chip-row-wrap {
    flex: 1 1 auto;
    min-width: 0;
}

.dfs-chip-and-filter-row .dfs-chip-row {
    margin: 0;
    /* override the standalone chip-row's 24px bottom margin */
    padding-bottom: 0;
}

/* Map dropdowns row — fixed-content size on desktop, fills width on mobile. */
.dfs-map-filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0;
    padding: 0;
    flex: 0 0 auto;
}

.dfs-map-filter-field {
    flex: 1 1 auto;
    min-width: 160px;
    max-width: 200px;
}

.dfs-map-filter-field .dfs-filter-select {
    width: 100% !important;
}

/* Mobile: dropdowns stack below the chip row, each select goes full-width. */
@media (max-width: 768px) {
    .dfs-chip-and-filter-row {
        flex-direction: column;
        align-items: stretch;
    }

    .dfs-map-filter-bar {
        width: 100%;
    }

    .dfs-map-filter-field {
        flex: 1 1 0;
        max-width: none;
    }
}

/* (Filters button is gated server-side in the Blade — not rendered on map view —
   so no CSS-level hide is needed.) */

/* ============================================
   SIDE FILTER — desktop sticky sidebar + mobile slide-over drawer
   Single <aside> element; CSS handles both modes via breakpoints.
   ============================================ */

/* Page layout wrapper — places sidebar alongside listings content at md+ */
.dfs-layout {
    display: block;
    /* mobile: stacks naturally; sidebar is fixed slide-over so doesn't affect flow */
}

@media (min-width: 1200px) {
    .dfs-layout {
        display: flex;
        gap: 24px;
        align-items: flex-start;
    }
}

.dfs-content {
    flex: 1;
    min-width: 0;
    /* prevent flex-item from overflowing parent on narrow viewports */
}

/* Backdrop for mobile drawer mode — fades in when .is-open is set on sidebar */
.dfs-filter-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.dfs-filter-overlay.is-open {
    opacity: 1;
    pointer-events: auto;
}

@media (min-width: 1200px) {
    .dfs-filter-overlay {
        display: none;
    }
}

/* The filter element itself — fixed slide-over on mobile, sticky inline on md+ */
.dfs-filter-sidebar {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(320px, 100%);
    background: var(--v2-bg-card);
    padding: 24px;
    overflow-y: auto;
    z-index: 1000;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    box-shadow: -4px 0 16px rgba(0, 0, 0, 0.1);
}

.dfs-filter-sidebar.is-open {
    transform: translateX(0);
}

@media (min-width: 1200px) {
    .dfs-filter-sidebar {
        position: sticky;
        top: 96px;
        /* below header */
        right: auto;
        bottom: auto;
        width: 256px;
        flex-shrink: 0;
        transform: none;
        padding: 20px;
        max-height: calc(100vh - 120px);
        box-shadow: none;
        border: 1px solid var(--v2-border);
        border-radius: 12px;
    }
}

/* Sidebar header — title + close button (close only visible on mobile) */
.dfs-filter-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.dfs-filter-title {
    font-family: var(--v2-font) !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    color: var(--v2-fg) !important;
    margin: 0 !important;
    letter-spacing: normal !important;
}

.dfs-filter-close {
    background: transparent;
    border: none;
    padding: 4px;
    cursor: pointer;
    color: var(--v2-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.dfs-filter-close svg {
    width: 20px;
    height: 20px;
    display: block;
}

@media (min-width: 1200px) {
    .dfs-filter-close {
        display: none;
    }
}

/* Form layout — vertical stack with consistent spacing */
.dfs-filter-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.dfs-filter-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.dfs-filter-label {
    font-family: var(--v2-font) !important;
    font-size: 12px !important;
    font-weight: 500 !important;
    color: var(--v2-muted) !important;
    letter-spacing: normal !important;
    margin: 0 !important;
}

/* Field controls — defeat bare-element rules in style.css (select, input) */
.dfs-filter-input,
.dfs-filter-select {
    appearance: none !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    width: 100% !important;
    min-height: 0 !important;
    height: 36px !important;
    padding: 0 12px !important;
    font-family: var(--v2-font) !important;
    font-size: 14px !important;
    color: var(--v2-fg) !important;
    background-color: var(--v2-bg) !important;
    border: 1px solid var(--v2-border) !important;
    border-radius: 8px !important;
    outline: none;
    letter-spacing: normal !important;
}

.dfs-filter-select {
    padding-right: 36px !important;
    cursor: pointer;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8' fill='none'><path d='M1 1l5 5 5-5' stroke='%236b7280' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/></svg>") !important;
    background-repeat: no-repeat !important;
    background-position: right 12px center !important;
    background-size: 12px 8px !important;
}

.dfs-filter-input:focus,
.dfs-filter-select:focus {
    border-color: var(--v2-primary) !important;
}

/* Hide spinners on number inputs (Min/Max) */
.dfs-filter-input[type="number"]::-webkit-outer-spin-button,
.dfs-filter-input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.dfs-filter-input[type="number"] {
    -moz-appearance: textfield;
}

/* Price row — two inputs side by side */
.dfs-filter-price-row {
    display: flex;
    gap: 8px;
}

/* Checkboxes — vertical stack, clickable labels */
.dfs-filter-checkboxes {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.dfs-filter-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: var(--v2-font) !important;
    font-size: 14px !important;
    color: var(--v2-fg) !important;
    cursor: pointer;
    letter-spacing: normal !important;
}

.dfs-filter-checkbox input[type="checkbox"] {
    width: 16px !important;
    height: 16px !important;
    margin: 0 !important;
    accent-color: var(--v2-primary);
    cursor: pointer;
}

/* Apply button — primary, full-width */
.dfs-filter-apply {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100% !important;
    height: 36px !important;
    padding: 0 !important;
    font-family: var(--v2-font) !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    color: #fff !important;
    background-color: var(--v2-primary) !important;
    border: none !important;
    border-radius: 8px !important;
    cursor: pointer;
    letter-spacing: normal !important;
    appearance: none;
    -webkit-appearance: none;
    transition: background-color 0.2s ease;
}

.dfs-filter-apply:hover {
    background-color: var(--v2-primary-hover) !important;
}

/* ============================================
   GRID / LIST VIEW TOGGLE — applies to .listings-grid
   ============================================ */

/* Default = grid view (defined below in the LISTING CARDS section) */

/* List view: cards stack as horizontal rows — image left (fixed width), content right (flex) */
.listings-grid.is-list-view {
    grid-template-columns: 1fr;
    gap: 12px;
}

.listings-grid.is-list-view .listing-card {
    display: grid;
    grid-template-columns: 240px 1fr;
    gap: 0;
}

.listings-grid.is-list-view .listing-image {
    aspect-ratio: auto;
    height: 100%;
    min-height: 180px;
}

.listings-grid.is-list-view .listing-content {
    justify-content: space-between;
    padding: 16px 20px;
}

/* Boosted ribbon is still top-right of image in list view */
.listings-grid.is-list-view .listing-featured-ribbon {
    width: 90px;
    height: 90px;
}

.listings-grid.is-list-view .listing-featured-ribbon span {
    top: 14px;
    right: -34px;
    font-size: 9px;
    padding: 3px 0;
}

span.listing-featured-ribbon.ribbon-paired {
    top: -12px !important;
}

.listing-featured-ribbon.ribbon-paired span {
    top: var(--ribbon-slot-0-paired, 32px);
}

.listing-verified-ribbon {
    width: 90px;
    height: 90px;
    --ribbon-slot-1: 60px;
}

.listings-grid.is-list-view .listing-verified-ribbon span {
    top: 14px;
    right: -34px;
    font-size: 9px;
    padding: 3px 0;
}

/* Slot 1 needs a bigger clip box here too, for the same reason as the grid card: the
   band sits further from the corner and the 90px box truncates it. Higher specificity
   than the base .ribbon-slot-1 rule, which would otherwise impose the 140px grid size
   on these narrower cards. */
.listings-grid.is-list-view .listing-verified-ribbon.ribbon-slot-1 {
    width: 118px;
    height: 118px;
}

.listings-grid.is-list-view .listing-featured-ribbon.ribbon-paired {
    width: 118px;
    height: 118px;
    --ribbon-slot-0-paired: 26px;
}

/* On mobile, force grid layout regardless of the toggle */
@media (max-width: 767px) {
    .listings-grid.is-list-view {
        grid-template-columns: 1fr;
    }

    .listings-grid.is-list-view .listing-card {
        grid-template-columns: 1fr;
    }

    .listings-grid.is-list-view .listing-image {
        padding-top: 75%;
    }
}

/* ============================================
   LEGACY DOGS-FOR-SALE LAYOUT (existing styles below)
   Adjusted top padding since the new breadcrumb + heading row now sit above.
   ============================================ */

.dogs-for-sale {
    width: 100%;
    margin: 0 auto;
    padding: 0 0 50px;
}

/* Legacy .filters-bar block and #filterToggleBtn / #countySelectorBtn / #mapToggleBtn /
   #sortForm rules were removed when the v2 top filter row was introduced — those IDs
   are still on the new markup, so any ID-level styling here would defeat the v2
   .dfs-btn / .dfs-sort-select classes. Don't re-introduce ID rules for those buttons. */

/* Legacy #sortForm .sort-selector and #sortForm .select-field rules removed.
   The new sort UI is just a styled <select class="dfs-sort-select"> directly inside #sortForm —
   no .sort-selector wrapper, no .select-field class. See .dfs-sort-select at the top of this file. */

/* Legacy .filter-modal / .filter-section / .category-item / .category-title / .subcategory-list
   rules removed. The old centered filter modal is replaced by the v2 .dfs-filter-sidebar
   (desktop sticky + mobile slide-over). See .dfs-filter-* near the top of this file. */

/* Modal container */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    /* Higher than filters and other elements */
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.5);
}

.modal-content {
    background-color: #fff;
    margin: 5% auto;
    padding: 20px;
    border-radius: 6px;
    width: 90%;
    max-width: 600px;
    position: relative;
}

.close {
    position: absolute;
    top: 16px;
    right: 16px;
    font-size: 40px;
    font-weight: bold;
    color: #999;
    cursor: pointer;
}

.close:hover {
    color: #000;
}

.modal-title {
    text-align: center;
    margin-bottom: 1rem;
}

/* Legacy .county-modal* and .filter-actions rules removed.
   The county filter is no longer surfaced as a separate modal; future side-filter
   enhancements may re-introduce it inside the .dfs-filter-sidebar form. */

/* =====================
   Main Layout - Map & Listings
===================== */
/* Since only one view is shown at a time, we use a simple block layout */
.content-wrapper {
    margin-top: 1.25rem;
}

/* MAP SECTION */
.map-col {
    overflow: hidden;
    width: 100%;
    position: relative;
    top: 0;
    height: 700px;
    margin-bottom: 1rem;
    z-index: 50;
}

#map {
    width: 100%;
    height: 100%;
    border-radius: 1.25rem;
}

.map-loading-overlay {
    position: fixed;
    top: 50%;
    left: 50%;
    width: 150px;
    height: 150px;
    background: rgba(255, 255, 255, 0.8);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transform: translate(-50%, -50%);
    border: 1px solid #ccc;
    border-radius: 8px;
    text-align: center;
}

.map-loading-overlay .spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #ccc;
    border-top: 4px solid #2f8f3d;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 10px;
    /* Space between spinner and text */
}

/* Optional: styling for the text */
.map-loading-overlay .loading-text {
    font-size: 14px;
    color: #333;
}

/* .leaflet-marker-icon.custom-marker.leaflet-zoom-animated.leaflet-interactive {
    height: 14px !important;
    width: 14px !important;
} */

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.map-loading-overlay.hidden {
    display: none;
}

/* Elements hidden via the 'hidden' class */
#mapCol.hidden {
    display: none;
}

.listings-col.hidden {
    display: none;
}

.two-col-grid.map-hidden {
    grid-template-columns: 1fr;
}

/* Custom Popup (Centered on Page).
   Wraps a .popup-card in a floating overlay with a small close button.
   The wrapper itself is transparent — the .popup-card provides the visible
   surface and its own elevation. The .boosted class is left as a JS hook
   (toggled in dogs-for-sale.blade.php) but no longer applies a frame; the
   BOOSTED ribbon on the card itself signals boost status. */
.custom-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 11000;
    background: transparent;
    width: auto;
    transition: opacity 0.3s ease;
}

div#customPopupInner {
    width: -webkit-fill-available;
}

.custom-popup.hidden {
    opacity: 0;
    pointer-events: none;
}

.custom-popup.visible {
    opacity: 1;
    pointer-events: auto;
}

.custom-popup-content {
    position: relative;
    padding: 0;
}

/* Floating close button: small, neutral, sits on the corner of the card. */
.custom-popup-close {
    position: absolute;
    top: -10px;
    right: -10px;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    background: #fff;
    color: #444;
    border-radius: 50%;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
    z-index: 9997;
    transition:
        background-color 0.15s ease,
        color 0.15s ease,
        transform 0.15s ease;
}

.custom-popup-close span {
    font-size: 20px;
    line-height: 1;
    font-weight: 400;
}

.custom-popup-close:hover {
    background: #f3f3f3;
    color: #000;
    transform: scale(1.05);
}

/* Popup Card overrides — uses the same .listing-card structure as the grid but smaller image
   and tighter padding for the constrained Leaflet popup space. */
.popup-card.listing-card {
    width: 280px;
    /* Floating-card elevation — replaces the gold .custom-popup.boosted frame
       that used to wrap the card. Suppresses .listing-card's hover transform
       so the popup stays anchored when the cursor moves over it. */
    box-shadow:
        0 12px 32px rgba(0, 0, 0, 0.18),
        0 2px 8px rgba(0, 0, 0, 0.08);
    border-radius: 14px;
}

.popup-card.listing-card:hover {
    transform: none;
    box-shadow:
        0 12px 32px rgba(0, 0, 0, 0.18),
        0 2px 8px rgba(0, 0, 0, 0.08);
}

.popup-card .listing-image {
    aspect-ratio: auto;
    height: 160px;
}

.popup-card .listing-content {
    padding: 12px 14px;
}

.popup-card .listing-title {
    font-size: 14px !important;
    margin-bottom: 6px !important;
}

.popup-card .listing-price {
    font-size: 16px;
}

/* Tighten the category pill in the constrained popup space — shorter
   text + smaller font than the listing-page card's pill. Scoped to
   .popup-card so the listing-page card is untouched. */
.popup-card .category-badge {
    padding: 3px 9px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.02em;
}

/* Shrink the corner ribbon on the smaller popup image */
.popup-card .listing-featured-ribbon {
    width: 90px;
    height: 90px;
}

.popup-card .listing-featured-ribbon span {
    top: 14px;
    right: -34px;
    font-size: 9px;
    padding: 3px 0;
}

.popup-card .listing-verified-ribbon {
    width: 90px;
    height: 90px;
    --ribbon-slot-1: 60px;
}

.popup-card .listing-verified-ribbon span {
    top: 14px;
    right: -34px;
    font-size: 9px;
    padding: 3px 0;
}

/* Slot 1 needs a bigger clip box here too, for the same reason as the grid card: the
   band sits further from the corner and the 90px box truncates it. Higher specificity
   than the base .ribbon-slot-1 rule, which would otherwise impose the 140px grid size
   on these narrower cards. */
.popup-card .listing-verified-ribbon.ribbon-slot-1 {
    width: 118px;
    height: 118px;
    top: -30px;
    right: -20px;
}

.popup-card .listing-featured-ribbon.ribbon-paired {
    width: 118px;
    height: 118px;
    --ribbon-slot-0-paired: 26px;
    top: 0px !important;
}

.leaflet-marker-icon {
    font-family: var(--v2-font) !important;
}

.marker-cluster-small {
    background: linear-gradient(135deg, #2f8f3d 0%, #c9a137 100%);
    color: #fff;
    font-family: var(--v2-font) !important;
}

.marker-cluster-medium {
    background: linear-gradient(135deg, #2f8f3d 0%, #c9a137 100%);
    color: #fff;
    font-family: var(--v2-font) !important;
}

/* Base styles for the popup */
.leaflet-popup {
    z-index: 1000;
}

/* Remove the popup tip/arrow since we're customizing position */
.leaflet-popup-tip-container {
    display: none !important;
}

/* Style the popup content container */
.leaflet-popup-content-wrapper {
    border-radius: 8px !important;
    box-shadow: 0 3px 20px rgba(0, 0, 0, 0.3) !important;
    padding: 0 !important;
}

/* Popup positioning for markers in bottom half - moves popup above marker */
.popup-position-top {
    margin-top: -10px !important;
    transform: translateY(-100%) !important;
}

/* Popup positioning for markers in top half - moves popup below marker */
.popup-position-bottom {
    margin-top: 10px !important;
}

/* Style the close button */
.leaflet-popup-close-button {
    top: 5px !important;
    right: 5px !important;
    padding: 4px !important;
    width: 22px !important;
    height: 22px !important;
    background-color: white !important;
    border-radius: 50% !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2) !important;
    text-align: center;
    line-height: 14px;
    z-index: 1001;
}

/* Smooth animation */
.leaflet-fade-anim .leaflet-popup {
    animation: popupFadeIn 0.2s ease;
}

@keyframes popupFadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.custom-popup-content {
    display: flex;
    justify-content: center;
}

/* Legacy second .popup-card block (with .dog-sold / .listing-meta / .meta-item.separator
   rules for the old card structure) removed. The active .popup-card overrides live higher
   in this file, near the listing-card v2 rules. */

/* ADVERTS SECTION */
.listings-col {
    display: flex;
    flex-direction: column;
    width: 100%;
}

/* ============================================
   EMPTY STATE — rendered above the (empty) .listings-grid when $adverts is empty.
   Centered icon + heading + body + (optional) "Clear all filters" button.
   ============================================ */

.dfs-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 64px 24px;
    margin: 0 auto;
    max-width: 480px;
    color: var(--v2-fg);
}

.dfs-empty-icon {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: hsl(40, 33%, 92%);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
    color: var(--v2-muted);
}

.dfs-empty-icon svg {
    width: 36px;
    height: 36px;
    display: block;
}

.dfs-empty-heading {
    font-family: var(--v2-font) !important;
    font-weight: 600 !important;
    font-size: 20px !important;
    color: var(--v2-fg) !important;
    margin: 0 0 8px !important;
    letter-spacing: normal !important;
    line-height: 1.3 !important;
}

.dfs-empty-body {
    font-family: var(--v2-font);
    font-size: 14px;
    line-height: 1.6;
    color: var(--v2-muted);
    margin: 0 0 20px;
    letter-spacing: normal;
}

.dfs-empty-body a {
    color: var(--v2-primary);
    text-decoration: underline;
}

.dfs-empty-body a:hover {
    color: var(--v2-primary-hover);
}

.dfs-empty-clear {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 40px;
    padding: 0 20px;
    font-family: var(--v2-font);
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    background: var(--v2-primary);
    border-radius: 8px;
    text-decoration: none;
    transition: background-color 0.2s ease;
}

.dfs-empty-clear:hover {
    background: var(--v2-primary-hover);
    color: #fff;
    text-decoration: none;
}

/* ============================================
   LISTING CARDS — v2 Lovable-match
   Grid: 3 cols desktop / 2 tablet / 1 mobile (was 4/3/2/1).
   Card: rounded-xl, shadow-card → shadow-card-hover, hover lift,
         4:3 image with hover scale, title transitions to primary on hover.
   Badges: category pill (top-left, reuses .category-badge + .badge-* from home2.css),
           boosted ribbon (top-right corner, gold), photo count (bottom-right glass),
           verified-breeder inline icon next to seller name in footer.
   List view: image left (240px) + content right (existing .is-list-view modifier).
   ============================================ */

.listings-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

@media (max-width: 1024px) {
    .listings-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 640px) {
    .listings-grid {
        grid-template-columns: 1fr;
    }
}

/* Boost note — small pill above the grid that explains why boosted cards
   appear first. Uses --v2-accent (the BOOSTED ribbon gold) so it reads as
   "this is about the boosted ones". Hidden when there are no listings. */
.dfs-boost-note {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 14px;
    padding: 6px 12px;
    border: 1px solid rgba(212, 168, 71, 0.35);
    border-radius: 999px;
    background: rgba(212, 168, 71, 0.08);
    color: var(--v2-muted);
    font-family: var(--v2-font);
    font-size: 13px;
    line-height: 1.2;
}

.dfs-boost-note-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--v2-accent);
    flex: 0 0 8px;
}

.listing-card {
    position: relative;
    display: flex;
    flex-direction: column;
    background: var(--v2-bg-card);
    border-radius: 12px;
    overflow: hidden;
    text-decoration: none !important;
    color: var(--v2-fg) !important;
    box-shadow:
        0 1px 3px 0 hsla(0, 0%, 0%, 0.06),
        0 1px 2px -1px hsla(0, 0%, 0%, 0.06);
    transition:
        transform 0.3s ease,
        box-shadow 0.3s ease;
}

.listing-card:hover {
    transform: translateY(-4px);
    color: var(--v2-fg) !important;
    box-shadow:
        0 10px 25px -5px hsla(0, 0%, 0%, 0.1),
        0 8px 10px -6px hsla(0, 0%, 0%, 0.08);
}

/* Boosted variant — 2px gold ring (--v2-accent, same as BOOSTED ribbon).
   Implemented as an outer box-shadow rather than `border` so it doesn't
   shift the card layout, and stacks with the existing elevation shadow.
   Scoped to .listings-grid so the .popup-card map overlay (which carries
   its own elevation system) keeps its current look. */
.listings-grid .listing-card.boosted {
    box-shadow:
        0 0 0 2px var(--v2-accent),
        0 1px 3px 0 hsla(0, 0%, 0%, 0.06),
        0 1px 2px -1px hsla(0, 0%, 0%, 0.06);
}

.listings-grid .listing-card.boosted:hover {
    box-shadow:
        0 0 0 2px var(--v2-accent),
        0 10px 25px -5px hsla(0, 0%, 0%, 0.1),
        0 8px 10px -6px hsla(0, 0%, 0%, 0.08);
}

/* Image area — 4:3 aspect, hover-scaled inner image */
.listing-image {
    position: relative;
    aspect-ratio: 4 / 3;
    overflow: hidden;
    background: hsl(40, 33%, 96%);
    /* fallback while image loads */
    padding-top: 0;
    /* override legacy hack if any */
}

.listing-image img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: transform 0.5s ease;
}

.listing-card:hover .listing-image img {
    transform: scale(1.05);
}

/* Sold overlay — preserved, restyled */
.listing-sold {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3;
}

.listing-sold img {
    /* Override the descendant `.listing-image img` rule which absolutely-
       positions inside the image area at width/height 100% with inset:0 —
       that pins the sold badge to the corner instead of centering it. */
    position: static;
    inset: auto;
    width: auto;
    height: auto;
    /* max-width: 60%;
    max-height: 60%; */
    width: -webkit-fit-content;
    object-fit: contain;
}

/* Boosted ribbon — diagonal gold corner ribbon, top-right */
.listing-featured-ribbon {
    position: absolute;
    top: 0px;
    right: -15px;
    width: 110px;
    height: 110px;
    overflow: hidden;
    pointer-events: none;
    z-index: 2;
}

.listing-featured-ribbon span {
    position: absolute;
    top: 18px;
    right: -32px;
    transform: rotate(45deg);
    display: block;
    width: 150px;
    text-align: center;
    background: var(--v2-accent);
    color: #1a1a1a;
    font-family: var(--v2-font);
    font-weight: 700;
    font-size: 10px;
    letter-spacing: 0.08em;
    padding: 4px 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

/* Verified-breeder ribbon — same construction as the boosted ribbon above, so the two
   read as one system rather than two unrelated decorations. Both live in the top-right
   corner of the card image, so they cannot both sit at the same band position.

   The SLOT decides which band this one takes: slot 0 when it is the only ribbon, slot 1
   when BOOSTED already holds slot 0. Blade picks the slot, not CSS, because CSS cannot
   see whether the sibling was rendered -- and positioning it at slot 1 unconditionally
   is exactly what would leave BOOSTED's empty space above a lone VERIFIED ribbon.

   --ribbon-slot-1 is the one number to tune if the two bands sit too close or too far
   apart; every breakpoint override below re-declares it rather than repeating the rule. */
.listing-verified-ribbon {
    position: absolute;
    top: 9px;
    right: -45px;
    width: 110px;
    height: 110px;
    overflow: initial;
    pointer-events: none;
    z-index: 2;
    --ribbon-slot-1: 45px;
}

.listing-verified-ribbon span {
    position: absolute;
    top: 10px;
    right: -32px;
    transform: rotate(45deg);
    display: block;
    width: 200px;
    text-align: center;
    background: hsl(140, 50%, 46%);
    /* matches the tick this replaces */
    color: #fff;
    font-family: var(--v2-font);
    font-weight: 700;
    font-size: 10px;
    letter-spacing: 0.08em;
    padding: 4px 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

/* Paired with BOOSTED, the two bands touched exactly and read as a single two-tone
   wedge. The bands are rotated 45deg, so a vertical offset V yields a PERPENDICULAR
   separation of V*cos(45) = V*0.707 -- the old 28px offset gave 19.8px against a band
   ~20px tall, i.e. zero gap. Perpendicular gap G needs V = (bandHeight + G) / 0.707.

   58px here is a ~8px gap. It also needs a bigger clip box: further from the corner the
   band crosses a shorter chord, so the 110px box that suits slot 0 truncates slot 1.
   Only the slot-1 case is enlarged, so a lone VERIFIED ribbon is pixel-identical to
   what it is today. Both numbers are meant to be tuned by eye. */
.listing-verified-ribbon.ribbon-slot-1 {
    width: 140px;
    height: 150px;
    top: -12px;
    right: -15px;
}

.listing-verified-ribbon.ribbon-slot-1 span {
    top: var(--ribbon-slot-1);
}

/* Photo count badge — bottom-right, dark glass with Camera icon */
.listing-image-count {
    position: absolute;
    right: 12px;
    bottom: 12px;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    color: #fff;
    font-family: var(--v2-font);
    font-size: 12px;
    font-weight: 500;
}

.listing-image-count svg {
    width: 12px;
    height: 12px;
    display: block;
}

/* Body */
.listing-content {
    display: flex;
    flex-direction: column;
    padding: 16px;
    gap: 4px;
}

.listing-content .listing-title {
    font-family: var(--v2-font) !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    color: var(--v2-fg) !important;
    line-height: 1.4 !important;
    letter-spacing: normal !important;
    margin: 0 0 4px !important;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    transition: color 0.2s ease;
}

.listing-card:hover .listing-title {
    color: var(--v2-primary) !important;
}

.listing-breed {
    font-family: var(--v2-font);
    font-size: 12px;
    color: var(--v2-muted);
    margin: 0 0 8px;
    letter-spacing: normal;
}

/* Price + location row */
.listing-price-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.listing-price {
    font-family: var(--v2-font);
    font-size: 18px;
    font-weight: 700;
    color: var(--v2-fg);
    letter-spacing: normal;
}

.listing-location {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-family: var(--v2-font);
    font-size: 12px;
    color: var(--v2-muted);
    letter-spacing: normal;
    min-width: 0;
}

.listing-location svg {
    width: 12px;
    height: 12px;
    flex-shrink: 0;
    display: block;
}

/* Footer row — top-border separator with seller (verified icon inline) + date */
.listing-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--v2-border);
}

.listing-seller {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: var(--v2-font);
    font-size: 12px;
    color: var(--v2-muted);
    letter-spacing: normal;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* text-overflow is inert on the inline-flex .listing-seller itself (flex
   containers don't ellipsize); the child span is where the dots render. */
.listing-seller-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.listing-time {
    font-family: var(--v2-font);
    font-size: 12px;
    color: var(--v2-muted);
    flex-shrink: 0;
    letter-spacing: normal;
}

/* View count (eye icon + number). margin-left:auto pins views + date to the
   right so the flexible seller name keeps the leftover space. */
.listing-views {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-left: auto;
    font-family: var(--v2-font);
    font-size: 12px;
    color: var(--v2-muted);
    flex-shrink: 0;
    letter-spacing: normal;
}

.listing-views svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    display: block;
}

/* =====================
   7. Sponsored Section
===================== */
.partner-footer {
    /* max-width: 85%; */
    height: 330px;
    padding-top: 20px !important;
    padding-bottom: 20px !important;
}

.partner-footer .card {
    display: block;
    background: #fff;
    border: none;
    border-radius: 10px;
    text-decoration: none;
    color: var(--text-color);
    transition: all 0.3s ease;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
    width: 290px;
    height: 290px;
}

.partner-footer .card img {
    width: 290px;
    height: 290px;
}

.partner-footer .swiper {
    padding: 20px 0;
}

.partner-footer .swiper-slide {
    display: flex;
    justify-content: center;
}

.partner-footer .swiper-button-next,
.partner-footer .swiper-button-prev {
    color: #0c5b34;
}

.partner-footer .swiper-button-next:after,
.partner-footer .swiper-button-prev:after {
    font-weight: 900;
}

.partner-footer .card:hover {
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.432);
    transform: translateY(-3px);
}

/* =====================
   8. Pagination
===================== */
.pagination-container {
    margin: 1.5rem 0;
    display: flex;
    justify-content: center;
}

.pagination {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 26px;
}

.page-btn {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    background: transparent;
    color: var(--text-green);
    padding: 0px;
    padding-bottom: 5px;
    min-width: 8px;
    text-decoration: none;
    font-size: 16px;
    font-family: var(--v2-font);
    font-weight: 400;
    letter-spacing: 0;
    vertical-align: middle;
    cursor: pointer;
    line-height: 1;
}

.page-btn:hover:not(.disabled) {
    opacity: 0.9;
}

.page-btn.disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.page-btn.active {
    border-bottom: 1px solid var(--text-green);
}

.page-dots {
    align-self: center;
    color: #000;
    padding: 0 0.25rem;
}

/* =====================
   9. Responsive Breakpoints
===================== */
/* Large devices (desktops, < 1200px) */
@media (max-width: 1199.98px) {
    .sponsored-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 1025px) {
    .listings-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Medium devices (tablets, < 992px) */
@media (max-width: 991.98px) {
    .map-col {
        height: 100vh;
        max-height: 600px;
        position: relative;
    }

    .sponsored-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Small devices (landscape phones, < 768px) */
@media (max-width: 768px) {
    .page-title {
        font-size: 1.75rem;
        padding: 1.5rem 1rem;
    }

    .listings-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .sponsored-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }

    .map-col {
        margin-top: 15px;
        height: calc(100vh - 60px);
        max-height: 500px;
        position: relative !important;
        z-index: 50;
    }

    #map {
        height: 100% !important;
    }

    /* Mobile menu styles */
    .mobile-menu {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background-color: #165636;
        z-index: 1500;
        /* Higher than filters but lower than modals */
        overflow-y: auto;
    }

    .mobile-menu-content {
        padding: 1rem;
    }
}

/* Extra small devices (portrait phones, < 576px) */
@media (max-width: 575.98px) {
    html {
        font-size: 14px;
    }

    .dogs-for-sale {
        padding: 0 0.5rem;
    }

    .listings-grid {
        grid-template-columns: 1fr;
    }

    .map-col {
        height: 80vh;
    }

    .mobile-menu-toggle {
        display: block;
    }

    .page-title {
        font-size: 1.5rem;
        padding: 1rem;
    }
}

@media only screen and (max-width: 500px) {
    /* Single-column already enforced at <=640px in the main .listings-grid rule, but keep
       an explicit fallback here for older browsers or unusual breakpoint configs. */
    .listings-grid {
        grid-template-columns: 1fr;
    }

    /* Tighter padding on the smallest screens; main rule is 16px, this drops to 12px. */
    .listing-content {
        padding: 12px;
    }

    .listing-price {
        font-size: 16px;
    }
}

/* =====================
   Custom Marker
===================== */
.custom-marker .marker-content {
    font-family: var(--v2-font);
    font-size: 14px;
    font-weight: 600;
    color: #333;
    width: 50px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

/* =====================
   Typography Overrides for Custom Fonts
===================== */
.custom-marker,
.listing-content {
    font-family: var(--v2-font);
}
