/* =========================================================
   ใบเสร็จสำหรับพิมพ์ — กระดาษ A5
   แนวคิด: ซ่อนทุกอย่างด้วย display:none (ไม่ใช่ visibility)
   เพื่อไม่ให้เหลือพื้นที่ว่างจนกินกระดาษเพิ่มอีกแผ่น
========================================================= */
@media print {

    /* ---------- ขนาดกระดาษ ---------- */
    @page {
        size: A5;
        margin: 10mm;
    }

    html, body {
        width: auto !important;
        height: auto !important;
        margin: 0 !important;
        padding: 0 !important;
        background: #ffffff !important;
        color: #000000 !important;
        font-size: 11pt;
        line-height: 1.45;
    }

    /* ---------- ซ่อนทุกส่วนที่ไม่ใช่ใบเสร็จ ---------- */
    .navbar,
    .hero,
    .live-price,
    .about-us,
    .gallery,
    .tiktok-section,
    footer,
    .service-poster,
    .calculator-box > h2,
    #calc-form,
    .calc-rate,
    .calc-actions,
    .calc-error-inline,
    .save-bill-status,
    .no-print,
    .item-remove,
    .col-remove,
    button,
    .btn {
        display: none !important;
    }

    /* ---------- คลายกล่องที่ครอบใบเสร็จให้เต็มหน้ากระดาษ ---------- */
    .service-calc-container,
    .calculator-box,
    #calc-result {
        display: block !important;
        width: 100% !important;
        max-width: none !important;
        margin: 0 !important;
        padding: 0 !important;
        background: none !important;
        border: none !important;
        box-shadow: none !important;
        backdrop-filter: none !important;
    }

    /* ---------- ตัวใบเสร็จ ---------- */
    #receipt-slip {
        margin: 0 !important;
        padding: 6mm !important;
        background: #ffffff !important;
        color: #000000 !important;
        border: 1.5px solid #c9a227 !important;
        border-radius: 6px !important;
        box-shadow: none !important;
        animation: none !important;
        page-break-inside: avoid;
    }

    /* หัวใบเสร็จ + โลโก้ */
    .receipt-header {
        text-align: center !important;
        border-bottom: 1px solid #dddddd !important;
        padding-bottom: 4mm !important;
        margin-bottom: 4mm !important;
    }

    .receipt-logo {
        width: 70px !important;
        height: 70px !important;
        margin-bottom: 6px !important;
        /* บังคับให้เครื่องพิมพ์พิมพ์รูปออกมาจริง ไม่ตัดทิ้ง */
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    .receipt-shop {
        color: #9e1b1b !important;
        font-size: 16pt !important;
        margin: 0 0 2px !important;
        text-shadow: none !important;
    }

    .receipt-subtitle {
        color: #555555 !important;
        font-size: 10pt !important;
    }

    .receipt-date {
        color: #777777 !important;
        font-size: 9pt !important;
    }

    /* ตารางรายการ */
    .receipt-table-wrap {
        overflow: visible !important;
        margin-bottom: 4mm !important;
    }

    .receipt-table {
        width: 100% !important;
        border-collapse: collapse !important;
        font-size: 10pt !important;
    }

    .receipt-table th {
        color: #000000 !important;
        background: #f4f4f4 !important;
        border-bottom: 1px solid #999999 !important;
        padding: 5px 4px !important;
        font-size: 9pt !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    .receipt-table td {
        color: #000000 !important;
        border-bottom: 1px solid #e2e2e2 !important;
        padding: 5px 4px !important;
    }

    .receipt-table .col-no {
        color: #666666 !important;
    }

    .receipt-table .col-amount {
        color: #000000 !important;
        font-weight: bold !important;
    }

    /* ไม่ให้ตารางถูกตัดกลางแถว */
    .receipt-table tr {
        page-break-inside: avoid;
    }

    /* สรุปจำนวนรายการ / น้ำหนักรวม */
    .receipt-summary {
        font-size: 10pt !important;
        margin-bottom: 3mm !important;
    }

    .receipt-summary span {
        color: #555555 !important;
    }

    .receipt-summary strong {
        color: #000000 !important;
    }

    /* กล่องยอดสุทธิ */
    .receipt-total {
        background: #fdf5e6 !important;
        border: 1.5px solid #c9a227 !important;
        padding: 3mm !important;
        page-break-inside: avoid;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    .receipt-total-label {
        color: #7a5c00 !important;
        font-size: 10pt !important;
    }

    .receipt-total-value {
        color: #9e1b1b !important;
        -webkit-text-fill-color: #9e1b1b !important;
        font-size: 20pt !important;
        text-shadow: none !important;
    }

    .receipt-footnote {
        color: #888888 !important;
        font-size: 8pt !important;
        margin-top: 3mm !important;
    }
}
