/* assets/css/ads.css */

/* ================= صفحه لیست آگهی‌ها ================= */
.ads-container {
    padding: 30px 0 60px;
}

/* ================= بریدکرامب ================= */
.breadcrumb {
    margin-bottom: 25px;
    font-size: 0.85rem;
    color: var(--gray, #6b7280);
    display: flex;
    align-items: center;
    gap: 8px;
    margin-right: 40px;
}
.breadcrumb a{
    margin-right: 20px;
}

.breadcrumb .separator {
    font-size: 0.7rem;
    color: var(--border, #e5e7eb);
}

/* ================= باکس جستجو ================= */
.search-section {
    margin-bottom: 30px;
}

.search-box-wrapper {
    display: flex;
    align-items: center;
    background: #fff;
    border: 2px solid var(--border, #e5e7eb);
    border-radius: 50px;
    padding: 5px 20px;
    transition: all 0.3s;
    max-width: 600px;
    margin: 0 auto;
}

.search-box-wrapper:focus-within {
    border-color: var(--primary, #3396D3);
    box-shadow: 0 0 0 4px rgba(51, 150, 211, 0.1);
}

.search-box-wrapper i {
    color: var(--gray, #6b7280);
    font-size: 1.2rem;
    margin-left: 10px;
}

.search-input {
    width: 100%;
    padding: 15px 0;
    border: none;
    font-size: 1rem;
    font-family: inherit;
    background: transparent;
}

.search-input:focus {
    outline: none;
}

/* ================= چیدمان اصلی ================= */
.ads-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 30px;
    position: relative;
}

/* ================= سایدبار فیلترها (ثابت) ================= */
.filters-sidebar {
    background: #fff;
    border-radius: var(--radius, 12px);
    border: 1px solid var(--border, #e5e7eb);
    padding: 20px;
    height: fit-content;
    position: sticky;
    top: 100px;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    align-self: start;
}

/* استایل اسکرول برای فیلترها */
.filters-sidebar::-webkit-scrollbar {
    width: 6px;
}

.filters-sidebar::-webkit-scrollbar-track {
    background: var(--light, #f9fafb);
    border-radius: 10px;
}

.filters-sidebar::-webkit-scrollbar-thumb {
    background: var(--border, #e5e7eb);
    border-radius: 10px;
}

.filters-sidebar::-webkit-scrollbar-thumb:hover {
    background: var(--gray, #6b7280);
}

.filters-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border, #e5e7eb);
}

.filters-header h3 {
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--dark, #1e1e1e);
}

.filters-header h3 i {
    color: var(--primary, #3396D3);
}

.clear-filters {
    background: none;
    border: none;
    color: var(--primary, #3396D3);
    font-size: 0.85rem;
    cursor: pointer;
    padding: 5px 10px;
    border-radius: 6px;
    transition: all 0.2s;
}

.clear-filters:hover {
    background: var(--light, #f9fafb);
    color: #0050a0;
}

.filter-group {
    margin-bottom: 25px;
}

.filter-label {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 10px;
    color: var(--dark, #1e1e1e);
}

.filter-select {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--border, #e5e7eb);
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.9rem;
    background: #fff;
    cursor: pointer;
    transition: all 0.2s;
}

.filter-select:focus {
    border-color: var(--primary, #3396D3);
    outline: none;
    box-shadow: 0 0 0 3px rgba(51, 150, 211, 0.1);
}

/* ========== بخش قیمت با راهنما ========== */
.price-range {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
}

.price-input {
    flex: 1;
    min-width: 0;
    padding: 10px 12px;
    border: 2px solid var(--border, #e5e7eb);
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.price-input:focus {
    border-color: var(--primary, #3396D3);
    outline: none;
    box-shadow: 0 0 0 3px rgba(51, 150, 211, 0.1);
}

.price-input::placeholder {
    color: #a0aec0;
    font-size: 0.8rem;
}

.price-range span {
    color: var(--gray, #6b7280);
    font-size: 0.9rem;
    font-weight: 500;
    white-space: nowrap;
    padding: 0 2px;
}

/* راهنمای قیمت */
.price-hint {
    font-size: 0.75rem;
    color: var(--gray, #6b7280);
    margin-top: 5px;
    display: block;
}

/* ========== استایل دسته‌بندی تودرتو ========== */
#categoryFilter {
    max-height: 300px;
    overflow-y: auto;
}

#categoryFilter option {
    padding: 8px 12px;
    font-size: 0.9rem;
    border-bottom: 1px solid transparent;
}

#categoryFilter option[value=""] {
    font-weight: 600;
    color: var(--dark, #1e1e1e);
    background-color: var(--light, #f9fafb);
}

/* دسته‌بندی اصلی */
#categoryFilter option[style*="padding-right: 0px"] {
    font-weight: 600;
    color: var(--dark, #1e1e1e);
    background-color: #f8fafc;
}

/* زیردسته سطح 1 */
#categoryFilter option[style*="padding-right: 15px"] {
    font-weight: normal;
    color: #4b5563;
}

/* زیردسته سطح 2 */
#categoryFilter option[style*="padding-right: 30px"] {
    font-weight: normal;
    color: #6b7280;
    font-size: 0.85rem;
}

/* زیردسته سطح 3 */
#categoryFilter option[style*="padding-right: 45px"] {
    font-weight: normal;
    color: #9ca3af;
    font-size: 0.8rem;
}

/* خط جداکننده بین دسته‌های اصلی */
#categoryFilter option[value=""] {
    border-bottom: 1px solid var(--border, #e5e7eb);
}

/* هاور روی گزینه‌ها */
#categoryFilter option:hover {
    background-color: rgba(51, 150, 211, 0.1) !important;
}

/* ========== بقیه استایل‌ها بدون تغییر ========== */

.apply-filters-mobile {
    display: none;
    width: 100%;
    padding: 12px;
    background: var(--primary, #3396D3);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    margin-top: 20px;
}

.apply-filters-mobile:hover {
    background: #0050a0;
}

/* ================= محتوای آگهی‌ها ================= */
.ads-content {
    min-height: 500px;
}

.results-header {
    margin-bottom: 20px;
    font-size: 0.95rem;
    color: var(--gray, #6b7280);
}

#resultsCount {
    font-weight: 700;
    color: var(--primary, #3396D3);
    font-size: 1.2rem;
}

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

/* کارت آگهی */
.ad-card {
    background: #fff;
    border-radius: var(--radius, 12px);
    border: 1px solid var(--border, #e5e7eb);
    overflow: hidden;
    transition: all 0.3s;
    text-decoration: none;
    color: inherit;
    display: block;
}

.ad-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
}

.ad-image {
    height: 180px;
    background: var(--light, #f9fafb);
    overflow: hidden;
    position: relative;
}

.ad-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s;
}

.ad-card:hover .ad-image img {
    transform: scale(1.05);
}

.no-image {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--light, #f9fafb);
    color: var(--gray, #6b7280);
    font-size: 3rem;
}

.ad-body {
    padding: 15px;
}

.ad-title {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--dark, #1e1e1e);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    height: 3em;
}

.ad-category {
    font-size: 0.8rem;
    color: var(--primary, #3396D3);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.ad-category i {
    font-size: 0.9rem;
}

.ad-location {
    font-size: 0.8rem;
    color: var(--gray, #6b7280);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.ad-price {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid var(--border, #e5e7eb);
    padding-top: 10px;
    margin-top: 10px;
}

.price-value {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--primary, #3396D3);
}

.price-unit {
    font-size: 0.7rem;
    color: var(--gray, #6b7280);
}

/* ================= حالت‌های صفحه ================= */
.state-box {
    text-align: center;
    padding: 80px 20px;
    background: #fff;
    border-radius: var(--radius, 12px);
    border: 1px solid var(--border, #e5e7eb);
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--border, #e5e7eb);
    border-top-color: var(--primary, #3396D3);
    border-radius: 50%;
    margin: 0 auto 20px;
    animation: spin 1s infinite linear;
}

@keyframes spin {
    100% { transform: rotate(360deg); }
}

.error-state i {
    font-size: 4rem;
    color: #f44336;
    margin-bottom: 20px;
}

.error-state h3 {
    color: #d32f2f;
    margin-bottom: 15px;
    font-size: 1.5rem;
}

.empty-state i {
    font-size: 4rem;
    color: var(--gray, #6b7280);
    margin-bottom: 20px;
}

.empty-state h3 {
    color: var(--dark, #1e1e1e);
    margin-bottom: 15px;
    font-size: 1.5rem;
}

.btn-retry {
    display: inline-block;
    padding: 12px 30px;
    background: var(--primary, #3396D3);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    margin-top: 20px;
    transition: all 0.3s;
}

.btn-retry:hover {
    background: #0050a0;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(51, 150, 211, 0.3);
}

/* ================= صفحه‌بندی ================= */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-top: 40px;
    flex-wrap: wrap;
}

.page-btn {
    min-width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 8px;
    font-size: 0.9rem;
    color: var(--dark, #1e1e1e);
    cursor: pointer;
    transition: all 0.2s;
    padding: 0 10px;
}

.page-btn:hover:not(.active):not(.disabled) {
    background: var(--light, #f9fafb);
    border-color: var(--primary, #3396D3);
    color: var(--primary, #3396D3);
}

.page-btn.active {
    background: var(--primary, #3396D3);
    border-color: var(--primary, #3396D3);
    color: #fff;
    cursor: default;
}

.page-btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.page-dots {
    color: var(--gray, #6b7280);
    padding: 0 5px;
}

/* ================= ریسپانسیو ================= */
@media (max-width: 992px) {
    .ads-layout {
        grid-template-columns: 1fr;
    }

    .filters-sidebar {
        position: fixed;
        top: 0;
        right: -300px;
        width: 280px;
        height: 100vh;
        z-index: 1001;
        border-radius: 0;
        transition: right 0.3s;
        overflow-y: auto;
        max-height: 100vh;
    }

    .filters-sidebar.active {
        right: 0;
    }

    .apply-filters-mobile {
        display: block;
    }

    .filters-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0,0,0,0.5);
        z-index: 1000;
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s;
    }

    .filters-overlay.active {
        opacity: 1;
        visibility: visible;
    }

    .mobile-filter-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        background: #fff;
        border: 1px solid var(--border, #e5e7eb);
        border-radius: 8px;
        padding: 12px 20px;
        margin-bottom: 20px;
        cursor: pointer;
        font-size: 0.9rem;
        width: 100%;
    }

    .mobile-filter-toggle i {
        color: var(--primary, #3396D3);
    }
}

@media (max-width: 768px) {
    .ads-grid {
        grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
        gap: 15px;
    }
}

@media (max-width: 480px) {
    .ads-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .price-range {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 8px;
    }

    .price-input {
        flex: 1 1 calc(50% - 20px);
        min-width: 100px;
        padding: 8px 10px;
        font-size: 0.85rem;
    }

    .price-range span {
        display: inline-block;
        font-size: 0.85rem;
    }

    .page-btn {
        min-width: 35px;
        height: 35px;
        font-size: 0.85rem;
        padding: 0 8px;
    }

    @media (max-width: 360px) {
        .price-range {
            flex-direction: column;
            align-items: stretch;
        }
        
        .price-input {
            width: 100%;
            flex: none;
        }
        
        .price-range span {
            text-align: center;
            padding: 5px 0;
        }
    }
}

@media (min-width: 1400px) {
    .ads-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}