/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: #333;
    background: #f5f5f5;
    min-height: 100vh;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
header {
    background: #ffffff;
    padding: 1.5rem 0;
    text-align: center;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    margin-bottom: 2rem;
}

header h1 {
    font-size: 1.8rem;
    color: #1a1a1a;
    margin-bottom: 0.3rem;
    font-weight: 600;
    letter-spacing: -0.5px;
}

.tagline {
    font-size: 0.95rem;
    color: #666;
    font-weight: 400;
}

/* Filter Section */
.filter-section {
    background: white;
    padding: 1.2rem;
    border-radius: 8px;
    margin-bottom: 2rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    border: 1px solid #e5e5e5;
}

.filter-section h3 {
    margin-bottom: 1rem;
    color: #1a1a1a;
    font-size: 1.1rem;
    font-weight: 600;
}

.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.8rem;
}

.filters select {
    padding: 0.6rem 0.9rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.9rem;
    background: white;
    cursor: pointer;
    transition: border-color 0.2s;
    color: #374151;
}

.filters select:hover {
    border-color: #9ca3af;
}

.filters select:focus {
    outline: none;
    border-color: #3b82f6;
}

.reset-btn {
    padding: 0.6rem 1.2rem;
    background: #6b7280;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.2s;
    font-weight: 500;
}

.reset-btn:hover {
    background: #4b5563;
}

/* Cars Grid */
.cars-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 0.85rem;
    align-items: start;
    padding-bottom: 1rem;
}

/* Car Card */
.car-card {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
    transition: box-shadow 0.3s ease;
    border: 1px solid #e5e5e5;
    cursor: pointer;
}

.car-card:hover {
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.14);
}

/* Image Gallery */
.car-image-gallery {
    position: relative;
    overflow: hidden;
    height: 185px;
}

.car-image-gallery img {
    width: 100%;
    height: 185px;
    object-fit: cover;
    position: absolute;
    top: 0;
    left: 0;
    opacity: 0;
    transition: opacity 0.5s ease;
    cursor: pointer;
}

.car-image-gallery img:hover {
    opacity: 1 !important;
    filter: brightness(1.1);
}

.car-image-gallery img.active {
    opacity: 1;
}

.click-hint {
    position: absolute;
    bottom: 45px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.75);
    color: white;
    padding: 0.4rem 0.9rem;
    border-radius: 4px;
    font-size: 0.8rem;
    z-index: 5;
    pointer-events: none;
    animation: fadeInOut 3s ease-in-out infinite;
    font-weight: 500;
}

@keyframes fadeInOut {
    0%, 100% { opacity: 0; }
    50% { opacity: 0.9; }
}

.gallery-nav {
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    transform: translateY(-50%);
    display: flex;
    justify-content: space-between;
    padding: 0 10px;
    z-index: 10;
}

.gallery-nav button {
    background: rgba(0, 0, 0, 0.5);
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    transition: background 0.3s;
}

.gallery-nav button:hover {
    background: rgba(0, 0, 0, 0.8);
}

.image-counter {
    position: absolute;
    bottom: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 0.3rem 0.8rem;
    border-radius: 15px;
    font-size: 0.9rem;
    z-index: 10;
}

.badge {
    position: absolute;
    top: 12px;
    right: 12px;
    background: #10b981;
    color: white;
    padding: 0.35rem 0.75rem;
    border-radius: 999px;
    font-weight: 600;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.35px;
}

.badge.sold {
    background: #6b7280;
}

/* Car Details */
.car-details {
    padding: 0.85rem;
}

.car-details h2 {
    font-size: 1.1rem;
    color: #1a1a1a;
    margin-bottom: 0.35rem;
    font-weight: 600;
    line-height: 1.35;
}

.price {
    font-size: 1.25rem;
    font-weight: 700;
    color: #1a1a1a;
    margin-bottom: 0.65rem;
}

.specs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.55rem;
    padding-bottom: 0.55rem;
    border-bottom: 1px solid #ecf0f1;
}

.spec-item {
    background: #f3f4f6;
    padding: 0.35rem 0.6rem;
    border-radius: 999px;
    font-size: 0.78rem;
    color: #4b5563;
    border: 1px solid #e5e7eb;
    font-weight: 500;
}

.description {
    color: #555;
    margin-bottom: 0.45rem;
    line-height: 1.45;
    font-size: 0.9rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.contact-info {
    background: #f9fafb;
    padding: 0.75rem;
    border-radius: 8px;
    margin-top: 0.7rem;
    border: 1px solid #e5e7eb;
    display: none;
}

.contact-info p {
    margin-bottom: 0.35rem;
    color: #4b5563;
    font-size: 0.82rem;
}

.contact-info p strong {
    color: #1a1a1a;
}

.contact-info p:last-child {
    margin-bottom: 0;
}

.whatsapp-btn {
    display: block;
    background: #25D366;
    color: white;
    text-align: center;
    padding: 0.62rem;
    border-radius: 8px;
    text-decoration: none;
    margin-top: 0.65rem;
    font-weight: 600;
    font-size: 0.85rem;
    transition: background 0.3s;
}

.whatsapp-btn:hover {
    background: #20ba5a;
}

/* Hidden car cards (for filtering) */
.car-card.hidden {
    display: none;
}

.car-card:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* Listing details modal */
.listing-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9500;
    background: rgba(17, 24, 39, 0.72);
    padding: 1.25rem;
    overflow-y: auto;
}

.listing-modal.active {
    display: block;
}

.listing-modal-panel {
    position: relative;
    max-width: 980px;
    margin: 0 auto;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 18px 45px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

.listing-modal-close {
    position: absolute;
    top: 10px;
    right: 12px;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.65);
    color: #fff;
    font-size: 1.8rem;
    line-height: 1;
    cursor: pointer;
    z-index: 20;
}

#listing-modal-body .car-card {
    border: none;
    border-radius: 0;
    box-shadow: none;
    cursor: default;
}

#listing-modal-body .car-image-gallery {
    height: 360px;
}

#listing-modal-body .car-image-gallery img {
    height: 360px;
}

#listing-modal-body .car-details {
    padding: 1.25rem;
}

#listing-modal-body .description {
    display: block;
    -webkit-line-clamp: unset;
    -webkit-box-orient: initial;
    overflow: visible;
    margin-bottom: 1rem;
}

#listing-modal-body .contact-info {
    display: block;
}

/* Lightbox Modal */
.lightbox {
    display: none;
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.95);
    animation: fadeIn 0.3s;
}

.lightbox.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.lightbox-content {
    position: relative;
    max-width: 90%;
    max-height: 90%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox-content img {
    max-width: 100%;
    max-height: 85vh;
    object-fit: contain;
    border-radius: 10px;
    box-shadow: 0 0 50px rgba(255, 255, 255, 0.2);
}

.lightbox-close {
    position: absolute;
    top: 20px;
    right: 40px;
    color: white;
    font-size: 50px;
    font-weight: bold;
    cursor: pointer;
    z-index: 10000;
    transition: color 0.3s;
}

.lightbox-close:hover {
    color: #ff4444;
}

.lightbox-prev,
.lightbox-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: none;
    font-size: 40px;
    padding: 20px 25px;
    cursor: pointer;
    border-radius: 10px;
    transition: background 0.3s;
    z-index: 10000;
}

.lightbox-prev:hover,
.lightbox-next:hover {
    background: rgba(255, 255, 255, 0.4);
}

.lightbox-prev {
    left: 20px;
}

.lightbox-next {
    right: 20px;
}

.lightbox-counter {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 0.8rem 1.5rem;
    border-radius: 25px;
    font-size: 1.1rem;
    z-index: 10000;
}

/* Footer */
footer {
    background: #ffffff;
    padding: 2rem 0;
    text-align: center;
    margin-top: 2rem;
    border-top: 1px solid #e5e5e5;
}

footer p {
    color: #6b7280;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    header h1 {
        font-size: 2rem;
    }

    .tagline {
        font-size: 1rem;
    }

    .cars-grid {
        grid-template-columns: 1fr;
        gap: 0.8rem;
    }

    .price {
        font-size: 1.3rem;
    }

    .car-details h2 {
        font-size: 1.05rem;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 15px;
    }

    header h1 {
        font-size: 1.7rem;
    }

    .specs {
        gap: 0.5rem;
    }

    .spec-item {
        font-size: 0.85rem;
        padding: 0.3rem 0.6rem;
    }

    .filters {
        flex-direction: column;
    }

    .filters select, .reset-btn {
        width: 100%;
    }

    .gallery-nav button {
        width: 35px;
        height: 35px;
        font-size: 1rem;
    }

    /* Lightbox mobile adjustments */
    .lightbox-close {
        top: 10px;
        right: 20px;
        font-size: 40px;
    }

    .lightbox-prev,
    .lightbox-next {
        font-size: 30px;
        padding: 15px 20px;
    }

    .lightbox-prev {
        left: 10px;
    }

    .lightbox-next {
        right: 10px;
    }

    .lightbox-counter {
        bottom: 20px;
        font-size: 0.95rem;
        padding: 0.6rem 1.2rem;
    }

    .click-hint {
        font-size: 0.75rem;
        padding: 0.3rem 0.8rem;
    }

    .listing-modal {
        padding: 0.75rem;
    }

    #listing-modal-body .car-image-gallery,
    #listing-modal-body .car-image-gallery img {
        height: 250px;
    }
}
