/* --- Global & Layout --- */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    margin: 0;
    padding: 20px;
    background-color: #f4f4f4;
    color: #333;
}

.container {
    display: flex;
    max-width: 1300px; /* Increased max width for better layout */
    margin: 0 auto;
    gap: 30px;
}

/* --- Input Section Styling --- */
.input-section {
    flex: 0 0 380px; /* Wider input panel */
    padding: 25px;
    background: #ffffff;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
    height: fit-content;
}

.input-section h2 {
    color: #007bff; /* Primary blue color */
    border-bottom: 2px solid #007bff;
    padding-bottom: 10px;
    margin-bottom: 20px;
}

.input-table { 
    width: 100%; 
    border-collapse: separate; /* Use separate for rounded inputs */
    border-spacing: 0 10px; 
}
.input-table td { 
    padding: 5px 0; 
}
.input-table label { 
    font-weight: 600; 
    font-size: 0.95em; 
    color: #555; 
}
.input-table input { 
    width: 100%; 
    padding: 10px; 
    box-sizing: border-box; 
    border: 1px solid #ccc; 
    border-radius: 6px; /* Slightly rounded edges */
    font-size: 1em;
    transition: border-color 0.3s, box-shadow 0.3s;
}
.input-table input:focus {
    border-color: #1d1e1f;
    box-shadow: 0 0 5px rgba(0, 123, 255, 0.3);
    outline: none;
}

.button-cell { text-align: right; padding-top: 20px !important; }

#generateBillBtn, #saveBillBtn, #homeBillBtn, #printBillBtn {
    background-color: #28a745; /* Success Green */
    color: white;
    border: none;
    padding: 10px 15px;
    text-align: center;
    text-decoration: none;
    display: inline-block;
    font-size: 16px;
    margin: 4px 2px;
    cursor: pointer;
    border-radius: 5px;
    transition: background-color 0.3s;
}

#generateBillBtn:hover { background-color: #218838; }

#saveBillBtn: { background-color: red; }
#saveBillBtn:hover { background-color: #060a5c; }
#downloadBillBtn { background-color: #007bff; } /* Primary Blue for Download */
#downloadBillBtn:hover { background-color: #0056b3; }
#printBillBtn { background-color: #6c757d; } /* Grey for Print */
#printBillBtn:hover { background-color: #5a6268; }
#homeBillBtn { background-color: #4750f5; } /* Grey for Print */
#homeBillBtn:hover { background-color: #060a5c; }

/* --- Bill Output Section --- */
.bill-output-section {
    flex-grow: 1;
    background: #fff;
    padding: 40px;
    border: 1px solid #ddd;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
    border-radius: 8px;
    min-height: 800px;
}
.placeholder-text {
    text-align: center;
    color: #999;
    padding-top: 100px;
    font-size: 1.2em;
}


/* --- Bill Content Styling --- */
.bill-page {
    line-height: 1.4;
    position: relative; 
}

/* BILL Header */
.bill-header-title {
    text-align: center;
    font-size: 38px; 
    font-weight: 800; 
    margin: 20px 0 10px 0; 
    color: #000; 
    text-transform: uppercase;
    letter-spacing: 5px;
    border-bottom: 4px double #333; 
    padding-bottom: 5px;
}

.header-info {
    font-size: 0.95em;
    margin-bottom: 25px;
    line-height: 1.5;
}
.header-info p { margin: 0; }
.header-info .date { text-align: left; font-weight: 600; }
.header-info strong { color: #000; }

.subject {
    font-size: 1.1em;
    font-weight: 600;
    margin-top: 15px;
    margin-bottom: 20px;
}
.body-text { margin-bottom: 30px; }
.body-text p { margin-bottom: 10px; }
.content-paragraph strong {
    color: #111212; 
    font-weight: 700;
}
.obliged-line { margin-top: 20px; }
.table-heading { font-weight: 600; margin-bottom: 5px; }


/* --- Professional Bill Table Design (5 Columns) --- */
.bill-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
    font-size: 0.95em;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.bill-table thead tr {
    background-color: #8db9e5; 
    color: black;
}

.bill-table th, .bill-table td {
    border: 1px solid #ccc; 
    padding: 10px 12px;
    text-align: left;
}

.bill-table th {
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-color: #343a40; 
}

.bill-table tbody tr:nth-child(even) {
    background-color: #f9f9f9; 
}

.bill-table td.amount, .bill-table td.rate-blank {
    text-align: right;
    font-family: monospace, sans-serif; 
    font-weight: 600;
}


/* --- Total Rows Styling --- */

/* Sub Total Row */
.sub-total-row {
    background-color: #e9ecef !important; 
    border-top: 2px solid #ccc;
    font-weight: 600;
}
.sub-total-row .total-label { font-weight: 700; text-align: right; }

/* VAT/TAX Rows */
.vat-row, .tax-row {
    background-color: #f0f8ff !important; 
    font-weight: 500;
}
.vat-row .total-label, .tax-row .total-label { text-align: right; }
.vat-row .amount, .tax-row .amount { color: #28a745; } 


/* Grand Total Row */
.grand-total-row {
    background-color: #8db9e5 !important; 
    color: black;
    border-top: ;
    font-size: 1 em;
}
.grand-total-row .total-label { font-weight: 700; text-align: right; }
.grand-total-row .grand-total-amount { 
    font-size: 1 em; 
    font-weight: 800; 
    text-align: right; 
}


/* --- Footer & Signature --- */
.amount-in-word { 
    margin-top: 25px; 
    font-weight: 600; 
    font-style: bold; 
    color: #111212; 
    display: block; 
    padding: 5px 0;
}
.footer-signature { 
    margin-top: 40px; 
    text-align: left; 
}
.footer-signature .faithfully { 
    margin-bottom: 0; 
    font-weight: 600; 
    color: #333; 
}


.footer-signature .signature-name { 
    border-top: 1px solid #000; 
    display: inline-block; 
    padding-top: 0; 
    margin-top: 0;
	margin-bottom: 0;	
    font-weight: 700; 
    color: #000; 
}

/* --- Print Styles (A4 and Margins) --- */
@media print {
    /* 1. 🛑 @page থেকে মার্জিন অপসারণ */
    @page {
        size: A4;
        margin: 0; 
    }
    
    body { 
        background-color: #fff; 
        color: #000 !important; 
        font-size: 11pt;
    }
    
    .input-section { 
        display: none !important; 
    }
    .container { 
        display: block !important; 
        max-width: 100%; 
    }
    .bill-output-section { 
        padding: 0; 
        border: none; 
        box-shadow: none; 
        width: 100%;
        min-height: auto;
        /* ফিক্স: আউটপুট সেকশনের ব্যাকগ্রাউন্ড স্বচ্ছ করা হলো */
        background-color: transparent !important;
    }

    /* 2. ✅ A4 সাইজ ও মার্জিন সেটআপ */
    .bill-page {
        position: relative; 
        page-break-after: always;
        page-break-inside: avoid;
        padding: 20mm; 
        background-color: transparent !important;
        /* A4 ফিজিক্যাল সাইজ */
        width: 210mm;
        min-height: 297mm;
        box-sizing: border-box;
        
        /* কন্টেন্টের জন্য মার্জিন (এখন প্যাডিং হিসেবে কাজ করবে) */
        padding: 20mm; 
        
        /* ফিক্স: বিল পেইজের ব্যাকগ্রাউন্ড স্বচ্ছ করা হলো */
        background-color: transparent !important;
    }
    
    /* 🖼️ ওয়াটারমার্ক ফিক্সড: সম্পূর্ণ পেইজ কাভার করবে */
    .bill-page::before {
        content: "";
        position: absolute;
        
        /* মার্জিন শূন্য হওয়ায় অফসেটও শূন্য হবে */
        top: 0; 
		right: 0;
        left: -2mm; 
        
        /* A4 ফিজিক্যাল সাইজ */
        width: 210mm; 
        height: 297mm;
        
        background-image: url('images/bill_watermark.png'); 
        background-repeat: no-repeat;
        background-size: 210mm 297mm; 
        background-position: top left;
        
        opacity: ; 
        z-index: -10; 
        
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
    
    /* নিশ্চিত করা হয়েছে যে কন্টেন্ট ওয়াটারমার্কের উপরে থাকবে */
    .bill-page > * {
        position: relative;
        z-index: 10; 
    }
    
    /* ফিক্স: অন্যান্য ব্যাকগ্রাউন্ড স্বচ্ছ করা হলো */
    .header-info,
    .bill-header-title,
    .bill-page p, 
    .bill-page div {
        background-color: transparent !important;
    }

    /* 🎯 টেবিল ডিজাইন ফিক্স শুরু */
    .bill-table {
        /* নিশ্চিত করা হয়েছে যে টেবিল নিজেই ঠিক আছে */
        border-collapse: collapse;
        border: 1px solid #000;
        box-shadow: none; 
    }

    .bill-table th, 
    .bill-table td {
        border: 1px solid #000; /* সলিড কালো বর্ডার */
        padding: 8px 10px;
        background-color: transparent !important; /* সেলের ব্যাকগ্রাউন্ড স্বচ্ছ */
        color: #000 !important;
    }
    
    /* টেবিল হেডার: সলিড ব্যাকগ্রাউন্ড দিয়ে লেখা স্পষ্ট করা */
    .bill-table thead tr {
        -webkit-print-color-adjust: exact;
        color-adjust: exact;
        /* প্রিন্টের জন্য একটি হালকা কিন্তু সলিড ব্যাকগ্রাউন্ড দেওয়া হলো */
        background-color: #d0e1f3 !important; /* হালকা নীল */
        color: #000 !important;
    }

    /* Grand Total Row: সলিড ব্যাকগ্রাউন্ড দিয়ে লেখা স্পষ্ট করা */
    .grand-total-row {
        -webkit-print-color-adjust: exact;
        color-adjust: exact;
        background-color: #c4d7ed !important; /* হালকা নীল ব্যাকগ্রাউন্ড */
        color: #000 !important;
        font-weight: bold;
    }

    /* অন্যান্য রঙিন রো-গুলোর ব্যাকগ্রাউন্ড স্বচ্ছ করা হয়েছে */
    .sub-total-row, 
    .vat-row, 
    .tax-row {
        background-color: transparent !important;
        color: #000 !important;
        font-weight: normal; 
    }
    /* 🎯 টেবিল ডিজাইন ফিক্স শেষ */
}