/**
 * KP Template — Two sheet (фиксированные 2 листа A4)
 */

.kp-container--two-sheet {
    max-width: 210mm;
    padding: 0;
}

.kp-page--two-sheet {
    padding: 12px;
    background: #e8e8e8;
}

.kp-page--two-sheet .kp-container--two-sheet {
    background: transparent;
}

.kp-sheet {
    box-sizing: border-box;
    min-height: 277mm;
    background: #fff;
    padding: 12mm 10mm;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.kp-sheet--1 {
    /* Жёсткий лист A4: преимущества не вылезают на 2-ю страницу */
    height: 277mm;
    max-height: 277mm;
    min-height: 277mm;
    overflow: hidden;
    page-break-after: always;
    break-after: page;
    page-break-inside: avoid;
    break-inside: avoid;
    margin-bottom: 16px;
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.12);
}

.kp-sheet--2 {
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.12);
}

/* Разрыв только через .kp-sheet--1; элемент-маркер не должен создавать лишние страницы */
.kp-container--two-sheet > .kp-pagebreak {
    display: none !important;
    height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    page-break-before: auto !important;
    break-before: auto !important;
    page-break-after: auto !important;
    break-after: auto !important;
}

/* —— Лист 1 —— */
.kp-sheet1__intro {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    flex: 0 1 auto;
    max-height: 38%;
    min-height: 0;
    overflow: hidden;
}

.kp-sheet1__desc {
    font-size: 12px;
    line-height: 1.45;
    color: var(--kp-text);
    overflow: hidden;
    min-height: 0;
}

.kp-sheet1__desc-text {
    max-height: 100%;
    overflow: hidden;
}

.kp-sheet1__meta {
    display: flex;
    flex-direction: column;
    min-height: 0;
    gap: 8px;
    overflow: hidden;
}

.kp-sheet1__title {
    font-size: 16px;
    font-weight: 700;
    color: var(--kp-primary, #004a8e);
    text-decoration: none;
    line-height: 1.3;
}

a.kp-sheet1__title:hover {
    text-decoration: underline;
}

.kp-sheet1__brand {
    font-size: 11px;
    color: var(--kp-text-light);
}

.kp-sheet1__attrs {
    width: 100%;
    font-size: 11px;
    overflow: hidden;
}

.kp-sheet1__price {
    margin-top: auto;
    align-self: flex-end;
    text-align: right;
    flex: 0 0 auto;
}

.kp-sheet1__visual {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 0;
    max-height: 100%;
    overflow: hidden;
}

.kp-sheet1__advantages {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    min-height: 0;
    max-height: 100%;
    overflow: hidden;
    page-break-inside: avoid;
    break-inside: avoid;
}

.kp-sheet1__advantages .kp-section-title {
    flex: 0 0 auto;
    margin-bottom: 6px;
}

.kp-sheet1__advantages .kp-advantages__images {
    flex: 1 1 0;
    margin: 0;
    min-height: 0;
    height: 100%;
    max-height: 100%;
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow: hidden;
}

.kp-sheet1__advantages .kp-advantages__images--grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-auto-rows: minmax(0, 1fr);
    gap: 8px;
    height: 100%;
    max-height: 100%;
}

.kp-sheet1__advantages .kp-advantages__image {
    flex: 1 1 0;
    width: 100%;
    max-width: 100%;
    margin: 0;
    min-height: 0;
    max-height: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border: none;
}

.kp-sheet1__advantages .kp-advantages__image img,
.kp-sheet1__advantages .kp-advantages__images--grid .kp-advantages__image img,
.kp-sheet1__advantages .kp-advantages__images--count-3 .kp-advantages__image img {
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 100%;
    margin: 0;
    object-fit: contain;
    object-position: center top;
}

/* —— Лист 2 —— */
.kp-sheet2__specs {
    display: grid;
    grid-template-columns: 3fr 1fr;
    gap: 14px;
    flex: 0 0 auto;
    align-items: start;
}

.kp-sheet2__attrs .kp-section-title {
    margin-bottom: 8px;
}

.kp-sheet2__attrs-grid {
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
}

.kp-sheet2__attrs-grid .kp-attributes__table {
    font-size: 10px;
}

.kp-sheet2__attrs-grid .kp-attributes__table th,
.kp-sheet2__attrs-grid .kp-attributes__table td {
    padding: 2px 4px;
}

.kp-sheet2__sidebar {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.kp-sheet2__scheme {
    border: none;
    border-radius: 0;
    overflow: hidden;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 45mm;
}

.kp-sheet2__scheme img {
    max-width: 100%;
    max-height: 55mm;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
}

.kp-sheet2__qr {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px;
    border: none;
    border-radius: 0;
    background: transparent;
}

.kp-sheet2__qr > div {
    margin: 0 auto;
}

.kp-sheet2__features {
    flex: 0 0 auto;
}

.kp-sheet2__features .kp-section-title {
    margin-bottom: 8px;
}

.kp-sheet2__features-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.kp-sheet2__features-grid--n1 {
    grid-template-columns: 1fr;
}

.kp-sheet2__features-grid--n2 {
    grid-template-columns: repeat(2, 1fr);
}

.kp-sheet2__features-grid--n3 {
    grid-template-columns: repeat(3, 1fr);
}

.kp-sheet2__features-grid--n4 {
    grid-template-columns: repeat(4, 1fr);
}

.kp-sheet2__feature {
    padding: 8px 10px;
    background: var(--kp-bg);
    border-radius: 4px;
    border: none;
    font-size: 11px;
    min-width: 0;
}

.kp-sheet2__feature-title {
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--kp-text);
}

.kp-sheet2__feature-text {
    color: var(--kp-text-light);
    line-height: 1.35;
    font-size: 10px;
}

.kp-sheet2__feature-text ul,
.kp-sheet2__feature-text ol {
    margin: 0;
    padding-left: 1.15em;
}

.kp-sheet2__feature-text li {
    margin: 0 0 2px;
    padding-left: 0.15em;
}

.kp-sheet--2 .kp-warranty {
    margin-top: 4px;
}

.kp-sheet--2 .kp-footer {
    margin-top: auto;
}

.kp-sheet--2 .kp-manager-table:empty {
    display: none;
}

/* Обычная печать two-sheet: меньше поля сверху/снизу (PDF — отдельно через is-exporting) */
@page {
    size: A4;
    margin: 5mm 10mm;
}

/* Печать / PDF */
@media print {
    .kp-page--two-sheet {
        padding: 0;
        background: #fff;
    }

    .kp-sheet {
        box-shadow: none;
        margin: 0;
        padding: 5mm 6mm;
        break-inside: avoid;
        page-break-inside: avoid;
    }

    .kp-sheet--1 {
        /* 297 − 5 − 5 (@page) */
        height: 287mm;
        max-height: 287mm;
        min-height: 287mm;
        overflow: hidden;
        page-break-after: always;
        break-after: page;
        margin: 0 !important;
        margin-bottom: 0 !important;
    }

    .kp-sheet--2 {
        min-height: 0;
        height: auto;
        max-height: none;
        page-break-before: auto;
        break-before: auto;
        margin: 0 !important;
    }

    .kp-container--two-sheet > .kp-pagebreak {
        display: none !important;
        height: 0 !important;
        page-break-before: auto !important;
        break-before: auto !important;
        page-break-after: auto !important;
        break-after: auto !important;
    }

    .kp-sheet1__advantages,
    .kp-sheet1__advantages .kp-advantages__images,
    .kp-sheet1__advantages .kp-advantages__image,
    .kp-sheet1__advantages .kp-advantages__image img {
        break-inside: avoid;
        page-break-inside: avoid;
    }

    /* Превью печати часто узкое — не схлопывать сетки листа 2 */
    .kp-sheet2__specs {
        display: grid !important;
        grid-template-columns: 3fr 1fr !important;
        align-items: start;
    }

    .kp-sheet2__attrs-grid {
        display: grid !important;
        grid-template-columns: 1fr 1fr 1fr !important;
    }

    .kp-sheet2__features-grid {
        display: grid !important;
    }

    .kp-sheet2__features-grid--n1 {
        grid-template-columns: 1fr !important;
    }

    .kp-sheet2__features-grid--n2 {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    .kp-sheet2__features-grid--n3 {
        grid-template-columns: repeat(3, 1fr) !important;
    }

    .kp-sheet2__features-grid--n4 {
        grid-template-columns: repeat(4, 1fr) !important;
    }

    .kp-sheet2__scheme {
        min-height: 0;
        border: none !important;
    }

    .kp-sheet2__scheme img {
        max-height: 50mm;
    }

    .kp-sheet2__qr {
        border: none !important;
    }

    .kp-sheet2__feature {
        border: none !important;
        border-left: none !important;
    }
}

body.kp-page.is-exporting.kp-page--two-sheet {
    padding: 0;
    background: #fff;
}

/* PDF two-sheet: без CSS-разрывов — страницы собирает kp-pdf.js по .kp-sheet */
body.kp-page.is-exporting.kp-page--two-sheet .kp-sheet {
    box-shadow: none !important;
    margin: 0 !important;
    padding: 8mm 6mm !important;
    page-break-after: auto !important;
    break-after: auto !important;
    page-break-before: auto !important;
    break-before: auto !important;
    page-break-inside: auto !important;
    break-inside: auto !important;
    min-height: 0 !important;
}

body.kp-page.is-exporting.kp-page--two-sheet .kp-sheet--1 {
    height: 270mm !important;
    max-height: 270mm !important;
    min-height: 0 !important;
    overflow: hidden !important;
}

body.kp-page.is-exporting.kp-page--two-sheet .kp-sheet--2 {
    height: auto !important;
    max-height: 270mm !important;
    overflow: hidden !important;
}

body.kp-page.is-exporting .kp-container--two-sheet > .kp-pagebreak {
    display: none !important;
    height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    page-break-before: auto !important;
    break-before: auto !important;
    page-break-after: auto !important;
    break-after: auto !important;
}

body.kp-page.is-exporting .kp-sheet2__specs {
    display: grid !important;
    grid-template-columns: 3fr 1fr !important;
}

body.kp-page.is-exporting .kp-sheet2__features-grid--n3 {
    grid-template-columns: repeat(3, 1fr) !important;
}

body.kp-page.is-exporting .kp-sheet2__features-grid--n4 {
    grid-template-columns: repeat(4, 1fr) !important;
}

body.kp-page.is-exporting .kp-sheet2__feature {
    border: none !important;
    border-left: none !important;
}

@media screen and (max-width: 720px) {
    .kp-sheet1__intro,
    .kp-sheet2__specs,
    .kp-sheet2__features-grid {
        grid-template-columns: 1fr;
    }

    .kp-sheet {
        min-height: 0;
        height: auto;
        max-height: none;
    }

    .kp-sheet--1 {
        height: auto;
        max-height: none;
        min-height: 0;
        overflow: visible;
    }

    .kp-sheet1__price {
        align-self: stretch;
        text-align: left;
    }
}
