/* 
 * Pinmaps Blog - Print Stylesheet
 * Optimized for clean, professional printing
 * Saves ink and paper while maintaining readability
 */

@media print {
    /* ===================================
       RESET & HIDE NON-ESSENTIAL ELEMENTS
       =================================== */
    
    /* Hide navigation and interactive elements */
    header,
    nav,
    .navbar,
    .navbar-brand,
    .navbar-nav,
    .navbar-collapse,
    .sidebar,
    .sidebar-sticky,
    footer,
    .footer,
    .social-share-buttons,
    .btn,
    .alert,
    .toc-container,
    .reading-progress-container,
    .code-copy-button,
    .breadcrumb,
    .recent-posts,
    .related-posts-section,
    form,
    input,
    button,
    select,
    textarea,
    .no-print,
    .admin-header,
    .admin-table,
    .search-box,
    .category-filter,
    .pagination,
    .back-to-top {
        display: none !important;
    }
    
    /* ===================================
       PAGE SETUP
       =================================== */
    
    @page {
        margin: 2cm;
        size: auto;
        
        /* Page numbers in footer */
        @bottom-right {
            content: "Page " counter(page) " of " counter(pages);
            font-size: 9pt;
            color: #666;
        }
    }
    
    @page :first {
        margin-top: 1cm;
    }
    
    /* ===================================
       BODY & CONTAINER RESETS
       =================================== */
    
    * {
        background: none !important;
        box-shadow: none !important;
        text-shadow: none !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
    
    body {
        background: white !important;
        color: black !important;
        font-size: 12pt;
        line-height: 1.5;
        font-family: Georgia, 'Times New Roman', serif;
        margin: 0;
        padding: 0;
    }
    
    .container,
    .post-content,
    article,
    main {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        float: none !important;
    }
    
    /* ===================================
       PRINT HEADER (BRANDING)
       =================================== */
    
    .print-header {
        display: block !important;
        text-align: center;
        margin-bottom: 20pt;
        padding-bottom: 10pt;
        border-bottom: 2px solid #000;
    }
    
    .print-header::before {
        content: "Pinmaps Tutorials";
        display: block;
        font-size: 20pt;
        font-weight: bold;
        margin-bottom: 5pt;
    }
    
    .print-header::after {
        content: "www.pinmaps.net";
        display: block;
        font-size: 10pt;
        color: #666;
    }
    
    /* ===================================
       TYPOGRAPHY
       =================================== */
    
    h1, h2, h3, h4, h5, h6 {
        color: #000 !important;
        page-break-after: avoid;
        page-break-inside: avoid;
        font-weight: bold;
        margin-top: 12pt;
    }
    
    h1 {
        font-size: 24pt;
        margin-top: 0;
        margin-bottom: 12pt;
        border-bottom: 3px solid #000;
        padding-bottom: 6pt;
    }
    
    h2 {
        font-size: 18pt;
        margin-top: 16pt;
        margin-bottom: 8pt;
        border-bottom: 2px solid #000;
        padding-bottom: 4pt;
    }
    
    h3 {
        font-size: 14pt;
        margin-top: 12pt;
        margin-bottom: 6pt;
        border-bottom: 1px solid #ccc;
        padding-bottom: 3pt;
    }
    
    h4, h5, h6 {
        font-size: 12pt;
        margin-top: 10pt;
        margin-bottom: 6pt;
    }
    
    p {
        orphans: 3;
        widows: 3;
        margin-bottom: 8pt;
        text-align: justify;
    }
    
    /* ===================================
       LINKS
       =================================== */
    
    a {
        color: #000 !important;
        text-decoration: underline;
    }
    
    /* Show URLs for external links */
    a[href^="http"]:after {
        content: " (" attr(href) ")";
        font-size: 9pt;
        font-style: italic;
        color: #666;
        word-wrap: break-word;
    }
    
    /* Don't show URLs for anchors or JavaScript links */
    a[href^="#"]:after,
    a[href^="javascript:"]:after {
        content: "";
    }
    
    /* ===================================
       IMAGES
       =================================== */
    
    img {
        max-width: 100% !important;
        height: auto !important;
        page-break-inside: avoid;
        page-break-after: avoid;
        border: 1px solid #ddd;
        padding: 5pt;
        margin: 10pt 0;
    }
    
    figure {
        page-break-inside: avoid;
        margin: 10pt 0;
    }
    
    figcaption {
        font-style: italic;
        font-size: 10pt;
        color: #666;
        text-align: center;
        margin-top: 5pt;
    }
    
    /* ===================================
       CODE BLOCKS
       =================================== */
    
    pre,
    code {
        border: 1px solid #ccc !important;
        background: #f5f5f5 !important;
        page-break-inside: avoid;
        font-family: 'Courier New', Courier, monospace;
    }
    
    pre {
        padding: 10pt !important;
        margin: 10pt 0 !important;
        white-space: pre-wrap;
        word-wrap: break-word;
        font-size: 9pt;
        line-height: 1.3;
        border-left: 4px solid #000 !important;
    }
    
    code {
        padding: 2pt 4pt !important;
        font-size: 10pt;
    }
    
    pre code {
        padding: 0 !important;
        border: none !important;
        background: transparent !important;
    }
    
    /* ===================================
       LISTS
       =================================== */
    
    ul, ol {
        page-break-inside: avoid;
        margin: 8pt 0;
        padding-left: 20pt;
    }
    
    li {
        page-break-inside: avoid;
        margin-bottom: 4pt;
    }
    
    ul ul,
    ol ol,
    ul ol,
    ol ul {
        margin: 4pt 0;
    }
    
    /* ===================================
       TABLES
       =================================== */
    
    table {
        border-collapse: collapse;
        width: 100%;
        page-break-inside: avoid;
        margin: 10pt 0;
        font-size: 10pt;
    }
    
    table, th, td {
        border: 1px solid #000;
    }
    
    th, td {
        padding: 6pt;
        text-align: left;
        vertical-align: top;
    }
    
    th {
        background: #f0f0f0 !important;
        font-weight: bold;
        border-bottom: 2px solid #000;
    }
    
    tr {
        page-break-inside: avoid;
    }
    
    /* ===================================
       BLOCKQUOTES
       =================================== */
    
    blockquote {
        border-left: 4px solid #000;
        padding-left: 12pt;
        margin: 12pt 0;
        margin-left: 20pt;
        font-style: italic;
        page-break-inside: avoid;
    }
    
    blockquote p {
        margin-bottom: 6pt;
    }
    
    /* ===================================
       ARTICLE METADATA
       =================================== */
    
    .post-meta {
        display: block !important;
        margin: 10pt 0;
        padding: 10pt;
        border: 1px solid #ccc;
        background: #f9f9f9 !important;
    }
    
    .post-meta::before {
        content: "Article Information";
        display: block;
        font-weight: bold;
        margin-bottom: 5pt;
        font-size: 11pt;
    }
    
    /* Print author and date info */
    time[datetime]::before {
        content: "Published: ";
        font-weight: bold;
    }
    
    /* ===================================
       PAGE BREAKS
       =================================== */
    
    /* Force page break before these elements */
    .page-break,
    .page-break-before {
        page-break-before: always;
    }
    
    /* Prevent page breaks inside these */
    .page-break-avoid,
    h1, h2, h3, h4, h5, h6,
    img, figure, table, pre, blockquote {
        page-break-inside: avoid;
    }
    
    /* Prevent page breaks after headings */
    h1, h2, h3, h4, h5, h6 {
        page-break-after: avoid;
    }
    
    /* ===================================
       PRINT FOOTER
       =================================== */
    
    .print-footer {
        display: block !important;
        text-align: center;
        margin-top: 30pt;
        padding-top: 10pt;
        border-top: 1px solid #ccc;
        font-size: 9pt;
        color: #666;
    }
    
    .print-footer::after {
        content: "Printed from Pinmaps Tutorials - www.pinmaps.net";
        display: block;
    }
    
    /* ===================================
       ARTICLE STRUCTURE
       =================================== */
    
    article {
        position: relative;
    }
    
    article header {
        margin-bottom: 20pt;
        padding-bottom: 10pt;
        border-bottom: 2px solid #000;
    }
    
    article footer {
        display: none !important;
    }
    
    /* ===================================
       BADGES AND LABELS
       =================================== */
    
    .badge,
    .label,
    .tag {
        border: 1px solid #000;
        padding: 2pt 4pt;
        font-size: 9pt;
        font-weight: bold;
        background: #f0f0f0 !important;
        color: #000 !important;
    }
    
    /* ===================================
       SPECIAL CONTENT
       =================================== */
    
    /* Highlighted text */
    mark {
        background: #ffff00 !important;
        color: #000 !important;
        padding: 2pt;
    }
    
    /* Keyboard shortcuts */
    kbd {
        border: 1px solid #000;
        padding: 2pt 4pt;
        font-family: 'Courier New', monospace;
        font-size: 10pt;
        background: #f0f0f0 !important;
    }
    
    /* Horizontal rules */
    hr {
        border: none;
        border-top: 1px solid #000;
        margin: 20pt 0;
    }
    
    /* ===================================
       UTILITY CLASSES
       =================================== */
    
    .text-center {
        text-align: center !important;
    }
    
    .text-right {
        text-align: right !important;
    }
    
    .font-weight-bold,
    .fw-bold,
    strong, b {
        font-weight: bold !important;
    }
    
    .font-italic,
    .fst-italic,
    em, i {
        font-style: italic !important;
    }
    
    /* ===================================
       PRINT-SPECIFIC CONTENT
       =================================== */
    
    /* Show print-only content */
    .print-only {
        display: block !important;
    }
    
    /* Add "Continued on next page" for long content */
    .long-content::after {
        content: "Continued on next page...";
        display: block;
        font-style: italic;
        text-align: right;
        margin-top: 10pt;
        font-size: 9pt;
    }
    
    /* ===================================
       ACCESSIBILITY
       =================================== */
    
    /* Ensure abbreviations are clear */
    abbr[title]::after {
        content: " (" attr(title) ")";
        font-size: 9pt;
        font-style: italic;
    }
    
    /* ===================================
       OPTIMIZATION
       =================================== */
    
    /* Remove all colors except for code syntax (if desired) */
    * {
        color: #000 !important;
    }
    
    /* Keep syntax highlighting in code blocks (optional) */
    pre code .token {
        color: #000 !important;
    }
    
    /* Reduce spacing for compact printing */
    .compact-print h2 {
        margin-top: 10pt;
    }
    
    .compact-print p {
        margin-bottom: 6pt;
    }
}

/* ===================================
   PRINT PREVIEW MODE (FOR TESTING)
   =================================== */

/* Add this class to body to preview print styles in browser */
.print-preview {
    background: white;
}

.print-preview header,
.print-preview nav,
.print-preview .sidebar,
.print-preview footer,
.print-preview .btn {
    display: none;
}

.print-preview .container {
    max-width: 8.5in;
    margin: 0 auto;
    padding: 1in;
    background: white;
    box-shadow: 0 0 20px rgba(0,0,0,0.1);
}

/* ===================================
   BROWSER-SPECIFIC FIXES
   =================================== */

/* Chrome/Edge print optimization */
@media print and (-webkit-min-device-pixel-ratio:0) {
    body {
        -webkit-print-color-adjust: exact;
    }
}

/* Firefox print optimization */
@-moz-document url-prefix() {
    @media print {
        body {
            color-adjust: exact;
        }
    }
}
