/* Import removed; styles are included via styles.css */
/* Base styles are also linked in index.html; this import ensures they are applied when only print.css is used */
@media print {

    /* Base background for printed page */
    body {
        background: #fff;
    }

    /* Remove forced page breaks and size constraints for .page */
    .page {
        /* Keep any visual styling that may be needed, but remove page‑break rules */
        width: auto;
        padding: 0;
        box-shadow: none;
        page-break-before: auto !important;
        page-break-after: auto !important;
        page-break-inside: auto !important;
        break-before: auto !important;
        break-after: auto !important;
        break-inside: auto !important;
    }

    /* Ensure A4 size */
    @page {
        size: A4 portrait;
        margin: 10mm;
        margin-top: 5mm;
    }
}

/* Additional print rules */
@media print {
    table {
        page-break-inside: auto;
    }

    /* Ensure table rows are not split across pages when printing */
    tr {
        page-break-inside: avoid;
        break-inside: avoid;
    }

    /* More specific selectors for tables used in the price list */
    .price-page table tr,
    .log-table table tr {
        page-break-inside: avoid;
        break-inside: avoid;
    }

    thead {
        display: table-header-group;
    }

    tfoot {
        display: table-footer-group;
    }
}

@media print {

    .price-page thead,
    .log-table thead {
        display: table-row-group;
    }
}

/* Global reset to prevent automatic page breaks */
@media print {
    * {
        page-break-before: auto !important;
        page-break-after: auto !important;
        page-break-inside: auto !important;
        break-before: auto !important;
        break-after: auto !important;
        break-inside: auto !important;
    }

    /* Hide editor comment elements when printing */
    .sp-save-bar,
    .sp-cell-changed,
    .sp-edit-mode,
    .sp-inline-input,
    .sp-save-dot,
    .sp-save-info,
    .sp-save-actions,
    .sp-save-btn,
    .sp-discard-btn,
    .sp-modal-overlay,
    .sp-modal,
    .sp-modal-header,
    .sp-modal-close,
    .sp-toast {
        display: none !important;
    }

}

@media print {

    /* 1️⃣ Фиксированный макет для всех таблиц price‑page */
    .price-page {
        table-layout: fixed;
        /* одинаковая ширина колонок */
        width: 100%;
        /* растягиваем таблицу на всю ширину страницы */
        border-spacing:2mm;
    }

    .log-table {
        border-spacing: 2mm;
    }

    /* 2️⃣ Если количество колонок фиксировано, задайте им одинаковую ширину.
        Пример для 6‑колоночной таблицы (6 * 16.66% ≈ 100%). */
    .price-page th,
    .price-page td {
        width: 16.66%;
        /* подберите под реальное количество колонок */
        word-wrap: break-word;
        /* перенос длинных слов/чисел */
    }

    /* 3️⃣ Сохраните уже существующие правила по разрыву страниц */
    .price-page table tr,
    .log-table table tr {
        page-break-inside: avoid;
        break-inside: avoid;
    }

    /* 4️⃣ Оставьте остальные правила, которые уже есть у вас */
    /* … (ваши текущие правила) … */
    .contacts-grid {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 4mm;
        text-align: left;
        margin: 3mm 0 5mm;
    }
}