/**
 * Print Stylesheet for Chastotnik.ua
 * Optimized for printing product pages, manuals, and articles
 */

/* Reset and base styles for print */
@media print {
    /* Document setup */
    @page {
        size: A4;
        margin: 1.5cm 2cm;
    }

    @page :first {
        margin-top: 2.5cm;
    }

    @page :left {
        margin-left: 2.5cm;
        margin-right: 1.5cm;
    }

    @page :right {
        margin-left: 1.5cm;
        margin-right: 2.5cm;
    }

    /* Base typography */
    * {
        background: transparent !important;
        color: black !important;
        box-shadow: none !important;
        text-shadow: none !important;
    }

    body {
        font-family: Georgia, 'Times New Roman', serif;
        font-size: 11pt;
        line-height: 1.6;
        color: #000;
        background: #fff;
    }

    /* Headers */
    h1 {
        font-size: 24pt;
        margin-bottom: 0.5em;
        page-break-after: avoid;
    }

    h2 {
        font-size: 18pt;
        margin-top: 1em;
        margin-bottom: 0.5em;
        page-break-after: avoid;
    }

    h3 {
        font-size: 14pt;
        margin-top: 1em;
        margin-bottom: 0.5em;
        page-break-after: avoid;
    }

    h4, h5, h6 {
        font-size: 12pt;
        margin-top: 1em;
        margin-bottom: 0.5em;
        page-break-after: avoid;
    }

    /* Paragraphs and lists */
    p {
        margin: 0.5em 0;
        orphans: 3;
        widows: 3;
    }

    ul, ol {
        margin: 0.5em 0 0.5em 1.5em;
    }

    li {
        margin: 0.2em 0;
    }

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

    /* Show URLs for external links */
    a[href^="http"]:not([href*="chastotnik.ua"]):after {
        content: " [" attr(href) "]";
        font-size: 0.8em;
        font-style: italic;
        word-wrap: break-word;
    }

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

    /* Images */
    img {
        max-width: 100%;
        height: auto;
        page-break-inside: avoid;
    }

    figure {
        margin: 1em 0;
        page-break-inside: avoid;
    }

    figcaption {
        font-size: 0.9em;
        font-style: italic;
        margin-top: 0.5em;
    }

    /* Tables */
    table {
        border-collapse: collapse;
        width: 100%;
        margin: 1em 0;
        page-break-inside: avoid;
    }

    thead {
        display: table-header-group;
    }

    tfoot {
        display: table-footer-group;
    }

    tr {
        page-break-inside: avoid;
    }

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

    th {
        background-color: #f0f0f0;
        font-weight: bold;
    }

    /* Product-specific styles */
    .product-card {
        page-break-inside: avoid;
        border: 1px solid #ddd;
        padding: 1em;
        margin-bottom: 1em;
    }

    .product-image {
        float: left;
        margin-right: 1em;
        max-width: 150px;
    }

    .product-info {
        overflow: hidden;
    }

    .product-title {
        font-size: 14pt;
        font-weight: bold;
        margin-bottom: 0.5em;
    }

    .product-sku {
        font-family: 'Courier New', monospace;
        font-size: 10pt;
        color: #333;
    }

    .price {
        font-size: 16pt;
        font-weight: bold;
        margin-top: 0.5em;
    }

    /* Technical specifications */
    .specifications,
    .tech-specs {
        margin: 1em 0;
        padding: 0.5em;
        border: 1px solid #ccc;
        page-break-inside: avoid;
    }

    .specifications dt,
    .tech-specs dt {
        font-weight: bold;
        float: left;
        width: 40%;
        clear: left;
        margin-bottom: 0.5em;
    }

    .specifications dd,
    .tech-specs dd {
        margin-left: 45%;
        margin-bottom: 0.5em;
    }

    /* Article content */
    article {
        max-width: 100%;
    }

    .article-header {
        margin-bottom: 1em;
        padding-bottom: 0.5em;
        border-bottom: 2pt solid #000;
    }

    .article-meta {
        font-size: 0.9em;
        color: #666;
        margin-bottom: 1em;
    }

    blockquote {
        margin: 1em 2em;
        padding-left: 1em;
        border-left: 3px solid #ccc;
        font-style: italic;
    }

    /* Code blocks */
    pre, code {
        font-family: 'Courier New', monospace;
        font-size: 0.9em;
        background-color: #f5f5f5;
        border: 1px solid #ddd;
        padding: 0.2em 0.4em;
    }

    pre {
        padding: 1em;
        overflow-x: auto;
        white-space: pre-wrap;
        word-wrap: break-word;
        page-break-inside: avoid;
    }

    /* Hide elements not needed for print */
    nav,
    header nav,
    footer,
    .navigation,
    .menu,
    .sidebar,
    .advertisement,
    .ads,
    .social-share,
    .comments,
    .comment-form,
    .related-posts,
    .pagination,
    .breadcrumb,
    .back-to-top,
    .mobile-menu,
    .hamburger,
    .search-form,
    .filter-section,
    .filterDiv,
    .cart-button,
    .buy-button,
    .add-to-cart,
    .wishlist,
    .compare,
    .newsletter,
    .popup,
    .modal,
    .tooltip,
    .alert-dismissible,
    .video-container,
    video,
    audio,
    iframe,
    embed,
    object,
    .no-print,
    [data-print="hide"] {
        display: none !important;
    }

    /* Show print-only content */
    .print-only,
    [data-print="show"] {
        display: block !important;
    }

    /* Page header for print */
    .print-header {
        display: block;
        text-align: center;
        margin-bottom: 2em;
        padding-bottom: 1em;
        border-bottom: 2pt solid #000;
    }

    .print-header .company-name {
        font-size: 18pt;
        font-weight: bold;
    }

    .print-header .company-url {
        font-size: 10pt;
        color: #666;
    }

    /* Page footer for print */
    .print-footer {
        display: block;
        margin-top: 2em;
        padding-top: 1em;
        border-top: 1pt solid #ccc;
        font-size: 9pt;
        color: #666;
    }

    /* Contact information */
    .contact-info {
        display: block;
        margin: 1em 0;
        padding: 0.5em;
        border: 1px solid #ccc;
    }

    .contact-info .phone {
        font-size: 12pt;
        font-weight: bold;
    }

    .contact-info .email {
        font-size: 10pt;
    }

    /* Manual/documentation specific */
    .manual-content {
        font-size: 10pt;
        line-height: 1.5;
    }

    .manual-content h1 {
        font-size: 20pt;
        border-bottom: 2pt solid #000;
        padding-bottom: 0.5em;
    }

    .manual-content h2 {
        font-size: 16pt;
        border-bottom: 1pt solid #ccc;
        padding-bottom: 0.3em;
    }

    .manual-warning,
    .manual-caution,
    .manual-note {
        margin: 1em 0;
        padding: 0.5em;
        border: 1px solid #000;
        page-break-inside: avoid;
    }

    .manual-warning {
        border-width: 2px;
        font-weight: bold;
    }

    /* QR codes for URLs (optional) */
    .qr-code {
        display: inline-block;
        margin: 0.5em;
        page-break-inside: avoid;
    }

    /* Utility classes */
    .page-break {
        page-break-after: always;
    }

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

    .keep-together {
        page-break-inside: avoid;
    }

    /* Clear floats */
    .clearfix:after {
        content: "";
        display: table;
        clear: both;
    }
}

/* High-resolution print */
@media print and (min-resolution: 300dpi) {
    body {
        font-size: 10pt;
    }

    h1 {
        font-size: 22pt;
    }

    h2 {
        font-size: 16pt;
    }

    .product-image {
        max-width: 200px;
    }
}

/* Landscape orientation */
@media print and (orientation: landscape) {
    @page {
        size: A4 landscape;
        margin: 1cm 1.5cm;
    }

    .product-card {
        width: 48%;
        float: left;
        margin-right: 2%;
    }

    .product-card:nth-child(even) {
        margin-right: 0;
    }
}