@import url('https://fonts.googleapis.com/css2?family=Bebas+Neue&display=swap');
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600&display=swap');

:root {
    --black:    #1a1a1a;
    --white:    #ffffff;
    --gray-1:   #f5f5f5;
    --gray-2:   #e8e8e8;
    --gray-3:   #aaaaaa;
    --gray-4:   #666666;
    --yellow:   #f5c400;
    --yellow-d: #c49a00;
    --yellow-bg:#fffbe6;
    --accent:   #e8001c;
    --radius:   14px;
    --card-shadow: 0 2px 16px rgba(0,0,0,0.07);
    --font-display: 'Bebas Neue', sans-serif;
    --font-body:    'DM Sans', sans-serif;
}

*, *::before, *::after { margin:0; padding:0; box-sizing:border-box; }

body {
    font-family: var(--font-body);
    background: var(--gray-1);
    color: var(--black);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* =================== HEADER =================== */
.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--white);
    border-bottom: 1px solid var(--gray-2);
    transition: transform 0.3s ease;
}

.site-header.hidden { transform: translateY(-100%); }

.header-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 10px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}

.logo-wrap { flex-shrink: 0; }
.logo-wrap img { width: 100%; max-width: 9rem; height: auto; }

.nav-pill {
    background: var(--black);
    border-radius: 50px;
    padding: 6px 10px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.nav-pill a {
    color: var(--white);
    text-decoration: none;
    font-family: var(--font-display);
    font-size: 17px;
    letter-spacing: 2px;
    padding: 9px 16px;
    border-radius: 30px;
    transition: background 0.25s, color 0.25s;
    white-space: nowrap;
    display: flex;
    align-items: center;
}
.nav-pill a:hover { background: #333; color: var(--white); }
.nav-pill a.active { background: var(--yellow); color: var(--black); }
.nav-pill a svg { width: 20px; height: 20px; stroke: currentColor; }

.hamburger {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
}
.hamburger span {
    display: block;
    width: 26px;
    height: 2px;
    background: var(--black);
    border-radius: 2px;
    transition: all 0.3s;
}
.hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger.open span:nth-child(2) { opacity: 0; }
.hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.mobile-nav {
    display: none;
    flex-direction: column;
    background: #111;
    border-top: 2px solid var(--yellow);
    padding: 16px 24px 20px;
    gap: 4px;
}
.mobile-nav.open { display: flex; }
.mobile-nav a {
    color: var(--gray-3);
    text-decoration: none;
    font-family: var(--font-display);
    font-size: 22px;
    letter-spacing: 2px;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    transition: color 0.2s;
}
.mobile-nav a:hover { color: var(--yellow); }

/* =================== SEARCH BAR =================== */
.search-bar-wrap {
    background: var(--white);
    padding: 20px 32px;
    border-bottom: 1px solid var(--gray-2);
    position: sticky;
    top: 0;
    z-index: 90;
    transition: top 0.3s ease;
}

.site-header.hidden ~ .search-bar-wrap { top: 0; }

.search-bar {
    max-width: 860px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--gray-1);
    border: 1.5px solid var(--gray-2);
    border-radius: 50px;
    padding: 6px 8px 6px 18px;
    transition: border-color 0.25s;
}
.search-bar:focus-within { border-color: var(--black); }

.search-icon { width: 18px; height: 18px; stroke: var(--gray-3); flex-shrink: 0; }

.search-bar input {
    flex: 1;
    border: none;
    background: transparent;
    font-family: var(--font-body);
    font-size: 15px;
    color: var(--black);
    outline: none;
}
.search-bar input::placeholder { color: var(--gray-4); }

.btn-filter-toggle {
    display: flex;
    align-items: center;
    gap: 7px;
    background: var(--black);
    color: var(--white);
    border: none;
    border-radius: 50px;
    padding: 9px 18px;
    font-family: var(--font-display);
    font-size: 15px;
    letter-spacing: 1.5px;
    cursor: pointer;
    transition: background 0.25s;
    white-space: nowrap;
    flex-shrink: 0;
    font-weight: 700;
}
.btn-filter-toggle:hover { background: #333; }
.btn-filter-toggle svg { width: 16px; height: 16px; }

/* =================== LAYOUT =================== */
.marketplace-layout {
    display: flex;
    align-items: flex-start;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
    padding: 32px 32px 64px;
    gap: 32px;
    flex: 1;
}

/* ========== SIDEBAR ========== */
.filters-sidebar {
    width: 260px;
    flex-shrink: 0;
    background: var(--white);
    border: 2px solid var(--gray-2);
    border-top: 4px solid var(--yellow);
    border-radius: var(--radius);
    padding: 24px 20px;
    position: sticky;
    top: calc(var(--header-h) + 54px + 16px);
    max-height: calc(100vh - var(--header-h) - 54px - 32px);
    overflow-y: auto;
}

.filters-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}
.filters-header h2 {
    font-family: var(--font-display);
    font-size: 1.4rem;
    letter-spacing: 2px;
    color: var(--black);
}
.btn-clear-filters {
    background: none;
    border: none;
    font-family: var(--font-body);
    font-size: 0.82rem;
    color: var(--gray-4);
    cursor: pointer;
    text-decoration: underline;
    padding: 0;
}
.btn-clear-filters:hover { color: var(--yellow-d); }

.filter-group {
    margin-bottom: 18px;
    display: flex;
    flex-direction: column;
    gap: 7px;
}
.filter-label {
    font-family: var(--font-display);
    font-size: 13px;
    letter-spacing: 1.5px;
    color: var(--black);
}
.filter-group select,
.filter-group input[type="number"],
.filter-group input[type="text"] {
    width: 100%;
    padding: 9px 14px;
    border: 1.5px solid var(--gray-2);
    border-radius: 50px;
    font-family: var(--font-body);
    font-size: 14px;
    color: var(--black);
    background: var(--gray-1);
    outline: none;
    appearance: none;
    -webkit-appearance: none;
    transition: border-color 0.2s;
}
.filter-group select:focus,
.filter-group input:focus { border-color: var(--yellow); background: var(--white); }

.range-row {
    display: flex;
    align-items: center;
    gap: 8px;
}
.range-row input { width: 0; flex: 1; }
.range-row span { color: var(--gray-3); font-size: 0.85rem; flex-shrink: 0; }

.check-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    cursor: pointer;
}
.check-group input[type="checkbox"] {
    accent-color: var(--yellow);
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.btn-apply-filters {
    width: 100%;
    background: var(--yellow);
    color: var(--black);
    border: none;
    border-radius: 50px;
    padding: 12px;
    font-family: var(--font-display);
    font-size: 16px;
    letter-spacing: 2px;
    cursor: pointer;
    margin-top: 8px;
    transition: background 0.25s;
    font-weight: 700;
}
.btn-apply-filters:hover { background: var(--yellow-d); }

/* ========== GRID ========== */
.vehicles-main { flex: 1; min-width: 0; }

.results-count {
    font-size: 0.88rem;
    color: var(--gray-4);
    margin-bottom: 18px;
    letter-spacing: 0.3px;
}

.vehicles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 24px;
}

/* ========== CARD ========== */
.vehicle-card {
    background: var(--white);
    border: 1px solid var(--gray-2);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--card-shadow);
    display: flex;
    flex-direction: column;
    transition: transform 0.25s, box-shadow 0.25s;
    animation: fadeUp 0.4s ease both;
    border-top: 3px solid var(--yellow);
}
.vehicle-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 32px rgba(245,196,0,0.18), 0 4px 16px rgba(0,0,0,0.1);
}

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(18px); }
    to   { opacity: 1; transform: translateY(0); }
}

.card-img-wrap {
    position: relative;
    width: 100%;
    aspect-ratio: 4/3;
    background: var(--gray-1);
    overflow: hidden;
    flex-shrink: 0;
}
.card-img-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s;
}
.vehicle-card:hover .card-img-wrap img { transform: scale(1.04); }

/* ===== FIX BADGES: no se solapan ===== */
.card-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    /* Nunca llega hasta el badge derecho (deja espacio para el HP badge + gap) */
    max-width: calc(100% - 90px);
    background: var(--yellow);
    color: var(--black);
    font-family: var(--font-display);
    font-size: 11px;
    letter-spacing: 1.5px;
    padding: 3px 10px;
    border-radius: 50px;
    font-weight: 700;
    /* Texto que no quepa se corta con … */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-badge-hp {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(0,0,0,0.65);
    color: var(--yellow);
    font-family: var(--font-display);
    font-size: 11px;
    letter-spacing: 1px;
    padding: 3px 9px;
    border-radius: 50px;
    backdrop-filter: blur(4px);
    white-space: nowrap;          /* el HP nunca parte en dos líneas */
}

.card-sold-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.4);
    pointer-events: none;
}
.card-sold-stamp {
    font-family: var(--font-display);
    font-size: 3rem;
    letter-spacing: 4px;
    color: var(--accent);
    border: 5px solid var(--accent);
    padding: 6px 18px;
    border-radius: 8px;
    transform: rotate(-12deg);
    text-shadow: 0 2px 8px rgba(0,0,0,0.4);
    opacity: 0.92;
}

/* ===== card-body ocupa todo el espacio restante ===== */
.card-body {
    padding: 16px 18px;
    display: flex;
    flex-direction: column;
    flex: 1;
    gap: 6px;
    min-height: 0;
}

.card-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
}
.card-name {
    font-family: var(--font-display);
    font-size: 1.15rem;
    letter-spacing: 1.5px;
    color: var(--black);
    line-height: 1.1;
}
.card-year {
    font-family: var(--font-display);
    font-size: 1.1rem;
    letter-spacing: 1px;
    color: var(--gray-3);
    flex-shrink: 0;
}

.card-desc {
    font-size: 0.85rem;
    color: var(--gray-4);
    line-height: 1.5;
    flex: 1;
}

.card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 2px;
}
.card-tag {
    font-size: 0.75rem;
    background: var(--yellow-bg);
    color: #7a6000;
    border-radius: 50px;
    padding: 2px 9px;
    border: 1px solid #e8d800;
}

/* ===== footer: precio + botón en misma fila, nunca se rompe ===== */
.card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 10px;
    gap: 8px;
    border-top: 1px solid var(--gray-2);
    padding-top: 12px;
    flex-wrap: nowrap;
}

.card-price {
    font-family: var(--font-display);
    font-size: 1.4rem;
    letter-spacing: 1px;
    color: var(--black);
    flex-shrink: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.btn-whatsapp {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--yellow);
    color: var(--black);
    text-decoration: none;
    font-family: var(--font-display);
    font-size: 13px;
    letter-spacing: 1.5px;
    padding: 9px 16px;
    border-radius: 50px;
    transition: background 0.25s;
    white-space: nowrap;
    flex-shrink: 0;
    font-weight: 700;
}
.btn-whatsapp:hover { background: #25D366; color: var(--white); }
.btn-whatsapp svg { width: 15px; height: 15px; fill: currentColor; }

/* ========== NO RESULTS ========== */
.no-results {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 20px;
    gap: 16px;
    color: var(--gray-3);
    text-align: center;
}
.no-results svg { width: 52px; height: 52px; stroke: var(--yellow); }
.no-results p { font-size: 1rem; }
.no-results button {
    background: var(--yellow);
    color: var(--black);
    border: none;
    border-radius: 50px;
    padding: 10px 24px;
    font-family: var(--font-display);
    font-size: 15px;
    letter-spacing: 1.5px;
    cursor: pointer;
    transition: background 0.25s;
    font-weight: 700;
}
.no-results button:hover { background: var(--yellow-d); }

/* =================== FOOTER =================== */
.footer {
    background-color: #111111;
    color: var(--white);
    padding: 80px 80px 40px 80px;
    display: flex;
    flex-direction: column;
    gap: 48px;
    border-top: 4px solid var(--yellow);
}

.footer-inner {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    align-items: flex-start;
}

.footer-info {
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-width: 320px;
    flex: 1.2;
}

.footer-info h3 {
    font-family: var(--font-display);
    font-size: 1.6rem;
    letter-spacing: 3px;
    color: var(--yellow);
}

.footer-info p { font-size: 1rem; color: #aaaaaa; line-height: 1.8; }

.footer-nav { display: flex; flex-direction: column; gap: 14px; flex: 1; }
.footer-nav h4 {
    font-family: var(--font-display);
    font-size: 1.1rem;
    letter-spacing: 3px;
    color: var(--yellow);
    margin-bottom: 6px;
    text-transform: uppercase;
}
.footer-nav a { font-size: 1rem; color: #aaaaaa; text-decoration: none; transition: color 0.3s; }
.footer-nav a:hover { color: var(--yellow); }

.footer-contacto { display: flex; flex-direction: column; gap: 14px; flex: 1.2; }
.footer-contacto h4 {
    font-family: var(--font-display);
    font-size: 1.1rem;
    letter-spacing: 3px;
    color: var(--yellow);
    margin-bottom: 6px;
    text-transform: uppercase;
}
.footer-contacto p {
    font-size: 1rem; color: #aaaaaa; line-height: 1.6;
    display: flex; align-items: center; gap: 10px;
}
.footer-contacto p svg { width: 16px; height: 16px; fill: var(--yellow); flex-shrink: 0; }

.footer-logo-derecho { display: flex; align-items: flex-start; justify-content: flex-end; flex: 0.8; }
.footer-logo-derecho .logofooter { width: 16rem; height: auto; opacity: 0.6; }

.social-icons { display: flex; gap: 12px; margin-top: 8px; }
.social-icons a {
    display: flex; align-items: center; justify-content: center;
    width: 42px; height: 42px;
    background-color: #2e2e2e;
    border: 1px solid #444;
    border-radius: 50%;
    transition: background-color 0.3s, border-color 0.3s;
}
.social-icons a:hover { background-color: var(--yellow); border-color: var(--yellow); }
.social-icons a:hover svg { fill: var(--black); }
.social-icons svg { width: 18px; height: 18px; fill: var(--white); transition: fill 0.3s; }

.footer-bottom {
    border-top: 1px solid #2e2e2e;
    padding-top: 28px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}
.footer-bottom p { font-size: 0.85rem; color: #555555; }

/* =================== RESPONSIVE =================== */
@media (max-width: 900px) {
    :root { --header-h: 60px; }
    .nav-pill { display: none; }
    .hamburger { display: flex; }
    .logo-wrap img { width: 9rem; height: auto; }

    .marketplace-layout { padding: 20px 20px 48px; gap: 20px; }
    .filters-sidebar {
        position: fixed;
        top: 0; left: -300px;
        height: 100%;
        width: 280px;
        z-index: 200;
        border-radius: 0;
        border-right: 2px solid var(--yellow);
        border-top: none;
        transition: left 0.3s ease;
        max-height: 100vh;
        overflow-y: auto;
        padding-top: 48px;
    }
    .filters-sidebar.open { left: 0; }
    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.5);
        z-index: 199;
    }
    .sidebar-overlay.open { display: block; }
}

@media (max-width: 768px) {
    .header-inner { padding: 10px 20px; }
    .logo-wrap img { width: 8rem; height: auto; }
    .search-bar-wrap { padding: 12px 20px; }
    .vehicles-grid { grid-template-columns: repeat(2, 1fr); gap: 14px; }
    .card-name { font-size: 1rem; }

    /* En cards más angostas, el badge izquierdo tiene menos espacio */
    .card-badge { max-width: calc(100% - 80px); font-size: 10px; }

    .footer { padding: 48px 30px 28px 30px; gap: 36px; }
    .footer-inner { flex-wrap: wrap; gap: 32px; }
    .footer-info { max-width: 100%; width: 100%; }
    .footer-nav, .footer-contacto { flex: 1; min-width: 140px; }
    .footer-logo-derecho { width: 100%; justify-content: flex-start; }
    .footer-logo-derecho .logofooter { width: 140px; }
    .footer-bottom { flex-direction: column; align-items: flex-start; gap: 8px; }
}

@media (max-width: 480px) {
    .marketplace-layout { padding: 16px 14px 40px; }
    .vehicles-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .card-body { padding: 12px 13px; gap: 4px; }
    .card-name { font-size: 0.88rem; letter-spacing: 1px; }
    .card-year { font-size: 0.88rem; }
    .card-desc { font-size: 0.78rem; }
    .card-tags { display: none; }

    .card-badge { max-width: calc(100% - 72px); font-size: 10px; padding: 3px 8px; }
    .card-badge-hp { font-size: 10px; padding: 3px 7px; }

    .card-price { font-size: 1rem; }
    .btn-whatsapp { font-size: 11px; padding: 7px 10px; gap: 4px; }
    .btn-whatsapp svg { width: 13px; height: 13px; }
    .search-bar input { font-size: 14px; }
    .btn-filter-toggle span { display: none; }
    .btn-filter-toggle { padding: 9px 12px; }
    .footer { padding: 36px 20px 24px 20px; gap: 28px; }
    .footer-inner { flex-direction: column; gap: 28px; }
    .logo-wrap img { width: 7rem; }
}

@media (max-width: 360px) {
    .vehicles-grid { gap: 8px; }
    .card-body { padding: 10px; }
    .card-badge { max-width: calc(100% - 68px); font-size: 9px; }
    .card-price { font-size: 0.9rem; }
    .btn-whatsapp { font-size: 10px; padding: 6px 8px; }
    .logo-wrap img { width: 6.5rem; }
}