/**
 * IntCorde Print Styles
 * 
 * Works in conjunction with Elementor's native print button functionality.
 * JavaScript handles chart lazy-loading, this CSS handles header hiding.
 */

@media print {
    /* Force portrait orientation */
    @page {
        size: portrait;
        margin: 0.5cm;
    }
    
    /* Encourage printing of background colors and images */
    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        color-adjust: exact !important;
    }
    
    /* Remove default page margins and padding */
    body {
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
    }
    
    /* Add print-only header with branding */
    body::before {
        content: "CORDE Survey Results";
        display: block;
        width: 100%;
        text-align: center;
        font-size: 32px;
        font-weight: bold;
        font-family: Arial, sans-serif;
        color: #1E3A8A;
        padding: 30px 0;
        margin-bottom: 40px;
        border-bottom: 3px solid #1E3A8A;
    }
    
    html {
        margin: 0 !important;
        padding: 0 !important;
    }
    
    /* Reset margins and padding on main containers */
    .elementor,
    .elementor-section,
    .elementor-container,
    .e-con,
    .e-con-full {
        margin: 0 !important;
        padding: 0 !important;
        max-width: 100% !important;
        width: 100% !important;
    }
    
    /* Ensure titles and headings fit within page and center align */
    .elementor-widget-heading,
    .elementor-heading-title,
    .elementor-widget-heading *,
    h1, h2, h3, h4, h5, h6 {
        max-width: 100% !important;
        overflow: visible !important;
        text-align: center !important;
        margin-left: auto !important;
        margin-right: auto !important;
        text-align-last: center !important;
    }
    
    /* Force flex layout with vertical stacking */
    .e-con.e-parent {
        display: flex !important;
        flex-direction: column !important;
        flex-wrap: nowrap !important;
    }
    
    /* Force child containers to take full width and stack vertically */
    .e-con.e-child {
        flex: 0 0 auto !important;
        max-width: 100% !important;
        width: 100% !important;
        display: block !important;
    }
    
    /* Hide all headers and navigation */
    .elementor-location-header {
        display: none !important;
        visibility: hidden !important;
        height: 0 !important;
        overflow: hidden !important;
    }
    
    /* Also hide footers for cleaner print */
    .elementor-location-footer {
        display: none !important;
        visibility: hidden !important;
        height: 0 !important;
        overflow: hidden !important;
    }
    
    /* Hide button containers that contain print/download buttons */
    .e-con.e-child:has(.elementor-widget-button):has(.elementor-widget-share-buttons) {
        display: none !important;
        visibility: hidden !important;
        height: 0 !important;
        overflow: hidden !important;
    }
    
    /* Hide the original page title since we have a print-specific one */
    .elementor-widget-heading:first-of-type,
    .entry-title,
    .page-title {
        display: none !important;
        visibility: hidden !important;
        height: 0 !important;
        overflow: hidden !important;
    }

    /* Page break every 2 charts */
    .e-con.e-parent:nth-of-type(2n) {
        page-break-after: always !important;
        break-after: page !important;
        padding-top: 2cm !important;
    }
    
    /* Prevent charts from breaking across pages */
    .elementor-element.e-con.e-child,
    .elementor-widget-iqonic_graphina_pro_chart,
    .graphina-elementor-chart,
    .graphina-chart-container {
        page-break-inside: avoid !important;
        break-inside: avoid !important;
    }
}
