/* ─────────────────────────────────────────────────────────────────────────────
   Report Tab — WYSIWYG A4 Preview + Print Styles
   ───────────────────────────────────────────────────────────────────────────── */

/* ── Layout wrapper: sidebar + preview side by side ─────────────────────────*/
.report-layout-wrapper {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

/* ── Sidebar config panel ────────────────────────────────────────────────────*/
.report-sidebar-config {
    width: 260px;
    flex-shrink: 0;
    position: sticky;
    top: 16px;
}

/* ── Preview area (scrollable, grey background) ──────────────────────────────*/
.report-preview-container {
    flex: 1;
    background: #e8eaed;
    border-radius: 8px;
    padding: 28px 24px;
    min-height: 400px;
    overflow-x: auto;
}

/* ── Completeness bar badges ─────────────────────────────────────────────────*/
.report-module-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: opacity .15s;
    background: #e9ecef;
    color: #6c757d;
}
.report-module-badge:hover { opacity: .8; }
.report-module-badge.is-ready {
    background: #d1e7dd;
    color: #0a5133;
}
.report-module-badge.is-ready .bi { color: #198754; }
.report-module-badge .bi { font-size: .65rem; }

/* ── A4 page ─────────────────────────────────────────────────────────────────*/
.report-page {
    width: 210mm;
    min-height: 297mm;
    background: #ffffff;
    box-shadow: 0 4px 24px rgba(0,0,0,.14);
    margin: 0 auto 28px auto;
    padding: 14mm 16mm 14mm 16mm;
    position: relative;
    box-sizing: border-box;
    font-size: 10pt;
    font-family: 'Inconsolata', 'Fira Code', monospace, sans-serif;
    color: #1a1a2e;
    overflow: hidden;
}
.report-page.report-page--hidden {
    display: none !important;
}

/* ── Report header ───────────────────────────────────────────────────────────*/
.report-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 8px;
    margin-bottom: 14px;
    border-bottom: 2px solid #1a56db;
}
.report-header-logo {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 700;
    font-size: 13pt;
}
.report-header-brand { font-weight: 700; }
.report-header-meta {
    font-size: 8pt;
    color: #6b7280;
    text-align: right;
}

/* ── Title block ─────────────────────────────────────────────────────────────*/
.report-title-block { margin-bottom: 14px; }
.report-main-title {
    font-size: 15pt;
    font-weight: 700;
    margin: 0 0 4px 0;
    color: #111827;
}
.report-subtitle {
    font-size: 9pt;
    color: #6b7280;
    margin: 0;
}
.report-project-name-line {
    font-size: 10pt;
    font-weight: 600;
    color: #374151;
    margin: 3px 0 0 0;
}

/* ── Section title ───────────────────────────────────────────────────────────*/
.report-section-title {
    font-size: 9pt;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: #1a56db;
    border-bottom: 1px solid #1a56db33;
    padding-bottom: 4px;
    margin: 14px 0 8px 0;
}

/* ── KPI cards grid ──────────────────────────────────────────────────────────*/
.report-kpi-grid {
    display: grid;
    gap: 7px;
    margin-bottom: 10px;
}
.report-kpi-grid--3 { grid-template-columns: repeat(3, 1fr); }
.report-kpi-grid--4 { grid-template-columns: repeat(4, 1fr); }
.report-kpi-grid--5 { grid-template-columns: repeat(5, 1fr); }

.report-kpi-card {
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 8px 10px;
}
.report-kpi-card--blue   { background: #eff6ff; border-color: #bfdbfe; }
.report-kpi-card--green  { background: #f0fdf4; border-color: #bbf7d0; }
.report-kpi-card--orange { background: #fff7ed; border-color: #fed7aa; }
.report-kpi-card--red    { background: #fef2f2; border-color: #fecaca; }
.report-kpi-card--teal   { background: #f0fdfa; border-color: #99f6e4; }

.report-kpi-label {
    font-size: 7.5pt;
    color: #6b7280;
    margin-bottom: 3px;
    line-height: 1.2;
}
.report-kpi-value {
    font-size: 13pt;
    font-weight: 700;
    color: #111827;
    line-height: 1.1;
}
.report-kpi-unit {
    font-size: 8pt;
    font-weight: 400;
    color: #6b7280;
}

/* ── Table ───────────────────────────────────────────────────────────────────*/
.report-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 8.5pt;
    margin-bottom: 10px;
}
.report-table th {
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    padding: 5px 7px;
    text-align: left;
    font-weight: 600;
    color: #374151;
    font-size: 8pt;
}
.report-table td {
    border: 1px solid #e5e7eb;
    padding: 4px 7px;
    color: #374151;
}
.report-table tr:nth-child(even) td { background: #f9fafb; }
.report-table-total td {
    font-weight: 700;
    background: #eff6ff !important;
    border-top: 2px solid #bfdbfe;
}
.report-table .text-right { text-align: right; }
.report-table .text-center { text-align: center; }

/* ── Chart boxes ─────────────────────────────────────────────────────────────*/
.report-chart-box {
    width: 100%;
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 8px;
    box-sizing: border-box;
    margin-bottom: 10px;
}

/* ── Sensitivity table ───────────────────────────────────────────────────────*/
.report-sensitivity-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 8.5pt;
    margin-bottom: 10px;
}
.report-sensitivity-table th {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    padding: 5px 8px;
    text-align: center;
    font-weight: 600;
    color: #1e40af;
}
.report-sensitivity-table td {
    border: 1px solid #e5e7eb;
    padding: 4px 8px;
    text-align: center;
}
.report-sensitivity-table td:first-child { text-align: left; font-weight: 500; }

/* ── Savings bars (Taryfomat page) ──────────────────────────────────────────*/
.report-savings-bar-wrap { margin-bottom: 4px; }
.report-savings-bar-label {
    display: flex;
    justify-content: space-between;
    font-size: 8pt;
    margin-bottom: 2px;
    color: #374151;
}
.report-savings-bar-label .rbl-name { font-weight: 500; }
.report-savings-bar-label .rbl-val  { font-weight: 600; color: #059669; }
.report-savings-bar-label .rbl-val.is-current { color: #374151; }
.report-savings-bar-track {
    height: 10px;
    background: #e5e7eb;
    border-radius: 5px;
    overflow: hidden;
}
.report-savings-bar-fill {
    height: 100%;
    border-radius: 5px;
    background: #10b981;
    transition: width .3s;
}
.report-savings-bar-fill.is-current { background: #6366f1; }

/* ── Info box ────────────────────────────────────────────────────────────────*/
.report-info-box {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 6px;
    padding: 10px 12px;
    font-size: 8.5pt;
    color: #1e40af;
    margin-bottom: 10px;
}

/* ── Methodology block ───────────────────────────────────────────────────────*/
.report-methodology {
    background: #f9fafb;
    border-left: 3px solid #d1d5db;
    padding: 8px 12px;
    font-size: 8pt;
    color: #6b7280;
    border-radius: 0 4px 4px 0;
    margin-bottom: 10px;
    line-height: 1.5;
}

/* ── Footer ──────────────────────────────────────────────────────────────────*/
.report-footer {
    position: absolute;
    bottom: 10mm;
    left: 16mm;
    right: 16mm;
    display: flex;
    justify-content: space-between;
    font-size: 7pt;
    color: #9ca3af;
    border-top: 1px solid #e5e7eb;
    padding-top: 5px;
}

/* ── 24h dual-line chart title ───────────────────────────────────────────────*/
.report-chart-title {
    font-size: 8pt;
    font-weight: 600;
    color: #6b7280;
    margin-bottom: 4px;
}

/* ── Taryfomat diagnostic items ──────────────────────────────────────────────*/
.report-diag-item {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    padding: 5px 8px;
    border-radius: 5px;
    margin-bottom: 4px;
    font-size: 8pt;
}
.report-diag-item.high   { background: #fef2f2; color: #991b1b; }
.report-diag-item.medium { background: #fffbeb; color: #92400e; }
.report-diag-item.low    { background: #eff6ff; color: #1e40af; }
.report-diag-item .bi { flex-shrink: 0; margin-top: 1px; }

/* ── Logo firmy — upload widget ─────────────────────────────────────────────*/
.report-logo-upload-area {
    border: 1.5px dashed #d1d5db;
    border-radius: 6px;
    background: #f9fafb;
    cursor: pointer;
    overflow: hidden;
    min-height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color .15s, background .15s;
}
.report-logo-upload-area:hover {
    border-color: #6366f1;
    background: #f5f3ff;
}
.report-logo-upload-area.has-logo {
    border-color: #10b981;
    border-style: solid;
    background: #fff;
}
.report-logo-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 10px;
    color: #9ca3af;
    font-size: 7.5pt;
    pointer-events: none;
}
.report-logo-empty .bi { font-size: 1.3rem; }
.report-logo-preview {
    display: block;
    max-height: 56px;
    max-width: 100%;
    object-fit: contain;
    padding: 6px 8px;
}
.report-logo-hint {
    font-size: 6.8pt;
    color: #9ca3af;
    line-height: 1.3;
}

/* ── Custom page upload card (sidebar) ───────────────────────────────────────*/
.report-custom-upload-card {
    border: 1.5px dashed #d1d5db;
    border-radius: 6px;
    padding: 8px 10px;
    cursor: pointer;
    transition: border-color .15s, background .15s;
    background: #f9fafb;
    min-height: 44px;
    display: flex;
    align-items: center;
}
.report-custom-upload-card:hover {
    border-color: #6366f1;
    background: #f5f3ff;
}
.report-custom-upload-card.has-file {
    border-color: #10b981;
    border-style: solid;
    background: #f0fdf4;
}
.report-custom-upload-placeholder {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 7.5pt;
    color: #9ca3af;
    width: 100%;
    pointer-events: none;
}
.report-custom-upload-placeholder .bi { font-size: 1rem; }
.report-custom-upload-preview {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 7.5pt;
    color: #065f46;
    width: 100%;
    min-width: 0;
}
.report-custom-upload-preview .bi { flex-shrink: 0; font-size: .9rem; }
.report-custom-upload-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 500;
}
.report-custom-upload-preview .btn-close {
    flex-shrink: 0;
    width: 14px;
    height: 14px;
    font-size: .5rem;
    opacity: .5;
}
.report-custom-upload-preview .btn-close:hover { opacity: 1; }

/* ── Custom page in preview (cover / back) ───────────────────────────────────*/
.report-page--custom {
    padding: 0 !important;
    overflow: hidden;
}
.report-page--custom iframe,
.report-page--custom img {
    display: block;
    width: 100%;
    height: 100%;
    min-height: 297mm;
    border: none;
    object-fit: contain;
}
.report-page--custom img {
    object-fit: cover;
    height: 297mm;
}

/* ─────────────────────────────────────────────────────────────────────────────
   PRINT / PDF STYLES
   ───────────────────────────────────────────────────────────────────────────── */
@media print {
    /* Hide all app UI — only report pages visible */
    header,
    .page-header,
    .card:not(.report-page),
    .report-completeness-bar,
    .d-print-none,
    #report-no-data {
        display: none !important;
    }

    body, .page-wrapper, .page-body, .container-xl,
    .tab-content, #report-content, .report-layout-wrapper,
    .report-preview-container {
        background: transparent !important;
        padding: 0 !important;
        margin: 0 !important;
        box-shadow: none !important;
        border: none !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    .report-page {
        box-shadow: none !important;
        margin: 0 !important;
        page-break-after: always;
        break-after: page;
        width: 210mm !important;
        min-height: 297mm !important;
        padding: 14mm 16mm !important;
    }

    .report-page.report-page--hidden {
        display: none !important;
    }

    /* Custom pages (cover / back) */
    .report-page--custom {
        padding: 0 !important;
    }
    .report-page--custom iframe,
    .report-page--custom img {
        width: 210mm !important;
        height: 297mm !important;
        min-height: 297mm !important;
    }

    /* Last page: no extra break */
    .report-page:last-of-type {
        page-break-after: avoid;
        break-after: avoid;
    }

    @page {
        size: A4 portrait;
        margin: 0;
    }
}
