/* Company catalog: category page (catalog-category.hbs). Ported from the old per-page code injection («Знай Наших» category pages). */

/* --- WIDTH / HERO --- */
.catalog-category-template .post-content-grid,
.catalog-category-template .post-content-wrapper,
.catalog { max-width: 1100px; width: 100%; margin-left: auto; margin-right: auto; box-sizing: border-box; }
.catalog { padding-bottom: 20px; }
.catalog-hero,
.catalog-hero .section-hero-content {
  max-width: 1100px !important; width: 100% !important; margin-left: 0 !important; margin-right: 0 !important;
  padding-left: 0 !important; padding-right: 0 !important; box-sizing: border-box; text-align: left;
}
.catalog-hero { padding: 0 0 30px 0 !important; }
.catalog-hero h1 { margin: 0 0 10px; }
.catalog-hero p { margin: 0; }
.catalog [hidden] { display: none !important; }

/* --- BREADCRUMB --- */
.category-breadcrumb { width: 100%; margin-bottom: 10px; font-size: 14px; color: #444; text-align: left; }
.category-breadcrumb a { color: #000; text-decoration: none; }
.category-breadcrumb a:hover { color: #ff008a; }
.category-breadcrumb > span:last-child { color: #999; }

/* --- SEARCH + ADD --- */
.mu-search-row { display: flex; align-items: stretch; justify-content: space-between; gap: 15px; margin-bottom: 1rem; }
.mu-search { flex-grow: 1; position: relative; }
.mu-search input {
  width: 100%; height: 56px; padding: 1.1rem 1.5rem 1.1rem 3rem; font-size: 1.15rem; border-radius: 10px;
  border: 1px solid #ccc; box-shadow: 0 3px 8px rgba(0, 0, 0, 0.05); box-sizing: border-box; color: #111;
  background: #f5f5f5 url("data:image/svg+xml,%3Csvg width='20' height='20' viewBox='0 0 20 20' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M17.5 17.5L13.875 13.875M15.8333 9.16667C15.8333 12.8486 12.8486 15.8333 9.16667 15.8333C5.48477 15.8333 2.5 12.8486 2.5 9.16667C2.5 5.48477 5.48477 2.5 9.16667 2.5C12.8486 2.5 15.8333 5.48477 15.8333 9.16667Z' stroke='%23555' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat 1rem center;
  background-size: 20px 20px;
}
.mu-add-button {
  height: 56px; padding: 0 1.8rem; font-size: 1.1rem; font-weight: 700; color: #fff !important; background-color: #000;
  border: none; border-radius: 10px; cursor: pointer; display: flex; align-items: center; gap: 0.4rem; text-decoration: none; box-sizing: border-box;
}
.mu-add-button:hover { background-color: #ff008a; }
.mu-add-button .plus-icon { font-size: 1.7rem; font-weight: 900; margin-top: -1px; }

/* --- SORT BAR --- */
.mu-divider-icons { margin: 2rem 0; }
.mu-divider-icons .divider-content { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.mu-divider-icons hr { flex-grow: 1; height: 1px; background: #ccc; border: none; margin: 0; }
.view-toggle { display: flex; gap: 10px; }
.view-btn { border: none; padding: 0; background: none; cursor: pointer; line-height: 0; }
.view-btn svg { width: 24px; height: 24px; padding: 4px; border-radius: 6px; background-color: #eee; stroke: #555; transition: background-color .3s, stroke .3s; }
.view-btn.active svg { background-color: #ffe6f0; stroke: #ff008a; }
.view-btn:hover svg { stroke: #ff008a; }

.mu-sort-wrapper { display: flex; align-items: center; position: relative; }
.mu-sort-button {
  display: flex; align-items: center; gap: 6px; padding: 4px 10px; height: 32px; background-color: #eee;
  border: none; border-radius: 6px; font-size: 0.7rem; color: #333; cursor: pointer; white-space: nowrap;
}
.mu-sort-button:hover { background-color: #e0e0e0; }
.mu-sort-main { font-weight: 600; text-transform: uppercase; }
.mu-sort-sub { font-weight: 400; text-transform: uppercase; }
.mu-sort-arrow { font-size: 0.6rem; margin-top: 1px; }
.mu-sort-options {
  position: absolute; top: 36px; left: 0; background: #fff; border-radius: 6px; box-shadow: 0 4px 12px rgba(0,0,0,.1);
  padding: 6px 0; z-index: 20; min-width: 180px; max-height: 60vh; overflow-y: auto;
}
.mu-sort-options div { padding: 8px 12px; font-size: 0.85rem; color: #333; cursor: pointer; white-space: nowrap; }
.mu-sort-options div:hover { background-color: #f0f0f0; }
.mu-sort-options div.selected { color: #ff008a; font-weight: 600; }

/* --- TOP-5 + CARDS --- */
.top10-wrapper { margin: 50px 0 47px; text-align: left; }
.top10-heading { font-size: 1.25rem; font-weight: 700; margin: 0 0 20px; text-align: center; }
.top10-grid, .company-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; margin: 0 0 30px;
}
.company-card {
  position: relative; background-color: #f2f2f2; border-radius: 10px; padding: 1rem; color: inherit;
  box-shadow: 0 2px 6px rgba(0,0,0,.05); transition: transform .2s ease, background-color .2s ease, border .2s ease;
  border: 1px solid transparent; display: block; cursor: pointer;
}
.top10-grid .company-card:nth-child(5n+1) { background-color: #fde2e2; }
.top10-grid .company-card:nth-child(5n+2) { background-color: #d7eaff; }
.top10-grid .company-card:nth-child(5n+3) { background-color: #d9f5dc; }
.top10-grid .company-card:nth-child(5n+4) { background-color: #fff1d6; }
.top10-grid .company-card:nth-child(5n+5) { background-color: #f1e6ff; }
.company-card:hover { transform: scale(1.02); background-color: #ffe6f0 !important; border: 1px solid #ff008a; }
.company-card:hover .company-name a, .company-card:hover .company-phone a { color: #ff008a; }
.company-location { font-size: 0.8rem; color: #666; margin-bottom: 0.3rem; }
.company-name { line-height: 1.2em; max-height: 4.8em; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; }
.company-name a { color: #000; text-decoration: none; }
.company-name a::after { content: ""; position: absolute; inset: 0; z-index: 1; } /* whole card is the link */
.company-description {
  font-size: 0.9rem; color: #333; margin: 0.3rem 0; line-height: 1.3; max-height: calc(1.3em * 4);
  overflow: hidden; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical;
}
.company-phone { font-size: 0.95rem; margin-top: 0.3rem; }
.company-phone a { position: relative; z-index: 2; text-decoration: none; color: inherit; transition: color .2s ease; }
.grid-view .company-logo-wrapper { display: none; }

/* --- LIST VIEW --- */
.company-grid.list-view, .top10-grid.list-view { display: flex; flex-direction: column; gap: 16px; }
.list-view .company-card { display: flex; align-items: stretch; justify-content: space-between; gap: 20px; padding: 1.2rem 1.5rem; }
.list-view .company-text-content { flex: 1; display: flex; flex-direction: column; justify-content: center; }
.list-view .company-logo-wrapper { width: 130px; flex-shrink: 0; display: flex; align-items: stretch; justify-content: center; }
.list-view .company-logo-thumb {
  width: 100%; height: 100%; object-fit: cover; aspect-ratio: 1 / 1; border-radius: 8px;
  border: 1px solid rgba(0,0,0,.15); box-shadow: 0 2px 6px rgba(0,0,0,.06);
}
.list-view .company-name { font-size: 1.2rem; font-weight: 700; }
.list-view .company-description { font-size: 1rem; -webkit-line-clamp: 2; max-height: calc(1.3em * 2); }

/* --- LOAD MORE / EMPTY --- */
.catalog-more {
  display: block; margin: 24px auto 0; padding: 10px 24px; border-radius: 8px; background: #000; color: #fff;
  font-weight: 700; border: none; cursor: pointer;
}
.catalog-more:hover { background: #ff008a; }
.catalog-more:disabled { opacity: .5; cursor: wait; }
.catalog-empty { text-align: center; padding: 30px; }

/* --- CATEGORY CHIPS --- */
.mu-categories-grid { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin: 50px 0; }
.category-chip {
  padding: 0.6rem 1.2rem; background: #e0e0e0; border-radius: 999px; font-size: 1rem; color: #000;
  text-decoration: none; transition: background-color .3s ease, color .3s ease;
}
.category-chip:hover, .category-chip.selected { background-color: #ff008a; color: #fff; text-decoration: none; }
.category-chip .category-count { font-size: 0.75em; opacity: 0.7; margin-left: 4px; }

/* --- DARK MODE (Aspect: data-color-scheme on <html>) --- */
html[data-color-scheme="dark"] .company-card { background-color: #2a2a2a; }
html[data-color-scheme="dark"] .company-name a,
html[data-color-scheme="dark"] .company-description,
html[data-color-scheme="dark"] .category-breadcrumb a { color: var(--color-contrast, #fff); }
html[data-color-scheme="dark"] .top10-grid .company-card .company-name a,
html[data-color-scheme="dark"] .top10-grid .company-card .company-description,
html[data-color-scheme="dark"] .top10-grid .company-card .company-phone a { color: #111; }
html[data-color-scheme="dark"] .category-chip { background: #333; color: #fff; }

/* --- MOBILE --- */
@media (max-width: 768px) {
  .mu-add-button { padding: 0; width: 56px; justify-content: center; }
  .mu-add-button .add-label { display: none; }
  .mu-add-button .plus-icon { font-size: 2rem; line-height: 1; margin: 0; }
  .mu-divider-icons .divider-content { flex-wrap: wrap; gap: 10px; }
  .mu-divider-icons hr { display: none; }
  .view-toggle { margin-left: auto; }
  .top10-grid, .company-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .list-view .company-logo-wrapper { width: 80px; }
}

/* --- CATALOG HOME (custom-catalog-home.hbs) --- */
.category-badge {
  display: inline-block; max-width: 100%; padding: 4px 10px; border-radius: 8px; font-size: 0.75rem; font-weight: 600;
  background-color: rgba(255,255,255,.35); color: #000; margin-bottom: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.company-grid .category-badge { background-color: rgba(0,0,0,.06); }
.catalog-home .catalog-results { margin-bottom: 20px; }
.catalog-count { font-size: 0.8rem; color: #666; white-space: nowrap; }
.catalog-loading { display: flex; flex-direction: column; align-items: center; gap: 14px; margin: 40px 0; font-size: 1.15rem; color: #333; }
.zn-spinner {
  display: inline-block; width: 46px; height: 46px; border: 6px solid #f3f3f3; border-top-color: #ff008a; border-radius: 50%;
  animation: zn-spin 1s linear infinite;
}
@keyframes zn-spin { to { transform: rotate(360deg); } }
.catalog-home-template .section-read-next { max-width: 1100px; margin-left: auto; margin-right: auto; }

/* --- ONE SEARCH ON CATALOG PAGES: the catalog has its own search field, so hide the site-wide search in the top bar (as the old pages did) --- */
.catalog-category-template .navbar .search-toggle { display: none !important; }

/* ТОП-5: a #top-<slug> block replaces the Featured block */
.top-override ~ .top-featured { display: none !important; }
