/**
 * KP Module - Core Styles
 * Основные стили коммерческих предложений (без менеджера и действий)
 */

/* Глобальные настройки страницы для печати и PDF */
@page {
    size: A4;
    margin: 10mm;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body.kp-page {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--kp-text);
    background: #fff;
    padding: 20px;
}

.kp-container {
    max-width: 210mm;
    margin: 0 auto;
    padding: 20px;
}

.kp-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding-bottom: 20px;
    border-bottom: 2px solid var(--kp-primary);
    margin-bottom: 20px;
}

.kp-header__logo {
    flex: 0 0 auto;
    width: 220px;
    height: 60px;
    overflow: hidden;
    display: flex;
    align-items: center;
}

.kp-logo-canvas {
    display: block;
    width: 100%;
    height: 100%;
}

.kp-logo-canvas.kp-logo-canvas--brand {
    width: 150px;
    height: 50px;
}

.kp-header__logo img {
    display: block;
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.kp-header__company {
    text-align: right;
    font-size: 10px;
}

.kp-header__req-item {
    line-height: 1.4;
    margin-bottom: 2px;
}

.kp-header__req-name {
    font-weight: 600;
    font-size: 11px;
    color: var(--kp-primary);
}

.kp-header__date {
    font-size: 12px;
    color: var(--kp-text-light);
    text-align: right;
}

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

.kp-header__manager-title {
    font-weight: 600;
    font-size: 10px;
    color: var(--kp-primary);
    margin-bottom: 2px;
}

.kp-header__manager-phone {
    display: block;
    text-decoration: none;
    color: var(--kp-text);
    font-weight: 500;
}

.kp-header__manager-fio {
    margin-top: 2px;
    font-weight: 600;
    color: var(--kp-primary);
}

.kp-header__devider {
    margin-top: 4px;
    padding-top: 4px;
    border-bottom: 1px solid var(--kp-border);
}

.kp-header__phone {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 4px;
    font-size: 11px;
    justify-content: flex-end;
}

.kp-header__phone-icon {
    font-size: 12px;
}

.kp-header__phone a {
    color: var(--kp-text);
    text-decoration: none;
    font-weight: 500;
}

.kp-header__valid {
    font-weight: 600;
    color: #009900;
}

.kp-title {
    font-size: 24px;
    font-weight: 700;
    text-align: left;
    margin-bottom: 20px;
    text-transform: uppercase;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.kp-title .kp-product__brand-logo {
    display: inline-flex;
    align-items: center;
}

.kp-title .kp-product__brand-logo img,
.kp-title .kp-logo-canvas--brand {
    max-height: 25px;
    width: auto;
}

.kp-product {
    display: flex;
    gap: 30px;
    margin-bottom: 5px;
}

.kp-product__image {
    flex: 0 0 210px;
}

.kp-product__image img {
    width: 100%;
    height: auto;
    border: 1px solid var(--kp-border);
    border-radius: 4px;
}

.kp-product__info {
    flex: 1;
}

.kp-product__title {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 10px;
    color: var(--kp-text);
    text-decoration: none;
    line-height: 1.5rem;
}

.kp-product__sku,
.kp-product__brand {
    font-size: 13px;
    color: var(--kp-text-light);
    margin-bottom: 5px;
}

.kp-product__main-attrs-table {
    width: 100%;
    border-collapse: collapse;
    margin: 0;
    font-size: 13px;
    border-left: 3px solid #009900;
}

.kp-product__main-attrs-table th,
.kp-product__main-attrs-table td {
    padding: 5px 10px;
    text-align: left;
    background: var(--kp-bg);
    border: 1px solid var(--kp-border);
}

/* Белый фон для строки с артикулом */
.kp-product__main-attrs-table .kp-product__main-attr-sku th,
.kp-product__main-attrs-table .kp-product__main-attr-sku td {
    background: #fff;
}

.kp-product__main-attrs-table th {
    width: 50%;
    font-weight: 500;
    color: var(--kp-text-light);
}

.kp-product__main-attrs-table td {
    font-weight: 600;
    color: var(--kp-text);
}

.kp-product__brand-logo {
    margin: 10px 0;
    padding-top: 3px;
}

.kp-product__brand-logo img {
    max-width: 150px;
    max-height: 50px;
    width: auto;
    height: auto;
    display: block;
    object-fit: contain;
}

.kp-product__attrs-container {
    display: flex;
    align-items: flex-start;
    gap: 20px;
    margin: 10px 0;
}

.kp-product__qr-code {
    text-align: center;
    flex-shrink: 0;
}

.kp-product__qr-code canvas,
.kp-product__qr-code div {
    width: 100px;
    height: 100px;
    display: block;
    margin: 0 auto;
}

.kp-product__qr-text {
    font-size: 11px;
    color: var(--kp-text-light);
    margin-top: 5px;
    white-space: nowrap;
}

.kp-product__price {
    margin: 15px 0;
    font-size: 24px;
    text-align: right;
}

.kp-product__price-old {
    text-decoration: line-through;
    color: var(--kp-text-light);
    font-size: 16px;
    margin-right: 10px;
}

.kp-product__price-current {
    font-weight: 700;
    color: var(--kp-primary);
}

.kp-product__price-discount {
    background: #e74c3c;
    color: #fff;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 14px;
    margin-left: 10px;
}

.kp-product__price-vat {
    font-size: 12px;
    color: var(--kp-text-light);
    margin-left: 5px;
}

.kp-product__availability {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 13px;
    margin-bottom: 15px;
}

.kp-product__availability--instock {
    background: #e6f4e6;
    color: #009900;
}

.kp-product__availability--outofstock {
    background: #f8d7da;
    color: #721c24;
}

.kp-product__availability--onbackorder {
    background: #fff3cd;
    color: #856404;
}

.kp-product__description {
    font-size: 14px;
    line-height: 1.6;
}

.kp-section-title {
    font-size: 16px;
    font-weight: 600;
    color: #009900;
    margin-bottom: 15px;
    padding-bottom: 5px;
    border-bottom: 2px solid #009900;
}

.kp-description {
    margin-bottom: 25px;
}

.kp-description__text {
    font-size: 13px;
    line-height: 1.4;
    color: var(--kp-text);
}

.kp-description__text p {
    margin-bottom: 10px;
}

.kp-description__text ul,
.kp-description__text ol {
    margin: 10px 0;
    padding-left: 20px;
}

.kp-description__text li {
    margin-bottom: 5px;
}

.kp-description__text ul:has(li:nth-child(6)),
.kp-description__text ol:has(li:nth-child(6)) {
    column-count: 2;
    column-gap: 20px;
    line-height: 0.9rem;
}

.kp-advantages {
    margin-bottom: 20px;
}

.kp-advantages__images {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 10px;
}

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

.kp-advantages__image {
    overflow: hidden;
    border-radius: 4px;
    border: 1px solid var(--kp-border);
    width: 80%;
    margin: 0 auto;
}

.kp-advantages__image img {
    width: 80%;
    max-width: 80%;
    height: auto;
    display: block;
    margin: 0 auto;
}

/* Для ровно 3 изображений - растягиваем на 100% */
.kp-advantages__images--count-3 .kp-advantages__image,
.kp-advantages__images--count-3 .kp-advantages__image img {
    width: 100%;
    max-width: 100%;
}

/* Когда изображений несколько (сетка) - растягиваем на 100% */
.kp-advantages__images--grid .kp-advantages__image,
.kp-advantages__images--grid .kp-advantages__image img {
    width: 100%;
    max-width: 100%;
}

body.kp-page.is-exporting .kp-advantages__image {
    break-inside: avoid;
    break-inside: avoid-page;
    page-break-inside: avoid;
    -webkit-column-break-inside: avoid;
    margin-bottom: 10px;
}

body.kp-page.is-exporting .kp-advantages__image img {
    break-inside: avoid;
    break-inside: avoid-page;
    page-break-inside: avoid;
    -webkit-column-break-inside: avoid;
}

.kp-advantages__list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 15px;
    list-style: none;
    padding: 0;
    margin: 0;
}

.kp-advantages__item {
    display: flex;
    flex-direction: column;
    padding: 8px 10px;
    background: var(--kp-bg);
    border-radius: 4px;
    border-left: 3px solid #009900;
}

.kp-advantages__title {
    font-size: 12px;
    font-weight: 600;
    color: var(--kp-text);
}

.kp-advantages__text {
    font-size: 11px;
    color: var(--kp-text-light);
    margin-top: 3px;
}

.kp-attributes {
    margin-bottom: 20px;
}

.kp-attributes__grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 15px;
}

.kp-attributes__column {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.kp-attributes__group {
    font-size: 12px;
    font-weight: 600;
    margin: 8px 0 4px;
    color: var(--kp-text);
}

.kp-attributes__table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
    flex: 1; /* Занимает всю доступную высоту колонки */
}

.kp-attributes__table tr:nth-child(even) {
    background: var(--kp-bg);
}

.kp-attributes__table th,
.kp-attributes__table td {
    padding: 3px 6px;
    text-align: left;
    border: 1px solid var(--kp-border);
    line-height: 1.3;
}

.kp-attributes__table th {
    width: 70%;
    font-weight: 500;
    color: var(--kp-text-light);
}

.kp-attributes__table td {
    width: 430%;
}

.kp-complect {
    margin-bottom: 30px;
}

.kp-complect__table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.kp-complect__table th,
.kp-complect__table td {
    padding: 10px 12px;
    text-align: left;
    border: 1px solid var(--kp-border);
}

.kp-complect__table thead th {
    background: var(--kp-primary);
    color: #fff;
    font-weight: 500;
}

.kp-complect__table tbody tr:nth-child(even) {
    background: var(--kp-bg);
}

.kp-gallery {
    margin-bottom: 20px;
    max-height: 130mm;
    overflow: hidden;
}

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

.kp-gallery__item {
    aspect-ratio: 1;
    overflow: hidden;
}

.kp-gallery__item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border: 1px solid var(--kp-border);
    border-radius: 3px;
}

/* QR-код в галерее (квадрат, белый фон, центрирование) */
.kp-gallery__item--qr {
    background: #fff;
    border: 1px solid var(--kp-border);
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.kp-gallery__item--qr canvas,
.kp-gallery__item--qr div {
    margin: auto;
    display: block;
}

.kp-warranty {
    margin-bottom: 20px;
}

.kp-warranty__grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    align-items: stretch; /* Растягиваем колонки на равную высоту */
}

.kp-warranty__col {
    display: flex;
    flex-direction: column;
}

.kp-warranty__table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
    flex: 1; /* Занимает всю доступную высоту колонки */
}

.kp-warranty__table th,
.kp-warranty__table td {
    padding: 4px 8px;
    text-align: left;
    border: 1px solid var(--kp-border);
}

.kp-warranty__table th {
    width: 70%;
    font-weight: 500;
    background: var(--kp-bg);
}

.kp-warranty__table td {
    width: 30%;
    font-weight: 600;
    color: #009900;
}

/* Примечание в гарантии (вы spanning across columns) */
.kp-warranty__note {
    background: #f0f7ff;
    color: #0066cc;
    font-weight: 500;
    text-align: center !important;
    font-size: 12px;
    line-height: 1.3;
    padding: 10px !important; /* Добавляем padding вместо padding-top */
}

.kp-extra {
    background: var(--kp-bg);
    padding: 15px 20px;
    border-radius: 4px;
    margin-bottom: 30px;
    font-size: 13px;
}

.kp-footer {
    border-top: 1px solid var(--kp-primary);
    padding-top: 12px;
    margin-top: 15px;
    font-size: 11px;
    color: var(--kp-text);
}

.kp-footer__grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
    margin-bottom: 10px;
}

.kp-footer__title {
    font-weight: 600;
    font-size: 11px;
    color: var(--kp-primary);
    margin-bottom: 4px;
}

.kp-footer__phones-list {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.kp-footer__phone {
    display: flex;
    align-items: center;
    gap: 4px;
}

.kp-footer__phone-icon {
    font-size: 12px;
}

.kp-footer__address-item {
    font-size: 10px;
    line-height: 1.4;
    margin-bottom: 2px;
}

.kp-footer__address-place {
    font-weight: 600;
}

.kp-footer__phone a {
    color: var(--kp-text);
    text-decoration: none;
    font-weight: 500;
    font-size: 11px;
}

.kp-footer__emails {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.kp-footer__email-block a {
    display: block;
    color: var(--kp-primary);
    text-decoration: none;
    margin-top: 2px;
    font-size: 10px;
}

.kp-footer__address p {
    line-height: 1.4;
    font-size: 12px;
}

.kp-footer__worktime {
    font-size: 10px;
}

.kp-footer__worktime-item {
    line-height: 1.4;
    margin-bottom: 2px;
    font-weight: 600;
}

.kp-footer__worktime-place {
    font-weight: 600;
}

.kp-footer__info-right {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.kp-footer__requisites {
    margin-top: 8px;
}

.kp-footer__req-item {
    font-size: 9px;
    line-height: 1.8;
}

.kp-footer__req-name {
    font-weight: 600;
}

.kp-footer__logo {
    flex: 0 0 auto;
    width: 100px;
    height: 30px;
    overflow: hidden;
    display: flex;
    align-items: center;
}

.kp-footer__logo img {
    display: block;
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.kp-footer__bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 8px;
    border-top: 1px solid var(--kp-border);
    font-size: 10px;
    color: var(--kp-text-light);
}

.kp-footer__copyright {
    display: flex;
    gap: 10px;
}

.kp-footer__copyright span {
    white-space: nowrap;
}

.kp-footer__question {
    font-weight: 600;
    color: #009900;
}

.kp-footer__link a {
    color: var(--kp-primary);
    text-decoration: none;
}

.kp-pagebreak {
    break-before: page;
    page-break-before: always;
    height: 0;
    margin: 0;
    padding: 0;
    border: 0;
}

.kp-footer__site {
    font-weight: 500;
}

/* Mobile styles */
@media (max-width: 520px) {
    body.kp-page {
        padding: 10px;
        font-size: 12px;
    }

    .kp-container {
        padding: 10px;
    }

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

    .kp-header__logo {
        width: 160px;
        height: 45px;
        margin: 0 auto;
    }

    .kp-header__company {
        text-align: center;
        font-size: 9px;
    }

    .kp-header__date {
        text-align: center;
        font-size: 11px;
    }

    .kp-header__phone {
        justify-content: center;
    }

    .kp-title {
        font-size: 16px;
        flex-direction: column;
        gap: 8px;
    }

    .kp-title .kp-product__brand-logo {
        align-self: flex-start;
    }

    .kp-product {
        flex-direction: column;
        gap: 15px;
    }

    .kp-product__image {
        flex: 0 0 auto;
        width: 100%;
        max-width: 200px;
        margin: 0 auto;
    }

    .kp-product__title {
        font-size: 16px;
        text-align: center;
    }

    .kp-product__sku,
    .kp-product__brand {
        text-align: center;
    }

    .kp-product__main-attrs-table {
        font-size: 11px;
    }

    .kp-product__price {
        font-size: 20px;
        text-align: center;
    }

    .kp-product__price-old {
        font-size: 14px;
    }

    .kp-product__price-discount {
        font-size: 12px;
    }

    .kp-product__price-vat {
        display: block;
        margin: 5px 0 0;
    }

    .kp-section-title {
        font-size: 14px;
    }

    .kp-attributes__grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

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

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

    .kp-gallery__grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
    }

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

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

    .kp-product__attrs-container {
        flex-direction: column;
        align-items: stretch;
    }

    .kp-product__qr-code {
        margin-top: 10px;
        margin-left: 0;
        align-self: center;
    }

    .kp-complect__table {
        font-size: 11px;
        display: block;
        overflow-x: auto;
    }

    .kp-complect__table thead,
    .kp-complect__table tbody,
    .kp-complect__table th,
    .kp-complect__table td,
    .kp-complect__table tr {
        display: block;
    }

    .kp-complect__table thead tr {
        position: absolute;
        top: -9999px;
        left: -9999px;
    }

    .kp-complect__table tr {
        border: 1px solid var(--kp-border);
        margin-bottom: 8px;
    }

    .kp-complect__table td {
        border: none;
        position: relative;
        padding-left: 50%;
        text-align: right;
    }

    .kp-complect__table td:before {
        position: absolute;
        left: 6px;
        width: 45%;
        padding-right: 10px;
        white-space: nowrap;
        text-align: left;
        font-weight: 600;
        content: attr(data-label);
    }

     .kp-warranty__table {
         overflow-x: auto;
     }

    .kp-description__text {
        font-size: 12px;
    }

    .kp-footer__grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .kp-footer__phones {
        text-align: center;
    }

    .kp-footer__phones-list {
        align-items: center;
    }

    .kp-footer__emails {
        align-items: center;
    }

    .kp-footer__address {
        text-align: center;
    }

    .kp-footer__worktime {
        text-align: center;
    }

    .kp-footer__bottom {
        flex-direction: column;
        gap: 8px;
        text-align: center;
    }

    .kp-footer__copyright {
        flex-wrap: wrap;
        justify-content: center;
        gap: 5px;
    }

    .kp-footer__logo {
        margin: 0 auto;
    }

    .kp-manager-table__table {
        display: block;
        overflow-x: auto;
    }
}

@media print {
    body.kp-page {
        padding: 0;
    }
    
    .kp-container {
        padding: 0;
    }
    .kp-header {
        page-break-inside: avoid;
    }

    .kp-manager-editor {
        display: none !important;
    }
    
    .kp-product {
        page-break-inside: avoid;
    }
    
    .kp-section-title {
        page-break-after: avoid;
    }

    .kp-advantages,
    .kp-advantages__images,
    .kp-advantages__list,
    .kp-advantages__item {
        break-inside: avoid-page;
        page-break-inside: avoid;
        -webkit-column-break-inside: avoid;
    }
    
    .kp-attributes {
        page-break-before: auto;
        break-inside: avoid-page;
        page-break-inside: avoid;
        -webkit-column-break-inside: avoid;
    }

    .kp-advantages__images--grid {
        display: grid !important;
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
    }

    .kp-advantages__image {
        margin-bottom: 0;
    }
    
    .kp-gallery {
        page-break-before: auto;
        page-break-inside: avoid;
    }
    
    .kp-complect {
        page-break-before: auto;
    }
    
    .kp-complect__table {
        page-break-inside: auto;
    }
    
    .kp-complect__table tr {
        page-break-inside: avoid;
    }
    
    .kp-footer {
        page-break-inside: avoid;
    }
    
    h3, h4 {
        page-break-after: avoid;
    }
    
    img {
        page-break-inside: avoid;
    }
}
