/* Gun Dog Equipment — public listing + detail.
   All selectors scoped under .gde-* so they coexist with legacy CSS (no specificity wars).
   Uses the v2 design tokens (var(--v2-*)) with fallbacks; no ad/advert/sponsored class tokens. */

.gde-page,
.gde-detail {
    --gde-primary: var(--v2-primary, #2d5a3d);
    --gde-fg: var(--v2-fg, #1f2937);
    --gde-muted: var(--v2-muted, #6b7280);
    --gde-border: var(--v2-border, #e5e7eb);
    --gde-bg: var(--v2-bg, #ffffff);
    --gde-soft: #f7f8f7;
    font-family: var(--v2-font, 'Plus Jakarta Sans', system-ui, sans-serif);
    color: var(--gde-fg);
    padding: 24px 0 64px;
}

/* Match the dogs-for-sale width strategy — beat the global .container-fluid { width:95% !important }. */
.gde-page .container-fluid,
.gde-detail .container-fluid {
    width: 100% !important;
    max-width: 1400px !important;
    margin-left: auto !important;
    margin-right: auto !important;
    padding-left: 16px;
    padding-right: 16px;
}

.gde-page svg,
.gde-detail svg { display: block; }

.gde-visually-hidden {
    position: absolute !important;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0);
    white-space: nowrap; border: 0;
}

/* ---------- Heading row + controls ---------- */
.gde-heading-row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}
.gde-heading {
    font-size: clamp(1.4rem, 4vw, 2rem);
    font-weight: 700;
    color: var(--gde-primary);
    margin: 0;
}
.gde-result-count {
    margin: 4px 0 0;
    color: var(--gde-muted);
    font-size: 0.9rem;
}
.gde-controls {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.gde-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 16px;
    border-radius: 8px;
    border: 1px solid transparent;
    font-size: 0.9rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    text-decoration: none;
    line-height: 1;
    transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}
.gde-btn-primary {
    background: var(--gde-primary);
    color: #fff;
}
.gde-btn-primary:hover { background: #244a32; color: #fff; }
.gde-btn-outline {
    background: #fff;
    border-color: var(--gde-border);
    color: var(--gde-fg);
}
.gde-btn-outline:hover { border-color: var(--gde-primary); color: var(--gde-primary); }
.gde-filters-mobile { display: none; }

.gde-sort-select,
.gde-filter-select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-color: #fff;
    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>");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 11px 7px;
    border: 1px solid var(--gde-border);
    border-radius: 8px;
    padding: 9px 34px 9px 12px;
    font-size: 0.9rem;
    font-family: inherit;
    color: var(--gde-fg);
    cursor: pointer;
    max-width: 100%;
}

.gde-view-toggle {
    display: inline-flex;
    border: 1px solid var(--gde-border);
    border-radius: 8px;
    overflow: hidden;
}
.gde-view-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 38px;
    background: #fff;
    border: 0;
    color: var(--gde-muted);
    cursor: pointer;
}
.gde-view-btn + .gde-view-btn { border-left: 1px solid var(--gde-border); }
.gde-view-btn.is-active { background: var(--gde-primary); color: #fff; }

/* ---------- Layout: sidebar + content ---------- */
.gde-layout { display: block; }
.gde-content { min-width: 0; }

.gde-filter-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .5);
    opacity: 0;
    pointer-events: none;
    transition: opacity .3s ease;
    /* Above the v2 header (z 1500): on mobile the filter is a modal drawer, so it + its backdrop
       must sit over everything, keeping the close button reachable. Reset to a low z on desktop. */
    z-index: 1599;
}
.gde-filter-overlay.is-open { opacity: 1; pointer-events: auto; }

.gde-filter-sidebar {
    position: fixed;
    top: 0; right: 0; bottom: 0;
    width: min(320px, 100%);
    background: #fff;
    transform: translateX(100%);
    transition: transform .3s ease;
    z-index: 1600; /* mobile drawer sits above the header (1500); lowered to 1 on desktop below */
    padding: 20px;
    overflow-y: auto;
    box-shadow: -4px 0 24px rgba(0, 0, 0, .12);
}
.gde-filter-sidebar.is-open { transform: translateX(0); }

.gde-filter-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}
.gde-filter-title { font-size: 1.1rem; font-weight: 700; margin: 0; color: var(--gde-fg); }
.gde-filter-close { background: none; border: 0; cursor: pointer; color: var(--gde-muted); padding: 4px; }

.gde-filter-field { margin-bottom: 16px; }
.gde-filter-label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--gde-fg);
    margin-bottom: 6px;
}
.gde-filter-select { width: 100%; }
.gde-filter-price-row { display: flex; gap: 10px; }
.gde-filter-input {
    width: 100%;
    border: 1px solid var(--gde-border);
    border-radius: 8px;
    padding: 9px 12px;
    font-size: 0.9rem;
    font-family: inherit;
    color: var(--gde-fg);
}
.gde-filter-apply {
    width: 100%;
    background: var(--gde-primary);
    color: #fff;
    border: 0;
    border-radius: 8px;
    padding: 11px;
    font-size: 0.92rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    margin-top: 4px;
}
.gde-filter-apply:hover { background: #244a32; }
.gde-filter-clear {
    display: block;
    text-align: center;
    margin-top: 10px;
    color: var(--gde-muted);
    font-size: 0.85rem;
    text-decoration: underline;
}

/* ---------- Listing grid + cards ---------- */
.gde-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 18px;
}
.gde-card {
    display: flex;
    flex-direction: column;
    background: #fff;
    border: 1px solid var(--gde-border);
    border-radius: 12px;
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    transition: box-shadow .15s ease, transform .15s ease;
}
.gde-card:hover { box-shadow: 0 8px 24px rgba(0, 0, 0, .1); transform: translateY(-2px); }
.gde-card-image {
    position: relative;
    aspect-ratio: 4 / 3;
    background: var(--gde-soft);
    overflow: hidden;
}
.gde-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.gde-card-cat {
    position: absolute;
    top: 10px;
    left: 10px;
    background: rgba(45, 90, 60, .92);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 600;
    padding: 4px 9px;
    border-radius: 6px;
}
.gde-card-imgcount {
    position: absolute;
    bottom: 10px;
    right: 10px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(0, 0, 0, .6);
    color: #fff;
    font-size: 0.72rem;
    padding: 3px 8px;
    border-radius: 6px;
}
.gde-card-sold {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, .35);
}
.gde-card-sold span {
    background: #d40000;
    color: #fff;
    font-weight: 700;
    letter-spacing: .08em;
    padding: 6px 18px;
    border-radius: 6px;
    transform: rotate(-8deg);
}
.gde-card-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 8px; }
.gde-card-title {
    font-size: 0.98rem;
    font-weight: 600;
    margin: 0;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.gde-card-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.gde-card-condition {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 999px;
    text-transform: capitalize;
}
.gde-condition-new { background: #e7f5ec; color: #1b7a44; }
.gde-condition-used { background: #eef1f5; color: #475569; }
.gde-condition-refurbished { background: #fff4e5; color: #b15c00; }
.gde-card-brand { font-size: 0.78rem; color: var(--gde-muted); }
.gde-card-price-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: 2px;
}
.gde-card-price { font-size: 1.05rem; font-weight: 700; color: var(--gde-primary); }
.gde-card-location {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.78rem;
    color: var(--gde-muted);
}
.gde-card-views {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-left: auto; /* right-aligns the view count in the meta row */
    font-size: 0.78rem;
    color: var(--gde-muted);
}

/* List-view modifier */
.gde-grid.is-list-view { grid-template-columns: 1fr; }
.gde-grid.is-list-view .gde-card { flex-direction: row; }
.gde-grid.is-list-view .gde-card-image { width: 220px; flex-shrink: 0; aspect-ratio: 4 / 3; }
.gde-grid.is-list-view .gde-card-body { flex: 1; justify-content: center; }
.gde-grid.is-list-view .gde-card-title { -webkit-line-clamp: 1; }

/* ---------- Empty state ---------- */
.gde-empty-state {
    text-align: center;
    padding: 56px 20px;
    border: 1px dashed var(--gde-border);
    border-radius: 12px;
    color: var(--gde-muted);
}
.gde-empty-icon { display: flex; justify-content: center; margin-bottom: 14px; color: var(--gde-border); }
.gde-empty-icon svg { color: var(--gde-muted); }
.gde-empty-heading { font-size: 1.15rem; font-weight: 700; color: var(--gde-fg); margin: 0 0 6px; }
.gde-empty-body { margin: 0 0 16px; }
.gde-empty-clear {
    display: inline-block;
    background: var(--gde-primary);
    color: #fff;
    padding: 9px 18px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
}

/* ---------- Pagination ---------- */
.gde-pagination {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
    margin-top: 32px;
}
.gde-page-btn {
    min-width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 10px;
    border: 1px solid var(--gde-border);
    border-radius: 8px;
    background: #fff;
    color: var(--gde-fg);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 600;
}
.gde-page-btn:hover { border-color: var(--gde-primary); color: var(--gde-primary); }
.gde-page-btn.is-active { background: var(--gde-primary); border-color: var(--gde-primary); color: #fff; }
.gde-page-btn.is-disabled { opacity: .4; pointer-events: none; }
.gde-page-dots { display: inline-flex; align-items: center; padding: 0 4px; color: var(--gde-muted); }

/* ---------- Detail page ---------- */
.gde-breadcrumb {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--gde-muted);
    margin-bottom: 18px;
}
.gde-breadcrumb a { color: var(--gde-primary); text-decoration: none; }
.gde-breadcrumb a:hover { text-decoration: underline; }

.gde-detail-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 28px;
}
.gde-gallery-main {
    position: relative;
    aspect-ratio: 4 / 3;
    background: var(--gde-soft);
    border: 1px solid var(--gde-border);
    border-radius: 12px;
    overflow: hidden;
}
.gde-gallery-main img { width: 100%; height: 100%; object-fit: contain; }
.gde-detail-sold {
    position: absolute;
    top: 14px;
    left: 14px;
}
.gde-detail-sold span {
    background: #d40000;
    color: #fff;
    font-weight: 700;
    letter-spacing: .08em;
    padding: 6px 16px;
    border-radius: 6px;
}
.gde-gallery-thumbs {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    overflow-x: auto;
    padding-bottom: 4px;
}
.gde-thumb {
    flex-shrink: 0;
    width: 72px;
    height: 72px;
    border: 2px solid transparent;
    border-radius: 8px;
    overflow: hidden;
    padding: 0;
    cursor: pointer;
    background: var(--gde-soft);
}
.gde-thumb.is-active { border-color: var(--gde-primary); }
.gde-thumb img { width: 100%; height: 100%; object-fit: cover; }

/* Slider controls over the main image (rendered only when >1 image). */
.gde-gallery-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    background: rgba(255, 255, 255, .9);
    border: 1px solid var(--gde-border);
    border-radius: 50%;
    color: var(--gde-fg);
    cursor: pointer;
    z-index: 2;
    transition: background-color .15s ease, color .15s ease;
}
.gde-gallery-nav:hover { background: #fff; color: var(--gde-primary); }
.gde-gallery-prev { left: 10px; }
.gde-gallery-next { right: 10px; }
.gde-gallery-counter {
    position: absolute;
    bottom: 10px;
    right: 10px;
    display: inline-flex;
    align-items: center;
    background: rgba(0, 0, 0, .6);
    color: #fff;
    font-size: .78rem;
    font-weight: 600;
    padding: 3px 9px;
    border-radius: 6px;
    z-index: 2;
}

.gde-detail-title { font-size: clamp(1.3rem, 3vw, 1.7rem); font-weight: 700; margin: 0 0 8px; color: var(--gde-fg); }
.gde-detail-price { font-size: 1.6rem; font-weight: 700; color: var(--gde-primary); margin-bottom: 16px; }

.gde-detail-specs { list-style: none; margin: 0 0 20px; padding: 0; border-top: 1px solid var(--gde-border); }
.gde-detail-specs li {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 10px 0;
    border-bottom: 1px solid var(--gde-border);
    font-size: 0.92rem;
}
.gde-detail-specs li span { color: var(--gde-muted); }
.gde-detail-specs li strong { font-weight: 600; text-align: right; }
.gde-detail-specs .gde-condition-new,
.gde-detail-specs .gde-condition-used,
.gde-detail-specs .gde-condition-refurbished {
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 0.8rem;
}

.gde-detail-contact { display: flex; flex-direction: column; gap: 10px; margin-bottom: 24px; }
.gde-contact-btn { justify-content: center; padding: 12px 16px; }
.gde-contact-note { font-size: 0.82rem; color: var(--gde-muted); margin: 2px 0 0; }
/* Owner viewing their own listing — make it unmistakable. */
.gde-owner-note {
    color: #d40000;
    text-align: center;
    font-style: italic;
    font-weight: 600;
    font-size: 0.95rem;
}

.gde-detail-description h2 { font-size: 1.05rem; font-weight: 700; margin: 0 0 8px; color: var(--gde-fg); }
.gde-detail-description p { color: var(--gde-fg); line-height: 1.6; margin: 0; }

/* ---------- Responsive ---------- */
@media (min-width: 768px) {
    .gde-detail-grid { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); align-items: start; }
}

@media (min-width: 992px) {
    .gde-layout {
        display: flex;
        gap: 28px;
        align-items: flex-start;
    }
    .gde-content { flex: 1; }
    .gde-filter-overlay, .gde-filter-close { display: none; }
    .gde-filter-sidebar {
        position: sticky;
        top: 96px;
        right: auto; bottom: auto;
        width: 268px;
        flex-shrink: 0;
        transform: none;
        border: 1px solid var(--gde-border);
        border-radius: 12px;
        box-shadow: none;
        max-height: calc(100vh - 120px);
        /* Inline sticky sidebar on desktop — must stay BELOW the header so its dropdown still
           paints over the sidebar (MISTAKE-027). The high mobile-drawer z-index doesn't apply here. */
        z-index: 1;
    }
}

/* Below 992px the sidebar is a drawer — show the toggle button. */
@media (max-width: 991.98px) {
    .gde-filters-mobile { display: inline-flex; }
}

@media (max-width: 575.98px) {
    .gde-controls { width: 100%; }
    .gde-sort-form { flex: 1; }
    .gde-sort-select { width: 100%; }
    .gde-sell-cta { display: none; }
    .gde-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
    .gde-grid.is-list-view .gde-card-image { width: 120px; }
}

/* Very narrow phones — stack each control on its own full-width row so nothing
   gets squeezed (the sort dropdown was truncating to "N…" at ~360px). */
@media (max-width: 399.98px) {
    .gde-controls {
        flex-direction: column;
        align-items: stretch;
    }
    .gde-controls > .gde-filters-mobile,
    .gde-controls > .gde-sort-form,
    .gde-controls > .gde-view-toggle {
        width: 100%;
    }
    .gde-filters-mobile { justify-content: center; }
    .gde-view-toggle { display: flex; }
    .gde-view-btn { flex: 1; }
}
