/* ========================================
   ОСНОВНЫЕ СТИЛИ ДЛЯ ВСЕГО САЙТА
   ======================================== */

* {
    font-family: 'Manrope', sans-serif;
}

body {
    background-color: #f5f5f5;
}

/* Хедер (десктопная версия) */
.public-header {
    background: white;
    padding: 12px 0;
}

/* Поисковая строка */
.search-row {
    background: white;
    padding: 16px 0;
}

.search-wrapper {
    display: flex;
    align-items: center;
    gap: 16px;
    max-width: 100%;
}

.search-form {
    flex: 1;
    display: flex;
}

.search-input {
    flex: 1;
    padding: 12px 20px;
    border: 2px solid #00AAFF;
    border-radius: 40px;
    font-size: 15px;
    outline: none;
    background: white;
    transition: all 0.2s;
    box-shadow: 0 0 0 3px rgba(0, 170, 255, 0.2);
}

.search-input:focus {
    border-color: #00AAFF;
    box-shadow: 0 0 0 5px rgba(0, 170, 255, 0.3);
}

.search-btn {
    background: #00AAFF;
    color: white;
    border: none;
    padding: 0 32px;
    border-radius: 40px;
    font-weight: 600;
    margin-left: 8px;
    white-space: nowrap;
    transition: all 0.2s;
}

.search-btn:hover {
    background: #0099e6;
}

.location {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: #f0f0f0;
    border-radius: 40px;
    cursor: pointer;
    font-size: 14px;
    white-space: nowrap;
    color: #1f1f1f;
}

.location i {
    color: #00AAFF;
}

/* Футер (десктопная версия) */
.site-footer {
    background: white;
    padding: 40px 0 24px;
    margin-top: 24px;
}

.footer-links {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 32px;
    margin-bottom: 32px;
}

.footer-link {
    color: #666;
    text-decoration: none;
    font-size: 14px;
    display: block;
    margin-bottom: 12px;
}

.footer-link:hover {
    color: #00AAFF;
}

.copyright {
    font-size: 12px;
    color: #8c8c8c;
    text-align: center;
    padding-top: 24px;
    border-top: 1px solid #e8e8e8;
}

/* ========================================
   ПРАВИЛЬНАЯ СЕТКА ДЛЯ ОБЪЯВЛЕНИЙ (4 КОЛОНКИ)
   ======================================== */

.section-title {
    font-size: 22px;
    font-weight: 700;
    margin: 24px 0 20px;
}

/* Десктоп: 4 колонки */
@media (min-width: 1025px) {
    .listings-grid-inner {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 16px !important;
        justify-content: flex-start !important;
    }
    
    .listing-card {
        width: 209px !important;
        flex-shrink: 0 !important;
    }
}

/* Планшеты: 2 колонки */
@media (min-width: 769px) and (max-width: 1024px) {
    .listings-grid-inner {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 16px !important;
    }
    
    .listing-card {
        width: 100% !important;
    }
}

/* Мобильные: 1 колонка */
@media (max-width: 768px) {
    .listings-grid-inner {
        display: flex !important;
        flex-direction: column !important;
        gap: 12px !important;
        padding: 0 12px !important;
    }
    
    .listing-card {
        width: 100% !important;
    }
}

/* Карточки объявлений */
.listing-card {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.2s;
    border: 1px solid #e8e8e8;
    position: relative;
}

.listing-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.listing-card-inner {
    position: relative;
}

/* Слайдер */
.listing-slider {
    position: relative;
    overflow: hidden;
    aspect-ratio: 1 / 1;
    background: white;
}

.listing-slider-container {
    position: relative;
    width: 100%;
    height: 100%;
}

.listing-slide {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    transition: opacity 0.3s ease;
    background: white;
}

.listing-slide.active {
    opacity: 1;
}

.listing-slide img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: white;
}

.no-image {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f5f5f5;
}

/* Кнопки навигации слайдера */
.listing-slider-prev,
.listing-slider-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 28px;
    height: 28px;
    background: rgba(0,0,0,0.5);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    z-index: 10;
    opacity: 0;
}

.listing-card:hover .listing-slider-prev,
.listing-card:hover .listing-slider-next {
    opacity: 1;
}

.listing-slider-prev {
    left: 8px;
}

.listing-slider-next {
    right: 8px;
}

.listing-slider-prev:hover,
.listing-slider-next:hover {
    background: rgba(0,0,0,0.8);
}

.listing-slider-prev i,
.listing-slider-next i {
    font-size: 12px;
}

/* Точки слайдера */
.listing-slider-dots {
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 6px;
    z-index: 10;
}

.listing-slider-dots .dot {
    width: 6px;
    height: 6px;
    background: rgba(255,255,255,0.5);
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s;
}

.listing-slider-dots .dot.active {
    background: white;
    width: 8px;
    height: 8px;
}

/* Счётчик фото */
.listing-photo-count {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(0,0,0,0.6);
    color: white;
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 4px;
    z-index: 10;
    pointer-events: none;
}

/* Кнопка избранного */
.listing-favorite {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 32px;
    height: 32px;
    background: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    transition: all 0.2s;
    z-index: 20;
}

.listing-favorite i {
    font-size: 16px;
    color: #666;
    transition: all 0.2s;
}

.listing-favorite:hover {
    transform: scale(1.05);
}

.listing-favorite:hover i {
    color: #ff4444;
}

.listing-favorite.favorited i {
    color: #ff4444;
}

.listing-favorite.favorited i::before {
    content: "\f004";
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
}

/* Информация об объявлении */
.listing-info-link {
    text-decoration: none;
    display: block;
}

.listing-info {
    padding: 12px;
}

.listing-title {
    font-size: 14px;
    font-weight: 500;
    color: #1f1f1f;
    margin-bottom: 6px;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.listing-price {
    font-size: 18px;
    font-weight: 700;
    color: #1f1f1f;
    margin-bottom: 8px;
}

.listing-location {
    font-size: 12px;
    color: #8c8c8c;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* ========================================
   НАТИВНОЕ МОБИЛЬНОЕ ПРИЛОЖЕНИЕ
   ======================================== */

@media (max-width: 768px) {
    
    /* Скрываем десктопный хедер */
    .public-header {
        display: none;
    }
    
    /* Скрываем десктопный футер */
    .site-footer {
        display: none;
    }
    
    /* Убираем стрелки у слайдера категорий на мобильных */
    .categories-slider-arrow {
        display: none !important;
    }
    
    /* Стили для мобильного body */
    body {
        background-color: white;
        padding-bottom: 70px;
    }
    
    /* Верхняя навигационная панель как в приложении */
    .mobile-header {
        position: sticky;
        top: 0;
        left: 0;
        right: 0;
        background: white;
        padding: 12px 16px;
        border-bottom: 1px solid #e8e8e8;
        z-index: 99;
        display: flex;
        align-items: center;
        justify-content: space-between;
    }
    
    .mobile-header-back {
        width: 32px;
        height: 32px;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        border-radius: 50%;
        background: transparent;
        border: none;
        font-size: 20px;
        visibility: hidden;
    }
    
    .mobile-header-back:active {
        background: #f0f0f0;
    }
    
    .mobile-header-title {
        font-size: 18px;
        font-weight: 700;
        text-decoration: none;
        color: #00AAFF;
    }
    
    .mobile-header-actions {
        display: flex;
        gap: 12px;
    }
    
    .mobile-header-action {
        width: 32px;
        height: 32px;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        border-radius: 50%;
        background: transparent;
        border: none;
        font-size: 18px;
        color: #1f1f1f;
        position: relative;
        text-decoration: none;
    }
    
    .mobile-header-action:active {
        background: #f0f0f0;
    }
    
    .mobile-badge {
        position: absolute;
        top: -2px;
        right: -2px;
        background: #ff4444;
        color: white;
        font-size: 9px;
        font-weight: 600;
        padding: 2px 5px;
        border-radius: 10px;
        min-width: 16px;
        text-align: center;
    }
    
    /* Поисковая строка на мобильных */
    .mobile-search {
        background: white;
        padding: 8px 16px;
        border-bottom: 1px solid #e8e8e8;
    }
    
    .mobile-search-form {
        display: flex;
        align-items: center;
        background: #f5f5f5;
        border-radius: 12px;
        padding: 8px 12px;
        gap: 8px;
    }
    
    .mobile-search-icon {
        color: #8c8c8c;
        font-size: 16px;
    }
    
    .mobile-search-input {
        flex: 1;
        border: none;
        background: transparent;
        outline: none;
        font-size: 14px;
    }
    
    .mobile-search-input::placeholder {
        color: #b0b0b0;
    }
    
    .mobile-search-cancel {
        background: none;
        border: none;
        color: #00AAFF;
        font-size: 14px;
        font-weight: 500;
        cursor: pointer;
    }
    
    /* Нижняя навигационная панель (таббар) */
    .mobile-tabbar {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: white;
        display: flex;
        justify-content: space-around;
        align-items: center;
        padding: 8px 16px 12px;
        border-top: 1px solid #e8e8e8;
        z-index: 100;
        box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
    }
    
    .mobile-tabbar-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 4px;
        text-decoration: none;
        font-size: 11px;
        color: #8c8c8c;
        transition: all 0.2s;
        padding: 4px 8px;
        border-radius: 8px;
    }
    
    .mobile-tabbar-item i {
        font-size: 22px;
    }
    
    .mobile-tabbar-item.active {
        color: #00AAFF;
    }
    
    .mobile-tabbar-item:active {
        background: #f0f0f0;
    }
    
    /* Слайдер категорий на мобильных */
    .categories-slider {
        gap: 12px;
        padding: 0 12px;
    }
    
    .categories-slider-icon {
        width: 55px;
        height: 55px;
        padding: 6px;
    }
    
    .categories-slider-icon i {
        font-size: 24px;
    }
    
    .categories-slider-label {
        font-size: 10px;
    }
    
    .categories-slider-item {
        min-width: 55px;
        gap: 4px;
    }
    
    .categories-slider-wrapper {
        padding: 16px 0;
    }
    
    /* Кнопка "Все категории" на мобильных */
    .categories-menu-trigger {
        width: auto;
        justify-content: center;
        padding: 8px 16px;
    }
    
    .categories-menu {
        width: auto;
    }
    
    /* Кнопка избранного на мобильных */
    .listing-favorite {
        width: 28px;
        height: 28px;
        top: 6px;
        right: 6px;
    }
    
    .listing-favorite i {
        font-size: 14px;
    }
    
    .listing-photo-count {
        font-size: 9px;
        padding: 1px 4px;
        bottom: 6px;
        right: 6px;
    }
    
    /* Стрелки слайдера на мобильных всегда видны */
    .listing-slider-prev,
    .listing-slider-next {
        opacity: 1;
        background: rgba(0,0,0,0.4);
        width: 24px;
        height: 24px;
    }
    
    .listing-slider-prev i,
    .listing-slider-next i {
        font-size: 10px;
    }
    
    /* Секции */
    .section-title {
        font-size: 18px;
        margin: 16px 16px 12px;
        padding: 0;
    }

    .listing-info {
        padding: 8px;
    }
    
    .listing-title {
        font-size: 12px;
        margin-bottom: 4px;
    }
    
    .listing-price {
        font-size: 14px;
        margin-bottom: 4px;
    }
    
    .listing-location {
        font-size: 10px;
    }
    
    /* Container отступы */
    .container {
        padding-left: 0;
        padding-right: 0;
    }
    
    /* Touch оптимизации */
    button, 
    .location,
    .listing-card,
    .categories-slider-item,
    .mobile-tabbar-item,
    .mobile-header-action {
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }
    
    button:active,
    .location:active,
    .mobile-tabbar-item:active {
        opacity: 0.7;
        transform: scale(0.98);
    }
    
    .listing-card:active {
        transform: scale(0.98);
        transition: transform 0.05s;
    }
    
    /* Отключаем hover эффекты на мобильных */
    .listing-card:hover {
        transform: none;
        box-shadow: none;
    }
    
    .categories-slider-item:hover .categories-slider-icon {
        transform: none;
    }
}

/* Планшеты (768px - 1024px) - скрываем мобильные компоненты */
@media (min-width: 769px) and (max-width: 1024px) {
    .footer-links {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .mobile-only {
        display: none !important;
    }
}

/* Десктоп (1025px и выше) - скрываем мобильные компоненты */
@media (min-width: 1025px) {
    .container {
        max-width: 1200px;
    }
    
    .mobile-only {
        display: none !important;
    }
}

/* Очень маленькие телефоны (до 380px) */
@media (max-width: 380px) {
    .listing-title {
        font-size: 11px;
    }
    
    .listing-price {
        font-size: 13px;
    }
    
    .categories-slider-icon {
        width: 45px;
        height: 45px;
    }
    
    .categories-slider-label {
        font-size: 9px;
    }
    
    .categories-slider-item {
        min-width: 45px;
    }
}

/* Мобильная версия для categories-menu */
@media (max-width: 768px) {
    .categories-menu {
        display: block;
        width: 100%;
    }
    
    .categories-menu-trigger {
        width: 100%;
        justify-content: center;
    }
    
    .categories-menu-dropdown {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        height: 100%;
        border-radius: 0;
        z-index: 9999;
    }
    
    .categories-menu-dropdown.open {
        display: flex;
    }
    
    .categories-menu-container {
        flex-direction: column;
        height: 100%;
        max-height: none;
    }
    
    .categories-menu-sidebar {
        width: 100%;
        max-height: 40%;
        border-right: none;
        border-bottom: 1px solid #e8e8e8;
    }
    
    .categories-menu-sidebar-item {
        padding: 14px 16px;
    }
    
    .categories-menu-content {
        flex: 1;
        overflow-y: auto;
        padding: 16px;
    }
    
    .categories-menu-grid {
        grid-template-columns: 1fr;
    }
    
    .categories-menu-grid-item {
        padding: 12px;
    }
}

/* Бесконечная загрузка */
.loading-spinner {
    text-align: center;
    padding: 30px;
    color: #8c8c8c;
}

.loading-spinner i {
    font-size: 24px;
    margin-right: 8px;
}

/* Анимация появления новых карточек */
.listing-card {
    animation: fadeInUp 0.3s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
/* Пагинация */
.listings-pagination nav {
    display: flex;
    justify-content: center;
}

.listings-pagination .pagination {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    list-style: none;
    padding: 0;
}

.listings-pagination .page-item {
    display: inline-block;
}

.listings-pagination .page-link {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 8px;
    background: white;
    border: 1px solid #e8e8e8;
    border-radius: 8px;
    color: #1f1f1f;
    text-decoration: none;
    font-size: 14px;
    transition: all 0.2s;
}

.listings-pagination .page-link:hover {
    background: #f5f5f5;
    border-color: #00AAFF;
}

.listings-pagination .active .page-link {
    background: #00AAFF;
    border-color: #00AAFF;
    color: white;
}

.listings-pagination .disabled .page-link {
    opacity: 0.5;
    cursor: not-allowed;
}

@media (max-width: 768px) {
    .listings-pagination .page-link {
        min-width: 32px;
        height: 32px;
        font-size: 13px;
    }
}