/* print toc switch */
#print-toc {
    display: none; /* Hide by default */
}

/* Print-specific styles */
@media print {
    /* Basic page setup */
    @page {
        margin: 1.5cm;
        size: A4;

        @top-right {
            content: "<!--COG_PARTNUM-version--> / <!--document_type-->";
            font-family: var(--fonts-sans-serif);
            font-size: 0.65em;     /* 80% of normal text size */
            margin-right: 100px;
        }

        @bottom-right {
            content: counter(page) " / " counter(pages);
            font-family: var(--fonts-sans-serif);
            font-size: 0.65em;     /* 80% of normal text size */
            margin-right: 100px;
        }
    }

    /* General optimizations */
    body {
        font-size: 11pt;
        line-height: 1.3;
        background: none !important;
        color: black !important;
    }

    /* Content area adjustments */
    .document {
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    /* Code block optimizations */
    pre {
        border: 1px solid #ccc;
        page-break-inside: avoid;
        white-space: pre-wrap;
        word-wrap: break-word;
        background-color: #f8f8f8 !important;
        color: black !important;
    }

    /* Table improvements */
    table {
        /*page-break-inside: avoid;*/
        border-collapse: collapse;
    }

    th, td {
        border: 1px solid #ddd;
        padding: 8px;
        font-size: small;
    }

    /* Page break control */
    h1, h2, h3 {
        page-break-after: avoid;
        page-break-inside: avoid;
    }

    /* Ensure orphans and widows are handled properly */
    p {
        orphans: 3;
        widows: 3;
    }

    /* TOC optimization */
    .toctree-wrapper {
        break-after: always;
    }

    #print-hide {
        display: none !important;
    }

    #print-toc {
        display: block; /* Show the TOC only when printing */
    }

    section > h1 {
        display: none; /* Hide by default */
    }

    div.body {
        border-left: none;
    }

    div.document {
        display: block;
    }

    figure, div.admonition {
        break-inside: avoid;
        page-break-inside: avoid;
      }

    div.pageheader > a > figure {
        break-inside: auto;
        page-break-inside: auto;
    }

    #print-show {
        display: block;
    }
    
}