/* ==========================================
   1. GLOBAL & CASHIER PAGE STYLE (หน้าจอคิดเงินหลัก)
   ========================================== */
   body { 
    font-family: 'Segoe UI', 'Kanit', sans-serif; 
    background-color: #1e293b; 
    margin: 0; 
    padding: 30px 20px; 
    color: #1e293b;
}
.pos-container { 
    max-width: 900px; 
    margin: 0 auto; 
    background: white; 
    padding: 35px; 
    border-radius: 20px; 
    box-shadow: 0 10px 25px rgba(0,0,0,0.05); 
}
h2 { 
    text-align: center; 
    color: #0f172a; 
    margin-bottom: 30px; 
    font-weight: 700;
}
.input-group { 
    background: #f8fafc; 
    padding: 25px; 
    border-radius: 14px; 
    margin-bottom: 25px; 
    border: 1px solid #e2e8f0;
}
label { 
    font-weight: 600; 
    display: block; 
    margin-bottom: 10px; 
    color: #475569; 
    font-size: 15px;
}
input[type="text"], input[type="number"], select { 
    width: 100%; 
    padding: 12px 16px; 
    box-sizing: border-box; 
    border: 2px solid #cbd5e1; 
    border-radius: 10px; 
    font-size: 16px; 
    outline: none; 
    transition: all 0.3s ease; 
    background-color: #fff;
}
input:focus, select:focus { 
    border-color: #3b82f6; 
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.15); 
}

/* 🚨 ตารางสำหรับหน้าเว็บหลัก (ห้ามแหว่ง) */
.pos-container table { 
    width: 100%; 
    border-collapse: separate; 
    border-spacing: 0; 
    margin-top: 25px; 
    border-radius: 12px; 
    overflow: hidden; 
    border: 1px solid #e2e8f0;
}
.pos-container th, .pos-container td { 
    padding: 14px 18px; 
    text-align: left; 
}
.pos-container th { 
    background-color: #f1f5f9; 
    color: #334155; 
    font-weight: 600; 
    border-bottom: 2px solid #e2e8f0;
}
.pos-container td { 
    border-bottom: 1px solid #f1f5f9; 
    background-color: #ffffff;
}
.pos-container tr:last-child td { 
    border-bottom: none; 
}

.total-section { 
    margin-top: 35px; 
    padding: 25px; 
    background: #f8fafc; 
    border-radius: 16px; 
    border: 1px solid #e2e8f0;
    text-align: right; 
}
.total-price { 
    font-size: 32px; 
    color: #2563eb; 
    font-weight: 800; 
}
.calculation-group { 
    display: flex; 
    justify-content: flex-end; 
    gap: 15px; 
    margin-top: 20px; 
    align-items: center; 
}

/* ปุ่มกดต่าง ๆ */
.btn { 
    padding: 14px 28px; 
    font-size: 16px; 
    border: none; 
    border-radius: 10px; 
    cursor: pointer; 
    font-weight: bold; 
    transition: all 0.2s ease; 
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.btn-success { 
    background-color: #10b981; 
    color: white; 
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.2);
}
.btn-success:hover { 
    background-color: #059669; 
    transform: translateY(-1px);
}
.btn-primary { 
    background-color: #3b82f6; 
    color: white; 
    width: 100%; 
    margin-top: 15px; 
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2);
}
.btn-primary:hover { 
    background-color: #2563eb; 
    transform: translateY(-1px);
}
.btn-secondary { 
    background-color: #64748b; 
    color: white; 
    padding: 10px 16px; 
    font-size: 14px; 
    border-radius: 8px; 
    border: none; 
    cursor: pointer; 
}
.btn-secondary:hover { 
    background-color: #475569; 
}
.btn-danger { background-color: #ef4444; color: white; border: none; padding: 6px 12px; border-radius: 6px; cursor: pointer; }
.btn-danger:hover { background-color: #dc2626; }

code {
    background-color: #f1f5f9;
    padding: 4px 8px;
    border-radius: 6px;
    font-family: 'Courier New', Courier, monospace;
    font-weight: bold;
    color: #0f172a;
}
.btn-quick-cash {
    background-color: #3b82f6; color: white; border: none; padding: 12px 20px; font-size: 15px; font-weight: bold; border-radius: 10px; cursor: pointer; min-width: 80px; text-align: center;
}
.btn-quick-cash:hover { background-color: #2563eb; transform: translateY(-2px); }

/* ==========================================
   2. 📑 PRINT INVOICE A4 STYLE (สำหรับหน้า print-a4.html)
   ========================================== */
.document-container {
    width: 210mm;
    max-width: 100%;
    margin: 0 auto;
    padding: 10px;
    border: 1px solid #d1d5db;
    background-color: #ffffff;
}
.items-table {
    width: 100%;
    border-collapse: collapse !important;
    margin-bottom: 0px;
}
.items-table th {
    background-color: #f8fafc !important;
    color: #1e3a8a !important;
    border: 1px solid #1e3a8a !important;
    padding: 8px;
    text-align: center;
}
.items-table td {
    border-left: 1px solid #1e3a8a !important;
    border-right: 1px solid #1e3a8a !important;
    border-bottom: 1px solid #cbd5e1 !important;
    padding: 8px;
    height: 35px;
}
.summary-section {
    display: flex;
    border: 1px solid #1e3a8a !important;
}
.notes-box { width: 60%; padding: 10px; border-right: 1px solid #1e3a8a; }
.totals-box { width: 40%; }
.totals-table { width: 100%; border-collapse: collapse; }
.totals-table td { border-bottom: 1px solid #1e3a8a !important; border-left: 1px solid #1e3a8a !important; padding: 6px 8px; }
.signature-section { display: flex; border: 1px solid #1e3a8a !important; border-top: none !important; }
.sig-col { padding: 10px; text-align: center; height: 90px; display: flex; flex-direction: column; justify-content: space-between; }

/* ==========================================
   3. 🧾 80mm THERMAL SLIP STYLE (บิลสลิปเล็กห้ามหาย!)
   ========================================== */
.slip-container {
    width: 80mm;
    padding: 5mm;
    background: #fff;
    margin: 0 auto;
    color: #000;
    font-size: 13px;
}
.slip-title { text-align: center; font-size: 16px; font-weight: bold; }
.slip-stars { text-align: center; margin: 5px 0; }
.slip-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.slip-table th { border-bottom: 1px dashed #000; padding: 5px 0; text-align: left; background: none; color: #000; }
.slip-table td { padding: 5px 0; border: none; background: none; }
.slip-total-row { border-top: 1px dashed #000; font-weight: bold; }

@media print {
    .no-print, .btn-print-zone { display: none !important; }
    body { background: white !important; padding: 0 !important; }
}

/* สไตล์ปกติของใบสั่งซื้อบนหน้าจอ */
.receipt-box {
    background: #fff;
    padding: 20px;
    border: 1px solid #ccc;
    border-radius: 8px;
    max-width: 400px;
    margin: 15px auto;
}

.btn-print {
    background-color: #28a745;
    color: white;
    padding: 10px 20px;
    font-size: 16px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
}

.btn-print:hover {
    background-color: #218838;
}

/* 🖨️ โค้ดส่วนนี้จะทำงานเฉพาะตอนกดสั่งพิมพ์เท่านั้น */
@media print {
    /* ซ่อนองค์ประกอบอื่นๆ บนหน้าเว็บทั้งหมด เช่น ปุ่มกด เมนู ซายด์บาร์ */
    body * {
        visibility: hidden;
    }
    
    /* แสดงเฉพาะส่วนใบสั่งซื้อ #po-receipt เท่านั้น */
    #po-receipt, #po-receipt * {
        visibility: visible;
    }
    
    #po-receipt {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        border: none;
        box-shadow: none;
    }

    .btn-print {
        display: none !important;
    }
}
@media print {
    /* ซ่อนทุกอย่างใน body */
    body * {
        visibility: hidden !important;
    }
    
    /* โชว์เฉพาะป้ายบาร์โค้ดและลูกๆ ของมัน */
    #printArea, #printArea * {
        visibility: visible !important;
    }
    
    /* จัดตำแหน่งให้อยู่มุมซ้ายบนสุด ไม่ล้นหน้า */
    #printArea {
        position: fixed !important;
        left: 0 !important;
        top: 0 !important;
        width: 100% !important;
        margin: 0 !important;
        padding: 10px !important;
    }
}


