/* ===================================================
   1.3.0 R1 cutting-layout preview (km-layout-view.js):
   inline preview, full-screen viewer, tooltip, print.
   =================================================== */
.km-lp {
    margin: 0 0 24px;
    padding: 16px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
}
.km-lp *, .km-lp-modal * { box-sizing: border-box; }
.km-lp-head, .km-lp-modal-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 10px;
}
.km-lp-title, .km-lp-modal-head h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    color: #111827;
}
.km-lp-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.km-lp-btn {
    padding: 7px 14px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    background: #ffffff;
    color: #1f2937;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.3;
    cursor: pointer;
}
.km-lp-btn:hover:not(:disabled) { background: #f3f4f6; }
.km-lp-btn:disabled { opacity: 0.4; cursor: default; }
.km-lp-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.km-lp-tab {
    padding: 6px 12px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: #ffffff;
    color: #374151;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    max-width: 100%;
    white-space: normal;
    overflow-wrap: anywhere;
    text-align: left;
}
.km-lp-tab.is-active { background: #2563eb; border-color: #2563eb; color: #ffffff; }
.km-lp-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 10px;
}
.km-lp-nav .km-lp-btn { min-width: 40px; font-size: 16px; padding: 4px 10px; }
.km-lp-stats { flex: 1 1 auto; text-align: center; font-size: 13px; color: #374151; }
.km-lp-svg-wrap {
    width: 100%;
    max-height: 420px;
    display: flex;
    justify-content: center;
    overflow: hidden;
}
.km-lp-svg-host svg { display: block; max-width: 100%; height: auto; }
.km-lp-svg-wrap svg { max-height: 420px; }
.km-lp-svg-host .km-lp-part { cursor: pointer; }
.km-lp-svg-host .km-lp-part:hover .km-part-rect { opacity: 0.85; }
.km-lp-legend { margin: 8px 0 0; font-size: 12px; color: #6b7280; }

/* Full-screen viewer (replaces the 1.2.x modal; same ids/classes for compatibility) */
.km-lp-overlay {
    position: fixed;
    inset: 0;
    z-index: 100000;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2.5vh 2.5vw;
    box-sizing: border-box;
}
.km-lp-modal {
    background: #ffffff;
    border-radius: 12px;
    max-width: 95vw;
    max-height: 95vh;
    overflow: auto;
    padding: 16px 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
}
.km-lp-close {
    background: none;
    border: none;
    font-size: 28px;
    line-height: 1;
    color: #6b7280;
    cursor: pointer;
    padding: 0 4px;
}
.km-lp-modal-body { display: flex; justify-content: center; }

.km-lp-tooltip {
    position: fixed;
    z-index: 100001;
    max-width: 280px;
    padding: 8px 10px;
    background: #111827;
    color: #f9fafb;
    border-radius: 6px;
    font-size: 12px;
    line-height: 1.5;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    pointer-events: none;
    overflow-wrap: anywhere;
}
.km-lp-tooltip[hidden] { display: none; }
.km-lp-tip-k { color: #9ca3af; }

/* Print: only after "Drukuj układ" (html.km-printing-layout); a normal Ctrl+P is unchanged. */
.km-print-root { display: none; }
/* UX-B1: inside the results column (padded) on phones - less inner padding for the board. */
@media (max-width: 480px) {
    .km-lp { padding: 10px; }
    .km-lp-nav { flex-wrap: wrap; }
    .km-lp-nav .km-lp-stats { order: -1; flex: 1 1 100%; min-width: 0; }
    .km-lp-nav .km-lp-btn { min-width: 34px; padding: 4px 8px; }
    .km-lp-nav .km-lp-next { margin-left: auto; }
}
@media print {
    @page { size: A4 landscape; margin: 10mm; }
    html.km-printing-layout body > *:not(.km-print-root) { display: none !important; }
    html.km-printing-layout, html.km-printing-layout body { background: #ffffff !important; margin: 0 !important; padding: 0 !important; }
    html.km-printing-layout .km-print-root { display: block !important; }
    .km-print-root { -webkit-print-color-adjust: exact; print-color-adjust: exact; color: #111827; font-family: Arial, Helvetica, sans-serif; }
    .km-print-page { page-break-after: always; break-after: page; page-break-inside: avoid; break-inside: avoid; }
    .km-print-page:last-child { page-break-after: auto; break-after: auto; }
    .km-print-title { margin: 0 0 2mm; font-size: 16pt; }
    .km-print-meta { margin: 0 0 4mm; font-size: 11pt; }
    .km-print-svg svg { display: block; width: 100%; height: auto; max-height: 150mm; }
    .km-print-legend { margin: 3mm 0 0; font-size: 9pt; color: #4b5563; }
    .km-lp-tooltip { display: none !important; }
}
