/* ============================================
   PRINT STYLESHEET - Fugeeksperten Professional
   Optimeret til A4 print (210 x 297 mm)
   ============================================ */

@media print {
    
    /* ===== GLOBAL RESET ===== */
    * {
        background: transparent !important;
        color: #000 !important;
        box-shadow: none !important;
        text-shadow: none !important;
    }
    
    /* ===== PAGE SETUP ===== */
    @page {
        size: A4 portrait;
        margin: 2cm 1.5cm;
    }
    
    @page :first {
        margin-top: 1cm;
    }
    
    /* ===== HIDE NON-PRINTABLE ELEMENTS ===== */
    header.site-header,
    footer.site-footer,
    .mobile-menu-toggle,
    button,
    nav.main-nav,
    .cta-section,
    .no-print {
        display: none !important;
    }
    
    /* ===== SHOW PRINT-ONLY ELEMENTS ===== */
    .print-only {
        display: block !important;
    }
    
    /* ===== BODY & CONTAINER ===== */
    body {
        font-family: "Times New Roman", Times, serif;
        font-size: 11pt;
        line-height: 1.5;
        color: #000;
        background: #fff;
        margin: 0;
        padding: 0;
    }
    
    .container {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    
    main {
        margin: 0 !important;
        padding: 0 !important;
    }
    
    /* ===== TYPOGRAPHY ===== */
    h1 {
        font-size: 20pt;
        font-weight: bold;
        margin: 0 0 12pt 0;
        page-break-after: avoid;
        color: #000;
        border-bottom: 2pt solid #000;
        padding-bottom: 6pt;
    }
    
    h2 {
        font-size: 16pt;
        font-weight: bold;
        margin: 18pt 0 10pt 0;
        page-break-after: avoid;
        color: #000;
        border-bottom: 1pt solid #333;
        padding-bottom: 4pt;
    }
    
    h3 {
        font-size: 14pt;
        font-weight: bold;
        margin: 14pt 0 8pt 0;
        page-break-after: avoid;
        color: #000;
    }
    
    h4 {
        font-size: 12pt;
        font-weight: bold;
        margin: 12pt 0 6pt 0;
        page-break-after: avoid;
        color: #000;
    }
    
    p {
        margin: 0 0 8pt 0;
        text-align: justify;
        orphans: 3;
        widows: 3;
    }
    
    /* ===== LISTS ===== */
    ul, ol {
        margin: 8pt 0;
        padding-left: 20pt;
    }
    
    li {
        margin: 4pt 0;
        page-break-inside: avoid;
    }
    
    /* ===== TABLES ===== */
    table {
        width: 100% !important;
        border-collapse: collapse;
        margin: 12pt 0;
        page-break-inside: avoid;
        font-size: 10pt;
    }
    
    thead {
        display: table-header-group;
    }
    
    tr {
        page-break-inside: avoid;
        page-break-after: auto;
    }
    
    th, td {
        border: 1pt solid #000 !important;
        padding: 6pt !important;
        text-align: left;
        background: #fff !important;
    }
    
    th {
        font-weight: bold;
        background: #e0e0e0 !important;
        color: #000 !important;
    }
    
    /* ===== DIAGRAMS & SVG ===== */
    .diagram-box {
        page-break-inside: avoid;
        margin: 12pt 0;
        padding: 0 !important;
        border: 1pt solid #000 !important;
        background: #fff !important;
    }
    
    svg {
        max-width: 100% !important;
        height: auto !important;
        page-break-inside: avoid;
    }
    
    /* Scale diagrams to fit A4 width */
    svg {
        width: 180mm !important;
        height: auto !important;
    }
    
    /* ===== INFO BOXES ===== */
    .info-box,
    .technical-section {
        border: 1pt solid #000 !important;
        padding: 8pt !important;
        margin: 12pt 0 !important;
        page-break-inside: avoid;
        background: #f5f5f5 !important;
    }
    
    /* ===== FORMULAS & CODE ===== */
    .formula-box {
        border: 1pt solid #000 !important;
        padding: 8pt !important;
        margin: 8pt 0 !important;
        background: #f9f9f9 !important;
        font-family: "Courier New", monospace;
        font-size: 10pt;
        page-break-inside: avoid;
    }
    
    /* ===== PAGE BREAKS ===== */
    section {
        page-break-before: auto;
        page-break-after: auto;
        page-break-inside: avoid;
    }
    
    /* Force page break before major sections */
    #tekniske-begreber,
    #materialevalg,
    #standarder-test,
    #drift-vedligehold,
    #tegninger,
    #projektering,
    #professionel-faq {
        page-break-before: always;
    }
    
    /* Avoid breaks after headings */
    h1, h2, h3, h4, h5, h6 {
        page-break-after: avoid;
    }
    
    /* Avoid breaks inside these elements */
    ul, ol, table, figure, .diagram-box, .info-box {
        page-break-inside: avoid;
    }
    
    /* ===== LINKS ===== */
    a {
        color: #000 !important;
        text-decoration: underline;
    }
    
    /* Show URL after external links */
    a[href^="http"]:after {
        content: " (" attr(href) ")";
        font-size: 9pt;
        color: #666;
    }
    
    /* Don't show URL for internal links */
    a[href^="#"]:after {
        content: "";
    }
    
    /* ===== TABLE OF CONTENTS ===== */
    .toc-box {
        page-break-after: always;
        border: 2pt solid #000 !important;
        padding: 15pt !important;
        margin: 20pt 0 !important;
        background: #f9f9f9 !important;
    }
    
    .toc-box h2 {
        text-align: center;
        font-size: 18pt;
        margin-bottom: 15pt;
        border-bottom: 2pt solid #000;
        padding-bottom: 10pt;
    }
    
    nav ol {
        list-style: decimal;
        margin: 12pt 0;
        padding-left: 20pt;
    }
    
    nav ol li {
        margin: 8pt 0;
        font-size: 11pt;
        line-height: 1.4;
    }
    
    nav ol li a {
        color: #000 !important;
        text-decoration: none !important;
        font-weight: 500;
    }
    
    /* Show page numbers in TOC if possible */
    nav ol li a::after {
        content: "";
        border-bottom: 1pt dotted #999;
        flex: 1;
        margin: 0 8pt;
    }
    
    /* ===== PRINT HEADER (on each page) ===== */
    @page {
        @top-center {
            content: "Fugeeksperten – Professionel Referencemanual";
            font-size: 9pt;
            color: #666;
        }
        
        @bottom-right {
            content: "Side " counter(page) " af " counter(pages);
            font-size: 9pt;
            color: #666;
        }
    }
    
    /* ===== ABBREVIATIONS ===== */
    abbr[title]:after {
        content: " (" attr(title) ")";
        font-size: 9pt;
        color: #666;
    }
    
    /* ===== BLOCKQUOTES ===== */
    blockquote {
        border-left: 3pt solid #000;
        padding-left: 12pt;
        margin: 12pt 0;
        font-style: italic;
        page-break-inside: avoid;
    }
    
    /* ===== PERFORMANCE TABLES ===== */
    .performance-table {
        font-size: 9pt;
    }
    
    /* ===== HIDE DOWNLOAD BUTTONS IN DIAGRAM BOXES ===== */
    .diagram-box div[style*="margin-top"] {
        display: none !important;
    }
    
    /* ===== OPTIMIZATIONS ===== */
    img {
        max-width: 100% !important;
        height: auto !important;
        page-break-inside: avoid;
    }
    
    /* Ensure white background on all boxes */
    div[style*="background"] {
        background: #fff !important;
    }
    
    /* Remove colored backgrounds from tables */
    tr[style*="background"] {
        background: #f5f5f5 !important;
    }
    
    /* ===== SPECIAL: First page title ===== */
    .page-header h1 {
        text-align: center;
        font-size: 24pt;
        margin: 24pt 0;
        border-bottom: 3pt solid #000;
        padding-bottom: 12pt;
    }
    
    /* ===== METADATA INFO ===== */
    .print-metadata {
        font-size: 9pt;
        color: #666;
        text-align: center;
        margin: 12pt 0;
        border-top: 1pt solid #ccc;
        padding-top: 8pt;
    }
    
    /* ===== END OF PRINT STYLES ===== */
}
