/* ═══════════════════════════════════════════════════════════
   صفحه دسته مستقل
   ═══════════════════════════════════════════════════════════ */

/* فقط روی دسکتاپ صفحه ثابت ۱۰۰vh — موبایل اسکرول طبیعی */
@media (min-width: 701px) {
  html, body { height: 100%; overflow: hidden; }
  .cat-app { height: 100vh; }
}

.cat-body {
  font-family: var(--font-main);
  background: var(--bg);
  color: var(--text);
}

.cat-app {
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 100vh;
}

.cat-title-text {
  font-size: 13.5px;
  color: var(--text-dim);
  font-weight: 600;
}

.back-btn {
  font-size: 12px;
  color: var(--text-dim);
  text-decoration: none;
  padding: 5px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: all .15s;
}
.back-btn:hover { color: var(--text); border-color: var(--border-hi); background: var(--surface-hi); }

.cat-main {
  display: grid;
  grid-template-columns: 220px 1fr 320px;
  grid-template-areas: "side feed ads";
  gap: var(--gap);
  padding: var(--gap);
  min-height: 0;
}
.cat-sidebar { grid-area: side; }
.cat-feed    { grid-area: feed; }
.cat-ads-col { grid-area: ads; }
@media (min-width: 701px) {
  .cat-main { overflow: hidden; }
}

/* ─── sidebar ──────────────────────────────────────────── */

.cat-sidebar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.cat-side-head {
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
  background: var(--bg-2);
}
.cat-nav {
  flex: 1;
  overflow-y: auto;
  padding: 6px 0;
}
.cat-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  color: var(--text);
  text-decoration: none;
  font-size: 13px;
  transition: background .15s;
  border-inline-start: 3px solid transparent;
}
.cat-nav-item:hover { background: var(--surface-2); }
.cat-nav-item.active {
  background: var(--surface-2);
  font-weight: 700;
}
.cat-nav-item .nav-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 6px -1px currentColor;
}
.cat-nav-item .nav-count {
  margin-inline-start: auto;
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-num);
  font-weight: 600;
  background: var(--surface-hi);
  padding: 1px 7px;
  border-radius: 10px;
}
.cat-nav-item.active .nav-count { background: var(--c, var(--accent)); color: #fff; }

.cat-side-stats {
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-muted);
}

/* ─── feed (main column) ────────────────────────────── */

.cat-feed {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  position: relative;
}
.cat-feed::before {
  content: '';
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--c, var(--accent)) 50%, transparent);
  opacity: .7;
}

.cat-feed-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, var(--surface-2) 0%, var(--surface) 100%);
  flex-shrink: 0;
}
.cat-feed-head h2 {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -.3px;
  color: var(--c, var(--text));
}
.cat-feed-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
}
.cat-feed-meta .dot { opacity: .5; }
.cat-feed-meta #cat-count {
  color: var(--text-dim);
  font-weight: 700;
  font-family: var(--font-num);
}

.cat-list {
  list-style: none;
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  padding: 4px 0;
  scrollbar-width: thin;
  scrollbar-color: var(--border-hi) transparent;
}
.cat-list::-webkit-scrollbar          { width: 8px; }
.cat-list::-webkit-scrollbar-thumb    { background: var(--border); border-radius: 8px; }
.cat-list::-webkit-scrollbar-thumb:hover { background: var(--border-hi); }
.cat-list:empty::before {
  content: attr(data-empty);
  display: block;
  text-align: center;
  color: var(--text-muted);
  padding: 50px 20px;
  font-size: 13px;
}

.cat-list .item {
  padding: 12px 18px;
}
.cat-list .item-title {
  font-size: 14px;
  -webkit-line-clamp: 2;
}
.cat-list .item-meta {
  margin-top: 6px;
  font-size: 11px;
}

/* جداکننده گروه‌های زمانی */
.cat-list .time-divider {
  padding: 8px 18px;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--text-muted);
  background: var(--bg-2);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  letter-spacing: .5px;
  position: sticky;
  top: 0;
  z-index: 1;
}

/* ─── ads col on category page ────────────────────────── */

.cat-ads-col {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* ─── search-specific ─────────────────────────────────── */

.search-meta-block {
  padding: 12px 14px;
  font-size: 12px;
  color: var(--text-dim);
}
.search-meta-row {
  padding: 4px 0;
  border-bottom: 1px solid var(--border);
}
.search-meta-row:last-of-type { border-bottom: none; }
.search-meta-row b { color: var(--text); margin-inline-start: 4px; }
.search-meta-hint {
  margin-top: 10px;
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.6;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.search-empty {
  list-style: none;
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
  font-size: 13px;
}

.search-cat-tag {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 10.5px;
  font-weight: 700;
  color: #fff;
  letter-spacing: .2px;
}

.cat-list .item-title mark {
  background: rgba(251,191,36,.2);
  color: #fcd34d;
  padding: 0 2px;
  border-radius: 2px;
}

/* ─── Load more button (mobile pagination) ─────────────── */

.load-more-wrap {
  list-style: none;
  padding: 14px 16px;
  display: flex;
  justify-content: center;
}
.load-more-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 100%;
  padding: 14px 18px;
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--border-hi);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-main);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all .2s;
  position: relative;
}
.load-more-btn:hover {
  border-color: var(--c, var(--accent));
  background: linear-gradient(180deg, var(--surface-hi), var(--surface-2));
  transform: translateY(-1px);
  box-shadow: 0 4px 12px -4px rgba(0,0,0,.4);
}
.load-more-btn:active { transform: translateY(0); }
.load-more-count {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  font-family: var(--font-num);
}

/* ─── responsive ────────────────────────────────────── */

@media (max-width: 1280px) {
  .cat-main { grid-template-columns: 200px 1fr 260px; }
}
@media (max-width: 1024px) {
  .cat-main {
    grid-template-columns: 200px 1fr;
    grid-template-rows: 1fr auto;
    grid-template-areas:
      "side feed"
      "ads  ads";
  }
  .cat-sidebar { grid-area: side; }
  .cat-feed    { grid-area: feed; }
  .cat-ads-col { grid-area: ads; min-height: 140px; max-height: 200px; }
  .cat-ads-col .ads-stack { flex-direction: row; overflow-x: auto; overflow-y: hidden; }
  .cat-ads-col .ad { min-width: 220px; flex-shrink: 0; }
}
@media (max-width: 700px) {
  .cat-main {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
    grid-template-areas:
      "side"
      "feed"
      "ads";
    overflow: visible;
    padding: 8px;
    gap: 8px;
  }
  .cat-sidebar { max-height: 200px; }
  .header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 2px 8px rgba(0,0,0,.4);
  }
  .cat-nav { display: flex; flex-wrap: wrap; gap: 4px; padding: 8px; }
  .cat-nav-item {
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    border-inline-start: none;
    border: 1px solid var(--border);
  }
  .cat-nav-item.active { border-color: var(--c, var(--accent)); }
  .cat-side-head { display: none; }
  .cat-feed { min-height: 60vh; }
  .header { flex-direction: column; align-items: flex-start; gap: 8px; padding: 10px 12px; }
  .header-meta { width: 100%; flex-wrap: wrap; gap: 6px; }
  .cat-ads-col { min-height: 130px; max-height: 180px; }
}
