/*
 * ফাইল: styles.css
 * উদ্দেশ্য: ফর্মের আধুনিক ডিজাইন, টেবিল স্টাইল এবং A4 ওয়াটারমার্ক প্রিন্ট কন্ট্রোল।
*/

/* --- A. Form Design (General Styles) --- */

:root {
    /* 🎨 নতুন প্রফেশনাল কালার স্কিম */
    --primary-color: #004d99; /* Deep Navy Blue */
    --secondary-color: #00b3b3; /* Dark Aqua/Cyan */
    --background-light: #f7f9fc;
    --border-color: #d1d9e6;
    --text-dark: #333;
    --highlight-bg: #e6f7ff;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--background-light);
    color: var(--text-dark);
    padding: 20px;
}

.form-container {
    max-width: 950px;
    margin: 30px auto;
    background: #ffffff;
    padding: 30px;
    border-radius: 12px; 
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15); 
}

header {
    text-align: center;
    margin-bottom: 40px;
}

.logo-container {
    margin: 0 0 15px 0;
}

.company-logo {
    max-width: 120px; 
    height: auto;
    display: block;
    margin: 0 auto;
    border: 1px solid var(--primary-color);
    border-radius: 8px;
    padding: 5px;
}

h1 {
    font-size: 2em;
    color: var(--primary-color);
    margin-top: 10px;
    font-weight: 600;
}

fieldset {
    border: 1px solid var(--border-color);
    padding: 20px;
    margin-bottom: 25px;
    border-radius: 10px;
    background-color: var(--highlight-bg); 
}

legend {
    font-size: 1.3em;
    font-weight: bold;
    color: var(--secondary-color);
    padding: 0 15px;
    border-bottom: none;
    background-color: #fff;
    border-radius: 5px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

label {
    display: block;
    margin-top: 12px;
    font-weight: 600;
    color: var(--primary-color);
}

input[type="text"], input[type="number"], input[type="date"], textarea, select {
    width: 98%;
    padding: 12px;
    margin-top: 5px;
    margin-bottom: 10px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    box-sizing: border-box;
    transition: border-color 0.3s, box-shadow 0.3s;
}

input:focus, textarea:focus, select:focus {
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 2px rgba(0, 179, 179, 0.2);
    outline: none;
}

/* Grid for Financial Table Input */
.item-grid {
    display: grid;
    grid-template-columns: 2.5fr 1fr 1.2fr 1.2fr; 
    gap: 10px;
    align-items: center;
    margin-top: 15px;
}

.grid-header {
    background-color: var(--primary-color); 
    color: white;
    padding: 10px 5px;
    border-radius: 4px;
    text-align: center;
    font-size: 0.95em;
    font-weight: 600;
}

.item-grid input {
    width: 95%;
}

.total-output {
    color: var(--secondary-color);
    font-size: 1.2em;
}

.final-summary {
    border-top: 2px solid var(--secondary-color); 
}

.in-words {
    color: var(--primary-color);
}



#generateButton, #saveButton #printButton {
    padding: 8px;
    background-color: var(--secondary-color);
    font-size: 1.3em;
    border-radius: 8px;
}

#generateButton:hover {
    background-color: #008080; 
}
#saveButton:hover {
    background-color: #008080; 
}
#printButton {
    background-color: #333; 
}

#printButton:hover {
    background-color: #555;
}

/* Hidden Output Area Style (On Screen) */
#quotationOutput {
    border: 3px solid var(--primary-color); 
}

/* --- B. Generated Quotation Table Styles (On Screen & Print) --- */

.financial-table {
    border-radius: 8px;
    overflow: hidden; 
}
.financial-table th, .financial-table td {
    border: 1px solid #e0e0e0;
    padding: 12px 10px;
}
.financial-table th {
    background-color: var(--primary-color); 
    color: white;
    font-weight: 600;
}
.financial-table tr:nth-child(even) {
    background-color: #f9f9f9; 
}
.financial-table .grand-total-label {
    background-color: var(--highlight-bg); 
    color: var(--primary-color);
    border-left: 3px solid var(--secondary-color);
    text-align: right;
}
.financial-table .grand-total-value {
    background-color: var(--secondary-color); 
    color: white;
    font-size: 1.2em;
}





/* --- C. Print Styles (@media print) --- */

@media print {
    
    @page {
        size: A4;  
        margin: 0;  
    }

    body {
        margin: 0;
        padding: 0;
        background: white;
        color: black;
    }
    
    .form-container, .button-group {
        display: none !important;  
    }
    
    #quotationOutput {
        display: block !important;  
        margin: 0;
        padding: 0;
        box-shadow: none;
        border: none;
        max-width: none;
        width: 100%;
    }
    
    .quotation-page {
        /* A4 সাইজের মান: 210mm x 297mm */
        width: 210mm;  
        min-height: 297mm;
        height: auto;
        margin: 0 auto;
        padding: 22mm;
        box-sizing: border-box;
        border: none;
        
        /* আগের page-break-after: always; লাইনটি এখান থেকে সরানো হয়েছে */
        page-break-inside: avoid;
        position: relative;
        
        /* ফন্ট সাইজ সামান্য কমানো হয়েছে */
        font-size: 10.5pt;  
    }

    /* 👇 ফাকা পেজ এড়ানোর জন্য মূল সমাধান: শেষ পেজ ছাড়া বাকি সব পেজের পরে ব্রেক করুন */
    .quotation-page:not(:last-child) {
        page-break-after: always;
    }
    /* 👆 এখন .quotation-page:last-child { page-break-after: avoid; } এই নিয়মটির আর প্রয়োজন নেই, তাই এটি মুছে দেওয়া হয়েছে */

    .quotation-page p, .quotation-page ul, .quotation-page li {
        font-size: 10.5pt;
        line-height: 1.35; 
        margin-top: 5px;
        margin-bottom: 5px;
    }
    
    /* ওয়াটারমার্ক কোড */
    .quotation-page::before {
        content: "";
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        
        background-image: url('images/watermark.png');  
        background-repeat: no-repeat;
        background-size: 210mm 297mm;  
        background-position: center center;
        
        opacity: ;  
        z-index: 1;  
        
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
    
    /* কন্টেন্টের জন্য একটি স্তর তৈরি করা যাতে তা ওয়াটারমার্কের উপরে থাকে */
    .quotation-page > * {
        position: relative;
        z-index: 2;  
    }
    
    /* প্রিন্টিংয়ের সময় হেডার, ফুটার এবং টেবিলের স্টাইল */
    .quotation-page .page-header {
        border-bottom: 2px solid var(--primary-color);  
    }
    
    .financial-table {
        font-size: 9pt; 
    }

    .financial-table th, .financial-table td {
        padding: 8px 6px; 
    }
    
    .financial-table .grand-total-value {
        background-color: #1a1a1a !important;  
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        color: white !important;
    }

    .quotation-page h3 {
        color: var(--primary-color);  
        border-bottom: 1px solid #ccc;
        padding-bottom: 5px;
    }
    
    .quotation-page strong {
        color: #000;
    }
    
    .quotation-page .header-logo {
        max-width: 80px;
        height: auto;    
    }
}