/* Print-optimized CSS for Terna Documentation */
@media print {
    /* Page setup */
    @page {
        size: A4 portrait;
        margin: 25mm 20mm;

        @top-left {
            content: "Terna Systems Documentation";
            font-size: 10pt;
            color: #666;
        }

        @top-right {
            content: string(chapter-title);
            font-size: 10pt;
            color: #666;
        }

        @bottom-center {
            content: "Page " counter(page);
            font-size: 10pt;
            color: #666;
        }
    }

    @page :first {
        @top-left { content: none; }
        @top-right { content: none; }
        @bottom-center { content: none; }
    }

    /* Reset for print */
    * {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
        color-adjust: exact;
    }

    /* Hide unnecessary elements */
    .md-header,
    .md-sidebar,
    .md-nav,
    .md-footer,
    .md-search,
    .reading-time-badge,
    .language-selector,
    [data-md-component="announce"],
    [data-md-component="header"],
    [data-md-component="sidebar"],
    [data-md-component="navigation"],
    .md-content__button,
    .md-top,
    button,
    .md-source-file,
    .md-feedback {
        display: none !important;
    }

    /* Main content adjustments */
    .md-main {
        margin: 0 !important;
        padding: 0 !important;
    }

    .md-content {
        margin: 0 !important;
        padding: 0 !important;
        max-width: none !important;
        width: 100% !important;
        box-shadow: none !important;
    }

    .md-content__inner {
        margin: 0 !important;
        padding: 0 !important;
    }

    /* Typography for print */
    body {
        font-family: "Times New Roman", Times, serif !important;
        font-size: 12pt !important;
        line-height: 1.5 !important;
        color: #000 !important;
        background: white !important;
    }

    /* Headings */
    h1 {
        string-set: chapter-title content();
        font-size: 20pt !important;
        font-weight: bold !important;
        color: #000 !important;
        page-break-before: always;
        margin-top: 0 !important;
        margin-bottom: 18pt !important;
        border-bottom: 2pt solid #01a93d !important;
        padding-bottom: 6pt !important;
    }

    h1:first-of-type {
        page-break-before: avoid;
    }

    h2 {
        font-size: 16pt !important;
        font-weight: bold !important;
        color: #000 !important;
        margin-top: 24pt !important;
        margin-bottom: 12pt !important;
        page-break-after: avoid;
    }

    h3 {
        font-size: 14pt !important;
        font-weight: bold !important;
        color: #333 !important;
        margin-top: 18pt !important;
        margin-bottom: 9pt !important;
        page-break-after: avoid;
    }

    h4, h5, h6 {
        font-size: 12pt !important;
        font-weight: bold !important;
        color: #333 !important;
        margin-top: 12pt !important;
        margin-bottom: 6pt !important;
        page-break-after: avoid;
    }

    /* Paragraphs */
    p {
        margin: 0 0 12pt 0 !important;
        orphans: 2;
        widows: 2;
    }

    /* Lists */
    ul, ol {
        margin: 12pt 0 !important;
        padding-left: 20pt !important;
    }

    li {
        margin-bottom: 6pt !important;
        page-break-inside: avoid;
    }

    /* Code blocks */
    code {
        font-family: "Courier New", Courier, monospace !important;
        font-size: 10pt !important;
        background: #f5f5f5 !important;
        border: 1pt solid #ddd !important;
        padding: 2pt 4pt !important;
        border-radius: 2pt !important;
    }

    pre {
        font-family: "Courier New", Courier, monospace !important;
        font-size: 9pt !important;
        background: #f8f8f8 !important;
        border: 1pt solid #ddd !important;
        border-left: 4pt solid #01a93d !important;
        padding: 12pt !important;
        margin: 12pt 0 !important;
        page-break-inside: avoid;
        overflow: visible !important;
        white-space: pre-wrap !important;
        word-wrap: break-word !important;
    }

    pre code {
        background: none !important;
        border: none !important;
        padding: 0 !important;
    }

    /* Tables */
    table {
        width: 100% !important;
        border-collapse: collapse !important;
        margin: 12pt 0 !important;
        page-break-inside: avoid;
        font-size: 10pt !important;
    }

    th {
        background: #01a93d !important;
        color: white !important;
        font-weight: bold !important;
        padding: 8pt !important;
        border: 1pt solid #000 !important;
        text-align: left !important;
    }

    td {
        padding: 6pt 8pt !important;
        border: 1pt solid #666 !important;
        vertical-align: top !important;
    }

    /* Blockquotes */
    blockquote {
        margin: 12pt 0 12pt 20pt !important;
        padding: 6pt 0 6pt 12pt !important;
        border-left: 3pt solid #01a93d !important;
        font-style: italic !important;
        color: #333 !important;
        page-break-inside: avoid;
    }

    /* Images */
    img {
        max-width: 100% !important;
        height: auto !important;
        page-break-inside: avoid;
        margin: 12pt 0 !important;
    }

    /* Links */
    a {
        color: #000 !important;
        text-decoration: none !important;
    }

    a[href]:after {
        content: " (" attr(href) ")";
        font-size: 9pt;
        color: #666;
    }

    /* Don't show URLs for internal links */
    a[href^="#"]:after,
    a[href^="/"]:after {
        content: "";
    }

    /* Hide feedback widget and links in PDF */
    .md-feedback,
    a[href="/feedback/"],
    a[href*="/feedback/"] {
        display: none !important;
    }

    /* Hide text containing feedback links */
    .md-feedback__note:has(a[href*="/feedback/"]) {
        display: none !important;
    }

    /* Admonitions */
    .admonition {
        border: 1pt solid #ddd !important;
        border-left: 4pt solid #01a93d !important;
        padding: 12pt !important;
        margin: 12pt 0 !important;
        background: #f9f9f9 !important;
        page-break-inside: avoid;
    }

    .admonition-title {
        font-weight: bold !important;
        color: #01a93d !important;
        margin-bottom: 6pt !important;
    }

    /* Page breaks */
    .page-break {
        page-break-before: always;
    }

    .no-page-break {
        page-break-inside: avoid;
    }

    /* Table of contents styling */
    .toc {
        page-break-after: always;
    }

    .toc ul {
        list-style: none !important;
        padding-left: 0 !important;
    }

    .toc li {
        margin-bottom: 6pt !important;
        border-bottom: 1pt dotted #ccc;
        padding-bottom: 3pt;
    }

    .toc a {
        text-decoration: none !important;
    }

    .toc a:after {
        content: leader(".") target-counter(attr(href), page);
        float: right;
    }

    /* Print utilities */
    .print-only {
        display: block !important;
    }

    .no-print {
        display: none !important;
    }
}