/* --- UNIFIED PRINT STYLES --- */

/* By default, hide the main app container for printing */
#root .app-container {
    display: none;
}

/* --- RECIPE PDF & INVENTORY PRINTING --- */
/* Show the main app container when printing inventory OR the recipes PDF page */
body.printing-inventory, 
body.printing-inventory #root,
body.printing-inventory #root .app-container,
body.printing-recipes-pdf,
body.printing-recipes-pdf #root,
body.printing-recipes-pdf #root .app-container,
body.printing-allergen-table, 
body.printing-allergen-table #root,
body.printing-allergen-table #root .app-container {
    display: block !important;
    background: none !important;
    box-shadow: none;
    margin: 0;
    padding: 0;
    max-width: 100%;
    border-radius: 0;
    min-height: 0;
}

body.printing-inventory main,
body.printing-allergen-table main {
    padding: 1cm;
    display: block !important;
}

body.printing-recipes-pdf main {
    padding: 0; /* Let the .pdf-page handle padding */
    display: block !important;
}

/* Hide all direct children of main EXCEPT the specific page container we want to print */
body.printing-recipes-pdf main > *:not(.recipes-pdf-container),
body.printing-inventory main > *:not(.inventory-page-container),
body.printing-allergen-table main > *:not(.inventory-page-container) {
    display: none !important;
}
    
/* Also hide header and other modals etc common to all print modes */
body.printing-inventory .global-header,
body.printing-recipes-pdf .global-header,
body.printing-allergen-table .global-header,
.completion-toast,
.pin-modal-overlay {
    display: none !important;
}

/* --- RECIPES PDF PRINTING --- */
@page {
    size: A4 portrait;
    margin: 0;
}

body.printing-recipes-pdf {
    font-size: 9pt; /* Smaller base font for printing */
}

body.printing-recipes-pdf .recipes-pdf-container {
    background-color: transparent !important;
}

body.printing-recipes-pdf .print-button-container {
    display: none;
}

body.printing-recipes-pdf .pdf-page {
    width: 100%;
    height: 100%;
    min-height: 0;
    padding: 1.5cm;
    margin: 0;
    box-shadow: none !important;
    page-break-after: always;
}
body.printing-recipes-pdf .pdf-page:last-child {
    page-break-after: auto;
}

body.printing-recipes-pdf .pdf-header {
    border-bottom-color: #000;
}
body.printing-recipes-pdf .pdf-header h1 {
    font-size: 18pt;
    color: #000;
}

body.printing-recipes-pdf .pdf-header-info {
    color: #333;
    font-size: 10pt;
}

body.printing-recipes-pdf .pdf-grid {
    gap: 1cm;
}

body.printing-recipes-pdf .pdf-recipe-item {
    border: 1px solid #000;
}

body.printing-recipes-pdf .pdf-recipe-item.placeholder {
    border: none;
    background: none;
}

body.printing-recipes-pdf .pdf-recipe-item h4 {
    font-size: 10pt;
    color: #000;
    border-bottom-color: #ccc;
}

body.printing-recipes-pdf .pdf-recipe-item ul {
    font-size: 8pt;
    line-height: 1.3;
}

body.printing-recipes-pdf .pdf-recipe-total {
    border-top-color: #000;
    font-size: 8.5pt;
}

body.printing-recipes-pdf .pdf-footer {
    border-top-color: #ccc;
    color: #666;
    font-size: 8pt;
}


/* --- INVENTORY & ALLERGEN PRINTING --- */
/* Hide screen-only elements */
body.printing-inventory .inventory-actions, 
body.printing-inventory .inventory-page-container form,
body.printing-allergen-table .inventory-actions {
    display: none !important;
}

/* Show print header */
body.printing-inventory .print-only-header,
body.printing-allergen-table .print-only-header {
    display: block;
    text-align: center;
    margin-bottom: 2rem;
    border-bottom: 2px solid #000;
    padding-bottom: 1rem;
}
body.printing-inventory .print-only-header h2,
body.printing-allergen-table .print-only-header h2 {
    margin: 0;
}

body.printing-inventory .recipe-card,
body.printing-allergen-table .recipe-card {
    border: none;
    box-shadow: none;
    padding: 0;
    background-color: transparent;
}

body.printing-inventory .inventory-table,
body.printing-allergen-table .inventory-table {
    font-size: 9pt; /* Reduced font size for compactness */
    width: 100%;
}

body.printing-inventory .inventory-table th, 
body.printing-inventory .inventory-table td,
body.printing-allergen-table .inventory-table th, 
body.printing-allergen-table .inventory-table td {
    color: #000;
    padding: 4px; /* Reduced padding for compactness */
}

body.printing-inventory .inventory-table .action-cell, 
body.printing-inventory .inventory-table .action-col {
    display: none;
}

body.printing-inventory .inventory-table thead,
body.printing-allergen-table .inventory-table thead {
    display: table-header-group; /* Ensure header repeats on each page */
}

/* Make inputs look like static text */
body.printing-inventory .inventory-input {
    border: none;
    background: transparent;
    padding: 0;
    margin: 0;
    width: 100%; 
    font-size: inherit;
    color: #000;
    -webkit-appearance: none;
    appearance: none;
}

body.printing-inventory .inventory-input::placeholder {
    color: transparent;
}

/* Hide rows that are meant to be hidden */
body.printing-inventory .inventory-table tbody tr.hidden-row {
    display: none;
}

body.printing-inventory .total-value-cell, 
body.printing-inventory .inventory-table .total-label-cell {
    font-weight: bold;
}

body.printing-inventory .inventory-table tfoot.screen-only {
    display: none;
}
body.printing-inventory .inventory-table tfoot.print-only {
    display: table-footer-group;
}
