.header {
  display: flex;
  flex-wrap: wrap;
  padding: 10px 12px;
  gap: 10px;
  position: relative;
  min-height: 60px;
}

.brand {
  flex: 1;
  align-self: flex-start;
}

.header .nav .btn-post {
  position: absolute;
  top: 10px;
  right: 12px;
  padding: 8px 12px;
  font-size: 14px;
  white-space: nowrap;
  z-index: 10;
}

.nav {
  order: 3;
  flex: 1 1 100%;
  justify-content: space-between;
  margin-top: 10px;
  flex-wrap: wrap;
  gap: 6px;
}

/* Скрываем кнопку "Подать объявление" в обычном потоке навигации */
.nav .btn-post {
  display: none;
}

/* Показываем её только в абсолютном позиционировании */
.header .nav .btn-post {
  display: block;
}

.theme-switch-wrapper {
  order: 6;
}

.nav button:not(.btn-post):nth-child(4) {
  order: 3; /* Кнопка "Войти" */
}

.nav select:nth-child(2) {
  order: 4; /* Выбор страны */
}

.nav select:nth-child(3) {
  order: 5; /* Выбор языка */
}

.nav button:not(.btn-post):not(:nth-child(4)) {
  display: none !important;
}

.brand .title {
  font-size: 16px;
}

.brand div:last-child {
  font-size: 12px;
}

.filter-card {
  padding: 10px;
}

.filter-card {
  position: relative;
}

.filter-card h4 {
  cursor: pointer;
  padding-right: 30px; /* Место для стрелки */
  margin-bottom: 0 !important;
}

/* Стрелка для индикации сворачивания */
.filter-card h4::after {
  content: '▼';
  position: absolute;
  right: 15px;
  top: 15px;
  font-size: 12px;
  transition: transform 0.3s ease;
  color: var(--muted);
}

.filter-card.collapsed h4::after {
  transform: rotate(-90deg);
}

/* Содержимое фильтров */
.filter-card .form-row,
.filter-card .filter-actions {
  max-height: 500px;
  opacity: 1;
  transition: all 0.3s ease;
  overflow: hidden;
}

.filter-card.collapsed .form-row,
.filter-card.collapsed .filter-actions {
  max-height: 0;
  opacity: 0;
  margin-top: 0;
  padding-top: 0;
}

/* Сортировка всегда видна */
.filter-card:not(:first-child) h4::after {
  display: none; /* Убираем стрелку у сортировки */
}

.filter-card:not(:first-child) .form-row {
  max-height: none !important;
  opacity: 1 !important;
}


.form-row {
  gap: 6px;
}

/* ПЕРЕНОСИМ БЛОКИ ВНИЗ ПОД ОБЪЯВЛЕНИЯ */
.layout {
  display: flex;
  flex-direction: column;
}

.sidebar {
  order: -1; /* Перемещаем сайдбар с фильтрами выше основного контента */
  margin-top: 0;
  position: static; /* Убираем sticky позиционирование */
}

/* Скрываем блоки статистики и форума в сайдбаре */
.sidebar .stats,
.sidebar .filter-card:last-child {
  display: none;
}

/* Показываем эти блоки в основном контенте внизу */
section .forum:last-child {
  display: block; /* Убедимся, что блок виден */
}

/* СКРЫВАЕМ СТАТИСТИКУ И ФОРУМ В САЙДБАРЕ */
.sidebar .stats,
.sidebar .filter-card:last-child {
  display: none;
}

/* СТАТИСТИКА В ОСНОВНОМ КОНТЕНТЕ - ПЕРЕМЕЩАЕМ ПОСЛЕ ОБЪЯВЛЕНИЙ */
.stats {
  order: 2;
  display: grid !important;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 18px 0;
  background: var(--card);
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--border-color);
}

.stats div {
  text-align: center;
  font-size: 14px;
  color: var(--muted);
  background: transparent !important;
  border: none !important;
  margin: 0 !important;
  padding: 0 !important;
}

.stats strong {
  display: block;
  font-size: 16px;
  color: var(--text-color);
  margin-top: 4px;
}

/* СКРЫВАЕМ СТАТИСТИКУ И ФОРУМ В САЙДБАРЕ */
.sidebar .stats,
.sidebar .filter-card:last-child {
  display: none;
}

.sidebar .stats,
.sidebar .filter-card:last-child {
  display: none !important;
}


section {
  display: flex;
  flex-direction: column;
}

/* Объявления идут первыми */
.card-grid {
  order: 1;
}

/* Пагинация после объявлений */
.card-grid + div {
  order: 2;
}


section .forum {
  order: 3;
  display: block !important;
}
