/**
 * Knowledge Base Print Styles
 *
 * Optimized styles for printing KB articles and PDF generation
 *
 * @package Remko_Theme
 * @since 1.0.0
 */

@media print {
    /* ==========================================================================
       Page Setup
       ========================================================================== */

    @page {
        margin: 2cm;
        size: A4;
    }

    body {
        font-size: 12pt;
        line-height: 1.6;
        color: #000;
        background: #fff;
    }

    /* ==========================================================================
       Hide Non-Essential Elements
       ========================================================================== */

    /* Navigation & UI */
    header,
    footer,
    nav,
    .kb-category-nav,
    .kb-toc-sidebar,
    .breadcrumbs,
    .mega-menu,
    .site-header,
    .site-footer,
    .kb-print-btn,
    .kb-pdf-btn,
    .kb-share-btn,
    .kb-related-articles,
    .bg-accent:not(.kb-article-header *),
    section.bg-accent,
    .d-flex.flex-wrap.gap-3:has(.kb-print-btn) {
        display: none !important;
    }

    /* Sidebar */
    aside,
    .kb-toc-sidebar {
        display: none !important;
    }

    /* Buttons & Interactive Elements */
    button,
    .btn,
    .button,
    input[type="submit"] {
        display: none !important;
    }

    /* ==========================================================================
       Layout Adjustments
       ========================================================================== */

    /* Main container */
    main.container {
        padding: 0;
        margin: 0;
        max-width: 100%;
    }

    .container,
    .container--boxed {
        max-width: 100%;
        padding: 0;
        margin: 0;
    }

    /* Full width article */
    .kb-article-main {
        width: 100%;
        grid-column: span 4 !important;
    }

    .grid {
        display: block;
    }

    /* Article content */
    .kb-article-content {
        padding: 0;
        box-shadow: none;
        background: transparent;
    }

    /* ==========================================================================
       Header Styling
       ========================================================================== */

    .kb-article-header {
        border-bottom: 2px solid #000;
        padding-bottom: 1rem;
        margin-bottom: 1.5rem;
    }

    .kb-article-header h1 {
        font-size: 24pt;
        line-height: 1.2;
        margin-bottom: 0.5rem;
    }

    /* Show category badge as text */
    .kb-article-header .bg-accent {
        background: transparent !important;
        border: 1px solid #000;
        padding: 0.25rem 0.5rem;
        font-size: 10pt;
    }

    /* Meta info */
    .kb-article-header .text-gray-600 {
        color: #666;
        font-size: 10pt;
    }

    /* ==========================================================================
       Typography
       ========================================================================== */

    h1, h2, h3, h4, h5, h6 {
        page-break-after: avoid;
        color: #000;
    }

    h2 {
        font-size: 16pt;
        margin-top: 1.5rem;
        margin-bottom: 0.75rem;
        border-bottom: 1px solid #ccc;
        padding-bottom: 0.25rem;
    }

    h3 {
        font-size: 14pt;
        margin-top: 1.25rem;
        margin-bottom: 0.5rem;
    }

    h4 {
        font-size: 12pt;
        margin-top: 1rem;
        margin-bottom: 0.5rem;
    }

    p {
        orphans: 3;
        widows: 3;
    }

    /* ==========================================================================
       Links
       ========================================================================== */

    a {
        color: #000;
        text-decoration: underline;
    }

    /* Show URL after links */
    a[href^="http"]:after {
        content: " (" attr(href) ")";
        font-size: 9pt;
        color: #666;
    }

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

    /* ==========================================================================
       Tables
       ========================================================================== */

    table {
        width: 100%;
        border-collapse: collapse;
        page-break-inside: avoid;
        font-size: 10pt;
    }

    th, td {
        border: 1px solid #000;
        padding: 0.5rem;
        text-align: left;
    }

    th {
        background: #f0f0f0 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    /* ==========================================================================
       Images
       ========================================================================== */

    img {
        max-width: 100%;
        page-break-inside: avoid;
    }

    figure {
        page-break-inside: avoid;
    }

    figcaption {
        font-size: 10pt;
        color: #666;
        text-align: center;
    }

    /* ==========================================================================
       Callout Boxes
       ========================================================================== */

    .kb-callout-info,
    .kb-callout-warning,
    .kb-callout-success,
    .kb-callout-note,
    .wp-block-paragraph.kb-callout-info,
    .wp-block-paragraph.kb-callout-warning,
    .wp-block-paragraph.kb-callout-success,
    .wp-block-paragraph.kb-callout-note {
        border: 1px solid #000;
        border-left-width: 4px;
        padding: 0.75rem 1rem;
        margin: 1rem 0;
        page-break-inside: avoid;
        background: transparent !important;
    }

    .kb-callout-info {
        border-left-color: #3B82F6;
    }

    .kb-callout-warning {
        border-left-color: #EF4444;
    }

    .kb-callout-success {
        border-left-color: #10B981;
    }

    .kb-callout-note {
        border-left-color: #666;
    }

    /* Add labels before callouts */
    .kb-callout-info:before {
        content: "INFO: ";
        font-weight: bold;
    }

    .kb-callout-warning:before {
        content: "WARNING: ";
        font-weight: bold;
    }

    .kb-callout-success:before {
        content: "KEY POINT: ";
        font-weight: bold;
    }

    /* ==========================================================================
       Lists
       ========================================================================== */

    ul, ol {
        page-break-inside: avoid;
    }

    li {
        page-break-inside: avoid;
    }

    /* ==========================================================================
       Code Blocks
       ========================================================================== */

    pre, code {
        font-family: "Courier New", monospace;
        font-size: 10pt;
        page-break-inside: avoid;
    }

    pre {
        border: 1px solid #ccc;
        padding: 0.5rem;
        background: #f9f9f9 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    /* ==========================================================================
       Footer Info
       ========================================================================== */

    /* Print article URL at end */
    .kb-article-content:after {
        content: "Source: " attr(data-url);
        display: block;
        margin-top: 2rem;
        padding-top: 1rem;
        border-top: 1px solid #ccc;
        font-size: 10pt;
        color: #666;
    }

    /* ==========================================================================
       Page Breaks
       ========================================================================== */

    .page-break {
        page-break-before: always;
    }

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

    /* Prevent breaking inside important elements */
    blockquote,
    pre,
    table,
    figure,
    .kb-callout-info,
    .kb-callout-warning,
    .kb-callout-success,
    .kb-callout-note {
        page-break-inside: avoid;
    }

    /* ==========================================================================
       Color Adjustments
       ========================================================================== */

    /* Force grayscale for better printing */
    * {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .text-accent,
    .text-gray-600,
    .text-gray-700 {
        color: #000 !important;
    }

    .bg-gray-100,
    .bg-gray-50,
    .bg-white {
        background: transparent !important;
    }
}
