/* css/home.css */
.main-content {
    padding: 25px 0;
    background-color: #f8f9fa;
}

.section-title {
    font-size: 28px;
    margin-bottom: 32px;
    color: #1a1a1a;
    font-weight: 700;
    position: relative;
    padding-left: 16px;
}

.section-title::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 6px;
    height: 28px;
    background-color: #8b0000;
    border-radius: 4px;
}

.ads-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 28px;
    margin-bottom: 60px;
}

.ad-card {
    background: white;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    cursor: pointer;
    border: 1px solid rgba(0,0,0,0.03);
    position: relative;
}

.ad-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 12px 24px rgba(0,0,0,0.1);
}

.ad-image {
    width: 100%;
    height: 200px;
    background: #f0f2f5;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ad-image::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image: var(--image);
    background-size: cover;
    background-position: center;
    filter: blur(12px);
    transform: scale(1.1);
    opacity: 0.4;
    pointer-events: none;
}

.ad-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: none;
}

.ad-card:hover .ad-image img {
    transform: none;
}

.ad-info {
    padding: 20px;
}

.ad-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 8px;
    color: #2c3e50;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    height: 44px;
    line-height: 1.4;
}

.ad-price {
    font-size: 20px;
    font-weight: 700;
    color: #8b0000;
    margin-bottom: 12px;
    letter-spacing: -0.5px;
}

.ad-location {
    font-size: 13px;
    color: #7f8c8d;
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 12px;
}

.ad-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 12px;
    border-top: 1px solid #f0f0f0;
}

.ad-time {
    font-size: 12px;
    color: #95a5a6;
}

.ad-favorite {
    background: none;
    border: none;
    cursor: pointer;
    color: #ccc;
    font-size: 18px;
    transition: color 0.2s;
    padding: 4px;
}

.ad-favorite:hover, .ad-favorite.active {
    color: #e74c3c;
}

.loading {
    text-align: center;
    padding: 40px;
    color: #666;
    display: none;
}

/* Empty state centralized */
.no-ads {
    grid-column: 1 / -1;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    min-height: 50vh;
    text-align: center;
    color: #666;
}

/* Older Ads Carousel */
.older-ads-section {
    margin-top: 40px;
    margin-bottom: 40px;
}

.carousel-container {
    position: relative;
    display: flex;
    align-items: center;
    gap: 15px;
}

.carousel-grid {
    flex: 1;
    margin-bottom: 0 !important; /* Override ads-grid margin */
}

.carousel-btn {
    display: none !important;
}

/* Remove extra layout spacing now that buttons are gone */
.carousel-container {
    display: block;
    gap: 0;
}

/* Desktop: garantir 4 colunas fixas e cards consistentes */
@media (min-width: 1024px) {
    .ads-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .ads-grid {
        display: flex;
        overflow-x: auto;
        scroll-snap-type: x mandatory;
        gap: 16px;
        padding: 0 16px 20px; /* Bottom padding for scrollbar/shadow */
        margin: 0 -20px 40px; /* Negative margin to go full width */
        width: calc(100% + 40px);
        -webkit-overflow-scrolling: touch; /* Smooth scroll on iOS */
        scrollbar-width: none; /* Hide scrollbar Firefox */
    }

    .ads-grid::-webkit-scrollbar {
        display: none; /* Hide scrollbar Chrome/Safari */
    }
    
    .ad-card {
        flex: 0 0 85%; /* Show 85% of card to encourage scroll */
        width: 85%;
        min-width: 280px; /* Minimum width constraint */
        scroll-snap-align: center;
        margin: 0; /* Reset margin */
        box-shadow: 0 4px 12px rgba(0,0,0,0.08); /* Slightly stronger shadow */
    }

    /* Adjust specific elements inside card for mobile consistency */
    .ad-image {
        height: 200px; /* Fixed height for consistency */
    }
    
    .ad-info {
        padding: 16px;
    }
    
    .ad-title {
        font-size: 16px;
        height: 44px; /* Ensure 2 lines */
        margin-bottom: 8px;
    }
    
    .ad-price {
        font-size: 18px;
        margin-bottom: 8px;
    }
    
    .ad-location {
        font-size: 13px;
    }

    /* Hide prev/next buttons on mobile as requested */
    .carousel-btn {
        display: none !important;
    }
    
    /* Remove padding/gap from container since buttons are gone */
    .carousel-container {
        padding: 0;
        display: block; /* Remove flex column */
        gap: 0;
    }
    
    /* Adjust loading/no-ads within the flex container */
    .no-ads, .loading {
        width: 100%;
        flex: 0 0 100%; /* Take full width in flex */
    }
}

/* CSS Mobile Improvements for Categories */
@media (max-width: 768px) {
    .categories {
        padding: 20px 0;
        background: #fff;
        border-bottom: 1px solid #f0f0f0;
    }

    .categories-container {
        display: flex;
        overflow-x: auto;
        margin-left: 15px;
        scroll-snap-type: x mandatory;
        gap: 16px;
        padding: 0 20px;
        justify-content: flex-start;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none; /* Firefox */
    }

    .categories-container::-webkit-scrollbar {
        display: none; /* Chrome/Safari */
    }

    .category-item {
        display: flex;
        flex-direction: row;
        align-items: baseline;
        justify-content: center;
        min-width: auto;
        flex-shrink: 0;
        scroll-snap-align: start;
        text-decoration: none;
        gap: 8px;
        background: #f8f9fa;
        padding: 8px 16px;
        border-radius: 50px;
        border: 1px solid rgba(0,0,0,0.03);
        transition: all 0.2s ease;
    }

    .category-item i {
        display: inline-block;
        width: auto;
        height: auto;
        font-size: 16px; /* Match text size closer */
        color: #8b0000;
        border: none;
        background: transparent;
        transition: color 0.2s ease;
        line-height: 1;
        margin: 0;
        padding: 0;
    }

    .category-item.active,
    .category-item:active {
        background: #8b0000;
        border-color: #8b0000;
        box-shadow: 0 4px 12px rgba(139, 0, 0, 0.25);
        transform: translateY(-1px);
    }

    .category-item.active i,
    .category-item:active i {
        color: #fff;
    }

    .category-item span {
        font-size: 14px;
        color: #333;
        font-weight: 600;
        text-align: left;
        line-height: 1;
        white-space: nowrap; /* Prevent wrapping */
        display: block;
        margin: 0;
        padding: 0;
    }

    .category-item.active span,
    .category-item:active span {
        color: #fff;
        font-weight: 600;
    }
}
