/* ========== Глобальные стили ========== */
* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: Arial, sans-serif;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.15s ease;
}

a:hover {
  color: var(--accent-hover);
}

/* ========== Контейнер страницы ========== */
.page-wrap {
  width: 95%;
  max-width: 1500px;
  margin: 0 auto;
  padding: 24px 0 40px;
}

/* ========== Хлебные крошки ========== */
.breadcrumbs {
  margin-bottom: 14px;
  color: var(--text-secondary);
  font-size: 14px;
}

.breadcrumbs a {
  color: var(--text-secondary);
}

.breadcrumbs a:hover {
  color: var(--accent-hover);
}

/* ========== Общие блоки ========== */
.hero-box,
.search-box,
.category-card,
.tech-note,
.loading-box,
.error-box,
.empty-state {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* ========== Hero ========== */
.hero-box {
  padding: 28px;
  margin-bottom: 24px;
}

.hero-box h1 {
  margin: 0 0 10px;
  font-size: 34px;
  line-height: 1.15;
  font-weight: 700;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--input-bg);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 600;
}

/* ========== Поиск ========== */
.search-box {
  padding: 18px;
  margin-bottom: 24px;
}

.search-row,
.search-row--single {
  display: block;
}

.search-input {
  width: 100%;
  padding: 14px 16px;
  font-size: 16px;
  border-radius: 14px;
  border: 1px solid var(--border-color);
  background: var(--input-bg);
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(78, 161, 255, 0.15);
}

/* ========== Мета-инфо ========== */
.catalog-meta {
  margin-top: 12px;
  font-size: 14px;
  color: var(--text-secondary);
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

/* ========== Заголовки ========== */
.section-title {
  font-size: 22px;
  font-weight: 700;
  margin: 0;
  color: var(--text-primary);
}

.results-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 0 0 14px;
}

/* ========== Иконки вида ========== */
.view-switch--icons {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.view-switch--icons button {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  background: var(--card-bg);
  color: var(--text-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 18px;
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease, color 0.18s ease;
}

.view-switch--icons button:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.view-switch--icons button.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* ========== Сетка категорий ========== */
.categories-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 18px;
}

#categoriesGrid.view-table {
  display: block;
}

/* ========== Карточка категории ========== */
.category-card {
  display: block;
  padding: 18px;
  height: 100%;
  color: var(--text-primary);
  transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}

.category-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.08);
}

.category-card--button {
  width: 100%;
  text-align: left;
  cursor: pointer;
  font: inherit;
  appearance: none;
}

.category-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.category-icon {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--input-bg);
  border: 1px solid var(--border-color);
  font-size: 20px;
}

.category-name {
  font-size: 19px;
  font-weight: 700;
  line-height: 1.3;
  margin: 0 0 6px;
}

.category-description {
  font-size: 15px;
  line-height: 1.55;
  color: var(--text-secondary);
  margin: 0 0 14px;
  min-height: 46px;
}

.category-footer {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.category-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 52px;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--input-bg);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 700;
  border: 1px solid var(--border-color);
}

.category-status {
  font-size: 13px;
  color: var(--text-secondary);
}

/* ========== Пустое состояние ========== */
.empty-state {
  display: none;
  margin-top: 20px;
  padding: 24px;
  border: 1px dashed var(--border-color);
  color: var(--text-secondary);
  text-align: center;
}

/* ========== Технический блок ========== */
.tech-note {
  margin-top: 24px;
  padding: 20px;
}

.tech-note p,
.tech-note li {
  color: var(--text-secondary);
  line-height: 1.6;
}

/* ========== Ошибки / загрузка ========== */
.loading-box,
.error-box {
  padding: 16px;
  margin-bottom: 18px;
}

.error-box {
  border-color: #dc3545;
  color: #dc3545;
}

/* ========== Мини-категория ========== */
.categories-mini {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.category-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--input-bg);
  border: 1px solid var(--border-color);
  font-size: 13px;
  color: var(--text-primary);
  transition: 0.15s ease;
}

.category-chip:hover {
  border-color: var(--accent);
}

.category-chip.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.remove-mini {
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.remove-mini:hover {
  background: rgba(255, 255, 255, 0.12);
}

/* ========== Диапазон ========== */
.range-row {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 16px;
}

.range-row label {
  font-weight: 600;
  color: var(--text-primary);
}

.range-slider-wrap {
  position: relative;
  width: 100%;
  height: 42px;
  user-select: none;
  touch-action: none;
  cursor: pointer;
}

.range-track-base {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 8px;
  transform: translateY(-50%);
  border-radius: 999px;
  background: var(--border-color);
  z-index: 1;
}

.range-track {
  position: absolute;
  top: 50%;
  left: 0;
  width: 0;
  height: 8px;
  transform: translateY(-50%);
  border-radius: 999px;
  background: var(--accent);
  z-index: 2;
  transition: left 0.12s ease, width 0.12s ease;
}

.range-handle {
  position: absolute;
  top: 50%;
  left: 0;
  width: 22px;
  height: 22px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
  z-index: 3;
  pointer-events: none;
  transition: left 0.12s ease;
}

.range-input-native {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 1px;
  height: 1px;
}

.range-values {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  font-size: 14px;
  color: var(--text-primary);
}

.range-values strong {
  font-weight: 700;
}

@media (max-width: 768px) {
  .range-slider-wrap {
    height: 48px;
  }

  .range-track-base,
  .range-track {
    height: 10px;
  }

  .range-handle {
    width: 26px;
    height: 26px;
  }
}

@media (max-width: 480px) {
  .range-slider-wrap {
    height: 52px;
  }

  .range-handle {
    width: 28px;
    height: 28px;
  }

  .range-values {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }
}

/* ========== Каналы ========== */
.channel-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  border-radius: 18px;
  border: 1px solid var(--border-color);
  background: var(--card-bg);
  box-shadow: var(--shadow);
  transition: 0.18s ease;
  min-height: 120px;
  overflow: hidden;
}

.channel-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
}

.channel-card__top {
  display: flex;
  align-items: center;
  gap: 10px;
}

.channel-card__avatar {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  object-fit: cover;
  background: var(--input-bg);
  border: 1px solid var(--border-color);
  flex-shrink: 0;
}

.channel-card__main {
  flex: 1;
  min-width: 0;
}

.channel-card__title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.channel-card__meta {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.channel-card__stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 2px;
}

.channel-card__stat {
  padding: 8px 10px;
  border-radius: 12px;
  background: var(--input-bg);
}

.channel-card__stat-label {
  font-size: 11px;
  color: var(--text-secondary);
  margin-bottom: 2px;
}

.channel-card__stat-value {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
}

.channel-card__bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: auto;
  gap: 8px;
}

.channel-card__link {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
}

.channel-card__badge {
  padding: 5px 8px;
  border-radius: 999px;
  background: var(--input-bg);
  font-size: 11px;
  font-weight: 700;
  border: 1px solid var(--border-color);
}

/* ========== Таблица ========== */
/* ========== Таблица ========== */
.catalog-table-wrap {
  width: 100%;
  overflow-x: auto;
  border-radius: 16px;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.catalog-table {
  width: 100%;
  min-width: 920px;
  border-collapse: collapse;
}

.catalog-table th,
.catalog-table td {
  padding: 14px 16px;
  font-size: 14px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--border-color);
  background: var(--card-bg);
  color: var(--text-primary);
  transition: background-color 0.2s ease;
}

/* Эффект наведения на строку таблицы */
.catalog-table tbody tr:hover {
  background-color: var(--hover-bg, rgba(0, 0, 0, 0.03));
}

.catalog-table th {
  font-weight: 700;
  color: var(--text-secondary);
  background: var(--table-header-bg, var(--input-bg));
  position: sticky;
  top: 0;
  z-index: 10;
}

.table-kind {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  white-space: nowrap;
  border: 1px solid var(--border-color);
  background: var(--input-bg);
  color: var(--text-primary);
  font-weight: 500;
}

/* Стили для постов */
.table-kind.post-kind {
  background: rgba(25, 118, 210, 0.1);
  color: #1976d2;
  border-color: rgba(25, 118, 210, 0.3);
}

/* Стили для каналов */
.table-kind.channel-kind {
  background: rgba(46, 125, 50, 0.1);
  color: #2e7d32;
  border-color: rgba(46, 125, 50, 0.3);
}

.table-title-link,
.table-title-btn {
  font-weight: 600;
  color: inherit;
  display: flex;
  align-items: center;
  gap: 8px;
}

.table-channel-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.table-channel-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
}

.table-title-btn {
  padding: 0;
  border: 0;
  background: transparent;
  font: inherit;
  cursor: pointer;
  text-align: left;
  display: inline-flex;
  align-items: center;
}

.table-title-link:hover,
.table-title-btn:hover {
  text-decoration: underline;
}

/* Стили для статистики и бейджей */
.table-stat {
  display: flex;
  align-items: center;
  gap: 8px;
}

.official-badge {
  background: #1976d2;
  color: white;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.75em;
  font-weight: 500;
  white-space: nowrap;
}

/* Стили для описания */
.category-description {
  max-width: 400px;
  line-height: 1.4;
  color: var(--text-secondary);
  font-size: 13px;
  word-wrap: break-word;
  overflow: hidden;
}

/* Анимация появления элементов */
.catalog-anim-item {
  opacity: 0;
  transform: translateY(10px);
  animation: fadeInUp 0.3s ease forwards;
}

@keyframes fadeInUp {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Адаптивность для мобильных устройств */
@media (max-width: 1024px) {
  .catalog-table {
    min-width: 768px;
  }
  
  .category-description {
    max-width: 250px;
    font-size: 12px;
  }
}

@media (max-width: 768px) {
  .catalog-table {
    min-width: 640px;
  }
  
  .catalog-table th:nth-child(3),
  .catalog-table td:nth-child(3) {
    display: none; /* Скрываем колонку «Описание» на планшетах */
  }
  
  .table-channel-info {
    gap: 8px;
  }
  
  .table-channel-avatar {
    width: 28px;
    height: 28px;
  }
}

@media (max-width: 480px) {
  .catalog-table-wrap {
    border-radius: 12px;
    border: none;
    box-shadow: none;
  }
  
  .catalog-table th,
  .catalog-table td {
    padding: 10px 12px;
    font-size: 12px;
  }
  
  .catalog-table th:nth-child(4),
  .catalog-table td:nth-child(4) {
    font-size: 11px;
  }
  
  .official-badge {
    padding: 1px 6px;
    font-size: 0.65em;
  }
}

/* Дополнительные стили для пустого состояния */
.catalog-table-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-secondary);
  font-style: italic;
}

/* Стили для длинных заголовков */
.table-title-link {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}

.table-title-link + .table-stat {
  margin-left: auto;
}



/* ========== Пагинация ========== */
.pagination-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  margin-top: 18px;
}

.pagination-btn {
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  background: var(--card-bg);
  color: var(--text-primary);
  cursor: pointer;
  font-size: 13px;
  transition: 0.18s ease;
}

.pagination-btn:hover:not(:disabled) {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.pagination-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.pagination-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

#pagination.hidden {
  display: none;
}


/* ========== Анимация карточек ========== */
.catalog-anim-item {
  will-change: transform, opacity;
}

.catalog-item-enter {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.26s ease, transform 0.26s ease;
}

.catalog-item-enter.catalog-item-enter-active {
  opacity: 1;
  transform: translateY(0);
}

.catalog-item-leave {
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

@media (prefers-reduced-motion: reduce) {
  .catalog-item-enter,
  .catalog-item-enter.catalog-item-enter-active,
  .catalog-item-leave {
    transition: none !important;
    transform: none !important;
    opacity: 1 !important;
  }
}

/* ========== Медиазапросы ========== */
@media (max-width: 992px) {
  .catalog-meta {
    justify-content: flex-start;
  }
}

@media (max-width: 768px) {
  .page-wrap {
    width: 94%;
    padding-top: 16px;
  }

  .hero-box {
    padding: 22px;
  }

  .hero-box h1 {
    font-size: 28px;
  }

  .categories-grid {
    grid-template-columns: 1fr;
  }

  .category-card {
    padding: 16px;
  }

  .category-name {
    font-size: 18px;
  }

  .category-description {
    font-size: 14px;
    min-height: auto;
  }

  .results-head {
    gap: 12px;
  }

  .view-switch--icons button {
    width: 40px;
    height: 40px;
  }

  .range-slider-wrap {
    height: 48px;
  }

  .range-track-base,
  .range-track {
    height: 10px;
  }

  .range-handle {
    width: 26px;
    height: 26px;
  }

  .range-values {
    font-size: 13px;
  }

  .pagination-btn {
    min-height: 42px;
  }
}

@media (max-width: 480px) {
  .page-wrap {
    width: 92%;
  }

  .hero-box,
  .search-box,
  .tech-note {
    padding: 16px;
  }

  .hero-box h1 {
    font-size: 24px;
  }

  .hero-actions {
    gap: 8px;
  }

  .hero-badge {
    font-size: 12px;
    padding: 7px 10px;
  }

  .catalog-meta {
    font-size: 13px;
    gap: 10px;
    flex-direction: column;
    align-items: flex-start;
  }

  .range-values {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  .range-slider-wrap {
    height: 52px;
  }

  .range-handle {
    width: 28px;
    height: 28px;
  }
}



:root {
  --stat-color: #333;
  --stat-accent: #007bff;
}

[data-theme="dark"] {
  --stat-color: #e9ecef;
  --stat-accent: #17a2b8;
}

.visibleCount{
 font-size: 16px;
}


.catalog-meta {
  display: flex;
  gap: 20px;
  padding: 12px 16px;
  background: var(--bg-secondary, #f8f9fa);
  border-radius: 8px;
  font-size: 14px;
  color: var(--stat-color);
  flex-wrap: wrap;
}

.catalog-meta strong {
  font-weight: 600;
  color: var(--stat-accent);
  transition: color 0.3s ease;
}


.table-loader, .card-loader {
  display: block !important; /* forcing visibility */
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 9999;
  background: rgba(0, 0, 0, 0.5);
  color: white;
  padding: 20px;
}


/* Стили для загрузчика внутри контейнера */
#categoriesGrid {
  position: relative;
}

.loading-indicator {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  z-index: 1000;
  color: #007bff;
  font-size: 16px;
  font-weight: bold;
}

.loading-indicator .spinner {
  width: 50px;
  height: 50px;
  border: 6px solid #f3f3f3;
  border-top: 6px solid #007bff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.loading-indicator .loading-text {
  margin-top: 10px;
}

/* Анимация для вращающегося круга */
@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}
