/* Document Styles - Quotation, Invoice, Receipt, Booking, Deposit */

/* A4 Page Base */
.a4-page {
    width: 210mm;
    min-height: 297mm;
    margin: 0 auto;
    padding: 10mm;
    box-sizing: border-box;
    background: white;
    font-size: 12px;
    line-height: 1.6;
    font-family: 'Tahoma', 'Arial Unicode MS', sans-serif;
    page-break-after: always;
    page-break-inside: avoid;
}

.a4-page:last-child {
    page-break-after: auto;
}

/* Multi-page document container */
.pdf-multi-page {
    margin: 0;
    padding: 0;
}

.pdf-multi-page .a4-page {
    margin: 0 auto;
}

.doc-print-layout {
    width: 210mm;
    min-height: 297mm;
    margin: 0 auto;
    padding: 10mm;
    box-sizing: border-box;
    background: white;
    font-size: 12px;
    line-height: 1.6;
}

/* Document Header Styles */
.doc-header {
    border: 2px solid #4a148c;
    margin-bottom: 10px;
}

.doc-header-top {
    display: flex;
    border-bottom: 5px solid #4a148c;
    padding: 10px;
    align-items: flex-start;
}

.doc-logo {
    height: 60px;
    width: auto;
    margin-right: 15px;
    object-fit: contain;
}

.doc-company-info {
    flex: 1;
    font-size: 11px;
    line-height: 1.5;
}

.doc-company-info h2 {
    margin: 0 0 5px 0;
    font-size: 14px;
    color: #4a148c;
    font-weight: bold;
}

.doc-company-info p {
    margin: 2px 0;
}

.doc-title-bar {
    background: #4a148c;
    color: white;
    text-align: center;
    padding: 8px;
    font-weight: bold;
    font-size: 14px;
}

/* Image Sizing Rules */
/*.a4-page img,
.doc-print-layout img {
    max-width: 100%;
    height: auto;
    object-fit: contain;
} */

/* DEPRECATED: Image sizing now handled by class selectors:
   .header-logo, .payment-logo, .signature-img
   See lines 151-168 below */

/* Table Styles */
.preview-table {
    width: 100%;
    border-collapse: collapse;
    font-family: 'Tahoma', sans-serif;
    font-size: 11px;
    margin-bottom: 10px;
}

.preview-table th {
    border: 1px solid #000;
    padding: 0px 4px;
    text-align: center;
    font-weight: bold;
    color: white;
}

.preview-table td {
    border: 1px solid #000;
    padding: 2px 5px;
    vertical-align: middle;
}

.preview-table .footer-label {
    background-color: #FFF5EE;
    text-align: right;
    font-weight: bold;
    padding-right: 8px;
}

.preview-table .footer-value {
    text-align: right;
    font-weight: bold;
    padding-right: 8px;
}

.baht-text-bar {
    background-color: #D9D9D9;
    text-align: center;
    font-weight: bold;
    border-top: 1px solid #000;
    padding: 5px;
}

/* Consolidated Image Classes - ปรับขนาดที่นี่ที่เดียว */
.payment-logo {
    width: 100px;
    height: auto;
    border: 1px solid #ccc;
}

.signature-img {
    height: 30px;
    width: auto;
    max-height: 45px;
    position:absolute; 
    bottom:30px; left:0; 
    right:0; 
    margin:auto;
}

.header-logo {
    height: 60px;
    width: auto;
    margin-left: 10px;
    margin-top: 5px;
}

/* DEPRECATED: ใช้ attribute selectors เฉพาะกรณีไม่มี class */
/* 
.a4-page img[src*="logo"],
.doc-print-layout img[src*="logo"] { max-height: 60px !important; }
*/
.info-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 10px;
    font-size: 11px;
}

.info-table td {
    padding: 4px 8px;
    border: 1px solid #ccc;
    vertical-align: top;
}

.info-table td:first-child {
    font-weight: bold;
    background: #f5f5f5;
    width: 120px;
}

/* Items Table */
.items-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
    margin-bottom: 10px;
}

.items-table th {
    background: #4a148c;
    color: white;
    padding: 8px 4px;
    border: 1px solid #4a148c;
    text-align: center;
    font-weight: bold;
}

.items-table td {
    padding: 6px 4px;
    border: 1px solid #ccc;
    text-align: center;
}

.items-table td:nth-child(2) {
    text-align: left;
}

.items-table .note-cell {
    text-align: left;
    background: #fff3e0;
    color: #d32f2f;
    font-size: 10px;
}

/* Summary Table */
.summary-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
    margin-bottom: 10px;
}

.summary-table td {
    padding: 6px 8px;
    border: 1px solid #ccc;
}

.summary-table .label {
    text-align: right;
    font-weight: bold;
    background: #f5f5f5;
}

.summary-table .value {
    text-align: right;
    width: 100px;
}

.summary-table .highlight {
    background: #ffebee;
    color: #d32f2f;
}

/* Payment Section */
.payment-section {
    border: 2px solid #4a148c;
    padding: 10px;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.payment-title {
    color: #d32f2f;
    text-decoration: underline;
    font-weight: bold;
    margin-bottom: 5px;
    font-size: 12px;
}

.payment-info {
    font-size: 11px;
    line-height: 1.6;
}

/* Removed duplicate .payment-logo - consolidated above */

/* Signature Section */
.signature-section {
    display: flex;
    justify-content: space-between;
    margin-top: 20px;
}

.signature-box {
    width: 45%;
    text-align: center;
}

.signature-line {
    border-top: 1px solid #000;
    margin-top: 0px;
    padding-top: 0px;
    font-size: 11px;
}

/* Removed duplicate .signature-img - consolidated above */

/* Header Flex Layout */
.header-flex {
    display: flex;
    border-bottom: 5px solid;
    padding-bottom: 0px;
    align-items: flex-start;
}

/* .header-logo consolidated above */

.header-info {
    flex-grow: 1;
    padding-left: 15px;
    font-size: 9px;
    padding-top: 5px;
}

.header-info h2 {
    margin: 0;
    font-size: 9px;
    font-weight: bold;
}

.header-info p {
    margin: 2px 0;
}

/* Color Variants */
.header-purple {
    border-color: #4a148c;
}

.header-purple h2 {
    color: #4a148c;
}

.header-purple-light {
    border-color: #7B1FA2;
}

.header-purple-light h2 {
    color: #7B1FA2;
}

.header-orange {
    border-color: #FF6B00;
}

.header-orange h2 {
    color: #FF6B00;
}

.header-green {
    border-color: #28a745;
}

.header-green h2 {
    color: #28a745;
}

.header-blue {
    border-color: #007bff;
}

.header-blue h2 {
    color: #007bff;
}

.header-gold {
    border-color: #f5a623;
}

.header-gold h2 {
    color: #f5a623;
}

/* Title Bar Colors */
.title-bar {
    color: white;
    text-align: center;
    padding: 0px;
    font-weight: bold;
    font-size: 13px;
}

.title-bar-purple {
    background: #4a148c;
}

.title-bar-purple-light {
    background: #7B1FA2;
}

.title-bar-orange {
    background: #FF6B00;
}

.title-bar-green {
    background: #28a745;
}

.title-bar-blue {
    background: #007bff;
}

.title-bar-gold {
    background: #f5a623;
}

/* Utility Classes - moved from inline styles in index.html */

/* Tab Button Colors */
.tab-btn-purple { background: #7B1FA2; color: white; }
.tab-btn-orange { background: #FF6B00; color: white; }
.tab-btn-green { background: #28a745; color: white; }
.tab-btn-blue { background: #007bff; color: white; }
.tab-btn-gold { background: #f0ad4e; color: white; }

/* Flexbox Layouts */
.flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.flex-between-col {
    display: flex;
    justify-content: space-between;
    margin-bottom: 15px;
    align-items: center;
}

.flex-align-center {
    display: flex;
    align-items: center;
}

/* Input Styles */
.input-search {
    padding: 8px;
    width: 300px;
    border: 1px solid #ccc;
    border-radius: 4px;
}

.input-bold {
    font-weight: bold;
}

.input-danger {
    font-weight: bold;
    color: #d9534f;
}

/* Button Styles */
.btn-create-new {
    padding: 10px 15px;
    background: #007bff;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 20px;
}

/* Table Styles */
.table-fixed {
    table-layout: fixed;
}

/* Label Styles */
.label-checkbox {
    cursor: pointer;
    display: flex;
    align-items: center;
}

.label-checkbox-gap {
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Cell Alignments */
.text-right {
    text-align: right;
}

.text-center {
    text-align: center;
}

/* Margin utilities */
.mt-10 {
    margin-top: 10px;
}

.mt-20 {
    margin-top: 20px;
}

.mb-10 {
    margin-bottom: 10px;
}

.mb-15 {
    margin-bottom: 15px;
}

/* Font sizes */
.fs-9 {
    font-size: 9px;

}

.fs-10 {
    font-size: 10px;
}

.fs-11 {
    font-size: 11px;
}

.fs-12 {
    font-size: 12px;
}

.fs-15 {
    font-size: 15px;
}

.fs-16 {
    font-size: 16px;
}

/* Font sizes with bold */
.fs-10-bold {
    font-size: 10px;
    font-weight: bold;
}

.fs-12-bold {
    font-size: 12px;
    font-weight: bold;
}

.fs-16-bold {
    font-size: 16px;
    font-weight: bold;
}

/* Flex utilities */
.flex {
    display: flex;
}

.flex-grow {
    flex-grow: 1;
}

/* Width utilities */
.w-40 {
    width: 40%;
}

.w-45 {
    width: 45%;
}

.w-50 {
    width: 50%;
}

.w-80 {
    width: 80%;
}

/* Signature section */
.signature-section {
    display: flex;
    justify-content: space-between;
    text-align: center;
    font-size: 12px;
    margin-top: 20px;
}

.signature-box {
    width: 40%;
}

.signature-line {
    border-top: 1px solid black;
    width: 80%;
    margin: 0 auto;
}

/* Payment section */
.payment-section {
    margin-top: 10px;
    border: 1px solid #000;
    padding: 5px;
    display: flex;
    align-items: center;
    font-size: 11px;
}

.payment-title {
    color: red;
    text-decoration: underline;
    font-weight: bold;
    margin-bottom: 2px;
}

.payment-info {
    margin: 1px 0;
}

/* Remark cell styles */
.remark-cell {
    border-bottom: none;
    vertical-align: top;
    padding: 5px;
    height: 100px;
}

.remark-title {
    color: red;
    text-decoration: underline;
    font-size: 10px;
}

/* Split Bill Document Layout */
.splitbill-doc {
    width: 210mm;
    min-height: 297mm;
    margin: 0 auto 20px auto;
    padding: 10mm;
    box-sizing: border-box;
    background: white;
    font-size: 12px;
    line-height: 1.6;
    font-family: 'Tahoma', 'Arial Unicode MS', sans-serif;
    page-break-after: always;
    page-break-inside: avoid;
    border: 1px solid #ddd;
}

.splitbill-doc:last-child {
    page-break-after: auto;
    margin-bottom: 0;
}

/* Split Bill container */
#splitBillDocuments {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px 0;
}

/* Mobile: A4 page scaling for preview */
@media (max-width: 768px) {
    .a4-page {
        transform: scale(0.55);
        transform-origin: top center;
        width: 182%;
        margin-left: -41%;
        margin-bottom: -120mm;
    }
    
    .preview-table {
        font-size: 9px;
    }
    
    .preview-table th,
    .preview-table td {
        padding: 2px 4px;
        min-height: 32px;
    }
}

/* Small mobile screens */
@media (max-width: 480px) {
    .a4-page {
        transform: scale(0.45);
        width: 222%;
        margin-left: -61%;
        margin-bottom: -150mm;
    }
    
    .preview-table {
        font-size: 8px;
    }
    
    .preview-table th,
    .preview-table td {
        padding: 1px 2px;
    }
}

/* Print styles for Split Bill */
@media print {
    .splitbill-doc {
        page-break-after: always;
        margin: 0 auto;
        padding: 10mm;
        box-sizing: border-box;
        border: none;
    }
    
    .splitbill-doc:last-child {
        page-break-after: auto;
    }
}
