/* Дерево категорий и подкатегории каталога */

.catalog-layout__nav {
  margin-bottom: 1rem;
  padding: 0.75rem;
}

.catalog-layout__grid--index {
  align-items: start;
}

.category-tree__list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.category-tree__list--nested {
  margin-left: 0;
  padding-left: calc(0.35rem + var(--tree-depth, 0) * 0.85rem);
  border-left: 0;
}

.category-tree__row {
  display: flex;
  align-items: stretch;
  gap: 0.25rem;
  margin-bottom: 0.1rem;
  border-radius: 0.5rem;
  transition: background 0.15s ease;
}

.category-tree__row:hover {
  background: rgba(0, 122, 255, 0.05);
}

.category-tree__toggle {
  flex: 0 0 1.75rem;
  width: 1.75rem;
  height: 1.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 0.35rem;
  background: transparent;
  cursor: pointer;
  padding: 0;
  align-self: center;
}

.category-tree__chevron {
  display: inline-block;
  width: 0.5rem;
  height: 0.5rem;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
  transition: transform 0.2s ease;
  opacity: 0.7;
}

.category-tree__item.is-expanded > .category-tree__row .category-tree__chevron {
  transform: rotate(45deg);
}

.category-tree__link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex: 1;
  min-height: 2.125rem;
  padding: 0.4rem 0.5rem;
  border-radius: 0.5rem;
  color: inherit;
  text-decoration: none;
  font-size: 0.9375rem;
}

.category-tree__item.is-flattened .category-tree__link {
  flex-direction: column;
  align-items: flex-start;
  gap: 0.1rem;
}

.category-tree__link:hover {
  background: #f8fafc;
  text-decoration: none;
}

.category-tree__link.is-active {
  background: #eff6ff;
  font-weight: 600;
  color: #0d7bf2;
  box-shadow: inset 3px 0 0 #0d7bf2;
}

.category-tree__path {
  display: block;
  font-size: 0.6875rem;
  line-height: 1.3;
  color: var(--text-muted, #9ca3af);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.category-tree__item.is-flattened .category-tree__title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-text, #1d1d1f);
}

.category-tree__item.is-flattened .category-tree__link.is-active .category-tree__path {
  color: rgba(0, 122, 255, 0.75);
}

.category-tree__count {
  flex-shrink: 0;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted, #9ca3af);
  font-variant-numeric: tabular-nums;
}

.category-tree__count--badge {
  min-width: 1.5rem;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  background: #f1f5f9;
  color: #64748b;
  text-align: center;
  font-size: 0.6875rem;
  font-weight: 600;
}

.category-tree__link.is-active .category-tree__count--badge {
  background: rgba(13, 123, 242, 0.12);
  color: #0d7bf2;
}

.category-tree--compact .category-tree__link {
  font-size: 0.875rem;
}

.category-tree__toggle:focus-visible,
.category-tree__link:focus-visible {
  outline: 2px solid var(--color-accent, #007aff);
  outline-offset: 2px;
}

.catalog-layout__main > .catalog-layout__nav .card__title {
  margin: 0 0 0.75rem;
}

.catalog-root-categories {
  display: grid;
  gap: 1rem;
}

.catalog-root-category__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.35rem;
}

.catalog-root-category__head h3 {
  margin: 0;
  font-size: 1.125rem;
}

.catalog-root-category__count,
.catalog-root-category__child-count {
  font-size: 0.8125rem;
  color: var(--text-muted, #6b7280);
}

.catalog-root-category__desc {
  margin: 0 0 0.75rem;
  color: var(--text-muted, #6b7280);
}

.catalog-root-category__children,
.catalog-root-category__grandchildren {
  list-style: none;
  margin: 0;
  padding: 0;
}

.catalog-root-category__children > li {
  margin-bottom: 0.35rem;
}

.catalog-root-category__grandchildren {
  margin: 0.35rem 0 0 1rem;
  padding-left: 0.75rem;
  border-left: 1px solid var(--border-subtle, #e5e7eb);
}

.catalog-subcategories {
  margin-bottom: 1rem;
  padding: 1rem;
}

.catalog-subcategories__title {
  margin: 0 0 0.75rem;
  font-size: 1rem;
}

.catalog-subcategories__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
  gap: 0.65rem;
}

.catalog-subcategory-card {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.75rem;
  border: 1px solid var(--border-subtle, #e5e7eb);
  border-radius: 1rem;
  text-decoration: none;
  color: inherit;
  background: #fff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.catalog-subcategory-card:hover {
  border-color: rgba(13, 123, 242, 0.45);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
  transform: translateY(-2px);
}

.catalog-subcategory-card__title {
  font-weight: 600;
}

.catalog-subcategory-card__desc {
  font-size: 0.8125rem;
  color: var(--text-muted, #6b7280);
}

.catalog-card__specs {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 0.75rem;
  line-height: 1.35;
  color: var(--text-muted, #6b7280);
}

.catalog-card__specs li {
  margin: 0;
  padding: 0.1rem 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.catalog-card__specs--compact li:nth-child(n + 3) {
  display: none;
}

.catalog-card__sku {
  margin: 0.2rem 0 0;
  font-size: 0.6875rem;
  color: var(--text-muted, #9ca3af);
  letter-spacing: 0.01em;
}

.catalog-card__stock {
  margin: 0;
  font-size: 0.75rem;
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.25rem 0.4rem;
}

.catalog-card__stock-dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  flex-shrink: 0;
}

.catalog-card__stock--in {
  color: #15803d;
}

.catalog-card__stock--in .catalog-card__stock-dot {
  background: #22c55e;
}

.catalog-card__stock--order {
  color: #b45309;
}

.catalog-card__stock--order .catalog-card__stock-dot {
  background: #f59e0b;
}

.catalog-card__stock-label {
  font-weight: 600;
}

.catalog-card__stock-qty {
  font-weight: 500;
  font-size: 0.6875rem;
  color: var(--text-muted, #6b7280);
}

@media (max-width: 480px) {
  .catalog-card:not(.catalog-card--list) .catalog-card__specs {
    display: none;
  }

  .catalog-card:not(.catalog-card--list) .catalog-card__sku {
    display: none;
  }
}

.catalog-card__badge--hit {
  background: #7c3aed;
}
