
/* --- Report Preview Styles --- */


.preview-pane {
    flex-grow: 1;
    overflow: auto; /* Enable both horizontal and vertical scroll */
    padding: 2rem;
    background-color: #e9ecef;
    display: flex;
    justify-content: flex-start; /* Changed from center */
    align-items: flex-start;
    min-width: 0; /* Allow flex item to shrink */
}

@media print {
    .preview-pane {
        padding: 0 !important;
        margin: 0 !important;
        background: none !important;
        box-shadow: none !important;
        display: block !important;
        min-width: 0 !important;
        overflow: visible !important;
        justify-content: initial !important;
        align-items: initial !important;
    }
    }


/* Wrapper that adjusts to zoom */
.preview-document-wrapper {
    display: inline-block;
    transition: width 0.3s ease, padding 0.3s ease;
    box-sizing: content-box;
    margin: 0 auto; /* Center the wrapper */
}

@media print {
    .preview-document-wrapper {
        display: block !important;
        width: auto !important;
        padding: 0 !important;
        margin: 0 !important;
        box-shadow: none !important;
        transition: none !important;
    }
}

/* Container for all pages */
.preview-document {
    margin: 0 auto;
    transform-origin: top center;
    transition: transform 0.3s ease;
    width: 210mm;
    font-family: var(--theme-font-family, "Open Sans", sans-serif);
}



/* DOCUMENT STRUCTURE
.preview-document          → Container for all pages
  └─ .page-wrapper         → Physical A4 page (what user sees)
       └─ .page            → Content area (inside margins)
            └─ .report-section  → Atomic unit (don't split)
*/
/* Physical A4 page wrapper with margins */
.page-wrapper {
    background: white;
    width: 210mm;
    height: 297mm; /* Fixed height - exactly A4 */
    box-shadow: 0 0.5rem 2rem rgba(0, 0, 0, 0.2);
    padding: 15mm 20mm; 
    border-radius: 2px;
    position: relative;
    margin: 0 auto 10mm auto;
    display: flex;
    flex-direction: column;
    overflow: visible; 
    /* WeasyPrint: each wrapper = one page */
    page-break-after: always;
    break-after: page;
}
        
/* First page has no top margin */
.page-wrapper:first-child {
    margin-top: 0;
}

/* Add visual separator between pages */
.page-wrapper:not(:last-child)::after {
    content: '';
    position: absolute;
    bottom: -30mm;
    left: 50%;
    transform: translateX(-50%);
    width: 60%;
    height: 1px;
    background: linear-gradient(to right, transparent, #ccc 20%, #ccc 80%, transparent);
}

.page-wrapper:last-child {
    page-break-after: auto;
    break-after: auto;
}


/* --- Zoom Controls --- */
.zoom-controls {
    position: fixed;
    top: 100px;
    right: 30px;
    z-index: 50;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    background: white;
    padding: 0.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
}

.zoom-btn {
    width: 40px;
    height: 40px;
    border: 1px solid var(--primary-300);
    background: white;
    color: var(--primary-700);
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    font-weight: 600;
    transition: all 0.2s ease;
}

.zoom-btn:hover {
    background: var(--primary-50);
    border-color: var(--primary-500);
}

.zoom-level {
    font-size: 0.75rem;
    text-align: center;
    color: var(--primary-700);
    font-weight: 600;
    padding: 0.25rem 0;
}

@media print {
    .zoom-controls {
        display: none;
    }
}

/* --- Page Break Styles --- */
        
/* Logical sections that should not be split across pages */
.report-section {
    break-inside: avoid;
    page-break-inside: avoid;
    overflow: hidden; /* Contain child margins */
    display: block; /* Ensure proper block formatting */
}

/* Force a new page before this section */
.page-break {
    break-before: page;
    page-break-before: always;
}

/* Print-specific overrides (visual changes only) */
@page {
  margin: 2cm 1.5cm 2cm 1.5cm; /* top right bottom left */
}


@media print {
    html {
        font-size: 18px !important;
    }
    body { 
        background: white; 
        padding: 0; 

        
    }
    
    .preview-document {
        width: auto;           /* Let WeasyPrint handle width */
        margin: 0;
        display: block;
        box-shadow: none;
        transition: none;
        transform: none;
        background: white;
    }
    
    .page-wrapper {
        background: white;
        width: 210mm;           /* A4 width */
        margin: 0 auto 10mm auto;
        box-shadow: none;       /* No shadow for PDF */
        border-radius: 0;       /* No rounded corners for PDF */
        padding: 15mm 20mm;     /* Page margins */
        display: block;
        /* No fixed height, no flex, no overflow */
        page-break-after: always;
        break-after: page;
        display: block !important;
    }
    
    .zoom-controls {
        display: none;
    }
}



/* --- Report Content Styles --- */

.theme-color {
    color: var(--theme-color, inherit) !important;
}

.logo-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
  margin-left: auto;
  margin-right: auto;
}


/* Black horizontal rule */
hr.hr-black {
    border: none;
    border-top: 2px solid #000 !important;
    opacity: 0.8 !important;
    background: none;
}

/* Theme color horizontal rule */
hr.hr-theme {
    border: none;
    border-top: 2px solid var(--theme-color) !important;
    opacity: 0.8 !important;
    background: none;
}

hr.hr-theme-sm {
    border: none;
    border-top: 1px solid var(--theme-color) !important;
    opacity: 0.5 !important;
    background: none;
}

.section-title {
    font-size: 0.875rem;
    text-transform: uppercase;
    color: var(--theme-color);
    letter-spacing: 0.05em;
    font-weight: bold;
}

section .data-label {
    font-weight: bold;
    /* color: rgba(54, 67, 108, 0.802) !important; */
    font-size: 0.875rem;
    color: var(--theme-color) !important;
}

section .data-caption {
    font-weight: normal;
    font-size: 0.75rem;
    color: var(--theme-color) !important;
}


/* Individual column header style */
section table.gradetable .group-header {
    border-left: 12px solid white;
    border-right: 12px solid white;
    border-bottom: 1px solid var(--theme-color);
}

section .table-padded td, .table-padded th {
    padding-left: 0.5rem !important; /* Increase left padding */
    padding-right: 0.5rem !important; /* Increase right padding */
}

section table.gradetable .no-border {
    border-top: 2px solid white;
}
section table.gradetable th {
    color: var(--theme-color);
}
section table.gradetable th.group-header {
    border-bottom: 1px solid var(--theme-color);
}
section table.gradetable th.no-group-header {
    border-bottom: none;
}

section hr {
    margin: 1rem 0 !important;
    border: none;
    border-top: 1px solid darkgray !important;
    opacity: 0.75 !important;
    background: none;
}


/* --- Signatures --- */

.sig-box {
    display: block;
    text-align: center;
    font-size: 0.75rem;
    margin-left: auto;
    margin-right: auto;
    width: 195px !important;
}



.sig-img {
    height: 50px;
    width: 195px;
    margin-bottom: 0.5rem;
    object-fit: contain;
}

.sig-line {
    width: 195px !important; 
    border-top: 1px solid var(--theme-color);
    padding-top: 0.5rem;
    white-space: nowrap;
}

.title-text {
    font-weight: bold;
    color: var(--theme-color);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* --- Table header fix --- */
th p {
    margin: 0 !important;
}
