/* Print styles */
@media print {
    header, footer, nav, .document-actions, .toc-toggle, .toc-wrapper, .print-controls {
        display: none !important;
    }
    
    @page {
        margin: 0.5cm !important; /* Set page margins for the entire print */
    }
    
    html {
        font-size: 10pt !important; /* Base font size */
    }
    
    body {
        padding: 0 !important;
        margin: 0 !important;
        font-size: 1em;
    }
    
    main {
        padding: 0 !important;
        margin: 0 !important;
        max-width: none !important;
    }
    
    article {
        padding: 0 !important;
        margin: 0 !important;
    }
    
    .markdown-content {
        width: 100%;
        max-width: 100%;
        margin: 0 !important;
        padding: 0 !important;
    }
    
    /* Proportional heading sizes */
    h1 { font-size: 1.6em !important; margin: 0.5em 0 0.3em 0 !important; }
    h2 { font-size: 1.4em !important; margin: 0.5em 0 0.3em 0 !important; }
    h3 { font-size: 1.2em !important; margin: 0.5em 0 0.3em 0 !important; }
    h4, h5, h6 { font-size: 1.1em !important; margin: 0.4em 0 0.2em 0 !important; }
    
    /* Reduce margins and spacing */
    p, ul, ol, pre, blockquote, table {
        margin-top: 0.2em !important;
        margin-bottom: 0.4em !important;
        line-height: 1.2 !important;
    }
    
    /* Adjust code blocks */
    pre code {
        font-size: 0.8em !important;
        padding: 0.3em !important;
    }
    
    pre {
        padding: 0.3em !important;
        margin: 0.4em 0 !important;
    }
    
    /* Other print styles */
    a {
        text-decoration: none;
        color: #000;
    }
    
    img {
        max-height: 300pt;
        max-width: 100%;
    }
    
    /* Page break controls */
    h1, h2, h3, h4, h5, h6, img, table, pre, blockquote {
        page-break-inside: avoid;
    }
    
    /* Tighter list spacing */
    li {
        margin-top: 0.1em !important;
        margin-bottom: 0.1em !important;
    }
    
    ul, ol {
        padding-left: 1em !important;
    }
    /*Clean printing*/
    .markdown-content pre code * {
        color: #000 !important; /* Force black text */
        background-color: transparent !important; /* Remove background colors */
    }

    .markdown-content .mermaid text,
    .markdown-content .mermaid tspan,
    .markdown-content .mermaid .label {
        fill: #000 !important; /* SVG uses fill */
        stroke: #000 !important; /* Sometimes stroke is used */
    }
    .markdown-content .mermaid .edgePaths path,
    .markdown-content .mermaid .node rect,
    .markdown-content .mermaid .node polygon,
    .markdown-content .mermaid .node ellipse,
    .markdown-content .mermaid .node circle {
        stroke: #000 !important; /* Keep lines black */
        fill: transparent !important; /* Remove node fills */
    }
    .markdown-content pre {
        background-color: #fff !important;
        border: 1px solid #ccc !important; /* Ensure border prints */
        color: #000 !important;
     }
}

/* Preview mode specific styles */
body.print-preview {
    background-color: #f5f5f5;
    padding: 0;
}

body.print-preview html {
    font-size: 10pt;
}

body.print-preview header,
body.print-preview footer,
body.print-preview nav,
body.print-preview .document-actions,
body.print-preview .toc-toggle,
body.print-preview .toc-wrapper {
    display: none;
}

body.print-preview main {
    background-color: white;
    padding: 0.5cm;
    margin: 2rem auto;
    max-width: 210mm; /* A4 width */
    min-height: 297mm; /* A4 height */
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}

body.print-preview .print-controls {
    position: fixed;
    top: 1rem;
    right: 1rem;
    background: white;
    padding: 0.5rem;
    border-radius: 4px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    font-size: 12pt; /* Keep controls readable */
}


/* Add to the existing print.css file, in the "Preview mode specific styles" section */
body.print-preview .font-size-controls {
    display: flex;
    align-items: center;
    margin-left: 1rem;
}

body.print-preview .font-size-control {
    background: white;
    border: 1px solid #ccc;
    border-radius: 4px;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-weight: bold;
}

body.print-preview .font-size-value {
    margin: 0 0.5rem;
    min-width: 2rem;
    text-align: center;
}

/* For HighlightJS */
body.print-preview .markdown-content pre code *,
@media print {
    .markdown-content pre code * {
        color: #000 !important; /* Force black text */
        background-color: transparent !important; /* Remove background colors */
    }
}

/* For Mermaid (may need more specific selectors) */
body.print-preview .markdown-content .mermaid text,
body.print-preview .markdown-content .mermaid tspan,
body.print-preview .markdown-content .mermaid .label,

@media print {
    .markdown-content .mermaid text,
    .markdown-content .mermaid tspan,
    .markdown-content .mermaid .label {
        fill: #000 !important; /* SVG uses fill */
        stroke: #000 !important; /* Sometimes stroke is used */
    }
    .markdown-content .mermaid .edgePaths path,
    .markdown-content .mermaid .node rect,
    .markdown-content .mermaid .node polygon,
    .markdown-content .mermaid .node ellipse,
    .markdown-content .mermaid .node circle {
        stroke: #000 !important; /* Keep lines black */
        fill: transparent !important; /* Remove node fills */
    }
}

/* Ensure pre background is white and border is visible */
 body.print-preview .markdown-content pre,
 @media print {
    .markdown-content pre {
        background-color: #fff !important;
        border: 1px solid #ccc !important; /* Ensure border prints */
        color: #000 !important;
     }
 }