.listings-layout {
    display: flex;
}

.categories-sidebar {
    width: 250px;
    flex-shrink: 0;
    padding: 2rem;
    border-right: 1px solid #2a2a2a;
}

.categories-sidebar h3 {
    color: #e8c97a;
    margin: 0 0 1rem;
    font-size: 1.05rem;
}

/* ─── Category nav (taxonomy-driven) ─────────────────────────────────────────
   Desktop: a clean vertical list. Each row is a full-width button so the hit
   area and alignment are consistent. The active category's subcategories appear
   indented directly beneath the category row. */
.category-nav {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.subcat-row {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.cat-item,
.subcat-item {
    /* Reset native button styling so these read as nav links */
    appearance: none;
    -webkit-appearance: none;
    font: inherit;
    text-align: left;
    width: 100%;
    border: none;
    background: transparent;
    color: #ddd;
    cursor: pointer;
    border-radius: 6px;
    transition: background 0.15s, color 0.15s;
}

.cat-item {
    display: flex;
    align-items: center;
    padding: 0.55rem 0.7rem;
    font-size: 0.95rem;
}

.cat-item:hover { background: #1f1f1f; color: #fff; }

.cat-item.is-active {
    background: #e8c97a;
    color: #0d0d0d;
    font-weight: 700;
}

/* Subcategory list — nested directly under the active category, indented with a
   connecting rail so it reads as a child of the category above it. */
.subcat-row {
    margin: 0.1rem 0 0.4rem 1.2rem;
    padding-left: 0.7rem;
    border-left: 2px solid #3a3a3a;
}

.subcat-item {
    padding: 0.4rem 0.6rem;
    font-size: 0.85rem;
    color: #aaa;
}

.subcat-item:hover { background: #1f1f1f; color: #fff; }

.subcat-item.is-active {
    color: #e8c97a;
    font-weight: 600;
}

/* Add styles for listings page */
.listings-page {
    padding: 2rem;
    flex-grow: 1;
}

/* ─── "Anuncios destacados" strip (paid featured listings) ───────────────────── */
.featured-strip {
    margin: 0 0 1.5rem;
    padding: 1rem 1.1rem 1.2rem;
    border: 1px solid #6b5a2a;
    border-radius: 10px;
    background: linear-gradient(180deg, rgba(232,201,122,0.06), rgba(232,201,122,0.02));
}

.featured-strip.hidden { display: none; }

.featured-strip-title {
    margin: 0 0 0.9rem;
    color: #e8c97a;
    font-size: 1.05rem;
}

/* Tighter grid for the strip so several featured cards fit in the row. */
.featured-strip-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}

.filters {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.filters select, .filters input, .filters button {
    padding: 0.5rem;
    border-radius: 5px;
    border: 1px solid #e8c97a;
    background-color: #1a1a1a;
    color: #fff;
}

.filters button {
    background-color: #e8c97a;
    color: #0d0d0d;
    cursor: pointer;
}

.listings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1.5rem;
}

.listing-item {
    background-color: #1a1a1a;
    border: 1px solid #333;
    border-radius: 8px;
    overflow: hidden;
    text-decoration: none;
    color: #fff;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    cursor: pointer;
    display: block;
}

.listing-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.4);
}

.listing-item:focus-visible {
    outline: 2px solid #e8c97a;
    outline-offset: 2px;
}

.listing-item img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    display: block;
    /* Static background reserves space and prevents CLS while lazy-loading */
    background-color: #1a1a1a;
}

.listing-item-content {
    padding: 1rem;
}

.listing-item-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.4rem;
    margin-top: 0.5rem;
    flex-wrap: wrap;
}

/* Badge + WA button grouped on the right side of the meta row.
   margin-left:auto pushes the group right; flex-wrap lets them
   drop to a second line on very narrow cards without overflowing. */
.listing-item-badges {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-wrap: wrap;
    margin-left: auto;
}

/* WhatsApp contact button — compact, card-inline */
.listing-wa-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.32rem;
    background: #25D366;
    color: #fff;
    text-decoration: none;
    font-size: 0.76rem;
    font-weight: 600;
    padding: 0.28rem 0.6rem;
    border-radius: 6px;
    transition: background 0.15s, transform 0.1s;
    white-space: nowrap;
    line-height: 1.4;
}

.listing-wa-btn:hover {
    background: #1dbe59;
    transform: translateY(-1px);
}

.listing-wa-btn:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

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

.listing-item-title {
    font-size: 1.2rem;
    font-weight: bold;
    margin-bottom: 0.5rem;
}

.listing-item-price {
    color: #e8c97a;
    font-weight: bold;
    flex-shrink: 0; /* never compress price — badges wrap instead */
}

.listing-item-subcat {
    display: inline-block;
    font-size: 0.7rem;
    color: #888;
    background: #232323;
    border: 1px solid #303030;
    border-radius: 4px;
    padding: 0.1rem 0.4rem;
    margin-bottom: 0.35rem;
}

.listing-item-location {
    font-size: 0.8rem;
    color: #888;
    margin-top: 0.4rem;
}

/* ─── Search bar ───────────────────────────────────────────────────────────── */
.search-bar {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.search-bar input[type="search"] {
    flex: 1;
    padding: 0.55rem 0.9rem;
    border-radius: 6px;
    border: 1px solid #e8c97a;
    background: #1a1a1a;
    color: #fff;
    font-size: 0.95rem;
}

.search-bar input[type="search"]::placeholder { color: #666; }

.search-bar button {
    padding: 0.55rem 1.2rem;
    background: #e8c97a;
    color: #0d0d0d;
    border: none;
    border-radius: 6px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s;
}

.search-bar button:hover { background: #d4b468; }

/* ─── Filter row additions ──────────────────────────────────────────────────── */
.filters select {
    padding: 0.5rem;
    border-radius: 5px;
    border: 1px solid #e8c97a;
    background-color: #1a1a1a;
    color: #fff;
    cursor: pointer;
}

.btn-secondary {
    background: transparent !important;
    color: #999 !important;
    border: 1px solid #444 !important;
    cursor: pointer;
}
.btn-secondary:hover { border-color: #888 !important; color: #ccc !important; }

/* ─── Count label ───────────────────────────────────────────────────────────── */
.listings-count {
    font-size: 0.8rem;
    color: #666;
    margin-bottom: 1rem;
    min-height: 1.2em;
}

/* ─── Condition badge ───────────────────────────────────────────────────────── */
.badge-condition {
    font-size: 0.68rem;
    font-weight: 600;
    padding: 0.18rem 0.45rem;
    border-radius: 4px;
    background: #2a2a2a;
    color: #aaa;
    border: 1px solid #333;
    white-space: nowrap;
}

/* ─── Pagination ────────────────────────────────────────────────────────────── */
.listings-pagination {
    display: flex;
    justify-content: center;
    gap: 0.4rem;
    margin-top: 2rem;
    flex-wrap: wrap;
}

.page-btn {
    padding: 0.4rem 0.75rem;
    border-radius: 5px;
    border: 1px solid #333;
    background: #1a1a1a;
    color: #ccc;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.15s, border-color 0.15s;
    min-width: 36px;
}

.page-btn:hover:not(:disabled) {
    background: #2a2a2a;
    border-color: #e8c97a;
    color: #fff;
}

.page-btn-active {
    background: #e8c97a;
    color: #0d0d0d;
    border-color: #e8c97a;
    font-weight: 700;
}

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

/* ─── Tablet / mobile (≤900px) ───────────────────────────────────────────────
   The sidebar moves above the grid but KEEPS the clean desktop layout: a vertical
   list of full-width category rows, with the active category's subcategories
   nested + indented directly beneath it. (Same accordion as laptop, just full
   width.) */
@media (max-width: 900px) {
    .listings-layout {
        flex-direction: column;
    }

    .categories-sidebar {
        width: 100%;
        flex-shrink: 1;
        padding: 1rem 1.25rem;
        border-right: none;
        border-bottom: 1px solid #2a2a2a;
    }

    .categories-sidebar h3 {
        margin-bottom: 0.6rem;
    }

    .listings-page { padding: 1rem; }
}

/* ─── Small phones (≤480px) ──────────────────────────────────────────────────
   Two-column product grid so cards aren't full-width-huge on small screens. */
@media (max-width: 480px) {
    .listings-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }

    .listing-item img { height: 130px; }
    .listing-item-content { padding: 0.6rem; }
    .listing-item-title { font-size: 0.95rem; }
}
