/* Avito Клон - Финальные стили */

/* ============ ЗАПРЕТ ТЁМНОЙ ТЕМЫ ============ */
:root {
    color-scheme: light only;
}
html {
    color-scheme: light only;
    background: #ffffff;
}
body {
    background: #ffffff;
    color: #1a1a1a;
}

/* ============ Базовые стили ============ */
:root {
    --primary: #007bff;
    --primary-dark: #0056b3;
    --secondary: #6c757d;
    --success: #28a745;
    --danger: #dc3545;
    --warning: #ffc107;
    --info: #17a2b8;
    --light: #f8f9fa;
    --dark: #343a40;
    --border-radius: 12px;
    --box-shadow: 0 2px 10px rgba(0,0,0,0.08);
}

* {
    box-sizing: border-box;
}

html, body {
    overflow-x: hidden;
    max-width: 100%;
}

/* Шапка — шире, чем контент */
.avito-header-inner {
    max-width: 1600px;
    margin: 0 auto;
    padding-left: 32px;
    padding-right: 32px;
    width: 100%;
}

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

a {
    color: var(--primary);
    text-decoration: none;
    transition: color 0.2s;
}

a:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

/* ============ Компоненты ============ */

/* Карточки объявлений */
.ad-card {
    background: #fff;
    border-radius: var(--border-radius);
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: var(--box-shadow);
    border: none;
    height: 100%;
}

.ad-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.12);
}

.ad-card .card-img-top {
    height: 200px;
    object-fit: cover;
    background: #e9ecef;
}

.ad-card .card-body {
    padding: 1rem;
}

.ad-card .price {
    font-size: 1.25rem;
    font-weight: 700;
    color: #2c3e50;
}

.ad-card .title {
    font-size: 1rem;
    font-weight: 500;
    color: #2c3e50;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.ad-card .location {
    font-size: 0.85rem;
    color: var(--secondary);
}

.ad-card .date {
    font-size: 0.8rem;
    color: #adb5bd;
}

/* Премиум-объявления */
.ad-card.premium {
    border: 2px solid #ffd700;
    position: relative;
}

.ad-card.premium::before {
    content: '⭐ PREMIUM';
    position: absolute;
    top: 10px;
    right: 10px;
    background: #ffd700;
    color: #000;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    z-index: 1;
}

/* Кнопки */
.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
}

.btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
}

.btn-outline-primary {
    color: var(--primary);
    border-color: var(--primary);
}

.btn-outline-primary:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

/* Формы */
.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 0.2rem rgba(0,123,255,0.25);
}

.form-label {
    font-weight: 500;
}

/* ============ Страницы ============ */

/* Детальная страница */
.ad-detail .gallery img {
    width: 100%;
    height: 400px;
    object-fit: cover;
    border-radius: var(--border-radius);
}

.ad-detail .thumbnails img {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    border: 2px solid transparent;
}

.ad-detail .thumbnails img:hover {
    border-color: var(--primary);
}

.ad-detail .thumbnails img.active {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0,123,255,0.3);
}

.ad-detail .price {
    font-size: 2rem;
    font-weight: 700;
    color: #2c3e50;
}

.ad-detail .views {
    font-size: 0.9rem;
    color: var(--secondary);
}

/* ============ Чат ============ */
.chat-window {
    height: 500px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: var(--border-radius) var(--border-radius) 0 0;
}

.chat-message {
    max-width: 70%;
    padding: 10px 15px;
    border-radius: 18px;
    margin-bottom: 10px;
    animation: fadeIn 0.3s ease-in;
}

.chat-message.sent {
    background: var(--primary);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.chat-message.received {
    background: #e9ecef;
    color: #2c3e50;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.chat-message .time {
    font-size: 0.7rem;
    opacity: 0.7;
    margin-top: 4px;
}

.chat-input-area {
    border-top: 1px solid #dee2e6;
    padding: 15px;
    background: white;
    border-radius: 0 0 var(--border-radius) var(--border-radius);
}

/* ============ Категории ============ */
.category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 15px;
}

.category-item {
    text-align: center;
    padding: 20px 10px;
    background: white;
    border-radius: var(--border-radius);
    transition: all 0.2s;
    cursor: pointer;
    text-decoration: none;
    color: #2c3e50;
    box-shadow: var(--box-shadow);
}

.category-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    text-decoration: none;
}

.category-item .icon {
    font-size: 2.5rem;
    margin-bottom: 8px;
}

.category-item .name {
    font-size: 0.9rem;
    font-weight: 500;
}

/* ============ Админка ============ */
.admin-stats-card {
    transition: all 0.3s;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
}

.admin-stats-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.1);
}

.admin-stats-card .stat-number {
    font-size: 2rem;
    font-weight: 700;
}

.admin-stats-card .stat-label {
    color: var(--secondary);
    font-size: 0.9rem;
}

.admin-table {
    font-size: 0.9rem;
}

.admin-table .badge-status {
    padding: 4px 12px;
    border-radius: 20px;
}

/* ============ Адаптивность ============ */
@media (max-width: 768px) {
    .ad-card .card-img-top {
        height: 150px;
    }
    
    .ad-detail .gallery img {
        height: 250px;
    }
    
    .chat-window {
        height: 350px;
    }
    
    .category-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    }
    
    .navbar .w-50 {
        width: 100% !important;
        order: 3;
        margin-top: 10px;
    }
    
    .ad-detail .price {
        font-size: 1.5rem;
    }
    
    .admin-stats-card .stat-number {
        font-size: 1.5rem;
    }
}

/* ============ Анимации ============ */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.3s ease-in;
}

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

.spinner {
    animation: spin 1s linear infinite;
}

/* ============ Утилиты ============ */
.text-truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.badge-premium {
    background: #ffd700;
    color: #000;
}

.cursor-pointer {
    cursor: pointer;
}

.user-select-none {
    user-select: none;
}

/* ============ Cropper.js ============ */
.cropper-container {
    max-height: 400px;
}

.cropper-container img {
    max-width: 100%;
}

/* ============ Фильтры ============ */
.filter-section {
    background: white;
    padding: 20px;
    border-radius: var(--border-radius);
    margin-bottom: 20px;
    box-shadow: var(--box-shadow);
}

.filter-section .filter-title {
    font-weight: 600;
    margin-bottom: 15px;
}

/* ============ Избранное ============ */
.favorite-btn {
    transition: all 0.2s;
}

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

.favorite-btn .bi-heart-fill {
    color: #dc3545;
}

/* ============ Звонки ============ */
.call-btn {
    transition: all 0.3s;
}

.call-btn:hover {
    transform: scale(1.02);
}

/* ============ Прогресс-бар ============ */
.progress-thin {
    height: 4px;
}

/* ============================================================
   ФИРМЕННЫЕ ЦВЕТА АВИТО
   ============================================================ */
:root {
    --avito-green: #04E061;
    --avito-green-hover: #00a046;
    --avito-red: #FF4053;
    --avito-purple: #965EEB;
    --avito-blue: #0AF;
    --avito-black: #000;
    --avito-white: #fff;
    --avito-bg: #fff;
    --avito-gray: #f5f5f5;
    --avito-gray-2: #f0f0f0;
    --avito-border: #e8e8e8;
    --avito-text: #1a1a1a;
    --avito-text-secondary: #999;
}

/* ============================================================
   ВЕРХНЯЯ ПОЛОСА
   ============================================================ */
.avito-topbar {
    background: #fff;
    border-bottom: 1px solid var(--avito-border);
    font-size: 13px;
    padding: 6px 0;
}

.avito-topbar .topbar-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.avito-topbar .topbar-menu {
    display: flex;
    gap: 20px;
    list-style: none;
    margin: 0;
    padding: 0;
    flex-wrap: wrap;
}

.avito-topbar .topbar-menu a {
    color: var(--avito-text-secondary);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 2px;
}

.avito-topbar .topbar-menu a:hover {
    color: var(--avito-green-hover);
}

.avito-topbar .topbar-menu i {
    font-size: 10px;
}

.avito-topbar .topbar-right a {
    color: var(--avito-text-secondary);
    text-decoration: none;
}

.avito-topbar .topbar-right a:hover {
    color: var(--avito-green-hover);
}

/* ============================================================
    ШАПКА
============================================================ */
.avito-header {
    background: #fff;
    border-bottom: 1px solid var(--avito-border);
    padding: 16px 0;
    position: sticky;
    top: 0;
    z-index: 999;
}

.header-main {
    display: flex;
    align-items: center;
    gap: 16px;
}

.avito-logo {
    flex-shrink: 0;
    display: block;
    line-height: 0;
}

/* Поиск */
.header-search {
    flex: 1;
    display: flex;
    align-items: stretch;
    border: 2px solid #00AAFF;
    border-radius: 10px;
    background: #fff;
    min-width: 0;
    height: 52px;
    transition: border-color 0.15s, box-shadow 0.15s;
    position: relative;
    overflow: visible;
    z-index: 10001;
}

.header-search:focus-within {
    border-color: #0088cc;
    box-shadow: 0 0 0 3px rgba(0, 170, 255, 0.15);
}

.search-categories {
    background: #f5f5f5;
    border: none;
    padding: 0 18px;
    font-size: 14px;
    font-weight: 600;
    color: var(--avito-text);
    cursor: pointer;
    border-right: 1px solid var(--avito-border);
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 100%;
    transition: background 0.15s;
}

.search-categories:hover {
    background: #ececec;
}

.header-search input {
    flex: 1;
    border: none;
    padding: 0 18px;
    font-size: 15px;
    outline: none;
    min-width: 0;
    height: 100%;
}

.search-submit {
    background: #00AAFF;
    color: #fff;
    border: none;
    padding: 0 28px;
    font-weight: 700;
    font-size: 15px;
    cursor: pointer;
    white-space: nowrap;
    height: 100%;
    transition: background 0.15s;
}

.search-submit:hover {
    background: #0088cc;
}

:root {
    --avito-blue: #00AAFF;
    --avito-blue-hover: #0088cc;
    --avito-green: #04E061;
    --avito-green-hover: #00A046;
}

/* Правая часть */
.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.header-location {
    display: flex;
    font-size: 13px;
    padding: 4px 8px;
}

.header-location:hover {
    color: var(--avito-green-hover);
}

.header-icon {
    color: var(--avito-text);
    font-size: 20px;
    text-decoration: none;
    padding: 8px;
    line-height: 1;
    border-radius: 6px;
    transition: background 0.15s;
}

.header-icon:hover {
    color: var(--avito-green-hover);
}

/* Кнопки шапки */
.btn-header {
    padding: 10px 16px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    transition: all 0.15s;
    height: 40px;
}

.btn-header-outline {
    border: 1px solid var(--avito-border);
    color: var(--avito-text);
    background: #fff;
}

.btn-header-outline:hover {
    border-color: var(--avito-green);
    color: var(--avito-green-hover);
}

.btn-header-primary {
    background: #00AAFF;
    color: #fff;
    border: none;
}
.btn-header-primary:hover {
    background: #0088cc;
    color: #fff;
}

/* ============================================================
РУБРИКАТОР ПЛИТКАМИ
   ============================================================ */
.avito-rubricator {
    background: #fff;
    border-bottom: 1px solid var(--avito-border);
    padding: 16px 0;
}

.rubricator-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
}

.rubricator-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 16px 8px;
    background: var(--avito-gray);
    border-radius: 12px;
    text-decoration: none;
    color: var(--avito-text);
    font-size: 13px;
    font-weight: 500;
    text-align: center;
    transition: all 0.2s;
    min-height: 90px;
    line-height: 1.3;
}

.rubricator-item:hover {
    background: #e8e8e8;
    color: var(--avito-green-hover);
}

.rubricator-item.active {
    background: rgba(4, 224, 97, 0.1);
    color: var(--avito-green-hover);
    border: 1px solid var(--avito-green);
}

.rubricator-item i {
    font-size: 24px;
    margin-bottom: 8px;
}

/* ============================================================
   ФУТЕР АВИТО
   ============================================================ */
.avito-footer {
    background: #fff;
    border-top: 1px solid var(--avito-border);
    padding: 40px 0 24px;
    margin-top: 40px;
}

.footer-columns {
    display: flex;
    flex-wrap: wrap;
    gap: 16px 24px;
    margin-bottom: 24px;
}

.footer-columns a {
    color: var(--avito-text-secondary);
    text-decoration: none;
    font-size: 13px;
}

.footer-columns a:hover {
    color: var(--avito-green-hover);
}

.footer-copyright {
    font-size: 13px;
    color: var(--avito-text-secondary);
    margin-bottom: 20px;
    line-height: 1.7;
}

.footer-copyright a {
    color: var(--avito-text-secondary);
    text-decoration: underline;
}

.footer-copyright a:hover {
    color: var(--avito-green-hover);
}

.footer-socials {
    display: flex;
    gap: 12px;
}

.footer-socials a {
    color: var(--avito-text-secondary);
    font-size: 22px;
    line-height: 1;
    text-decoration: none;
}

.footer-socials a:hover {
    color: var(--avito-green-hover);
}

/* ============================================================
   АДАПТИВНОСТЬ ШАПКИ
   ============================================================ */
@media (max-width: 1200px) {
    .search-categories span {
        display: none;
    }
}

@media (max-width: 992px) {
    .header-main {
        flex-wrap: wrap;
    }
    .header-search {
        order: 3;
        width: 100%;
        margin-top: 8px;
    }
    .header-right {
        margin-left: auto;
    }
    .rubricator-grid {
        grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    }
}

@media (max-width: 576px) {
    .avito-topbar .topbar-menu {
        gap: 12px;
        font-size: 12px;
    }
    .btn-header span {
        display: none;
    }

    .header-location span {
        max-width: 70px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
}

/* Визуальный рубрикатор */
.visual-rubricator {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
}

.rubricator-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 16px 12px;
    background: #f5f5f5;
    border-radius: 16px;
    text-decoration: none;
    color: #000;
    transition: all 0.2s;
    text-align: center;
    min-height: 100px;
}

.rubricator-tile:hover {
    background: #e8e8e8;
    transform: translateY(-2px);
    color: #000;
}

.rubricator-icon {
    font-size: 28px;
    margin-bottom: 8px;
    color: #007bff;
}

.rubricator-name {
    font-size: 13px;
    font-weight: 500;
    line-height: 1.2;
}

@media (max-width: 768px) {
    .visual-rubricator {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 8px;
    }
    .rubricator-tile {
        padding: 12px 8px;
        min-height: 80px;
    }
    .rubricator-icon {
        font-size: 22px;
    }
    .rubricator-name {
        font-size: 11px;
    }
}

/* ============ Мега-меню "Все категории" ============ */
.search-categories-wrapper {
    position: relative;
    display: inline-block;
}

.search-categories {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 16px;
    height: 44px;
    background: #00AAFF;
    color: #fff;
    border: none;
    border-right: 1px solid #e0e0e0;
    font-weight: 500;
    font-size: 14px;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s;
}

.search-categories:hover {
    background: #0088cc;
}

.mega-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: opacity 0.15s, transform 0.15s, visibility 0.15s;
    pointer-events: none;
    display: none;
    max-width: calc(100vw - 32px);
}

.mega-menu.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    pointer-events: auto;
    display: block;
}

.mega-menu-inner {
    display: flex;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.15);
    overflow: hidden;
    min-width: 0;
    width: max-content;
    max-width: min(900px, calc(100vw - 32px));
}

.mega-menu-sidebar {
    width: 240px;
    background: #fafafa;
    border-right: 1px solid #eee;
    padding: 8px 0;
    max-height: 480px;
    overflow-y: auto;
}

.mega-menu-sidebar-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    font-size: 14px;
    color: #2c3e50;
    text-decoration: none;
    transition: background 0.1s;
    cursor: pointer;
}

.mega-menu-sidebar-item:hover,
.mega-menu-sidebar-item.active {
    background: #fff;
    color: var(--primary);
}

.mega-menu-sidebar-item i:first-child {
    font-size: 16px;
    width: 20px;
    text-align: center;
}

.mega-menu-content {
    flex: 1;
    padding: 20px 24px;
    max-height: 480px;
    overflow-y: auto;
}

.mega-menu-panel {
    display: none;
}

.mega-menu-panel.active {
    display: block;
}

.mega-menu-panel-title {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 12px;
    color: #2c3e50;
}

.mega-menu-panel-children {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px 24px;
}

.mega-menu-panel-children a {
    font-size: 14px;
    color: #2c3e50;
    text-decoration: none;
    padding: 4px 0;
    transition: color 0.15s;
}

.mega-menu-panel-children a:hover {
    color: var(--primary);
}

.mega-menu-all {
    grid-column: 1 / -1;
    margin-top: 8px;
    font-weight: 600;
    color: var(--primary) !important;
}

@media (max-width: 992px) {
    .mega-menu {
        display: none !important;
    }
}

/* ============ Модалка "Все категории" ============ */
.categories-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 40px 16px;
    box-sizing: border-box;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
    overflow-y: auto;
    overflow-x: hidden;
}

.categories-modal-overlay.open {
    opacity: 1;
    visibility: visible;
}

.categories-modal {
    background: #fff;
    border-radius: 16px;
    width: 100%;
    max-width: 960px;
    box-sizing: border-box;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    transform: translateY(-20px) scale(0.98);
    transition: transform 0.2s;
    overflow: hidden;
    margin: auto;
}

.categories-modal-overlay.open .categories-modal {
    transform: translateY(0) scale(1);
}

.categories-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid #eee;
}

.categories-modal-title {
    font-size: 20px;
    font-weight: 700;
    margin: 0;
    color: #2c3e50;
}

.categories-modal-close {
    background: transparent;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #666;
    transition: background 0.15s;
}

.categories-modal-close:hover {
    background: #f0f0f0;
    color: #000;
}

.categories-modal-body {
    display: flex;
    max-height: calc(100vh - 180px);
    overflow: hidden;
}

.categories-modal-sidebar {
    width: 280px;
    background: #fafafa;
    border-right: 1px solid #eee;
    padding: 8px 0;
    overflow-y: auto;
    flex-shrink: 0;
}

.categories-modal-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    font-size: 15px;
    font-weight: 500;
    color: #2c3e50;
    text-decoration: none;
    transition: background 0.15s;
    cursor: pointer;
}

.categories-modal-item:hover,
.categories-modal-item.active {
    background: #fff;
    color: var(--primary);
}

.categories-modal-item i:first-child {
    font-size: 18px;
    width: 22px;
    text-align: center;
}

.categories-modal-content {
    flex: 1;
    padding: 24px 28px;
    overflow-y: auto;
    min-width: 0;
}

.categories-modal-panel {
    display: none;
}

.categories-modal-panel.active {
    display: block;
    animation: fadeIn 0.2s;
}

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

.categories-modal-panel-title {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 16px;
    color: #2c3e50;
}

.categories-modal-children {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px 24px;
}

.categories-modal-child {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    font-size: 14px;
    color: #2c3e50;
    text-decoration: none;
    border-radius: 8px;
    transition: background 0.15s, color 0.15s;
}

.categories-modal-child:hover {
    background: #f5f5f5;
    color: var(--primary);
}

.categories-modal-child-count {
    font-size: 12px;
    color: #999;
    background: #f0f0f0;
    padding: 2px 8px;
    border-radius: 10px;
}

.categories-modal-all {
    display: inline-block;
    margin-top: 20px;
    font-size: 14px;
    font-weight: 600;
    color: var(--primary);
    text-decoration: none;
}

.categories-modal-all:hover {
    text-decoration: underline;
}

.categories-modal-empty {
    font-size: 14px;
    color: #666;
}

.categories-modal-empty a {
    color: var(--primary);
    font-weight: 500;
}

/* Адаптив */
@media (max-width: 768px) {
    .categories-modal-overlay {
        padding: 0;
    }

    .categories-modal {
        max-width: 100%;
        height: 100%;
        border-radius: 0;
        margin: 0;
    }

    .categories-modal-body {
        flex-direction: column;
        max-height: none;
        flex: 1;
    }

    .categories-modal-sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid #eee;
        max-height: 40vh;
    }

    .categories-modal-content {
        padding: 16px;
    }

    .categories-modal-children {
        grid-template-columns: 1fr;
    }
}

/* Блокировка скролла на body, когда модалка открыта */
body.modal-open {
    overflow: hidden;
}

/* ============================================================
   КЛИКАБЕЛЬНАЯ КАРТОЧКА ОБЪЯВЛЕНИЯ
   ============================================================ */
.ad-card-link {
    display: block;
    color: inherit;
    text-decoration: none;
}

.ad-card-link:hover,
.ad-card-link:focus {
    color: inherit;
    text-decoration: none;
}

.ad-card-link .ad-card {
    transition: transform 0.2s, box-shadow 0.2s;
}

.ad-card-link:hover .ad-card {
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.12);
}

/* Заголовок внутри карточки — div, но подсвечивается при hover */
.ad-card .title {
    color: #2c3e50;
    font-weight: 500;
    transition: color 0.15s;
}

.ad-card-link:hover .title {
    color: var(--avito-green-hover);
}

/* Убираем underline у ссылок внутри карточки */
.ad-card-link a {
    text-decoration: none;
    color: inherit;
}

/* ============================================================
   ФУТЕР — колонки
   ============================================================ */
.avito-footer .list-unstyled {
    margin: 0;
    padding: 0;
}

.avito-footer .list-unstyled li {
    margin-bottom: 8px;
}

.avito-footer .list-unstyled a {
    color: var(--avito-text-secondary);
    text-decoration: none;
    font-size: 13px;
    transition: color 0.15s;
}

.avito-footer .list-unstyled a:hover {
    color: var(--avito-green-hover);
}

.avito-footer .footer-copyright {
    font-size: 13px;
    color: var(--avito-text-secondary);
}

.avito-footer .footer-copyright a {
    color: var(--avito-text-secondary);
    text-decoration: underline;
}

.avito-footer .footer-copyright a:hover {
    color: var(--avito-green-hover);
}

.rubricator-card-image {
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #f0f0f0 0%, #e8e8e8 100%);
}

.rubricator-card-image i {
    font-size: 48px;
    color: #00AAFF;
    opacity: 0.7;
}

/* Рубрикатор — адаптив */
@media (max-width: 768px) {
    .avito-rubricator {
        padding: 12px 0;
    }
    .rubricator-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 8px;
    }
    .rubricator-item {
        padding: 12px 6px;
        min-height: 80px;
        font-size: 12px;
    }
    .rubricator-item i {
        font-size: 20px;
    }
}

@media (max-width: 576px) {

    .rubricator-card-image i {
        font-size: 36px;
    }

    .avito-rubricator {
        padding: 10px 0;
        overflow-x: auto;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }

    .avito-rubricator::-webkit-scrollbar {
        display: none;
    }

    .rubricator-grid {
        display: flex;
        gap: 8px;
        flex-wrap: nowrap;
        overflow-x: auto;
        padding: 0 12px;
        scroll-snap-type: x mandatory;
    }

    .rubricator-item {
        flex: 0 0 auto;
        min-width: 90px;
        min-height: 72px;
        padding: 10px 6px;
        font-size: 11px;
        border-radius: 12px;
        scroll-snap-align: start;
    }

    .rubricator-item i {
        font-size: 20px;
        margin-bottom: 4px;
    }

        /* Карточка объявления */
    .ad-card .card-img-top {
        height: 180px;
    }

    .ad-card .card-body {
        padding: 10px 12px;
    }

    .ad-card .price {
        font-size: 16px;
    }

    .ad-card .title {
        font-size: 13px;
        -webkit-line-clamp: 2;
    }

    .ad-card .location {
        font-size: 12px;
    }

    .ad-card .card-footer {
        padding: 6px 12px;
        font-size: 11px;
    }

    /* Одна карточка на всю ширину */
    .ads-grid .col-md-6,
    .ads-grid .col-xl-4 {
        flex: 0 0 100%;
        max-width: 100%;
    }

    /* Заголовок страницы */
    .d-flex.justify-content-between.align-items-center {
        flex-direction: column;
        align-items: stretch !important;
        gap: 10px;
    }

    h5.fw-bold {
        font-size: 16px;
    }

    .btn-create {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 576px) {
    .rubricator-cards {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .rubricator-card {
        min-height: 90px;
    }

    .rubricator-card-image {
        padding: 12px;
    }

    .rubricator-card-image i {
        font-size: 32px;
    }

    .rubricator-card-name {
        font-size: 12px;
        padding: 6px 8px;
        font-weight: 600;
    }
}

/* ============ RUBRICATOR CARDS ============ */
.rubricator-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
}

.rubricator-card {
    display: flex;
    flex-direction: column;
    background: #f5f5f5;
    border-radius: 16px;
    overflow: hidden;
    text-decoration: none;
    color: #1a1a1a;
    transition: transform 0.2s, box-shadow 0.2s;
    min-height: 140px;
    position: relative;
}

.rubricator-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.1);
    color: #1a1a1a;
}

.rubricator-card-image {
    flex: 1;
    overflow: hidden;
    background: #e8e8e8;
}

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

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

.rubricator-card-name {
    padding: 10px 14px;
    font-size: 14px;
    font-weight: 600;
    background: #fff;
    text-align: center;
}

@media (max-width: 768px) {
    .rubricator-cards {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
    .rubricator-card {
        min-height: 110px;
    }
    .rubricator-card-name {
        font-size: 12px;
        padding: 8px 10px;
    }
}

/* ============ PROMO CARD ============ */
.promo-card {
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--box-shadow);
    height: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
}

.promo-card-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    background: rgba(0,0,0,0.7);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 4px;
    z-index: 2;
}

.promo-card-image {
    height: 160px;
    overflow: hidden;
    background: #f0f0f0;
}

.promo-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.promo-card-body {
    padding: 12px 14px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.promo-card-title {
    font-size: 15px;
    font-weight: 700;
    color: #1a1a1a;
    margin-bottom: 4px;
}

.promo-card-text {
    font-size: 13px;
    color: #666;
    flex: 1;
    margin-bottom: 8px;
}

.promo-card-link {
    font-size: 13px;
    font-weight: 600;
    color: #00AAFF;
    text-decoration: none;
}

.promo-card-link:hover {
    color: #0088cc;
}

/* ============ BANNERS CAROUSEL ============ */
.banners-carousel-wrapper {
    position: relative;
    border-radius: 16px;
    overflow: hidden;
    margin-bottom: 24px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
}

.banners-carousel {
    position: relative;
    height: 280px;
    background: #f0f0f0;
}

.banner-slide {
    position: absolute;
    inset: 0;
    opacity: 0;
    transition: opacity 0.5s ease;
    pointer-events: none;
}

.banner-slide.active {
    opacity: 1;
    pointer-events: auto;
}

.banner-slide-link {
    display: block;
    width: 100%;
    height: 100%;
    position: relative;
    text-decoration: none;
}

.banner-slide img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.banner-slide-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 40px 32px 24px;
    background: linear-gradient(transparent, rgba(0,0,0,0.7));
    color: #fff;
}

.banner-slide-title {
    font-size: 24px;
    font-weight: 700;
    margin: 0 0 4px;
}

.banner-slide-text {
    font-size: 14px;
    margin: 0;
    opacity: 0.9;
}

.banner-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255,255,255,0.9);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: #1a1a1a;
    transition: background 0.15s, transform 0.15s;
    z-index: 2;
}

.banner-nav:hover {
    background: #fff;
    transform: translateY(-50%) scale(1.05);
}

.banner-nav-prev { left: 16px; }
.banner-nav-next { right: 16px; }

.banner-dots {
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 6px;
    z-index: 2;
}

.banner-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255,255,255,0.5);
    border: none;
    cursor: pointer;
    transition: background 0.2s, width 0.2s;
    padding: 0;
}

.banner-dot.active {
    background: #fff;
    width: 24px;
    border-radius: 4px;
}

@media (max-width: 768px) {
    .banners-carousel {
        height: 180px;
    }
    .banner-slide-title {
        font-size: 18px;
    }
    .banner-slide-overlay {
        padding: 30px 16px 16px;
    }
    .banner-nav {
        width: 36px;
        height: 36px;
        font-size: 16px;
    }
}

/* ============ МОБИЛЬНАЯ ШАПКА (финальные правки) ============ */
@media (max-width: 992px) {
    /* Шапка — две строки */
    .header-main {
        flex-wrap: wrap;
        gap: 10px;
    }

    .avito-logo {
        order: 1;
        flex-shrink: 0;
    }

    .header-right {
        order: 2;
        margin-left: auto;
        gap: 6px;
        flex-shrink: 0;
    }

    .header-search {
        order: 3;
        width: 100%;
        margin-top: 8px;
        height: 46px;
        border-radius: 10px;
        flex: none;
    }

    /* Кнопка "Все категории" — компактная */
    .search-categories {
        padding: 0 12px;
        flex-shrink: 0;
    }

    .search-categories span {
        display: none;
    }

    .search-categories i {
        font-size: 18px;
    }

    /* Input поиска — занимает всё свободное место */
    .header-search input {
        padding: 0 14px;
        font-size: 14px;
        min-width: 0;
        flex: 1;
    }

    /* Кнопка "Найти" — компактная */
    .search-submit {
        padding: 0 16px;
        font-size: 14px;
        flex-shrink: 0;
    }

    /* Скрываем текст "Найти", оставляем иконку */
    .search-submit span {
        display: none;
    }

    .search-submit i {
        display: inline-block !important;
        font-size: 18px;
    }
}

@media (max-width: 576px) {
    .avito-header {
        padding: 10px 0;
    }

    .avito-header-inner {
        padding-left: 12px;
        padding-right: 12px;
    }

    .header-main {
        gap: 8px;
    }

    .avito-logo svg {
        width: 70px;
        height: 22px;
    }

    .header-search {
        height: 42px;
        margin-top: 6px;
    }

    .search-submit {
        padding: 0 14px;
    }

    /* Кнопка "Разместить" — только иконка */
    .btn-header-primary {
        padding: 8px 12px;
        width: 40px;
        height: 40px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .btn-header-primary span {
        display: none;
    }

    .btn-header-primary i {
        font-size: 18px;
    }

    .rubricator-cards {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .rubricator-card {
        min-height: 100px; /* Было 110-140 */
    }

    .rubricator-card-image {
        flex: 1;
    }

    .rubricator-card-name {
        font-size: 13px;
        padding: 8px 10px;
        font-weight: 600;
    }

    .main-container {
        padding-left: 12px;
        padding-right: 12px;
    }

    .avito-rubricator {
        padding: 10px 0;
        margin-bottom: 12px;
    }

    .banners-carousel-wrapper {
        margin-bottom: 16px;
    }

    h4, h5 {
        font-size: 16px;
        margin-bottom: 8px;
    }

    /* Секции */
    .mt-4 { margin-top: 12px !important; }
    .mt-5 { margin-top: 16px !important; }
    .mb-4 { margin-bottom: 12px !important; }
    .mb-3 { margin-bottom: 8px !important; }
}

/* ============ CITY FILTER BAR ============ */
.city-filter-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: #f5f9ff;
    border-radius: 12px;
    margin: 16px 0;
    font-size: 14px;
}
.city-filter-text {
    color: #1a1a1a;
}
.city-filter-text i {
    color: #00AAFF;
    margin-right: 6px;
}
.city-filter-link {
    color: #00AAFF;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
}
.city-filter-link:hover {
    color: #0088cc;
    text-decoration: none;
}

/* ============ BONUS TOAST ============ */
.bonus-toast {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 10000;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px 18px;
    background: linear-gradient(135deg, #00AAFF 0%, #0088cc 100%);
    color: #fff;
    border-radius: 14px;
    box-shadow: 0 8px 32px rgba(0,170,255,0.35);
    max-width: 360px;
    animation: bonusSlideIn 0.4s ease-out;
}
@keyframes bonusSlideIn {
    from { opacity: 0; transform: translateX(40px); }
    to { opacity: 1; transform: translateX(0); }
}

.bonus-toast-icon {
    font-size: 32px;
    line-height: 1;
    flex-shrink: 0;
}
.bonus-toast-content { flex: 1; min-width: 0; }
.bonus-toast-title {
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 4px;
}
.bonus-toast-message {
    font-size: 13px;
    opacity: 0.95;
    line-height: 1.4;
    margin-bottom: 8px;
}
.bonus-toast-link {
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    text-decoration: underline;
}
.bonus-toast-link:hover { color: #fff; opacity: 0.9; }

.bonus-toast-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 16px;
    cursor: pointer;
    padding: 0;
    opacity: 0.7;
    flex-shrink: 0;
}
.bonus-toast-close:hover { opacity: 1; }

@media (max-width: 576px) {
    .bonus-toast {
        top: auto;
        bottom: 80px;
        right: 12px;
        left: 12px;
        max-width: none;
    }
}