/* Блоки категорий сверху */
.cat-blocks {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 12px;
  margin-bottom: 32px;
}

.cat-block {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  padding: 16px;
  border-radius: 12px;
  text-decoration: none;
  color: white;
  font-size: 0.95rem;
  font-weight: 600;
  min-height: 120px;
  background: var(--primary-3);
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
  word-break: break-word;
}

.cat-block:nth-child(2) {
  background: #e8a0c0;
}
.cat-block:nth-child(3) {
  background: #a0c8e8;
}
.cat-block:nth-child(4) {
  background: #a0e8b8;
}
.cat-block:nth-child(5) {
  background: #e8c8a0;
}
.cat-block:nth-child(6) {
  background: #c8a0e8;
}
.cat-block:nth-child(7) {
  background: #e8e0a0;
}
.cat-block:nth-child(8) {
  background: #a0e8e8;
}

.cat-block:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
  color: white;
}

.cat-block-name {
  font-size: 0.95rem;
  hyphens: auto;
  word-break: break-word;
  overflow-wrap: break-word;
  font-weight: 500;
  line-height: 22px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

/* Основной лейаут */
.catalog-page {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 24px;
  align-items: start;
}

/* Сайдбар */
.catalog-aside {
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: sticky;
  top: 20px;
}

.aside-section {
  background: #f5f6f8;
  border-radius: 5px;
  padding: 16px;
}

.aside-title {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 12px;
}

.aside-cat-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 12px;
  line-height: 1.3;
}

/* Навигация категорий */
.aside-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.aside-nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 0;
  color: var(--text);
  text-decoration: none;
  font-size: 0.9rem;
  transition: color 0.15s;
  border-bottom: none;
}

.aside-nav-item:hover {
  color: var(--primary-3);
  background: none;
}

.aside-nav-item.active {
  color: var(--text);
  font-weight: 600;
  background: none;
}

.aside-nav-item.active .aside-count {
  background: none;
  border: none;
  color: var(--muted);
}

.aside-count {
  background: none;
  border: none;
  font-size: 0.82rem;
  color: var(--muted);
  padding: 0;
}

/* Фильтры */
.filter-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.filter-group {
  border-bottom: 1px solid var(--border);
  padding-bottom: 14px;
}

.filter-group:last-of-type {
  border-bottom: none;
  padding-bottom: 0;
}

.filter-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.filter-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.88rem;
  color: var(--text);
  cursor: pointer;
  padding: 4px 0;
  transition: color 0.15s;
}

.filter-check:hover {
  color: var(--primary-2);
}

.filter-check input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary-2);
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
  margin: 0;
  border-radius: 4px;
}

.filter-submit {
  padding: 10px;
  background: var(--primary-2);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.2s;
  font-family: inherit;
}

.filter-submit:hover {
  opacity: 0.85;
}

.filter-reset {
  text-align: center;
  font-size: 0.82rem;
  color: var(--muted);
  text-decoration: none;
  transition: color 0.2s;
}

.filter-reset:hover {
  color: var(--danger);
}

/* Тулбар */
.catalog-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding: 10px 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.catalog-count {
  font-size: 0.85rem;
  color: var(--muted);
}

.toolbar-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.toolbar-select {
  padding: 6px 30px 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  font-size: 0.85rem;
  font-family: inherit;
  color: var(--text);
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' xmlns='http://www.w3.org/2000/svg'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 14px;
}

.toolbar-select:focus {
  outline: none;
  border-color: var(--primary-2);
}

.view-toggle {
  display: flex;
  gap: 4px;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.view-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--muted);
  transition: all 0.15s;
}

.view-btn svg {
  width: 16px;
  height: 16px;
}

.view-btn:hover {
  background: var(--bg);
  color: var(--text);
}

.view-btn.active {
  background: var(--primary-2);
  color: white;
}

/* Вид — список */
.products-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.product-list-item {
  display: flex;
  gap: 16px;
  padding: 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  text-decoration: none;
  color: var(--text);
  transition: box-shadow 0.2s;
  align-items: center;
}

.product-list-item:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.product-list-item img {
  width: 80px;
  height: 80px;
  object-fit: contain;
  border-radius: 8px;
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.product-list-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.product-list-info h3 {
  font-size: 0.95rem;
  font-weight: 600;
}

.product-list-article {
  font-size: 0.8rem;
  color: var(--muted);
}

.product-list-info p {
  font-size: 0.85rem;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Вид — таблица */
.products-table-wrap {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.products-table {
  width: 100%;
  border-collapse: collapse;
}

.products-table th {
  padding: 12px 16px;
  text-align: left;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.products-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
  vertical-align: middle;
}

.products-table tr:last-child td {
  border-bottom: none;
}

.products-table tr:hover td {
  background: var(--bg);
}

.no-products {
  text-align: center;
  color: var(--muted);
  padding: 48px 0;
}

.product-card {
  color: var(--text);
  text-decoration: none;
}

.product-card p,
.product-card h3 {
  color: var(--text);
}

.excerpt {
  color: var(--muted);
}

/* Адаптив */
@media (max-width: 1024px) {
  .cat-blocks {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (max-width: 768px) {
  .cat-blocks {
    grid-template-columns: repeat(2, 1fr);
  }

  .catalog-page {
    grid-template-columns: 1fr;
  }

  .catalog-aside {
    position: static;
  }

  .catalog-toolbar {
    flex-direction: column;
    gap: 10px;
    align-items: flex-start;
  }

  .toolbar-controls {
    flex-wrap: wrap;
    width: 100%;
  }
}
