/*
 *   Printing CSS Styles
 *
 *   Provides clean, user-friendly printouts for all pages.
 *   Specifically tuned for:
 *     - Invoice summary list (order-history.html)
 *     - Invoice detail view  (order-detail.html)
 *     - Payment detail view  (order-payments.html)
 *     - Shipment detail view (order-shipments.html)
 *     - Order receipt         (order-complete.html)
 */

@media print {

    /* ===== Reset page-hostile defaults ===== */

    body {
        background: none !important;
        margin: 0 !important;
        padding: 0.5rem !important;
        font-size: 12pt;
        color: #000 !important;
    }

    /* ===== Hide non-print UI elements ===== */

    header,
    nav.navbar,
    nav.second-navbar,
    footer,
    .footer,
    .loader,
    .loader-background,
    .spinner-border,
    div.modal,
    .pagination,
    .breadcrumb,
    .pay-column,
    .pay-all-selector,
    .pay-selector,
    .pay-all-button,
    .export-button,
    .view-button,
    .print-button,
    .checkout-stepper,
    #payment-message {
        display: none !important;
    }

    /* Hide search/filter form, result-size selector, and action buttons */
    form[method="get"],
    select,
    .input-group,
    .input-daterange,
    .table-toolbar,
    .status-filter-group,
    a.btn,
    button.btn {
        display: none !important;
    }

    /* ===== Keep content headings and titles visible ===== */

    h2, h3, h4, h5 {
        display: block !important;
    }

    /* ===== Layout cleanup ===== */

    .content {
        margin-bottom: 0 !important;
    }

    .container-fluid {
        padding: 0 !important;
    }

    /* ===== Table styles ===== */

    /* Allow table-responsive to show full content instead of clipping */
    .table-responsive {
        overflow: visible !important;
    }

    table.table {
        width: 100% !important;
        border-collapse: collapse;
    }

    td, th {
        white-space: normal !important;
        padding: 4px 8px !important;
        text-align: center;
        border: 1px solid #ccc !important;
        font-size: 11pt;
    }

    /* Left-align text-heavy columns (SKU, description) */
    td:first-child,
    th:first-child {
        text-align: left;
    }

    thead {
        background-color: #f0f0f0 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    thead th {
        font-weight: bold;
    }

    /* Zebra-stripe for readability */
    tbody tr:nth-child(even) {
        background-color: #f9f9f9 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    /* Hide the actions column (last column with View buttons) */
    .my-orders-body + td:last-child,
    thead tr th:last-child:empty,
    tbody tr td:last-child:has(.view-button) {
        display: none !important;
    }

    /* Avoid breaking table rows across pages */
    tr {
        page-break-inside: avoid;
    }

    table {
        page-break-before: avoid;
    }

    /* ===== Invoice detail: addresses & metadata ===== */

    .border {
        border: 1px solid #ccc !important;
        padding: 8px !important;
        margin-bottom: 8px;
    }

    /* ===== Detail page cards ===== */

    .info-card {
        border: 1px solid #ccc !important;
        padding: 8px !important;
        margin-bottom: 8px;
        page-break-inside: avoid;
    }

    .info-card-title {
        border-bottom: 1px solid #ccc !important;
    }

    .status-badge {
        display: inline-block !important;
        padding: 0.2em 0.6em !important;
        font-size: 9pt !important;
        font-weight: 600 !important;
        border-radius: 1rem !important;
        text-transform: uppercase !important;
        letter-spacing: 0.03em !important;
        border: none !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .status-paid {
        background-color: #d1e7dd !important;
        color: #0f5132 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .status-processing {
        background-color: #cfe2ff !important;
        color: #084298 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .status-posting {
        background-color: #cfe2ff !important;
        color: #084298 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .status-backorder {
        background-color: #fff3cd !important;
        color: #664d03 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .status-default {
        background-color: #e9ecef !important;
        color: #495057 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .status-canceled {
        background-color: #e9ecef !important;
        color: #495057 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .totals-card {
        border: 2px solid #333 !important;
        padding: 6px 12px !important;
        page-break-inside: avoid;
    }

    .totals-total {
        border-top: 2px solid #333 !important;
    }

    .detail-table thead {
        background-color: #f0f0f0 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    /* ===== Invoice total summary box ===== */

    .justify-content-end .border {
        border: 2px solid #333 !important;
        padding: 6px 12px !important;
    }

    /* Invoice list total */
    div:has(> strong.ms-3) {
        margin-top: 8px;
        padding: 4px 0;
        font-size: 12pt;
    }

    /* ===== Links ===== */

    a {
        text-decoration: none !important;
        color: #000 !important;
    }

    li {
        list-style: none;
    }

    /* ===== Page break helpers ===== */

    h2 {
        page-break-after: avoid;
    }

    /* ===== Order receipt (order-complete.html) ===== */

    /* Keep the order items list together */
    .list-group {
        page-break-inside: avoid;
    }

    .list-group-item {
        border: 1px solid #ddd !important;
        padding: 8px 12px !important;
        page-break-inside: avoid;
    }

    /* Bold the total row */
    .list-group-item:last-child {
        border-top: 2px solid #333 !important;
        font-size: 13pt;
    }

    /* Address cards: keep each card together on same page */
    .card.shadow {
        box-shadow: none !important;
        border: 1px solid #ccc !important;
        margin-bottom: 12px !important;
        page-break-inside: avoid;
    }

    .card-body {
        padding: 10px 14px !important;
    }

    .card-body h5 {
        font-size: 12pt;
        margin-bottom: 4px !important;
        border-bottom: 1px solid #ddd;
        padding-bottom: 4px;
    }

    /* Tighten address line spacing */
    .card-text div {
        line-height: 1.6;
    }

    /* ===== Payment details card (order-complete.html) ===== */

    #payment-details {
        border: 1px solid #ccc !important;
        box-shadow: none !important;
        page-break-inside: avoid;
        margin-bottom: 12px !important;
    }

    #payment-details .badge {
        border: 1px solid #333 !important;
        padding: 2px 6px !important;
        font-size: 10pt;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    #payment-details .badge.bg-success {
        background-color: #198754 !important;
        color: #fff !important;
    }

    #payment-details .badge.bg-warning {
        background-color: #ffc107 !important;
        color: #000 !important;
    }

    #payment-details .badge.bg-danger {
        background-color: #dc3545 !important;
        color: #fff !important;
    }

    /* Ensure badge pill contrast prints */
    .badge.bg-primary {
        background-color: #105e96 !important;
        color: #fff !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    /* ===== Browse Hero — render as plain black text for print ===== */
    .browse-hero {
        background: none !important;
        padding: 0.5rem 0 !important;
        margin-top: 0 !important;
        color: #000 !important;
    }

    .browse-hero-overlay {
        display: none !important;
    }

    .browse-hero-title {
        color: #000 !important;
        font-size: 14pt !important;
    }

    .browse-hero-subtitle {
        color: #333 !important;
    }

    .browse-hero .badge,
    .browse-hero .status-badge {
        border: 1px solid #333 !important;
    }

    /* ===== Page content card — clean layout for print ===== */
    .page-content-section,
    .auth-form-section {
        margin-top: 0 !important;
        padding: 0 !important;
    }

    .page-content-card,
    .auth-form-card {
        box-shadow: none !important;
        border: none !important;
        border-radius: 0 !important;
        padding: 0 !important;
        max-width: 100% !important;
    }
}
