﻿/* ========================================
   PRINT STYLES
   Optimized for print preview and actual printing
   ======================================== */

/* ========== SCREEN (Preview Mode) ========== */
@media screen {
    /* Hide print-specific elements on screen */
    .print-header {
        display: none;
    }
    
    .screen-only {
        display: block;
    }

    /* Preview scroll container */
    .preview-scroll {
        max-height: 55vh;
        overflow: auto;
    }

    /* Screen preview uses theme colors */
    .preview-table {
        border-collapse: collapse;
        width: 100%;
        font-size: 12px;
        background-color: var(--md-sys-color-surface);
    }

    .preview-table th,
    .preview-table td {
        border: 1px solid var(--md-sys-color-outline-variant);
        padding: 4px 6px;
        color: var(--md-sys-color-on-surface);
    }

    .preview-table th {
        background-color: var(--md-sys-color-surface-container);
        font-weight: 600;
    }

    .preview-table tfoot th {
        background-color: var(--md-sys-color-surface-container-high);
        font-weight: 700;
    }

    .qty,
    .num {
        text-align: right;
    }

    .total-cell,
    .total-col {
        font-weight: 600;
        background-color: var(--md-sys-color-surface-container-highest);
    }
}

/* ========== PRINT (Actual Printing) ========== */
@media print {
    /* Page setup */
    @page {
        size: A4 landscape;
        margin: 10mm;
    }

    /* Reset page structure */
    html, body {
        margin: 0 !important;
        padding: 0 !important;
        height: auto !important;
        background: white !important;
    }

    /* ========== CONTAINER OVERRIDES ========== */
    
    /* Remove container styling for print */
    .page-container,
    .page-container-square {
        background-color: white !important;
        padding: 0 !important;
        border-radius: 0 !important;
        box-shadow: none !important;
    }

    /* Print area container */
    #print-area {
        position: absolute !important;
        left: 0 !important;
        top: 0 !important;
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        box-shadow: none !important;
        border: none !important;
    }

    #print-area.mud-paper {
        box-shadow: none !important;
        border-radius: 0 !important;
        border: none !important;
        padding: 0 !important;
    }

    /* ========== VISIBILITY CONTROLS ========== */
    
    /* Hide elements marked as no-print */
    .no-print,
    .screen-only {
        display: none !important;
        visibility: hidden !important;
    }

    /* Show print header */
    .print-header {
        display: block !important;
        margin-bottom: 4mm;
    }

    .print-header h2 {
        font-size: 14pt;
        font-weight: 700;
        margin: 0 0 2mm 0;
        color: #000;
    }

    .print-date {
        font-size: 9pt;
        color: #666;
        margin: 0;
    }

    /* ========== SCROLLABLE AREAS ========== */
    
    /* Remove scrollbars for print */
    .preview-scroll {
        overflow: visible !important;
        max-height: none !important;
    }

    /* ========== TABLE STYLING FOR PRINT ========== */
    
    .print-table,
    .preview-table {
        width: 100%;
        border-collapse: collapse;
        font-size: 10pt;
        margin: 0;
        page-break-inside: avoid;
        display: table !important;
        background: white !important;
    }

    /* Table header */
    .preview-table thead th,
    .print-table thead th {
        background: #e0e0e0 !important;
        color: #000 !important;
        font-weight: 700;
        border: 1px solid #444;
        padding: 3px 5px;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    /* Table body - alternating rows */
    .preview-table tbody tr:nth-child(odd),
    .print-table tbody tr:nth-child(odd) {
        background: #ffffff !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .preview-table tbody tr:nth-child(even),
    .print-table tbody tr:nth-child(even) {
        background: #f5f5f5 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    /* Table cells */
    .preview-table th,
    .preview-table td,
    .print-table th,
    .print-table td {
        border: 1px solid #444;
        padding: 3px 5px;
        color: #000;
    }

    /* Row header (stub column) */
    .preview-table th.stub,
    .print-table th.stub {
        text-align: left;
        min-width: 55mm;
        font-weight: 700;
    }

    /* Number alignment */
    .num {
        text-align: right;
    }

    /* Total column */
    .total-col {
        background: #d0d0d0 !important;
        font-weight: 700;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    /* Table footer */
    .preview-table tfoot th,
    .print-table tfoot th {
        background: #c0c0c0 !important;
        font-weight: 700;
        border: 1px solid #444;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    /* ========== PAGE BREAKS ========== */
    
    /* Avoid breaking inside important elements */
    .preview-table,
    .print-table,
    .section {
        page-break-inside: avoid;
    }

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

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