/* ============================================================
   CleanLabel.Life — 04-catalog.css
   Каталог, chips, additives-grid, пагинация, empty-results,
   карточка продукта (product.php), каталог продуктов.
   ============================================================ */

   .catalog-search {
    padding: 0 0 24px;
}

.search-box-catalog {
    display: flex;
    gap: 8px;
    max-width: 560px;
    margin: 0 auto;
    padding: 6px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 14px;
}

.search-box-catalog input {
    flex: 1;
    border: 0;
    outline: 0;
    padding: 10px 14px;
    font: inherit;
    background: transparent;
    min-width: 0;
}

.search-box-catalog button {
    padding: 0 18px;
    border: 0;
    background: var(--green);
    color: #fff;
    border-radius: 10px;
    font-weight: 750;
    cursor: pointer;
    font-size: 13px;
}

.search-box-catalog button:hover {
    background: var(--green-dark);
}

.search-reset {
    display: inline-flex;
    align-items: center;
    padding: 0 12px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.search-reset:hover {
    color: var(--green);
}

.catalog-header {
    padding: 48px 0 24px;
    text-align: center;
}

.catalog-header h1 {
    font-size: 40px;
    margin: 8px 0 16px;
    line-height: 1.15;
}

.catalog-header .section-description {
    max-width: 640px;
    margin: 0 auto;
}

.catalog-filters {
    border-bottom: 1px solid #ececec;
    margin-bottom: 24px;
}

.filter-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 16px 0 20px;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 999px;
    background: #f4f4f4;
    color: #333;
    text-decoration: none;
    font-size: 14px;
    white-space: nowrap;
    transition: background .15s, color .15s;
}

.chip:hover {
    background: #e8e8e8;
}

.chip.active {
    background: #111;
    color: #fff;
}

.chip-count {
    font-size: 12px;
    opacity: .65;
}

.chip.active .chip-count {
    opacity: .8;
}

.catalog-meta {
    font-size: 14px;
    color: #888;
    margin-bottom: 16px;
}

/* ---------- ADDITIVES GRID ---------- */
.additives-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 14px;
    padding: 8px 0 32px;
}

.additive-card {
    position: relative;
    display: flex;
    flex-direction: column;
    padding: 16px 18px 16px 22px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #fff;
    overflow: hidden;
    transition: border-color .15s, box-shadow .15s, transform .15s;
}

.additive-card:hover {
    border-color: var(--green);
    box-shadow: 0 6px 18px rgba(0, 0, 0, .06);
    transform: translateY(-1px);
}

.additive-card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: 4px;
    background: #e08c00;
    z-index: 2;
}

/* Ссылка внутри карточки — заполняет всё пространство */
.additive-card-link {
    display: block;
    text-decoration: none;
    color: inherit;
    flex: 1;
}

/* Мета-строка с кнопкой редактирования */
.additive-card-meta {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
}

.additive-card.level-success::before {
    background: #22a04a;
}

.additive-card.level-warning::before {
    background: #e08c00;
}

.additive-card.level-danger::before {
    background: #d40024;
}

.additive-card .additive-code {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12px;
    font-weight: 700;
    color: #666;
    margin-bottom: 8px;
    letter-spacing: .3px;
}

.additive-card .additive-name {
    font-size: 15px;
    font-weight: 700;
    line-height: 1.35;
    margin-bottom: 6px;
    color: var(--text);
}

.additive-card .additive-purpose {
    font-size: 12px;
    color: var(--muted);
    line-height: 1.4;
}

.empty {
    text-align: center;
    padding: 60px 0;
    color: #888;
}

/* ---------- EMPTY RESULTS ---------- */
.empty-results {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 30px;
    text-align: center;
    margin: 20px 0;
}

.empty-results h3 {
    font-size: 20px;
    margin-bottom: 12px;
}

.empty-results ul {
    list-style: none;
    padding: 0;
    margin: 12px 0;
}

.empty-results li {
    padding: 6px 0;
    color: var(--muted);
}

.empty-results a {
    color: var(--green);
    font-weight: 700;
}

/* ============================================================
   РЕЗУЛЬТАТЫ ПОИСКА (home.php / search)
   ============================================================ */

/* ---------- PAGE HEADER ---------- */
.page-header {
    margin: 0 0 22px;
    max-width: 780px;
}

.page-header h1 {
    font-size: clamp(30px, 4vw, 42px);
    line-height: 1.1;
    letter-spacing: -1.4px;
    margin: 0 0 10px;
    color: var(--text);
}

.page-description {
    color: var(--muted);
    font-size: 15px;
    line-height: 1.55;
    margin: 0;
}

.page-description .query {
    color: var(--green);
    font-weight: 800;
    background: var(--green-soft);
    padding: 2px 8px;
    border-radius: 7px;
    font-size: 14px;
}

/* ---------- SUMMARY (карточки-счётчики) ---------- */
.summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 240px));
    gap: 12px;
    margin: 0 0 26px;
}

.summary-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 18px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 16px;
    transition: border-color .15s, box-shadow .15s;
}

.summary-card:hover {
    border-color: var(--green);
    box-shadow: 0 4px 14px rgba(23, 76, 59, .06);
}

.summary-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: var(--green-soft);
    display: grid;
    place-items: center;
    font-size: 20px;
    flex-shrink: 0;
}

.summary-number {
    display: block;
    font-size: 22px;
    font-weight: 850;
    line-height: 1;
    color: var(--text);
    letter-spacing: -.6px;
}

.summary-label {
    display: block;
    font-size: 11px;
    color: var(--muted);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
    margin-top: 3px;
}

/* ---------- CONTENT LAYOUT (результаты + сайдбар) ---------- */
.content-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 300px;
    gap: 28px;
    align-items: start;
    margin-top: 8px;
}

/* ---------- SECTION TITLE ---------- */
.section-title {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 14px;
    margin: 0 0 16px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}

.section-title h2 {
    font-size: 22px;
    letter-spacing: -.6px;
    margin: 0;
    color: var(--text);
}

.section-count {
    font-size: 12px;
    color: var(--muted);
    font-weight: 700;
    white-space: nowrap;
}

/* ---------- SUBHEAD (Точное / Похожие) ---------- */
.section-subhead {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 14px;
    margin: 22px 0 14px;
}

.section-subhead-title {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.section-subhead-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 20px;
    padding: 0 8px;
    background: #eef3f0;
    color: var(--muted);
    border-radius: 999px;
    font-size: 11px;
    font-weight: 800;
}

.section-subhead-hint {
    font-size: 12px;
    color: var(--muted);
    line-height: 1.4;
    flex: 1 1 100%;
}

/* ---------- BADGE EXACT / SIMILAR ---------- */
.section-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 11px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 850;
    text-transform: uppercase;
    letter-spacing: .5px;
    line-height: 1;
}

.section-badge--exact {
    background: #d1f0dd;
    color: #1a7f37;
    border: 1px solid #a9dcbb;
}

.section-badge--similar {
    background: #fff7df;
    color: #8a6a1f;
    border: 1px solid #f0cd80;
}

/* ---------- САЙДБАР РЕЗУЛЬТАТОВ ---------- */
.sidebar {
    display: flex;
    flex-direction: column;
    gap: 14px;
    position: sticky;
    top: 90px;
}

/* ---------- АДАПТИВ РЕЗУЛЬТАТОВ ---------- */
@media (max-width: 900px) {
    .content-layout {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: static;
        top: auto;
    }
}

@media (max-width: 600px) {
    .summary {
        grid-template-columns: 1fr 1fr;
    }

    .summary-card {
        padding: 12px 14px;
        gap: 10px;
    }

    .summary-icon {
        width: 36px;
        height: 36px;
        font-size: 17px;
    }

    .summary-number {
        font-size: 18px;
    }

    .page-header h1 {
        font-size: 26px;
    }
}

/* ---------- ПАГИНАЦИЯ ---------- */
.pagination {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 6px;
    padding: 24px 0 48px;
}

.page-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    border-radius: 8px;
    background: #f4f4f4;
    color: #333;
    text-decoration: none;
    font-size: 14px;
    transition: background .15s;
}

.page-link:hover {
    background: #e8e8e8;
}

.page-link.active {
    background: #111;
    color: #fff;
    font-weight: 600;
}

.page-dots {
    padding: 0 4px;
    color: #999;
}

/* ---------- УРОВНИ ОПАСНОСТИ ---------- */
.level-success {
    background: linear-gradient(180deg, #e8f7ee 0%, #ffffff 480px);
}

.level-warning {
    background: linear-gradient(180deg, #fff5e0 0%, #ffffff 480px);
}

.level-danger {
    background: linear-gradient(180deg, #fde8e8 0%, #ffffff 480px);
}

.level-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.level-dot.success {
    background: #22a04a;
    box-shadow: 0 0 0 3px #d1f0dd;
}

.level-dot.warning {
    background: #e08c00;
    box-shadow: 0 0 0 3px #ffe8b8;
}

.level-dot.danger {
    background: #d40024;
    box-shadow: 0 0 0 3px #ffd1d1;
}

.e-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    border-radius: 9px;
    font-size: 12px;
    font-weight: 850;
    margin-bottom: 18px;
    cursor: help;
    transition: transform .15s, box-shadow .15s;
}

.e-badge:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, .12);
}

.e-badge.level-success {
    background: #d1f0dd;
    color: #1a7f37;
    border: 1px solid #a9dcbb;
}

.e-badge.level-warning {
    background: #ffe8b8;
    color: #a15c00;
    border: 1px solid #f0cd80;
}

.e-badge.level-danger {
    background: #ffd1d1;
    color: #b00020;
    border: 1px solid #f0a5a5;
}

/* ============================================================
   КАТАЛОГ ПРОДУКТОВ
   ============================================================ */

.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
    padding: 8px 0 32px;
}

/* Обёртка карточки — держит ссылку и иконку редактирования */
.product-card-wrap {
    position: relative;
    display: flex;
}

.product-card {
    position: relative;
    display: flex;
    flex-direction: column;
    flex: 1;
    width: 100%;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 16px;
    text-decoration: none;
    color: inherit;
    overflow: hidden;
    transition: border-color .15s, box-shadow .15s, transform .15s;
}

.product-card:hover {
    border-color: var(--green);
    box-shadow: 0 6px 18px rgba(0, 0, 0, .06);
    transform: translateY(-2px);
}

.product-card-image {
    width: 100%;
    aspect-ratio: 1 / 1;
    background: #f7faf8;
    overflow: hidden;
    display: flex; 
    align-items: center; 
    justify-content: center; 
    flex-shrink: 0;
}

.product-card-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
    display: block;
}

.product-card-body {
    padding: 14px 16px 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
}

.product-card-title {
    font-size: 14px;
    font-weight: 800;
    line-height: 1.35;
    color: var(--text);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.product-card-brand {
    font-size: 11px;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .4px;
}

.product-card-ingredients {
    font-size: 12px;
    color: var(--muted);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.product-card-footer {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    margin-top: auto;
    padding-top: 8px;
    border-top: 1px solid var(--border);
}

.product-card-category {
    font-size: 11px;
    color: var(--muted);
    font-weight: 700;
}

/* Иконка редактирования — в правом верхнем углу карточки */
.product-card-wrap .admin-edit-btn--icon {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 5;
}

/* ============================================================
   КАРТОЧКА ПРОДУКТА (product.php)
   заголовок сверху, ниже фото слева / состав+добавки справа,
   блоки ниже — одной колонкой, снизу — мета-полоса.
   ============================================================ */

.product-header {
    margin-bottom: 20px;
}

.product-header .product-title {
    margin: 0 0 4px;
    font-size: 28px;
    line-height: 1.2;
}

.product-header .product-brand {
    font-size: 14px;
    color: #7a8580;
}

/* Двухколоночная шапка: фото | состав — обе на всю ширину колонок */
.product-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 20px;
    align-items: start;
    margin-bottom: 24px;
}

/* === ФОТО ТОВАРА: контейнер с фиксированной пропорцией === */
.product-photo {
    background: #fafcfb;
    border: 1px solid #e8efeb;
    border-radius: 12px;
    overflow: hidden;
    width: 100%;
    aspect-ratio: 1 / 1;         /* квадрат — стандарт для карточки */
    display: flex;
    align-items: center;
    justify-content: center;
}

.product-photo img {
    display: block;
    width: 100%;
    height: 100%;                /* ← работает вместе с object-fit */
    object-fit: contain;         /* ← вписывает узкие/широкие фото */
    object-position: center;
}

.product-photo-empty {
    color: #9aa8a1;
    font-size: 13px;
}

.product-composition {
    background: #fff;
    border: 1px solid #e8efeb;
    border-radius: 12px;
    padding: 16px 18px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
    box-sizing: border-box;
    align-self: stretch;
}

.product-composition .status-label {
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #7a8580;
    margin-bottom: 6px;
}

.product-composition .status-title {
    font-size: 20px;
    font-weight: 800;
    margin-bottom: 10px;
}

/* Приглушённый вариант «Добавок не найдено» */
.product-composition .status-title--muted {
    font-size: 15px;
    font-weight: 700;
    color: #7a8580;
    margin-bottom: 0;
}

/* Разделитель между составом и добавками */
.product-composition-additives {
    padding-top: 14px;
    border-top: 1px solid #eef3f0;
}

/* Текст состава внутри шапки — компактнее, чем .ingredients-text в content-card */
.product-composition .ingredients-text {
    font-size: 13px;
    line-height: 1.6;
    padding: 12px 14px;
    margin: 0;
}

.product-composition .ingredients-text.muted {
    color: #9aa8a1;
}

.product-composition .ingredients-text h1,
.product-composition .ingredients-text h2,
.product-composition .ingredients-text h3,
.product-composition .ingredients-text h4 {
    font-size: 13px;
}

.product-composition .ingredients-text:last-child {
    margin-bottom: 0;
}

/* Ingredients-текст (используется в .content-card «Состав» и в шапке) */
.ingredients-text {
    font-size: 14px;
    line-height: 1.7;
    color: #52615a;
    background: #f7faf8;
    border-radius: 12px;
    padding: 16px 18px;
    margin: 0;
}

/* Внутри — компактные заголовки и списки */
.ingredients-text h1,
.ingredients-text h2,
.ingredients-text h3,
.ingredients-text h4 {
    font-size: 14px;
    font-weight: 800;
    margin: 12px 0 6px;
    color: var(--text);
    line-height: 1.3;
}
.ingredients-text h1:first-child,
.ingredients-text h2:first-child,
.ingredients-text h3:first-child,
.ingredients-text h4:first-child {
    margin-top: 0;
}
.ingredients-text p {
    margin: 0 0 8px;
}
.ingredients-text p:last-child {
    margin-bottom: 0;
}
.ingredients-text ul,
.ingredients-text ol {
    margin: 6px 0 10px;
    padding-left: 20px;
}
.ingredients-text li {
    margin: 3px 0;
}
.ingredients-text strong {
    color: var(--text);
}

/* --- Блоки под шапкой — те же .content-card, с отступом --- */
.product-layout ~ .content-card {
    margin-top: 20px;
}

/* --- Мета-полоса снизу --- */
.product-meta-strip {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 14px 20px;
    margin-top: 24px;
    padding: 16px 20px;
    background: #f7faf8;
    border: 1px solid #e8efeb;
    border-radius: 12px;
    font-size: 13px;
}

.product-meta-info {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 22px;
    color: #52615a;
}

.product-meta-info em {
    font-style: normal;
    color: #7a8580;
    font-weight: 700;
    margin-right: 6px;
}

.product-meta-info a {
    color: var(--green);
    font-weight: 800;
    text-decoration: none;
}

.product-meta-info a:hover {
    text-decoration: underline;
}

.product-meta-info strong {
    font-weight: 800;
    color: var(--text);
}

.product-meta-help {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #7a8580;
}

.product-meta-link {
    display: inline-flex;
    align-items: center;
    padding: 6px 12px;
    background: #fff;
    border: 1px solid var(--green);
    color: var(--green);
    border-radius: 8px;
    font-size: 12px;
    font-weight: 800;
    text-decoration: none;
    transition: background .15s;
}

.product-meta-link:hover {
    background: var(--green-soft);
}

/* ---------- АДАПТИВ КАРТОЧКИ ПРОДУКТА ---------- */
@media (max-width: 720px) {
    .product-layout {
        grid-template-columns: 1fr;
    }

    .product-header .product-title {
        font-size: 22px;
    }

    /* На мобильных фото — 4:3, компактнее по высоте */
    .product-photo {
        aspect-ratio: 4 / 3;
    }
}

@media (max-width: 600px) {
    .product-meta-strip {
        flex-direction: column;
        align-items: flex-start;
        padding: 14px 16px;
    }

    .product-meta-help {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }
}

@media (max-width: 700px) {
    .products-grid {
        grid-template-columns: 1fr;      /* одна колонка */
        gap: 14px;
        padding: 8px 0 24px;
    }

    .product-card-wrap {
        width: 100%;
    }

    /* Фото — компактнее по высоте, чтобы не занимало пол-экрана */
    .product-card-image {
        aspect-ratio: 4 / 3;
    }

    /* Внутренние отступы карточки — поплотнее */
    .product-card-body {
        padding: 12px 14px 14px;
    }

    .product-card-title {
        font-size: 15px;
    }

    .product-card-ingredients {
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    .products-grid {
        gap: 12px;
    }

    .product-card-image {
        aspect-ratio: 3 / 2;         /* ещё компактнее на узких экранах */
    }

    /* Фото товара на самых узких — 4:3, чтобы не резало упаковку */
    .product-photo {
        aspect-ratio: 4 / 3;
    }

    .product-card-title {
        font-size: 14px;
    }
}

/* ============================================================
   Подсветка совпадений в поиске
   ============================================================ */

mark.search-hit {
    background: #fff3a0;
    color: inherit;
    padding: 0 2px;
    border-radius: 2px;
    font-weight: 700;
}

.ingredients-text mark.search-hit {
    background: #fef08a;
    color: #1f2937;
    padding: 0 2px;
    border-radius: 2px;
}

/* ============================================================
   Авто-линковка ингредиентов состава на поиск по каталогу
   ============================================================ */

.ingredients-text a.product-link {
    color: inherit;
    text-decoration: none;
    background: #eef6ff;
    border-bottom: 1px dashed #93c5fd;
    padding: 0 2px;
    border-radius: 2px;
    transition: background 0.15s;
}
.ingredients-text a.product-link:hover {
    background: #dbeafe;
    border-bottom-style: solid;
    text-decoration: none;
}
.ingredients-text a.product-link mark.search-hit {
    background: #fef08a;
}