/* Page-level print system - New visibility-based architecture */
.print-mode {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: white;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.print-mode-hidden {
    display: none !important;
}

.print-preview-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.print-preview-header {
    padding: 1rem;
    background: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
    flex-shrink: 0;
}

.print-preview-content {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    background: #e9ecef;
}

.print-preview-paper {
    background: white;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    padding: 2rem;
    max-width: 21cm; /* A4 width */
    width: 100%;
}

.print-preview-actions {
    padding: 1rem;
    background: #f8f9fa;
    border-top: 1px solid #dee2e6;
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-shrink: 0;
}

/* Print-specific styles for the new system */
@media print {
    /* Hide everything by default - !important needed to override all existing styles */
    body * {
        visibility: hidden !important;
    }

    /* Hide navigation components during print */
    .sidebar,
    .top-row,
    nav,
    .navbar,
    .nav-menu,
    .navbar-toggler,
    .navbar-brand {
        visibility: hidden !important;
        display: none !important;
    }

    /* Show only the print mode container when printing */
    .print-mode {
        visibility: visible !important;
        position: relative; /* Relative positioning ensures content moves to top when other elements are hidden */
        width: 100%;
        height: auto; /* Auto height for proper printing */
        background: transparent;
        z-index: auto;
        display: block;
        flex-direction: initial;
        overflow: visible; /* Allow content to flow naturally for printing */
    }

    /* Make all children of print mode visible */
    .print-mode * {
        visibility: visible !important;
    }

    /* Hide print preview UI elements during actual printing */
    .print-preview-header,
    .print-preview-actions {
        display: none;
    }

    /* Style the print content for printing - minimal overrides needed */
    .print-preview-container {
        flex: initial;
        display: block;
        overflow: visible;
    }

    .print-preview-content {
        flex: initial;
        overflow: visible;
        padding: 0;
        display: block;
        justify-content: initial;
        align-items: initial;
        background: transparent;
    }

    .print-preview-paper {
        background: transparent;
        box-shadow: none;
        border-radius: 0;
        padding: 0;
        max-width: 100%;
        width: 100%;
    }

    /* Receipt content print styles - !important needed to override Bootstrap and other framework styles */
    .print-receipt-content {
        font-size: 12pt !important;
        line-height: 1.3 !important;
        font-family: 'Courier New', monospace !important;
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding: 10pt !important;
        box-sizing: border-box !important;
    }

    /* Receipt styling for print - !important needed to override component styles */
    .print-receipt-content .receipt-compact,
    .print-receipt-content .receipt-display {
        max-width: 100% !important;
        width: 100% !important;
        border: none !important;
        box-shadow: none !important;
        padding: 0 !important;
        margin: 0 !important;
        background: transparent !important;
    }

    /* Bootstrap utility overrides for print - !important needed to override Bootstrap */
    .print-receipt-content .mb-1 {
        margin-bottom: 0.3rem !important;
    }

    .print-receipt-content .mb-2 {
        margin-bottom: 0.5rem !important;
    }

    .print-receipt-content .mb-3 {
        margin-bottom: 0.7rem !important;
    }

    .print-receipt-content .py-1 {
        padding-top: 0.3rem !important;
        padding-bottom: 0.3rem !important;
    }

    .print-receipt-content .mt-2 {
        margin-top: 0.5rem !important;
    }

    .print-receipt-content .pt-2 {
        padding-top: 0.5rem !important;
    }

    /* Receipt table print styles - !important needed for table formatting */
    .print-receipt-content .receipt-table {
        border-collapse: collapse !important;
        width: 100% !important;
    }

    .print-receipt-content .receipt-table th,
    .print-receipt-content .receipt-table td {
        border: none !important;
        padding: 0.2rem 0.3rem !important;
    }

    /* Page settings - !important needed to override browser defaults */
    @page {
        margin: 0.5in !important;
        size: auto !important;
    }

    /* Ensure main content area is also properly handled */
    main {
        visibility: visible !important;
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    /* Hide any remaining page structure elements */
    .page {
        display: block !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    /* Override article content padding for print */
    article.content {
        padding: 0 !important;
        margin: 0 !important;
    }
}

/* Screen styles for receipt display */
.receipt-compact {
    width: 100%;
    font-family: 'Courier New', monospace;
    font-size: 0.875rem;
    line-height: 1.3;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    padding: 1rem;
    background-color: #fff;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
}

.receipt-display {
    /* Default display styles for modal view */
    background-color: #f8f9fa;
    border-radius: 0.375rem;
    padding: 1.5rem;
}

/* Legacy print receipt clone - kept for backward compatibility but hidden */
.print-receipt-clone {
    display: none !important;
    position: fixed;
    top: -9999px;
    left: -9999px;
    z-index: -1;
}

/* Legacy print system styles - deprecated but kept for compatibility */
@media print {
    .printing .print-receipt-clone {
        visibility: visible !important;
        display: block !important;
        position: absolute !important;
        left: 0 !important;
        top: 0 !important;
        width: 100% !important;
        height: 100% !important;
        z-index: 9999 !important;
    }
}