﻿/* ===============================================
   GENERAL FORM STYLES
   =============================================== */

/* Inline styles moved from tran.cshtml */
.payment-collapsed {
    display: block;
}

.payment-list-container {
    margin-top: 5px;
}

.card-header-spaced {
    margin-top: 5px;
}

.modal-header-fixed {
    height: 63px;
}

.table-cell-muted {
    color: #6c757d;
    font-style: italic;
}

.file-icon {
    margin-right: 8px;
    color: #0095da;
}

/* Price input with lastprice warning */
.price-lastprice-warning {
    color: red !important;
}

.serial-btn-full {
    width: 100%;
}

.table-header-width-80 {
    width: 80px;
}

.table-header-width-100 {
    width: 100px;
}

.table-header-width-120 {
    width: 120px;
}

.info-panel {
    background-color: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 15px;
    display: none;
}

.info-row {
    display: flex;
    gap: 30px;
    font-size: 14px;
    margin-bottom: 10px;
}

.info-row-last {
    display: flex;
    gap: 30px;
    font-size: 14px;
}

.info-column-250 {
    width: 250px;
}

.info-column-flex {
    flex: 1;
}

.info-label {
    color: #0095da;
}

.info-value {
    margin-left: 8px;
}

.table-header-width-15 {
    width: 15%;
}

.table-header-width-50 {
    width: 50%;
}

.table-header-width-20 {
    width: 20%;
}

.edit-form-row-spaced {
    margin-bottom: 20px;
}

/* ===============================================
   VENDOR PRODUCTS POPUP STYLES
   =============================================== */

.vendor-info-section {
    margin-bottom: 15px;
    padding: 0 20px;
}

.vendor-info-card {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    padding: 15px;
}

.vendor-info-card h4 {
    color: #495057;
    font-size: 14px;
    font-weight: 500;
    margin: 0 0 12px 0;
    padding-bottom: 6px;
    border-bottom: 1px solid #dee2e6;
}

.vendor-info-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-top: 8px;
}

.vendor-info-item {
    display: flex;
    align-items: baseline;
    font-size: 13px;
    color: #495057;
}

.vendor-info-item label {
    font-weight: 500;
    margin: 0 6px 0 0;
    color: #6c757d;
    min-width: auto;
}

.vendor-info-item span {
    color: #343a40;
    word-break: break-word;
}

/* Responsive design for vendor info */
@media (max-width: 768px) {
    .vendor-info-grid {
        flex-direction: column;
        gap: 8px;
    }
}

/* Additional styles for better visual hierarchy */
.vendor-info-section + .bill-search-container {
    border-top: 1px solid #dee2e6;
    padding-top: 15px;
}

.table-cell-center-loading {
    text-align: center;
    padding: 20px;
}

.popup-table-container-500 {
    height: 500px;
}

.unit-table-full {
    width: 100%;
}

.table-header-vendor-30 {
    width: 30%;
}

.table-header-vendor-40 {
    width: 40%;
}

.salesperson-popup {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.salesperson-popup-content {
    background-color: white;
    border-radius: 8px;
    width: 90%;
    max-width: 1200px;
    max-height: 80vh;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}

.popup-header-flex {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
}

.popup-header-title {
    margin: 0;
}

.popup-close-btn {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
}

.popup-content-padding {
    padding: 15px 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.search-row {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    align-items: center;
    flex-shrink: 0;
}

.search-input-flex {
    flex: 1;
}

.search-btn-fixed {
    width: 35px;
    height: 35px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.table-scroll-container {
    flex: 1;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #0095da #f1f1f1;
}

.table-scroll-container::-webkit-scrollbar {
    width: 8px;
}

.table-scroll-container::-webkit-scrollbar-track {
    background: #f1f1f1;        
    border-radius: 4px;
}

.table-scroll-container::-webkit-scrollbar-thumb {
    background: #0095da;
    border-radius: 4px;
}

.table-scroll-container::-webkit-scrollbar-thumb:hover {
    background: #0077b6;
}

.table-full-collapse {
    width: 100%;
    border-collapse: collapse;
}

.table-header-sticky {
    padding: 12px;
    background-color: #f8f9fa;
    border: 1px solid #e0e0e0;
    position: sticky;
    top: 0;
}

.product-col-padding-left-0 {
    padding-left: 0px;
    padding-right: 0px;
}

.product-selected-table-spaced {
    margin-top: 10px;
}

.popup-content-max-600 {
    max-width: 600px;
}

.column-label {
    display: block;
    margin-bottom: 10px;
    font-weight: 500;
}

.column-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 10px;
}

.form-footer-space-between {
    justify-content: space-between;
}

.popup-content-max-800 {
    max-width: 800px;
}

.product-info-section {
    margin-bottom: 15px;
    padding: 10px;
    background-color: #f8f9fa;
    border-radius: 5px;
}

.product-info-row {
    display: flex;
    gap: 20px;
    align-items: center;
}

.popup-table-container-400 {
    max-height: 400px;
    overflow-y: auto;
    margin-top: 10px;
}

.table-header-width-60 {
    width: 60px;
    text-align: center;
}

.table-header-width-auto {
    width: auto;
}

.selected-serials-section {
    margin-top: 15px;
    padding: 10px;
    background-color: #e9ecef;
    border-radius: 5px;
}

.selected-serials-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.selected-serials-list {
    max-height: 100px;
    overflow-y: auto;
    padding: 5px;
    background-color: white;
    border-radius: 3px;
    font-family: monospace;
    font-size: 12px;
}

.selected-serials-empty {
    color: #6c757d;
}

.search-filter-card-spaced {
    margin-bottom: 20px;
}

.filter-panel-hidden {
    display: none;
}

.bill-checkbox-col {
    width: 5%;
}

.bill-header-width-12 {
    width: 12%;
}

.bill-header-width-10 {
    width: 10%;
}

.bill-header-width-6 {
    width: 6%;
}

.loading-indicator-hidden {
    display: none;
    text-align: center;
    padding: 20px;
}

.popup-content-max-900 {
    max-width: 900px;
}

.search-container-spaced {
    margin-bottom: 15px;
}

.search-input-inline {
    display: inline-block;
    width: calc(100% - 120px);
    margin-right: 10px;
}

.search-button-inline {
    display: inline-block;
    width: 100px;
}

.table-container-border {
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid #ddd;
    border-radius: 5px;
}

.table-no-margin {
    margin-bottom: 0;
}

.table-header-bg-sticky {
    background-color: #f8f9fa;
    position: sticky;
    top: 0;
    z-index: 1;
}

.table-header-center-padding {
    text-align: center;
    padding: 10px;
}

.table-header-width-50px {
    width: 50px;
}

.table-header-width-200px {
    width: 200px;
}

.table-header-width-120px {
    width: 120px;
}

.table-header-width-80px {
    width: 80px;
}

.table-header-width-150px {
    width: 150px;
}

.selected-lot-section {
    margin-top: 15px;
    padding: 10px;
    background-color: #e8f5e8;
    border-radius: 5px;
}

.selected-lot-title {
    margin-bottom: 10px;
}

.selected-lot-info {
    font-size: 14px;
}

.selected-lot-empty {
    color: #6c757d;
}

/* Hidden elements */
.hidden {
    display: none !important;
}

/* Show elements */
.show {
    display: flex !important;
}

/* Form Header */
.form-header-clickable {
    cursor: pointer;
}

.toggle-icon {
    font-size: 20px;
    color: #0095da;
}

.product-toggle-icon {
    font-size: 20px;
    color: #0095da;
    margin-right: 15px;
}

.payment-toggle-icon {
    font-size: 20px;
    color: #0095da;
}

/* Header Summary */
.header-summary {
    padding: 10px 20px;
    background-color: #f8f9fa;
    border-bottom: 1px solid #eee;
    display: none;
}

.header-summary-content {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    font-size: 14px;
}

/* Input Groups */
.input-group-flex {
    display: flex;
    gap: 5px;
    align-items: center;
}

.input-flex {
    flex: 1;
}

.btn-action-square {
    height: 35px;
    width: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

/* Product Section */
.product-section-header {
    display: flex;
    align-items: center;
}

/* Table Container */
.table-container-main {
    overflow-x: auto;
    overflow-y: hidden;
    width: 100%;
    position: relative;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    /* Force scrollbar to always appear */
    scrollbar-width: thin;
    scrollbar-color: #0095da #f1f1f1; /* Firefox: thumb track */
    -webkit-overflow-scrolling: touch;
}

/* Custom scrollbar styling for WebKit browsers */
.table-container-main::-webkit-scrollbar {
    height: 10px !important;
    width: 10px !important;
}

.table-container-main::-webkit-scrollbar-track {
    background: #f1f1f1 !important;
    border-radius: 4px !important;
}

.table-container-main::-webkit-scrollbar-thumb {
    background: #0095da !important;
    border-radius: 4px !important;
    border: 2px solid #f1f1f1 !important;
}

.table-container-main::-webkit-scrollbar-thumb:hover {
    background: #007bb5 !important;
}

.table-container-main::-webkit-scrollbar-corner {
    background: #f1f1f1 !important;
}

.product-table-main {
    min-width: 1100px;
    width: max-content; /* Ensure table expands with content */
    table-layout: auto;
}

/* Table Column Styles */
.col-ordinary {
    min-width: 50px;
    width: 50px;
}

.col-scancode {
    min-width: 150px;
    width: 150px;
}

.col-itemname {
    min-width: 200px;
    width: 200px;
}

.col-unit {
    min-width: 80px;
    width: 80px;
}

.col-quantity {
    min-width: 100px;
    width: 100px;
}

.col-price {
    min-width: 100px;
    width: 100px;
}

.col-discount-item {
    min-width: 100px;
    width: 100px;
    display: none;
}

.col-discount-row {
    min-width: 120px;
    width: 120px;
}

.col-amount {
    min-width: 120px;
    width: 120px;
}

.col-taxtype {
    min-width: 100px;
    width: 100px;
    display: none;
}


.col-expire {
    min-width: 120px;
    width: 120px;
    display: none;
}

.col-comments {
    min-width: 150px;
    width: 150px;
    display: none;
}

/* Remove all inline styles - override with CSS classes */
.col-temp {
    /* This will be replaced by specific column classes */
}

/* Product Row States */
.cancelled-item {
    color: #dc3545 !important;
    background-color: #f8d7da !important;
    text-decoration: line-through;
    opacity: 0.8;
}

.cancelled-item input,
.cancelled-item select,
.cancelled-item textarea {
    color: #dc3545 !important;
    background-color: #f8d7da !important;
}

/* Cancel Button Styling - ใช้สีเดียวกับปุ่มอื่น ๆ */
.btn-cancel-item {
    background-color: #0095da !important;
    border-color: #0095da !important;
}

.btn-cancel-item:hover {
    background-color: #0084c3 !important;
    border-color: #0084c3 !important;
}

/* ===============================================
   PRODUCT POPUP STYLES
   =============================================== */

/* Product Popup Modal */
.product-popup-modal .popup-content {
    max-width: 1400px;
    width: 98%;
    min-width: 1000px;
    max-height: 90vh; /* จำกัดความสูงสูงสุด */
    overflow: hidden; /* ป้องกัน scroll */
}

/* Product Popup Container */
.product-popup-container {
    margin: 0 10px;
    overflow: hidden; /* ป้องกัน scroll ลงไป */
    height: fit-content; /* ปรับขนาดให้พอดีเนื้อหา */
    max-height: calc(90vh - 120px); /* จำกัดความสูงให้พอดีใน popup */
}

/* Product Popup Tabs */
.product-popup-tabs {
    display: flex;
    border-bottom: 2px solid #e0e0e0;
    margin-bottom: 0;
    flex-shrink: 0; /* ไม่ให้ tabs ย่อขนาด */
}

.product-tab-btn {
    padding: 12px 24px;
    border: none;
    background: none;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    color: #6c757d;
    font-weight: normal;
    transition: all 0.3s ease;
}

.product-tab-btn.active {
    border-bottom: 2px solid #007bff;
    color: #007bff;
    font-weight: 500;
}

.product-tab-btn:hover {
    color: #007bff;
}

.product-tab-btn:focus {
    outline: none;
    box-shadow: none;
}

/* Tab Content */
.product-tab-content {
    height: calc(100vh - 300px); /* ปรับให้พอดีกับหน้าจอ */
    overflow: hidden;
    padding: 0;
    margin-top: 0;
    max-height: calc(100vh - 300px); /* Ensure footer visibility */
    min-height: 400px; /* ลดลงเป็น 400px */
    display: flex;
    flex-direction: column;
}

/* Group tab content styling (no scroll) */
.product-group-tab-content {
    height: calc(100vh - 300px); /* เท่ากับ product-tab-content */
    overflow: hidden !important;
    padding: 0;
    margin-top: 0;
    max-height: calc(100vh - 300px);
    min-height: 400px;
    display: flex;
    flex-direction: column;
}

/* Ensure all child elements also don't cause scroll */
.product-group-tab-content * {
    box-sizing: border-box;
}

/* Override any inherited scroll properties */
#group-tab-content {
    overflow: hidden !important;
}

/* Override any inherited scroll properties for selected tab */
#selected-tab-content {
    overflow: hidden !important;
}

/* Selected Tab Header Section (to match search section height) */
.product-selected-header-section {
    display: flex;
    align-items: center;
    padding: 10px;
    margin-bottom: 15px;
    min-height: 44px; /* ให้เท่ากับ search section */
}

.product-selected-info-text {
    font-weight: 500;
    color: #333;
    font-size: 16px;
}


.product-tab-content.hidden {
    display: none;
}

/* Search Section */
.product-search-section {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    align-items: center;
    padding: 10px;
}

.product-search-input {
    flex: 1;
}

.product-search-btn {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Table Container */
.product-table-container {
    width: 100%;
    padding: 0 10px;
    flex: 1;
    height: calc(100vh - 60px - 70px - 40px - 100px - 55px);
    max-height: calc(100vh - 60px - 70px - 40px - 100px - 55px);
    overflow-y: auto;
    overflow-x: hidden;
    /* Scrollbar styling */
    scrollbar-width: thin;
    scrollbar-color: #0095da #e3f2fd;
}

.product-table-container::-webkit-scrollbar {
    width: 8px;
}

.product-table-container::-webkit-scrollbar-track {
    background: #e3f2fd;
    border-radius: 4px;
}

.product-table-container::-webkit-scrollbar-thumb {
    background: #0095da;
    border-radius: 4px;
}

.product-table-container::-webkit-scrollbar-thumb:hover {
    background: #0077b6;
}

.product-selected-table-container {
    width: 100%;
    padding: 0 10px;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    /* Scrollbar styling */
    scrollbar-width: thin;
    scrollbar-color: #0095da #f1f1f1;
}

.product-selected-table-container::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.product-selected-table-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.product-selected-table-container::-webkit-scrollbar-thumb {
    background: #0095da;
    border-radius: 4px;
}

.product-selected-table-container::-webkit-scrollbar-thumb:hover {
    background: #007bb5;
}

/* Product Table */
.product-table {
    width: 100%;
    border-collapse: collapse;
}

.product-table th {
    padding: 12px;
    background-color: #f8f9fa;
    border: 1px solid #e0e0e0;
    position: sticky;
    top: 0;
    z-index: 10;
    font-weight: 500;
}

.product-table td {
    padding: 12px;
    border: 1px solid #e0e0e0;
}

.product-table tbody tr {
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.product-table tbody tr:hover {
    background-color: #f8f9fa;
}

/* Checkbox Column */
.product-checkbox-col {
    width: 6%;
    text-align: center;
}

.product-code-col {
    width: 18%;
}

.product-name-col {
    width: 40%;
}

.product-unit-col {
    width: 12%;
}

.product-price-col {
    width: 12%;
}

.product-stock-col {
    width: 12%;
}

.product-action-col {
    width: 8%;
    text-align: center;
}

/* Product Checkbox */
.product-checkbox {
    cursor: pointer;
}

/* Empty State */
.product-empty-state {
    text-align: center;
    padding: 40px;
    color: #6c757d;
}

/* Footer */
.product-popup-footer {
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid #e0e0e0;
    background-color: #fff;
    position: sticky;
    bottom: 0;
    z-index: 10;
}

.product-selected-info {
    color: #6c757d;
}

.product-footer-actions {
    display: flex;
    gap: 10px;
}

.product-confirm-btn:disabled {
    opacity: 0.5;
}

/* Responsive adjustments for small screens */
@media (max-height: 768px) {
    .product-tab-content {
        height: calc(100vh - 250px);
        max-height: calc(100vh - 250px);
        min-height: 300px;
    }
}

@media (max-height: 600px) {
    .product-tab-content {
        height: calc(100vh - 200px);
        max-height: calc(100vh - 200px);
        min-height: 250px;
    }
    
    .product-popup-footer {
        padding: 10px 20px;
    }
}

/* Column Settings Popup Responsive Design */
@media (max-width: 768px) {
    #column-settings-popup .popup-content {
        width: 95% !important;
        max-width: 95% !important;
        margin: 20px auto;
    }
    
    #column-settings-popup .form-footer {
        position: sticky;
        bottom: 0;
        background: white;
        z-index: 10;
        margin-top: auto;
    }
}

@media (max-height: 600px) {
    #column-settings-popup .popup-content {
        max-height: 85vh !important;
        overflow-y: auto;
        display: flex;
        flex-direction: column;
    }
    
    #column-settings-popup .form-footer {
        position: sticky;
        bottom: 0;
        background: white;
        z-index: 10;
        box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
        margin-top: auto;
    }
}

/* Serial Number Popup Responsive Design */
@media (max-width: 768px) {
    #serialno-popup .popup-content {
        width: 95% !important;
        max-width: 95% !important;
        margin: 20px auto;
    }
    
    #serialno-popup .form-footer {
        position: sticky;
        bottom: 0;
        background: white;
        z-index: 10;
        margin-top: auto;
    }
}

@media (max-height: 600px) {
    #serialno-popup .popup-content {
        max-height: 85vh !important;
        overflow-y: auto;
        display: flex;
        flex-direction: column;
    }
    
    #serialno-popup .popup-body {
        flex: 1;
        overflow-y: auto;
    }
    
    #serialno-popup .form-footer {
        position: sticky;
        bottom: 0;
        background: white;
        z-index: 10;
        box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
        margin-top: auto;
        flex-shrink: 0;
    }
}

/* Lot Number Popup Responsive Design */
@media (max-width: 768px) {
    #lotno-popup .popup-content {
        width: 95% !important;
        max-width: 95% !important;
        margin: 20px auto;
    }
    
    #lotno-popup .form-footer {
        position: sticky;
        bottom: 0;
        background: white;
        z-index: 10;
        margin-top: auto;
    }
}

@media (max-height: 600px) {
    #lotno-popup .popup-content {
        max-height: 85vh !important;
        overflow-y: auto;
        display: flex;
        flex-direction: column;
    }
    
    #lotno-popup .popup-body {
        flex: 1;
        overflow-y: auto;
    }
    
    #lotno-popup .form-footer {
        position: sticky;
        bottom: 0;
        background: white;
        z-index: 10;
        box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
        margin-top: auto;
        flex-shrink: 0;
    }
}

/* Remove Button */
.product-remove-btn {
    background: #dc3545;
    color: white;
    border: none;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.product-remove-btn:hover {
    background: #c82333;
}

/* ===============================================
   FILE SELECTOR MODAL STYLES
   =============================================== */

/* File Modal Styles */
.btn-check {
    background-color: #ffc107;
    color: #212529;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-family: 'Kanit', sans-serif;
    font-weight: 500;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

    .btn-check:hover {
        background-color: #ffca2c;
        transform: translateY(-1px);
        box-shadow: 0 3px 8px rgba(255, 193, 7, 0.3);
    }
        
.file-modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    overflow: auto;
}

    .file-modal.show {
        display: flex;
        align-items: center;
        justify-content: center;
    }

.file-modal-dialog {
    margin: 30px auto;
    max-width: 1200px;
    width: 95%;
}

.file-modal-content {
    background-color: #fff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 3px 20px rgba(0, 0, 0, 0.15);
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

.file-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background-color: #f8f9fa;
    border-bottom: 1px solid #eee;
}

/* Remove unused file-modal-title class */

/* Remove unused file-close class */

.file-modal-body {
    padding: 20px;
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

.file-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 15px 20px;
    background-color: #f8f9fa;
    border-top: 1px solid #eee;
}

/* Data Display Styles */
.data-display {
    background-color: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 20px;
}

    .data-display h4 {
        margin: 0 0 15px 0;
        color: #0095da;
        font-weight: 600;
        display: flex;
        align-items: center;
        gap: 8px;
        font-size: 16px;
    }

        .data-display h4::before {
            content: "";
            display: inline-block;
            width: 4px;
            height: 16px;
            background-color: #0095da;
            margin-right: 4px;
            border-radius: 2px;
        }

/* Validation Error Highlighting */
.validation-error {
    background-color: #f8d7da !important;
    color: #721c24 !important;
    font-weight: bold !important;
}

/* File Drop Zone */
.file-drop-zone {
    border: 2px dashed #0095da;
    border-radius: 10px;
    padding: 40px;
    text-align: center;
    margin-bottom: 20px;
    transition: all 0.3s ease;
    cursor: pointer;
    background: #f8f9ff;
}

    .file-drop-zone.drag-over {
        border-color: #0084c3;
        background: #e3f2fd;
        transform: scale(1.02);
    }

    .file-drop-zone:hover {
        border-color: #0084c3;
        background: #e3f2fd;
    }

.drop-icon {
    font-size: 48px;
    color: #0095da;
    margin-bottom: 15px;
}

.file-input {
    display: none;
}

.file-input-button {
    background-color: #28a745;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    margin-top: 15px;
    transition: background-color 0.3s;
    font-family: 'Kanit', sans-serif;
    font-weight: 500;
}

    .file-input-button:hover {
        background-color: #218838;
    }

/* File Content */
.file-content {
    margin-top: 20px;
    max-height: 400px;
    overflow-y: auto;
    display: none;
}

.clear-file-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.btn-clear-file {
    background-color: #dc3545;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-family: 'Kanit', sans-serif;
    font-weight: 500;
    transition: background-color 0.3s;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

    .btn-clear-file:hover {
        background-color: #c82333;
    }

/* Messages */
.error {
    color: #721c24;
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    padding: 15px;
    border-radius: 8px;
    margin: 15px 0;
}

    .error h5 {
        margin: 0 0 10px 0;
        color: #721c24;
    }

    .error ul {
        margin: 0;
        padding-left: 20px;
    }

    .error small {
        display: block;
        margin-top: 10px;
        font-style: italic;
    }

.success {
    color: #155724;
    background-color: #d4edda;
    border: 1px solid #c3e6cb;
    padding: 10px 15px;
    border-radius: 8px;
    margin: 10px 0;
}

/* Note Box */
.note-box {
    margin-top: 10px;
    padding: 8px;
    background-color: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 8px;
}

    .note-box small {
        color: #856404;
    }

/* Selected File Display */
.selected-file-display {
    margin-top: 20px;
    padding: 15px;
    background-color: #e3f2fd;
    border-radius: 8px;
    display: none;
}

    .selected-file-display h3 {
        margin: 0 0 10px 0;
        color: #0095da;
        font-size: 16px;
    }

    .selected-file-display button {
        margin-top: 10px;
        padding: 8px 16px;
        background-color: #0095da;
        color: white;
        border: none;
        border-radius: 8px;
        cursor: pointer;
        font-family: 'Kanit', sans-serif;
    }

/* Animation */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-50px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.file-modal.show .file-modal-content {
    animation: slideIn 0.3s ease-out;
}

/* Responsive Design */
@media (max-width: 768px) {
    .file-modal-dialog {
        width: 95%;
        margin: 15px auto;
    }

    .file-modal-footer {
        flex-direction: column;
        gap: 10px;
    }

    .btn-cancel, .btn-save {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .file-modal-dialog {
        margin: 10px auto;
    }

    .data-display {
        padding: 10px;
    }
}

/* Serial Modal Specific Styles */
#product-popup.serial-context {
    z-index: 1100; /* สูงกว่า Serial Modal */
}
.serial-modal-wrapper {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    overflow: auto;
}

    .serial-modal-wrapper.show {
        display: block;
    }

.serial-modal-container {
    margin: 20px auto;
    max-width: 900px;
    width: 95%;
}

.serial-modal-card {
    background-color: #fff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 3px 20px rgba(0, 0, 0, 0.15);
    max-height: 95vh;
    display: flex;
    flex-direction: column;
}

.serial-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background-color: #f8f9fa;
    border-bottom: 1px solid #eee;
}

/* Remove unused serial-modal-title class */

.serial-close-btn {
    background: none;
    border: none;
    font-size: 20px;
    color: #6c757d;
    cursor: pointer;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s;
}

    .serial-close-btn:hover {
        background-color: rgba(0, 0, 0, 0.1);
        color: #404040;
    }

.serial-modal-body {
    padding: 20px;
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

.serial-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 15px 20px;
    background-color: #f8f9fa;
    border-top: 1px solid #eee;
}

/* Serial Form Styles */
.serial-form-group {
    margin-bottom: 20px;
}

    .serial-form-group label {
        display: block;
        margin-bottom: 6px;
        color: #404040;
        font-size: 14px;
        font-weight: 500;
    }

.serial-form-control {
    width: 100%;
    padding: 10px 12px;
    font-size: 14px;
    border: 1px solid #d6d6d6;
    border-radius: 8px;
    color: #404040;
    transition: border-color 0.3s, box-shadow 0.3s;
    font-family: 'Kanit', sans-serif;
    box-sizing: border-box;
}

    .serial-form-control:focus {
        border-color: #0095da;
        box-shadow: 0 0 0 3px rgba(0, 149, 218, 0.1);
        outline: none;
    }

    .serial-form-control.serial-select {
        color: #0095da;
        font-weight: 500;
        background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3e%3c/svg%3e");
        background-position: right 8px center;
        background-repeat: no-repeat;
        background-size: 16px;
        padding-right: 32px;
        -webkit-appearance: none;
        -moz-appearance: none;
        appearance: none;
    }

/* Serial Input with Button */
.serial-input-group {
    display: flex;
    gap: 5px;
    align-items: center;
}

    .serial-input-group .serial-form-control {
        flex: 1;
    }

.serial-action-btn {
    background-color: #0095da;
    color: white;
    border: none;
    border-radius: 8px;
    width: 35px;
    height: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.3s;
    flex-shrink: 0;
}

    .serial-action-btn:hover {
        background-color: #0084c3;
    }

/* Serial Input Row Layout */
.serial-input-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 15px;
}

/* Serial Button Styles */
.serial-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
    font-family: 'Kanit', sans-serif;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    gap: 5px;
}

.serial-btn-cancel {
    background-color: white;
    color: #404040;
    border: 1px solid #d6d6d6;
}

    .serial-btn-cancel:hover {
        background-color: #f0f0f0;
    }

.serial-btn-save {
    background-color: #0095da;
    color: white;
}

    .serial-btn-save:hover {
        background-color: #0084c3;
        transform: translateY(-1px);
        box-shadow: 0 3px 8px rgba(0, 149, 218, 0.3);
    }

/* Demo Button */
.serial-demo-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: linear-gradient(135deg, #0095da, #0084c3);
    color: white;
    border: none;
    padding: 15px 25px;
    border-radius: 50px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 149, 218, 0.3);
    transition: all 0.3s;
    z-index: 999;
}

    .serial-demo-btn:hover {
        transform: translateY(-2px);
        box-shadow: 0 6px 20px rgba(0, 149, 218, 0.4);
    }

/* Serial Section Styles */
.serial-section {
    background-color: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 20px;
}

.serial-section-title {
    margin: 0 0 15px 0;
    color: #0095da;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
}

/* Serial Table Styles */
.serial-table-wrapper {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    margin-top: 15px;
}

.serial-data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

    .serial-data-table th {
        background-color: #f8f9fa;
        padding: 10px;
        text-align: center;
        border-bottom: 1px solid #e0e0e0;
        font-weight: 500;
        position: sticky;
        top: 0;
        z-index: 10;
    }

    .serial-data-table td {
        padding: 8px 10px;
        text-align: center;
        border-bottom: 1px solid #f0f0f0;
    }

    .serial-data-table input {
        width: 100%;
        border: none;
        background: transparent;
        text-align: center;
        padding: 4px;
        font-family: 'Courier New', monospace;
    }

        .serial-data-table input:focus {
            background-color: #f0f9ff;
            outline: 1px solid #0095da;
            border-radius: 4px;
        }

/* Serial Generate Options */
.serial-generate-options {
    display: flex;
    gap: 15px;
    align-items: center;
    margin-bottom: 15px;
}

    .serial-generate-options label {
        margin: 0;
        cursor: pointer;
        display: flex;
        align-items: center;
        gap: 5px;
        font-weight: 500;
    }

    .serial-generate-options input[type="radio"] {
        margin-right: 5px;
    }

/* Responsive Design */
@media (max-width: 768px) {
    .serial-modal-container {
        width: 95%;
        margin: 15px auto;
    }

    .serial-input-row {
        grid-template-columns: 1fr;
    }

    .serial-demo-btn {
        bottom: 15px;
        right: 15px;
        padding: 12px 20px;
        font-size: 14px;
    }
}

@media (max-width: 480px) {
    .serial-modal-container {
        margin: 10px auto;
    }

    .serial-modal-footer {
        flex-direction: column;
        gap: 10px;
    }

    .serial-btn {
        width: 100%;
    }
}

/* Loading State */
.serial-loading {
    opacity: 0.7;
    cursor: not-allowed;
    position: relative;
}

    .serial-loading::after {
        content: "";
        position: absolute;
        top: 50%;
        left: 50%;
        width: 16px;
        height: 16px;
        margin: -8px 0 0 -8px;
        border: 2px solid transparent;
        border-top: 2px solid #ffffff;
        border-radius: 50%;
        animation: serial-spin 1s linear infinite;
    }

@keyframes serial-spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* Animation */
.serial-modal-wrapper.show .serial-modal-card {
    animation: serial-slideIn 0.3s ease-out;
}

@keyframes serial-slideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}
/* Payment Terms Modal - ขนาดเฉพาะสำหรับเงื่อนไขการชำระ */
.payment-terms-modal {
    z-index: 1100;
}

/* Related Documents Modal - ใช้ขนาดเหมือน Payment Terms Modal */
.related-documents-modal {
    z-index: 1100;
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(3px);
}

.related-documents-modal.show {
    display: flex !important;
    align-items: center;
    justify-content: center;
}

.related-documents-modal .modal-dialog {
    margin: 0;
}

/* Related Documents Table Styling */
.related-docs-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
    font-size: 14px;
}

.related-docs-table th,
.related-docs-table td {
    padding: 12px 8px;
    text-align: left;
    border-bottom: 1px solid #e0e0e0;
    vertical-align: middle;
}

.related-docs-table th {
    background-color: #f8f9fa;
    font-weight: 600;
    color: #333;
    border-bottom: 2px solid #dee2e6;
}

.related-docs-table tbody tr:hover {
    background-color: #f5f5f5;
}

.related-docs-table .amount-cell {
    text-align: right;
    font-weight: 500;
}

.related-docs-table .status-cell {
    text-align: center;
}

.status-badge {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

.status-paid {
    background-color: #d4edda;
    color: #155724;
}

.status-pending {
    background-color: #fff3cd;
    color: #856404;
}

.status-cancelled {
    background-color: #f8d7da;
    color: #721c24;
}

/* Documents Summary Section */
.documents-summary {
    border-top: 2px solid #dee2e6;
    padding-top: 15px;
    margin-top: 10px;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    gap: 20px;
}

.summary-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 16px;
}

.summary-item label {
    font-weight: 600;
    color: #333;
    margin-bottom: 0;
}

.amount-value {
    font-weight: 700;
    font-size: 18px;
    color: #0095da;
}

#remainingAmount {
    color: #28a745;
}

.table-container {
    overflow-x: auto;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
}

    .payment-terms-modal .modal-dialog {
        margin: 50px auto;
        max-width: 550px; /* ขนาดเฉพาะ - กว้างพอสำหรับ 2 คอลัมน์ */
        width: 90%;
    }

    .related-documents-modal .modal-dialog {
        max-width: 900px; /* ขนาดใหญ่สำหรับตารางข้อมูล */
        width: 90%;
    }

/* Responsive สำหรับ Payment Terms Modal และ Related Documents Modal */
@media (max-width: 768px) {
    .payment-terms-modal .modal-dialog {
        width: 95%;
        margin: 30px auto;
        max-width: 95%;
    }
    
    .related-documents-modal .modal-dialog {
        width: 98%;
        max-width: 98%;
    }
    
    /* Additional styling สำหรับ related documents table ในหน้าจอเล็ก */
    .related-docs-table {
        font-size: 12px;
    }
    
    .related-docs-table th,
    .related-docs-table td {
        padding: 6px 4px;
    }
    
    .summary-row {
        flex-direction: column;
        gap: 10px;
    }
    
    .amount-value {
        font-size: 16px;
    }
}

@media (max-width: 480px) {
    .payment-terms-modal .modal-dialog {
        width: 98%;
        margin: 20px auto;
        max-width: 98%;
    }
    
    .related-documents-modal .modal-dialog {
        width: 99%;
        max-width: 99%;
    }
}

/* สำหรับหน้าจอใหญ่มาก */
@media (min-width: 1200px) {
    .payment-terms-modal .modal-dialog {
        max-width: 600px; /* ขยายเล็กน้อยสำหรับหน้าจอใหญ่ */
    }
    
    .related-documents-modal .modal-dialog {
        max-width: 1000px; /* ขนาดใหญ่มากสำหรับตารางข้อมูล */
    }
}


/* ===============================================
   EDIT ADDRESS MODAL STYLES
   =============================================== */

/* Edit Modal - Higher z-index and same width as main modal */
.edit-address-modal {
    z-index: 1100;
}

    .edit-address-modal .modal-dialog {
        max-width: 1200px;
        margin: 50px auto;
    }

/* Edit Form Group Styles */
.edit-form-group {
    margin-bottom: 10px;
}

    .edit-form-group label {
        display: block;
        margin-bottom: 5px;
        font-weight: 500;
        color: #404040;
        font-size: 14px;
    }

    .edit-form-group input,
    .edit-form-group select,
    .edit-form-group textarea {
        width: 100%;
        padding: 10px 12px;
        border: 1px solid #d6d6d6;
        border-radius: 8px;
        font-size: 14px;
        font-family: 'Kanit', sans-serif;
        box-sizing: border-box;
    }

        .edit-form-group input:focus,
        .edit-form-group select:focus,
        .edit-form-group textarea:focus {
            border-color: #0095da;
            outline: none;
            box-shadow: 0 0 0 3px rgba(0, 149, 218, 0.1);
        }

    .edit-form-group textarea {
        resize: vertical;
        min-height: 80px;
    }

/* Edit Form Row Layout */
.edit-form-row {
    display: flex;
    gap: 15px;
}

    .edit-form-row .edit-form-group {
        flex: 1;
    }

/* Edit Form Container */
.edit-address-form {
    padding: 0;
    flex: 1;
    overflow-y: auto;
}

/* Edit Actions (Bottom Buttons) */
.edit-address-actions {
    padding: 15px 20px;
    border-top: 1px solid #e0e0e0;
    background-color: #fff;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

/* Edit Buttons */
.btn-address-update {
    background-color: #28a745;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 10px 20px;
    cursor: pointer;
    font-family: 'Kanit', sans-serif;
    font-weight: 500;
    transition: background-color 0.3s;
}

    .btn-address-update:hover {
        background-color: #218838;
    }

.btn-address-cancel {
    background-color: #6c757d;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 10px 20px;
    cursor: pointer;
    font-family: 'Kanit', sans-serif;
    font-weight: 500;
    transition: background-color 0.3s;
}

    .btn-address-cancel:hover {
        background-color: #5a6268;
    }

/* Edit Section Styles (Compact Version) */
.edit-address-section {
    margin-bottom: 10px;
    padding-bottom: 0px;
    border-bottom: none;
}

    .edit-address-section:last-child {
        border-bottom: none;
        margin-bottom: 0;
    }

.edit-section-title {
    font-size: 16px;
    font-weight: 600;
    color: #0095da;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
}

    .edit-section-title::before {
        content: "";
        display: inline-block;
        width: 4px;
        height: 16px;
        background-color: #0095da;
        margin-right: 8px;
        border-radius: 2px;
    }

/* Required Field Indicator for Edit Form */
.edit-required {
    color: #dc3545;
    margin-left: 2px;
}

/* Tax Branch Group - Conditional Display */
.edit-tax-branch-group {
    display: none;
}

    .edit-tax-branch-group.show {
        display: block;
    }

/* Hidden Fields in Edit Form */
.edit-hidden-field {
    display: none;
}

/* Responsive Design for Edit Modal */
@media (max-width: 768px) {
    .edit-address-modal .modal-dialog {
        width: 95%;
        margin: 30px auto;
    }

    .edit-form-row {
        flex-direction: column;
    }

    .edit-form-group {
        margin-bottom: 15px;
    }
}

@media (max-width: 480px) {
    .edit-address-modal .modal-dialog {
        margin: 20px auto;
    }

    .edit-address-actions {
        flex-direction: column;
    }

    .btn-address-update,
    .btn-address-cancel {
        width: 100%;
        margin-bottom: 5px;
    }

    .edit-form-group input,
    .edit-form-group select,
    .edit-form-group textarea {
        font-size: 16px; /* Prevent zoom on iOS */
    }
}

/* Edit Button in Table */
.btn-address-edit {
    background-color: #28a745;
    color: white;
    border: none;
    border-radius: 6px;
    padding: 6px 8px;
    cursor: pointer;
    transition: background-color 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
}

    .btn-address-edit:hover {
        background-color: #218838;
    }

    .btn-address-edit svg {
        width: 16px;
        height: 16px;
    }

/* Edit Form Input Placeholders */
.edit-form-control::placeholder {
    color: #6c757d;
    opacity: 0.7;
}

/* Custom Select Arrow for Edit Form */
.edit-form-group select {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 8px center;
    background-repeat: no-repeat;
    background-size: 16px;
    padding-right: 32px;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

/* Focus States for Edit Form */
.edit-form-control:focus {
    border-color: #0095da;
    box-shadow: 0 0 0 3px rgba(0, 149, 218, 0.1);
    outline: none;
}

/* Validation States for Edit Form */
.edit-form-control.is-invalid {
    border-color: #dc3545;
}

    .edit-form-control.is-invalid:focus {
        border-color: #dc3545;
        box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.1);
    }

.edit-form-control.is-valid {
    border-color: #28a745;
}

    .edit-form-control.is-valid:focus {
        border-color: #28a745;
        box-shadow: 0 0 0 3px rgba(40, 167, 69, 0.1);
    }

/* Loading State for Edit Form */
.btn-address-update.loading,
.btn-address-cancel.loading {
    opacity: 0.7;
    cursor: not-allowed;
    position: relative;
}

    .btn-address-update.loading::after {
        content: "";
        position: absolute;
        top: 50%;
        left: 50%;
        width: 16px;
        height: 16px;
        margin: -8px 0 0 -8px;
        border: 2px solid transparent;
        border-top: 2px solid #ffffff;
        border-radius: 50%;
        animation: edit-spin 1s linear infinite;
    }

@keyframes edit-spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* Edit Form Header */
.edit-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background-color: #f8f9fa;
    border-bottom: 1px solid #eee;
}

/* Remove unused edit-modal-title class */

.edit-modal-close {
    background: none;
    border: none;
    font-size: 20px;
    color: #6c757d;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

    .edit-modal-close:hover {
        color: #404040;
    }

/* Edit Modal Body */
.edit-modal-body {
    padding: 20px;
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

/* Address Type Dropdown Specific Styles */
.address-type-select {
    color: #0095da;
    font-weight: 500;
}

    .address-type-select option:checked {
        background-color: #0095da;
        color: white;
    }

    .address-type-select:focus {
        border-color: #0095da;
        box-shadow: 0 0 0 0.2rem rgba(0, 149, 218, 0.25);
    }

/* Person Name Fields Container */
.person-name-container {
    display: flex;
    gap: 15px;
    margin-bottom: 10px;
}

    .person-name-container .edit-form-group {
        flex: 1;
    }

/* Person ID Fields Container */
.person-id-container {
    display: flex;
    gap: 15px;
    margin-bottom: 10px;
}

    .person-id-container .edit-form-group {
        flex: 1;
    }

/* Address Fields Container */
.address-fields-container {
    margin-bottom: 10px;
}

/* Contact Fields Container */
.contact-fields-container {
    display: flex;
    gap: 15px;
    margin-bottom: 10px;
}

    .contact-fields-container .edit-form-group {
        flex: 1;
    }

/* Tax Fields Container */
.tax-fields-container {
    display: flex;
    gap: 15px;
    margin-bottom: 10px;
}

    .tax-fields-container .edit-form-group {
        flex: 1;
    }

/* =================================
   Address Selection System Styles
   ================================= */

/* Person type badge styles */
.person-type-badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-align: center;
    margin-right: 5px;
}
.person-address-info {
    line-height: 1.4;
}

.person-name {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 5px;
}
.person-type-0 {
    background-color: #e7f3ff;
    color: #0066cc;
}

.person-type-1 {
    background-color: #fff0e6;
    color: #cc6600;
}

.person-type-2 {
    background-color: #f0f8e6;
    color: #339900;
}

/* Tax type badge styles */
.tax-type-badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-align: center;
}

.tax-type-0 {
    background-color: #d4edda;
    color: #155724;
}

.tax-type-1 {
    background-color: #cce7ff;
    color: #004085;
}

.tax-type-2 {
    background-color: #fff3cd;
    color: #856404;
}

/* Address type badges */
.address-type-badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-align: center;
    min-width: 60px;
}

.address-type-0 {
    background-color: #d4edda;
    color: #155724;
}

.address-type-1 {
    background-color: #cce7ff;
    color: #004085;
}

.address-type-2 {
    background-color: #fff3cd;
    color: #856404;
}

.address-type-3 {
    background-color: #f8d7da;
    color: #721c24;
}

/* Highlight value and empty field styles */
.highlight-value {
    font-weight: 600;
    color: #0095da;
}

.empty-field {
    color: #6c757d;
    font-style: italic;
}

/* Address detail styles */
.address-detail {
    line-height: 1.4;
    max-width: 300px;
}

.address-line {
    display: block;
}
#info-panel {
    background-color: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 15px;
    display: none;
    font-size: 14px;
}

    #info-panel strong {
        color: #0095da;
    }

    #info-panel span {
        margin-left: 8px;
    }

.modal-body {
    padding: 20px;
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

/* Table Container Specific */
.popup-table-container {
    max-height: 500px;
    overflow-y: auto;
    position: relative;
    width: 100%;
    /* Scrollbar styling */
    scrollbar-width: thin;
    scrollbar-color: #0095da #f1f1f1;
}

.popup-table-container::-webkit-scrollbar {
    width: 8px;
}

.popup-table-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.popup-table-container::-webkit-scrollbar-thumb {
    background: #0095da;
    border-radius: 4px;
}

.popup-table-container::-webkit-scrollbar-thumb:hover {
    background: #007bb5;
}

/* Unit Table Selection */
.unit-table tbody tr {
    cursor: pointer;
    transition: background-color 0.15s;
}

    .unit-table tbody tr:hover {
        background-color: #f5f9ff;
    }

    .unit-table tbody tr.selected {
        background-color: #e3f2fd;
    }

.unit-table thead th {
    position: sticky;
    top: 0;
    z-index: 10;
}
.search-input {
    flex: 1;
}

.search-button {
    width: 40px;
    height: 40px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}
.btn-save:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
}
@media (max-width: 768px) {
    .modal-dialog {
        width: 95%;
        margin: 20px auto;
    }

    .unit-table th,
    .unit-table td {
        padding: 8px;
        font-size: 13px;
    }
}

@media (max-width: 480px) {
    .unit-table th,
    .unit-table td {
        padding: 6px;
        font-size: 12px;
    }
}
/* Contact info styles */
.contact-info {
    font-size: 13px;
    color: #6c757d;
}

.contact-item {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-bottom: 2px;
}

.contact-icon {
    width: 12px;
    height: 12px;
    opacity: 0.7;
}

/* Table selection styles */
.unit-table tbody tr.selected {
    background-color: #e3f2fd;
}

/* Input with button styles */
.input-with-button {
    display: flex;
    gap: 8px;
    align-items: center;
}

.btn-action {
    background-color: #0095da;
    color: white;
    border: none;
    border-radius: 8px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.3s;
    flex-shrink: 0;
}

    .btn-action:hover {
        background-color: #0084c3;
    }

/* Demo button styles */
.btn-demo {
    background-color: #0095da;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    cursor: pointer;
    font-family: 'Kanit', sans-serif;
    font-size: 16px;
    font-weight: 500;
    transition: background-color 0.3s;
    margin: 10px;
}

    .btn-demo:hover {
        background-color: #0084c3;
    }

/* Demo container styles */
.demo-container {
    max-width: 800px;
    margin: 0 auto;
    background: white;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 3px 16px rgba(0, 0, 0, 0.1);
    text-align: center;
}

.demo-title {
    color: #0095da;
    margin-bottom: 30px;
    font-size: 24px;
    font-weight: 600;
}

/* Additional responsive adjustments for address selection */
@media (max-width: 768px) {
    .address-detail {
        max-width: 200px;
    }
}

@media (max-width: 480px) {
    .search-container {
        flex-direction: column;
    }

    .search-button {
        width: 100%;
        height: 35px;
    }
}



document-status /* เพิ่มความกว้างของ popup ทั่วไป */
/* ปรับ popup ให้มีขนาดเท่ากับ submenu-container */
.popup {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.popup-content {
    background-color: white;
    border-radius: 12px;
    width: 90%;
    max-width: 1200px; /* ตั้งค่าให้เท่ากับ submenu-container */
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 3px 16px rgba(0, 0, 0, 0.1); /* ใช้ shadow แบบเดียวกับ submenu-container */
    margin-left: auto;
    margin-right: auto;
}


.modal-content {
    border-radius: 12px 12px 0 0; /* ใช้ border-radius แบบเดียวกับ submenu-container */
    max-height: 90vh;
    overflow: hidden;
    box-shadow: 0 3px 16px rgba(0, 0, 0, 0.1); /* ใช้ shadow แบบเดียวกับ submenu-container */
}

/* ปรับปรุง media query สำหรับหน้าจอขนาดต่างๆ */
@media (max-width: 1200px) {
    .popup-content, .modal-dialog {
        width: 95%; /* ใช้ 95% ของความกว้างหน้าจอเมื่อหน้าจอเล็กกว่า 1200px */
    }
}

@media (min-width: 1200px) {
    .popup-content, .modal-dialog {
        width: 1200px; /* ความกว้างคงที่ 1200px เมื่อหน้าจอใหญ่กว่า 1200px */
    }
}

/* ปรับขนาดพื้นที่แสดงผลภายใน popup */
.popup-table-container {
    max-height: 500px;
    overflow-y: auto;
    position: relative;
    width: 100%;
}

.popup-content > div:nth-child(2) {
    flex: 1;
    overflow-y: auto;
    min-height: 500px;
    max-height: calc(90vh - 130px);
}

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.loading-spinner {
    background-color: white;
    padding: 20px;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #0095da;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin-bottom: 10px;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}


.loading-text {
    color: #333;
    font-size: 14px;
}

/* ===============================================
   DRAG AND DROP COLUMN STYLES
   =============================================== */

/* Draggable column styles */
.draggable-column {
    cursor: move;
    user-select: none;
    position: relative;
    transition: all 0.2s ease;
}

.draggable-column:hover {
    background-color: #e3f2fd !important;
}

/* Dragging state */
.draggable-column.dragging {
    opacity: 0.5;
    background-color: #bbdefb !important;
    transform: scale(0.98);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

/* Drop target highlight */
.draggable-column.drag-over {
    background-color: #81c784 !important;
    border: 2px dashed #4caf50 !important;
    transform: scale(1.02);
}

/* Visual indicator for draggable columns */
.draggable-column::before {
    content: "⋮⋮";
    position: absolute;
    left: 2px;
    top: 50%;
    transform: translateY(-50%);
    color: #999;
    font-size: 12px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.draggable-column:hover::before {
    opacity: 1;
}

/* Ensure draggable headers don't interfere with resizing */
.draggable-column.resizing {
    cursor: col-resize !important;
}

.draggable-column.resizing::before {
    display: none;
}

/* สไตล์สำหรับส่วนการชำระเงิน */
/* เพิ่ม CSS สำหรับรายการชำระเงิน */
.payment-status.payment-overpaid {
    background-color: #9c27b0;
    color: white;
}

.overpayment-row {
    color: #9c27b0;
    font-weight: 500;
}

#overpayment-amount {
    color: #9c27b0;
    font-weight: 600;
}

#summary-overpayment {
    color: #9c27b0;
    font-weight: 600;
}
.form-card {
    background-color: white;
    border-radius: 12px;
    box-shadow: 0 3px 16px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    margin-bottom: 20px;
    max-width: 1300px;
    width: 95%;
    margin-left: auto;
    margin-right: auto;
}

/* ปรับปรุงการแสดงผลของส่วนการชำระเงิน */
#payment-content .card-layout {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

/* แก้ไขการแสดงวิธีการชำระเงิน */
.payment-methods {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 10px;
    margin-bottom: 10px;
}

.payment-method-item {
    position: relative;
}

    .payment-method-item input[type="radio"] {
        position: absolute;
        opacity: 0;
        width: 0;
        height: 0;
    }

    .payment-method-item label {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        padding: 12px 8px;
        border: 1px solid #e0e0e0;
        border-radius: 8px;
        cursor: pointer;
        transition: all 0.2s ease;
    }

    .payment-method-item input[type="radio"]:checked + label {
        background-color: #e6f3ff;
        border-color: #0095da;
    }

.payment-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background-color: #0095da;
    border-radius: 50%;
    color: white;
    margin-bottom: 8px;
}

.payment-label {
    font-size: 14px;
    text-align: center;
}

/* แก้ไขรายการชำระเงิน */
.payment-item {
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    margin-bottom: 10px;
    background-color: #fff;
    overflow: hidden;
    transition: all 0.2s ease;
}

    .payment-item:hover {
        box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    }

    .payment-item.selected {
        border-color: #0095da;
        background-color: #f0f9ff;
    }

.payment-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    background-color: #f8f9fa;
    border-bottom: 1px solid #e0e0e0;
    cursor: pointer;
}

.payment-item.selected .payment-item-header {
    background-color: #e6f3ff;
}

.payment-item-details {
    padding: 15px;
    display: none;
}

.payment-item.selected .payment-item-details {
    display: block;
}

/* แก้ไขปุ่มการชำระเงิน */
#btn-add-payment, #btn-update-payment {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 8px 16px;
    background-color: #0095da;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.3s;
    width: auto;
    margin-left: auto;
}

/* สถานะการชำระเงิน */
.payment-status {
    display: inline-block;
    padding: 5px 10px;
    border-radius: 4px;
    font-weight: 500;
}

.payment-pending {
    background-color: #ffecb3;
    color: #856404;
}

.payment-partial {
    background-color: #b3e0ff;
    color: #0c5460;
}

.payment-complete {
    background-color: #c8e6c9;
    color: #155724;
}

.payment-overpaid {
    background-color: #ffe0b2;
    color: #856404;
}

/* ปรับปรุงการแสดงผล file upload */
.file-upload-container {
    width: 100%;
}

.file-upload-input {
    display: none;
}

.file-upload-label {
    display: flex;
    align-items: center;
    gap: 8px;
    background-color: #f0f0f0;
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s;
    font-size: 14px;
}

    .file-upload-label:hover {
        background-color: #e0e0e0;
    }

.file-name {
    margin-top: 5px;
    font-size: 12px;
    color: #666;
    word-break: break-all;
}

/* แก้ไขการแสดงเงินทอน */
#change-amount.has-change {
    color: #4caf50;
    font-weight: bold;
}

/* Empty payment list */
.empty-payment-list {
    padding: 20px;
    text-align: center;
    color: #888;
    font-style: italic;
    background-color: #f9f9f9;
    border-radius: 6px;
    margin-top: 10px;
}

.payment-item-actions {
    display: flex;
    gap: 5px;
}

.btn-edit-payment, .btn-delete-payment {
    background: none;
    border: none;
    padding: 5px;
    cursor: pointer;
    border-radius: 4px;
    transition: background-color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

    .btn-edit-payment:hover {
        background-color: #eaeaea;
    }

.btn-delete-payment {
    color: #ff6b6b;
}

    .btn-delete-payment:hover {
        background-color: #ffe6e6;
    }
/* end สไตล์สำหรับส่วนการชำระเงิน */
body {
    font-family: 'Kanit', sans-serif;
    background-color: #f5f5f5;
    margin: 0;
    padding: 20px;
    color: #404040;
}
.form-check {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
    gap: 8px;
}

    .form-check input[type="checkbox"] {
        appearance: none;
        -webkit-appearance: none;
        height: 18px;
        width: 18px;
        border: 2px solid #0095da;
        border-radius: 4px;
        outline: none;
        margin-right: 8px;
        position: relative;
        cursor: pointer;
        transition: all 0.3s;
    }

        .form-check input[type="checkbox"]:checked {
            background-color: #0095da;
            border-color: #0095da;
        }

            .form-check input[type="checkbox"]:checked::before {
                content: '✔';
                position: absolute;
                top: 50%;
                left: 50%;
                transform: translate(-50%, -50%);
                color: white;
                font-size: 12px;
            }

        .form-check input[type="checkbox"]:disabled {
            border-color: #cccccc;
            background-color: #f4f4f4;
            cursor: not-allowed;
        }

    .form-check label {
        margin-bottom: 0;
        cursor: pointer;
    }
.form-card {
    background-color: white;
    border-radius: 12px;
    box-shadow: 0 3px 16px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    margin-bottom: 20px;
    max-width: 1300px;
    width: 95%;
    margin-left: auto;
    margin-right: auto;
}

/* ส่วนหัวของการ์ด */
.form-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: linear-gradient(to right, #f8f9fa, #f0f7fc);
    border-bottom: 1px solid #e0e8ef;
    cursor: pointer;
}

    .form-header h3 {
        margin: 0;
        color: #404040;
        font-weight: 600;
        font-size: 18px;
        display: flex;
        align-items: center;
    }

        .form-header h3:before {
            content: "";
            display: inline-block;
            width: 4px;
            height: 18px;
            background-color: #0095da;
            margin-right: 10px;
            border-radius: 2px;
        }

.toggle-icon {
    font-size: 20px;
    color: #0095da;
}

/* ส่วนสรุปข้อมูลแบบย่อ */
.summary-collapsed {
    padding: 14px 20px;
    background-color: #f8f9fa;
    border-bottom: 1px solid #eee;
}

.summary-collapsed-content {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    justify-content: flex-end;
    align-items: center;
}

.summary-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

    .summary-item strong {
        color: #555;
        font-weight: 500;
        font-size: 14px;
    }

    .summary-item span {
        font-size: 15px;
        font-weight: 500;
    }

.summary-total {
    font-size: 18px !important;
    font-weight: 600 !important;
    color: #0095da;
}

/* ส่วนสรุปข้อมูลแบบเต็ม */
.form-sections {
    padding: 15px;
}

/* การจัดวางแบบการ์ด */
.card-layout {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 15px;
}

/* รูปแบบการ์ด */
.summary-card {
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    overflow: hidden;
}

.card-header {
    padding: 12px 15px;
    background-color: rgba(0, 149, 218, 0.05);
    border-bottom: 1px solid #eee;
}

.card-title {
    font-weight: 500;
    color: #0095da;
}

.card-body {
    padding: 15px;
}

/* แถวข้อมูลภายในการ์ด */
.flex-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid #f0f0f0;
}

    .flex-row:last-child {
        margin-bottom: 0;
        padding-bottom: 0;
        border-bottom: none;
    }

.flex-label {
    color: #555;
    font-size: 14px;
    flex: 1;
}

.flex-value {
    font-weight: 500;
    min-width: 80px;
    margin-left: 15px;
}

/* แถวสำหรับยอดรวม */
.total-row {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #e0e8ef;
    border-bottom: none;
}

    .total-row .flex-label {
        font-weight: 600;
        color: #404040;
    }

    .total-row .flex-value {
        font-size: 20px;
        font-weight: 600;
        color: #0095da;
    }

/* กำหนดสไตล์ช่องป้อนข้อมูล */
.form-control {
    width: 100%;
    padding: 8px 10px;
    font-size: 14px;
    border: 1px solid #d6d6d6;
    border-radius: 8px;
    color: #404040;
    transition: border-color 0.3s;
}

    .form-control:focus {
        border-color: #0095da;
        outline: none;
    }

.text-right {
    text-align: right;
}

/* ส่วนนำเข้าเปอร์เซ็นต์ */
.percent-input-group {
    display: flex;
    align-items: center;
    gap: 5px;
    flex-wrap: nowrap;
}

.percent-input {
    width: 60px;
    text-align: center;
    border-color: #9ccdf1;
}

.amount-display {
    padding: 5px 8px;
    background-color: #f0f7fc;
    border-radius: 6px;
    color: #0095da;
    margin-left: auto;
    font-weight: 500;
    min-width: 70px;
    text-align: right;
    font-size: 13px;
}

/* การปรับแต่งสำหรับมือถือ */
@media (max-width: 767px) {
    .summary-collapsed-content {
        justify-content: space-between;
        width: 100%;
    }

    .summary-item {
        flex-basis: 48%;
        justify-content: space-between;
    }

        .summary-item:last-child {
            flex-basis: 100%;
            margin-top: 5px;
            justify-content: flex-end;
        }

    /* ปรับขนาดช่องป้อนข้อมูล */
    .percent-input-group {
        width: 100%;
    }

    /* ปรับการแสดงผลแถวข้อมูล */
    .flex-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }

    .flex-value {
        width: 100%;
        margin-left: 0;
    }

    /* ยกเว้นแถวยอดรวมให้คงแสดงแบบแนวนอน */
    .total-row {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }

        .total-row .flex-label {
            flex: 1;
        }

        .total-row .flex-value {
            width: auto;
        }
}

/* สำหรับมือถือหน้าจอเล็กมาก */
@media (max-width: 380px) {
    .form-header {
        padding: 12px 15px;
    }

        .form-header h3 {
            font-size: 16px;
        }

    .summary-item {
        flex-basis: 100%;
        margin-bottom: 5px;
    }

        .summary-item strong,
        .summary-item span {
            font-size: 13px;
        }

    .summary-total {
        font-size: 16px !important;
    }

    .percent-input {
        width: 50px;
    }
}

/* สลับรูปแบบสำหรับหน้าจอกลางและใหญ่ */
@media (min-width: 768px) and (max-width: 991px) {
    .card-layout {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 15px;
    }

    .note-card {
        grid-column: 1 / -1;
    }

    .discount-card {
        grid-column: 1 / 2;
    }

    .discount-item-card {
        grid-column: 2 / 3;
    }

    .value-card {
        grid-column: 1 / -1;
    }
}

/* ขนาดจอใหญ่ */
@media (min-width: 992px) {
    .card-layout {
        display: grid;
        grid-template-columns: 1fr 1fr 1fr; /* เปลี่ยนจาก 2 คอลัมน์เป็น 3 คอลัมน์ */
        gap: 15px;
    }

    .note-card {
        grid-column: 1 / -1; /* ให้การ์ดหมายเหตุกินพื้นที่เต็มความกว้าง */
        grid-row: 1; /* กำหนดให้อยู่แถวบนสุด */
    }

    .discount-card {
        grid-column: 1 / 2; /* คอลัมน์ที่ 1 */
        grid-row: 2; /* แถวที่ 2 */
    }

    .discount-item-card {
        grid-column: 2 / 3; /* คอลัมน์ที่ 2 */
        grid-row: 2; /* แถวที่ 2 */
    }

    .value-card {
        grid-column: 3 / 4; /* คอลัมน์ที่ 3 */
        grid-row: 2; /* แถวที่ 2 */
    }
}

/* ปุ่มสลับขนาดหน้าจอ (สำหรับการสาธิต) */
.screen-size-toggle {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
    gap: 10px;
}

.screen-size-btn {
    background-color: #0095da;
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 5px;
    cursor: pointer;
    font-family: 'Kanit', sans-serif;
}

    .screen-size-btn:hover {
        background-color: #0084c3;
    }

/* สำหรับการสาธิตรูปแบบหน้าจอต่างๆ */
.device-frame {
    max-width: 100%;
    margin: 0 auto;
    transition: max-width 0.5s ease-in-out;
}

    .device-frame.mobile {
        max-width: 380px;
    }

    .device-frame.tablet {
        max-width: 768px;
    }

    .device-frame.desktop {
        max-width: 1200px;
    }

.form-card {
    background-color: white;
    border-radius: 12px;
    box-shadow: 0 3px 16px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    margin-bottom: 20px;
    max-width: 1300px;
    width: 95%;
    margin-left: auto;
    margin-right: auto;
}

/* CSS สำหรับ Footer ที่ปรับปรุงแล้ว */
.form-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    background: linear-gradient(to right, #f8f9fa, #edf6fc);
    border-top: 1px solid #e0e8ef;
    border-radius: 0 0 12px 12px;
}

/* Form Footer with form-card and submenu-container classes */
.form-footer.form-card.submenu-container {
    max-width: 1300px;
    width: 95%;
    margin-left: auto;
    margin-right: auto;
    background-color: white;
    border-radius: 12px;
    box-shadow: 0 3px 16px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    margin-bottom: 20px;
}

/* Responsive design for form-footer with form-card submenu-container */
@media (max-width: 1024px) {
    .form-footer.form-card.submenu-container {
        width: 95% !important;
        max-width: 1300px !important;
    }
}

@media (max-width: 768px) {
    .form-footer.form-card.submenu-container {
        width: 95% !important;
        max-width: 1300px !important;
        display: flex !important;
        flex-direction: column !important;
        gap: 15px !important;
        padding: 16px !important;
    }
}

@media (max-width: 480px) {
    .form-footer.form-card.submenu-container {
        width: 98% !important;
        max-width: 1300px !important;
        margin: 10px auto 20px auto !important;
    }
}

.footer-info {
    display: flex;
    align-items: center;
    gap: 20px;
    padding-left: 10px;
}

.document-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    background-color: #e6f4fc;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    color: #0084c3;
    border: 1px solid #c0e3f8;
    min-width: 120px;
    justify-content: center;
}
.document-status-void {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    background-color: rgba(255, 107, 107, 0.1);
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    color: var(--danger);
    border: 1px solid rgba(255, 107, 107, 0.1);
    min-width: 120px;
    justify-content: center;
}

.document-status-save {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    background-color: #c8e6c9;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    color: #2e7d32;
    border: 1px solid #2e7d32;
    min-width: 120px;
    justify-content: center;
}
.document-status-approve {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    background-color: #FFECB3;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    color: #856404;
    border: 1px solid #856404;
    min-width: 120px;
    justify-content: center;
}
.status-icon {
    width: 10px;
    height: 10px;
    background-color: #0095da;
    border-radius: 50%;
    flex-shrink: 0;
}
.status-icon-void {
    width: 10px;
    height: 10px;
    background-color: #FF0000;
    border-radius: 50%;
    flex-shrink: 0;
}
.status-icon-save {
    width: 10px;
    height: 10px;
    background-color: #2e7d32;
    border-radius: 50%;
    flex-shrink: 0;
}
.status-icon-approve {
    width: 10px;
    height: 10px;
    background-color: #856404;
    border-radius: 50%;
    flex-shrink: 0;
}

.footer-actions {
    display: flex;
    gap: 12px;
}

.btn-cancel,
.btn-save {
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease-in-out;
    font-family: 'Kanit', sans-serif;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    min-width: 100px;
    justify-content: center;
}

.btn-cancel {
    background-color: white;
    color: #404040;
    border: 1px solid #e0e0e0;
}

    .btn-cancel:hover {
        background-color: #f5f5f5;
        transform: translateY(-1px);
        box-shadow: 0 3px 6px rgba(0, 0, 0, 0.08);
    }

.btn-save {
    background-color: #0095da;
    color: white;
    position: relative;
    overflow: hidden;
}

    .btn-save:before {
        content: '';
        position: absolute;
        top: 0;
        left: -100%;
        width: 100%;
        height: 100%;
        background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
        transition: 0.5s;
    }

    .btn-save:hover {
        background-color: #0084c3;
        transform: translateY(-1px);
        box-shadow: 0 3px 8px rgba(0, 149, 218, 0.3);
    }

        .btn-save:hover:before {
            left: 100%;
        }

.user-info {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #6c757d;
    background-color: #f8f8f8;
    padding: 5px 12px;
    border-radius: 20px;
    border: 1px solid #e9e9e9;
}

.user-avatar {
    width: 24px;
    height: 24px;
    background-color: #0095da;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 12px;
    font-weight: 500;
    flex-shrink: 0;
}

.user-avatar-save {
    width: 24px;
    height: 24px;
    background-color: #2e7d32;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 12px;
    font-weight: 500;
    flex-shrink: 0;
}
.user-avatar-void {
    width: 24px;
    height: 24px;
    background-color: #DC3545;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 12px;
    font-weight: 500;
    flex-shrink: 0;
}
.user-avatar-approve {
    width: 24px;
    height: 24px;
    background-color: #FDCB6E;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 12px;
    font-weight: 500;
    flex-shrink: 0;
}
.icon-save,
.icon-cancel {
    width: 16px;
    height: 16px;
}

/* Media queries สำหรับความเข้ากันได้กับอุปกรณ์มือถือ */
@media (max-width: 768px) {
    .form-footer {
        flex-direction: column;
        gap: 15px;
        padding: 16px;
    }

    .footer-info {
        width: 100%;
        justify-content: center;
        order: 2;
        padding-left: 0;
    }

    .footer-actions {
        width: 100%;
        order: 1;
        justify-content: center;
    }

    .btn-cancel,
    .btn-save {
        flex: 1;
        justify-content: center;
        max-width: 160px;
    }
}

@media (max-width: 480px) {
    .footer-info {
        flex-direction: column;
        align-items: center;
        gap: 10px;
    }

    .document-status,
    .user-info {
        width: 100%;
        justify-content: center;
    }
}

.modal-content {
    background-color: #fff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 3px 20px rgba(0, 0, 0, 0.15);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background-color: #f8f9fa;
    border-bottom: 1px solid #eee;
}

.modal-title {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #404040;
}

.modal-body {
    padding: 20px;
    max-height: 70vh;
    overflow-y: auto;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 15px 20px;
    background-color: #f8f9fa;
    border-top: 1px solid #eee;
}

.close {
    background: none;
    border: none;
    font-size: 20px;
    color: #6c757d;
    cursor: pointer;
}

    .close:hover {
        color: #404040;
    }

/* Unit table styles ที่ยังขาด */
.unit-table {
    width: 100%;
    border-collapse: collapse;
}

    .unit-table th,
    .unit-table td {
        padding: 10px;
        text-align: left;
        border-bottom: 1px solid #eee;
        font-size: 14px;
    }

    .unit-table th {
        background-color: #f8f9fa;
        font-weight: 500;
        color: #404040;
    }

    .unit-table tbody tr:last-child td {
        border-bottom: none;
    }

.no-data-message {
    padding: 15px;
    text-align: center;
    color: #6c757d;
    font-size: 14px;
}

/* Popup Components CSS */
.search-container {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    align-items: center;
}

.search-input {
    flex: 1;
}

.search-button {
    width: 40px;
    height: 40px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.popup-table-container {
    height: 400px;
    overflow-y: auto;
}

/* เพิ่มเติมจากที่มีอยู่ในไฟล์ CSS หลัก */
.unit-table tbody tr {
    cursor: pointer;
    transition: background-color 0.15s;
}

    .unit-table tbody tr:hover {
        background-color: #f5f9ff;
    }

/* กรณีมี Modal แสดงอยู่ */
.modal.show {
    display: block;
}






.form-control.custom-select {
    color: #0095da; /* Blue text color for all select elements */
    font-weight: 500; /* Make text slightly bolder */
}

    /* Style for selected option */
    .form-control.custom-select option:checked {
        background-color: #0095da; /* Blue background for selected option */
        color: white; /* White text for better contrast on blue */
    }

    /* Style for option hover (only works in some browsers) */
    .form-control.custom-select option:hover {
        background-color: #e6f3ff; /* Light blue background on hover */
    }

    /* Focus style for the select element */
    .form-control.custom-select:focus {
        border-color: #0095da;
        box-shadow: 0 0 0 0.2rem rgba(0, 149, 218, 0.25);
    }

.form-check {
    margin-bottom: 8px;
}

    .form-check input[type="checkbox"] {
        margin-right: 8px;
    }

/* Ensure table takes enough width to force scrolling */
.table-container {
    overflow-x: auto !important;
    max-width: 100%;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    margin-bottom: 10px;
}

/* Force minimum width on table to ensure horizontal scrolling */
.resizable-table {
    min-width: 1200px;
    width: 100%;
    table-layout: fixed;
}

    /* Make sure rows don't wrap */
    .resizable-table tr {
        white-space: nowrap;
    }

/* Add some visual indication of scrollability */
.table-container::-webkit-scrollbar {
    height: 8px;
}

.table-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.table-container::-webkit-scrollbar-thumb {
    background: #0095da;
    border-radius: 4px;
}

    .table-container::-webkit-scrollbar-thumb:hover {
        background: #0084c3;
    }

/* Fix for IE and Edge */
.table-container {
    -ms-overflow-style: -ms-autohiding-scrollbar;
}

/* Make sure resizable columns are working properly */
.resizable-table th {
    position: relative;
    overflow: hidden;
}

.resizer {
    position: absolute;
    top: 0;
    right: 0;
    width: 5px;
    height: 100%;
    background-color: #ddd;
    cursor: col-resize;
    user-select: none;
    touch-action: none;
    z-index: 1;
}

    .resizer:hover,
    .resizing .resizer {
        background-color: #0095da;
    }

/* Keep headers visible when scrolling vertically */
.resizable-table thead th {
    position: sticky;
    top: 0;
    z-index: 10;
    background-color: #f8f9fa;
}
/* end  */




.menu-color {
    color: #0095da;
    font-size: 1.25rem;
}

.btn-menu {
    background: none;
    border: none;
    padding: 0.5rem;
}

/* Form Styles */
.client-form {
    max-width: 1200px;
    margin: 20px auto;
    padding: 0 15px;
}

.form-card {
    background-color: white;
    border-radius: 12px;
    box-shadow: 0 3px 16px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    margin-bottom: 20px;
    max-width: 1300px;
    width: 95%;
    margin-left: auto;
    margin-right: auto;
}

.form-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background-color: #f8f9fa;
    border-bottom: 1px solid #eee;
}

    .form-header h3 {
        margin: 0;
        color: #404040;
        font-weight: 600;
        font-size: 18px;
    }

.form-sections {
    padding: 20px;
}

.form-section {
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 1px solid #eee;
}

    .form-section:last-child {
        margin-bottom: 10px;
        border-bottom: none;
    }

.section-title {
    color: #0095da;
    font-size: 16px;
    font-weight: 500;
    margin: 0 0 15px 0;
    display: flex;
    align-items: center;
}

    .section-title::before {
        content: "";
        display: inline-block;
        width: 4px;
        height: 16px;
        background-color: #0095da;
        margin-right: 8px;
        border-radius: 2px;
    }

.input-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 15px;
}

.form-group {
    margin-bottom: 15px;
}

label {
    display: block;
    margin-bottom: 6px;
    color: #404040;
    font-size: 14px;
    font-weight: 500;
}

.form-control {
    width: 100%;
    padding: 10px 12px;
    font-size: 14px;
    border: 1px solid #d6d6d6;
    border-radius: 8px;
    color: #404040;
    transition: border-color 0.3s, box-shadow 0.3s;
    font-family: 'Kanit', sans-serif;
    box-sizing: border-box;
}

    .form-control:focus {
        border-color: #0095da;
        box-shadow: 0 0 0 3px rgba(0, 149, 218, 0.1);
        outline: none;
    }

.required {
    color: #dc3545;
    margin-left: 2px;
}

/* Table Styles */
table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 15px;
    font-size: 14px;
}

th, td {
    padding: 12px;
    border: 1px solid #e0e0e0;
    text-align: left;
}

th {
    background-color: #f8f9fa;
    color: #404040;
    font-weight: 500;
}

.table-responsive {
    overflow-x: auto;
}

.orange-row {
    background-color: #fff8f0;
}

.form-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    background: linear-gradient(to right, #f8f9fa, #edf6fc);
    border-top: 1px solid #e0e8ef;
    border-radius: 0 0 12px 12px;
}

.btn-cancel,
.btn-save {
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: all 0.3s;
    font-family: 'Kanit', sans-serif;
}

.btn-cancel {
    background-color: white;
    color: #404040;
    border: 1px solid #d6d6d6;
}

    .btn-cancel:hover {
        background-color: #f0f0f0;
    }

.btn-save {
    background-color: #0095da;
    color: white;
}

    .btn-save:hover {
        background-color: #0084c3;
    }

.btn-action {
    background-color: #0095da;
    color: white;
    border: none;
    border-radius: 6px;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.3s;
}

    .btn-action:hover {
        background-color: #0084c3;
    }

.actions-container {
    display: flex;
    gap: 5px;
}

/* Custom Elements */
.highlight-cell {
    background-color: #f0f7fb;
}

.label-cell {
    background-color: #f8f9fa;
    font-weight: 500;
}

.pagination {
    display: flex;
    justify-content: flex-end;
    margin-top: 15px;
    gap: 5px;
}

    .pagination button {
        width: 30px;
        height: 30px;
        display: flex;
        align-items: center;
        justify-content: center;
        border: 1px solid #d6d6d6;
        background-color: white;
        border-radius: 4px;
        cursor: pointer;
        transition: all 0.3s;
    }

        .pagination button:hover {
            background-color: #f0f0f0;
        }

/* Popup Styles */
.popup {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}


.popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
}

    .popup-header h3 {
        margin: 0;
    }

.close-button {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
}

.popup-body {
    padding: 15px 20px;
}

.search-container {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    align-items: center;
}

.table-container {
    height: 400px;
    overflow-y: auto;
}

.popup-table {
    width: 100%;
    border-collapse: collapse;
}

    .popup-table th {
        padding: 12px;
        background-color: #f8f9fa;
        border: 1px solid #e0e0e0;
        position: sticky;
        top: 0;
    }

    .popup-table td {
        padding: 12px;
        border: 1px solid #e0e0e0;
    }

    .popup-table tr {
        cursor: pointer;
    }

        .popup-table tr:hover {
            background-color: #f5f5f5;
        }

/* Header Summary */
.header-summary {
    padding: 10px 20px;
    background-color: #f8f9fa;
    border-bottom: 1px solid #eee;
}

.summary-content {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    font-size: 14px;
}

/* Responsive Styles */
@media (max-width: 820px) {
    .form-sections {
        padding: 18px;
    }
    
    .form-section {
        margin-bottom: 20px;
        padding-bottom: 15px;
    }
    
    .section-title {
        font-size: 15px;
        margin: 0 0 12px 0;
    }
    
    .input-row {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
        margin-bottom: 12px;
    }
    
    .form-group {
        margin-bottom: 12px;
    }
}

@media (max-width: 768px) {
    .input-row {
        grid-template-columns: 1fr;
    }

    .input-row .form-group {
        grid-column: span 1 !important;
    }

    .form-sections {
        padding: 15px;
    }
}


/* Vendor Popup Main Container */
#vendor-popup {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

    #vendor-popup.show {
        display: flex;
    }

    /* Vendor Popup Content */
    #vendor-popup .popup-content {
        background-color: white;
        border-radius: 12px;
        max-width: 1400px;
        width: 98%;
        min-width: 1000px;
        max-height: 90vh;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        box-shadow: 0 3px 16px rgba(0, 0, 0, 0.1);
        margin-left: auto;
        margin-right: auto;
    }

    /* Form Header for Vendor Popup */
    #vendor-popup .form-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 16px 20px;
        background: linear-gradient(to right, #f8f9fa, #f0f7fc);
        border-bottom: 1px solid #e0e8ef;
        cursor: default; /* ไม่ให้เป็น pointer เหมือน form-header ปกติ */
    }

        #vendor-popup .form-header h3 {
            margin: 0;
            color: #404040;
            font-weight: 600;
            font-size: 18px;
            display: flex;
            align-items: center;
        }

            #vendor-popup .form-header h3:before {
                content: "";
                display: inline-block;
                width: 4px;
                height: 18px;
                background-color: #0095da;
                margin-right: 10px;
                border-radius: 2px;
            }

        /* Close Button in Form Header */
        #vendor-popup .form-header .close-button {
            background: none;
            border: none;
            font-size: 20px;
            color: #6c757d;
            cursor: pointer;
            width: 30px;
            height: 30px;
            display: flex;
            align-items: center;
            justify-content: center;
            border-radius: 50%;
            transition: background-color 0.2s;
        }

            #vendor-popup .form-header .close-button:hover {
                background-color: rgba(0, 0, 0, 0.1);
                color: #404040;
            }

    /* Vendor Popup Body */
    #vendor-popup .popup-body {
        padding: 20px;
        flex: 1;
        overflow-y: auto;
        min-height: 0;
    }

    /* Form Footer for Vendor Popup */
    #vendor-popup .form-footer {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 16px 24px;
        background: linear-gradient(to right, #f8f9fa, #edf6fc);
        border-top: 1px solid #e0e8ef;
        border-radius: 0 0 12px 12px;
    }

/* Responsive Design */
@media (max-width: 768px) {
    #vendor-popup .popup-content {
        width: 95%;
        margin: 20px auto;
    }

    #vendor-popup .form-header {
        padding: 12px 15px;
    }

        #vendor-popup .form-header h3 {
            font-size: 16px;
        }
}

@media (max-width: 480px) {
    #vendor-popup .popup-content {
        margin: 10px auto;
    }

    #vendor-popup .form-header {
        padding: 10px 15px;
    }
}



/* Address Selection Popup Main Container - เปลี่ยนวิธีการ center */
#address-selection-popup {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    overflow: auto;
}

    #address-selection-popup.show {
        display: block;
    }

    /* Address Selection Modal Dialog - Fix positioning */
    #address-selection-popup .modal-dialog {
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        max-width: 1200px;
        width: 95%;
        max-height: 90vh;
    }

    /* Address Selection Modal Content */
    #address-selection-popup .modal-content {
        background-color: white;
        border-radius: 12px;
        max-height: 90vh;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        box-shadow: 0 3px 16px rgba(0, 0, 0, 0.1);
    }

    /* Form Header for Address Selection Popup - Fix header styling */
    #address-selection-popup .modal-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 16px 20px;
        background: linear-gradient(to right, #f8f9fa, #f0f7fc);
        border-bottom: 1px solid #e0e8ef;
        cursor: default;
        flex-shrink: 0;
        height: 63px;
    }

    #address-selection-popup .modal-title {
        margin: 0;
        color: #404040;
        font-weight: 600;
        font-size: 18px;
        display: flex;
        align-items: center;
        flex: 1;
    }

        #address-selection-popup .modal-title:before {
            content: "";
            display: inline-block;
            width: 4px;
            height: 18px;
            background-color: #0095da;
            margin-right: 10px;
            border-radius: 2px;
            flex-shrink: 0;
        }

    /* Close Button in Form Header */
    #address-selection-popup .close {
        background: none;
        border: none;
        font-size: 20px;
        color: #6c757d;
        cursor: pointer;
        width: 30px;
        height: 30px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 50%;
        transition: background-color 0.2s;
        flex-shrink: 0;
    }

        #address-selection-popup .close:hover {
            background-color: rgba(0, 0, 0, 0.1);
            color: #404040;
        }

    /* Address Selection Modal Body */
    #address-selection-popup .modal-body {
        padding: 20px;
        flex: 1;
        overflow-y: auto;
        min-height: 0;
    }

    /* Form Footer for Address Selection Popup */
    #address-selection-popup .modal-footer {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 16px 24px;
        background: linear-gradient(to right, #f8f9fa, #edf6fc);
        border-top: 1px solid #e0e8ef;
        border-radius: 0 0 12px 12px;
        flex-shrink: 0;
    }

        #address-selection-popup .modal-footer .footer-actions {
            display: flex;
            gap: 12px;
            margin-left: auto;
        }

    /* Info Panel Styling within Address Selection */
    #address-selection-popup #info-panel {
        background: linear-gradient(135deg, #f8f9fa 0%, #e3f2fd 100%);
        border: 1px solid #e0e8ef;
        border-radius: 8px;
        padding: 15px;
        margin-bottom: 15px;
        display: none;
        font-size: 14px;
    }

        #address-selection-popup #info-panel strong {
            color: #0095da;
        }

    /* Table styling within Address Selection */
    #address-selection-popup .popup-table-container {
        max-height: 500px;
        overflow-y: auto;
        position: relative;
        width: 100%;
        border: 1px solid #e0e0e0;
        border-radius: 8px;
    }

    #address-selection-popup .unit-table {
        width: 100%;
        border-collapse: collapse;
        font-size: 14px;
    }

        #address-selection-popup .unit-table thead th {
            background-color: #f8f9fa;
            padding: 12px;
            text-align: left;
            border-bottom: 2px solid #e0e0e0;
            font-weight: 500;
            position: sticky;
            top: 0;
            z-index: 10;
            color: #404040;
        }

        #address-selection-popup .unit-table tbody td {
            padding: 10px 12px;
            border-bottom: 1px solid #f0f0f0;
            vertical-align: top;
        }

        #address-selection-popup .unit-table tbody tr {
            cursor: pointer;
            transition: background-color 0.15s;
        }

            #address-selection-popup .unit-table tbody tr:hover {
                background-color: #f5f9ff;
            }

            #address-selection-popup .unit-table tbody tr.selected {
                background-color: #e3f2fd;
            }

            #address-selection-popup .unit-table tbody tr:last-child td {
                border-bottom: none;
            }

    /* Search Container Styling */
    #address-selection-popup .search-container {
        display: flex;
        gap: 10px;
        margin-bottom: 15px;
        align-items: center;
    }

    #address-selection-popup .search-input {
        flex: 1;
        padding: 10px 12px;
        font-size: 14px;
        border: 1px solid #d6d6d6;
        border-radius: 8px;
        color: #404040;
        transition: border-color 0.3s, box-shadow 0.3s;
        font-family: 'Kanit', sans-serif;
    }

        #address-selection-popup .search-input:focus {
            border-color: #0095da;
            box-shadow: 0 0 0 3px rgba(0, 149, 218, 0.1);
            outline: none;
        }

    #address-selection-popup .search-button {
        width: 40px;
        height: 40px;
        padding: 0;
        display: flex;
        align-items: center;
        justify-content: center;
    }

/* Responsive Design */
@media (max-width: 768px) {
    #address-selection-popup .modal-dialog {
        width: 95%;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
    }

    #address-selection-popup .modal-header {
        padding: 12px 15px;
    }

    #address-selection-popup .modal-title {
        font-size: 16px;
    }

    #address-selection-popup .modal-footer {
        padding: 15px 20px;
    }
}

@media (max-width: 480px) {
    #address-selection-popup .modal-dialog {
        width: 98%;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
    }

    #address-selection-popup .modal-header {
        padding: 10px 15px;
    }

    #address-selection-popup .modal-footer {
        flex-direction: column;
        gap: 10px;
        align-items: stretch;
    }

        #address-selection-popup .modal-footer .footer-actions {
            width: 100%;
            justify-content: center;
            margin-left: 0;
        }
}

/* แก้ไขเมื่อหน้าจอเล็กมาก */
@media (max-height: 600px) {
    #address-selection-popup .modal-dialog {
        top: 20px;
        transform: translateX(-50%);
        max-height: calc(100vh - 40px);
    }
}

/* Edit Address Popup Main Container */
#edit-address-popup {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1100; /* สูงกว่า popup อื่น */
    overflow: auto;
}

    #edit-address-popup.show {
        display: block;
    }

    /* Edit Address Modal Dialog */
    #edit-address-popup .modal-dialog {
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        max-width: 1200px;
        width: 95%;
        max-height: 90vh;
    }

    /* Edit Address Modal Content */
    #edit-address-popup .modal-content {
        background-color: white;
        border-radius: 12px;
        max-height: 90vh;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        box-shadow: 0 3px 16px rgba(0, 0, 0, 0.1);
    }

    /* Form Header for Edit Address Popup */
    #edit-address-popup .modal-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 16px 20px;
        background: linear-gradient(to right, #f8f9fa, #f0f7fc);
        border-bottom: 1px solid #e0e8ef;
        cursor: default;
        flex-shrink: 0;
    }

    #edit-address-popup .modal-title {
        margin: 0;
        color: #404040;
        font-weight: 600;
        font-size: 18px;
        display: flex;
        align-items: center;
        flex: 1;
    }

        #edit-address-popup .modal-title:before {
            content: "";
            display: inline-block;
            width: 4px;
            height: 18px;
            background-color: #0095da;
            margin-right: 10px;
            border-radius: 2px;
            flex-shrink: 0;
        }

    /* Close Button for Edit Address */
    #edit-address-popup .close {
        background: none;
        border: none;
        font-size: 20px;
        color: #6c757d;
        cursor: pointer;
        width: 30px;
        height: 30px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 50%;
        transition: background-color 0.2s;
        flex-shrink: 0;
    }

        #edit-address-popup .close:hover {
            background-color: rgba(0, 0, 0, 0.1);
            color: #404040;
        }

    /* Edit Address Modal Body */
    #edit-address-popup .modal-body {
        padding: 20px;
        flex: 1;
        overflow-y: auto;
        min-height: 0;
    }

    /* Edit Address Actions (Footer) */
    #edit-address-popup .edit-address-actions {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 16px 24px;
        background: linear-gradient(to right, #f8f9fa, #edf6fc);
        border-top: 1px solid #e0e8ef;
        border-radius: 0 0 12px 12px;
        flex-shrink: 0;
    }

        #edit-address-popup .edit-address-actions .footer-actions {
            display: flex;
            gap: 12px;
            margin-left: auto;
        }

    /* Edit Form Group Styles */
    #edit-address-popup .edit-form-group {
        margin-bottom: 15px;
    }

        #edit-address-popup .edit-form-group label {
            display: block;
            margin-bottom: 6px;
            font-weight: 500;
            color: #404040;
            font-size: 14px;
        }

        #edit-address-popup .edit-form-group input,
        #edit-address-popup .edit-form-group select,
        #edit-address-popup .edit-form-group textarea {
            width: 100%;
            padding: 10px 12px;
            border: 1px solid #d6d6d6;
            border-radius: 8px;
            font-size: 14px;
            font-family: 'Kanit', sans-serif;
            box-sizing: border-box;
            transition: border-color 0.3s, box-shadow 0.3s;
        }

            #edit-address-popup .edit-form-group input:focus,
            #edit-address-popup .edit-form-group select:focus,
            #edit-address-popup .edit-form-group textarea:focus {
                border-color: #0095da;
                outline: none;
                box-shadow: 0 0 0 3px rgba(0, 149, 218, 0.1);
            }

        #edit-address-popup .edit-form-group textarea {
            resize: vertical;
            min-height: 80px;
        }

    /* Edit Form Row Layout */
    #edit-address-popup .edit-form-row {
        display: flex;
        gap: 15px;
        margin-bottom: 15px;
    }

        #edit-address-popup .edit-form-row .edit-form-group {
            flex: 1;
            margin-bottom: 0;
        }

    /* Edit Buttons */
    #edit-address-popup .btn-address-update,
    #edit-address-popup .btn-save {
        background-color: #0095da;
        color: white;
        border: none;
        border-radius: 8px;
        padding: 10px 20px;
        cursor: pointer;
        font-family: 'Kanit', sans-serif;
        font-weight: 500;
        transition: all 0.2s ease-in-out;
        display: flex;
        align-items: center;
        gap: 8px;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    }

        #edit-address-popup .btn-address-update:hover,
        #edit-address-popup .btn-save:hover {
            background-color: #0084c3;
            transform: translateY(-1px);
            box-shadow: 0 3px 8px rgba(0, 149, 218, 0.3);
        }

    #edit-address-popup .btn-address-cancel,
    #edit-address-popup .btn-cancel {
        background-color: white;
        color: #404040;
        border: 1px solid #e0e0e0;
        border-radius: 8px;
        padding: 10px 20px;
        cursor: pointer;
        font-family: 'Kanit', sans-serif;
        font-weight: 500;
        transition: all 0.2s ease-in-out;
        display: flex;
        align-items: center;
        gap: 8px;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    }

        #edit-address-popup .btn-address-cancel:hover,
        #edit-address-popup .btn-cancel:hover {
            background-color: #f5f5f5;
            transform: translateY(-1px);
            box-shadow: 0 3px 6px rgba(0, 0, 0, 0.08);
        }

    /* Required Field Indicator */
    #edit-address-popup .edit-required {
        color: #dc3545;
        margin-left: 2px;
    }

    /* Tax Branch Group - Conditional Display */
    #edit-address-popup .edit-tax-branch-group {
        display: none;
    }

        #edit-address-popup .edit-tax-branch-group.show {
            display: block;
        }

    /* Custom Select Arrow */
    #edit-address-popup .edit-form-group select {
        background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3e%3c/svg%3e");
        background-position: right 8px center;
        background-repeat: no-repeat;
        background-size: 16px;
        padding-right: 32px;
        -webkit-appearance: none;
        -moz-appearance: none;
        appearance: none;
    }

    /* Custom Select Color */
    #edit-address-popup .form-control.custom-select {
        color: #0095da;
        font-weight: 500;
    }

        #edit-address-popup .form-control.custom-select option:checked {
            background-color: #0095da;
            color: white;
        }

        #edit-address-popup .form-control.custom-select:focus {
            border-color: #0095da;
            box-shadow: 0 0 0 0.2rem rgba(0, 149, 218, 0.25);
        }

    /* Validation States */
    #edit-address-popup .edit-form-control.is-invalid {
        border-color: #dc3545;
    }

        #edit-address-popup .edit-form-control.is-invalid:focus {
            border-color: #dc3545;
            box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.1);
        }

    #edit-address-popup .edit-form-control.is-valid {
        border-color: #28a745;
    }

        #edit-address-popup .edit-form-control.is-valid:focus {
            border-color: #28a745;
            box-shadow: 0 0 0 3px rgba(40, 167, 69, 0.1);
        }

    /* Loading State */
    #edit-address-popup .btn-address-update.loading,
    #edit-address-popup .btn-address-cancel.loading {
        opacity: 0.7;
        cursor: not-allowed;
        position: relative;
    }

        #edit-address-popup .btn-address-update.loading::after {
            content: "";
            position: absolute;
            top: 50%;
            left: 50%;
            width: 16px;
            height: 16px;
            margin: -8px 0 0 -8px;
            border: 2px solid transparent;
            border-top: 2px solid #ffffff;
            border-radius: 50%;
            animation: edit-spin 1s linear infinite;
        }

@keyframes edit-spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    #edit-address-popup .modal-dialog {
        width: 95%;
    }

    #edit-address-popup .modal-header {
        padding: 12px 15px;
    }

    #edit-address-popup .modal-title {
        font-size: 16px;
    }

    #edit-address-popup .edit-form-row {
        flex-direction: column;
    }

    #edit-address-popup .edit-form-group {
        margin-bottom: 15px;
    }

    #edit-address-popup .edit-address-actions {
        padding: 15px 20px;
    }
}

@media (max-width: 480px) {
    #edit-address-popup .modal-dialog {
        width: 98%;
    }

    #edit-address-popup .modal-header {
        padding: 10px 15px;
    }

    #edit-address-popup .edit-address-actions {
        flex-direction: column;
        gap: 10px;
        align-items: stretch;
    }

        #edit-address-popup .edit-address-actions .footer-actions {
            width: 100%;
            justify-content: center;
            margin-left: 0;
        }

    #edit-address-popup .btn-address-update,
    #edit-address-popup .btn-address-cancel,
    #edit-address-popup .btn-save,
    #edit-address-popup .btn-cancel {
        width: 100%;
        justify-content: center;
    }

    #edit-address-popup .edit-form-group input,
    #edit-address-popup .edit-form-group select,
    #edit-address-popup .edit-form-group textarea {
        font-size: 16px; /* Prevent zoom on iOS */
    }
}

@media (max-height: 600px) {
    #edit-address-popup .modal-dialog {
        top: 20px;
        transform: translateX(-50%);
        max-height: calc(100vh - 40px);
    }
}

/* ===============================================
   PAYMENT TERMS MODAL WITH FORM-HEADER STYLES (FIXED)
   =============================================== */

/* Payment Terms Modal Main Container */
#paymentTermsModal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1100; /* สูงกว่า popup อื่น */
    overflow: auto;
}

    #paymentTermsModal.show {
        display: block;
    }

    /* Payment Terms Modal Dialog */
    #paymentTermsModal .modal-dialog {
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        max-width: 600px; /* ขนาดเฉพาะสำหรับ Payment Terms */
        width: 90%;
        max-height: 90vh;
    }

    /* Payment Terms Modal Content */
    #paymentTermsModal .modal-content {
        background-color: white;
        border-radius: 12px;
        max-height: 90vh;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        box-shadow: 0 3px 16px rgba(0, 0, 0, 0.1);
    }

    /* Form Header for Payment Terms Modal */
    #paymentTermsModal .modal-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 16px 20px;
        background: linear-gradient(to right, #f8f9fa, #f0f7fc);
        border-bottom: 1px solid #e0e8ef;
        cursor: default;
        flex-shrink: 0;
    }

    #paymentTermsModal .modal-title,
    #relatedDocumentsModal .modal-title,
    #fileModal .modal-title {
        margin: 0;
        color: #404040;
        font-weight: 600;
        font-size: 18px;
        display: flex;
        align-items: center;
        flex: 1;
    }

    /* Modal Header for File Modal */
    #fileModal .modal-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 15px 20px;
        background-color: #f8f9fa;
        border-bottom: 1px solid #eee;
    }

        #paymentTermsModal .modal-title:before,
        #relatedDocumentsModal .modal-title:before,
        #fileModal .modal-title:before {
            content: "";
            display: inline-block;
            width: 4px;
            height: 18px;
            background-color: #0095da;
            margin-right: 10px;
            border-radius: 2px;
            flex-shrink: 0;
        }

    /* Close Button for Payment Terms and File Modal */
    #paymentTermsModal .close,
    #fileModal .close {
        background: none;
        border: none;
        font-size: 20px;
        color: #6c757d;
        cursor: pointer;
        width: 30px;
        height: 30px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 50%;
        transition: background-color 0.2s;
        flex-shrink: 0;
    }

        #paymentTermsModal .close:hover,
        #fileModal .close:hover {
            background-color: rgba(0, 0, 0, 0.1);
            color: #404040;
        }

    /* Payment Terms Modal Body */
    #paymentTermsModal .modal-body {
        padding: 20px;
        flex: 1;
        overflow-y: auto;
        min-height: 0;
    }

    /* Payment Terms Actions (Footer) */
    #paymentTermsModal .edit-address-actions {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 16px 24px;
        background: linear-gradient(to right, #f8f9fa, #edf6fc);
        border-top: 1px solid #e0e8ef;
        border-radius: 0 0 12px 12px;
        flex-shrink: 0;
    }

        #paymentTermsModal .edit-address-actions .footer-actions {
            display: flex;
            gap: 12px;
            margin-left: auto;
        }

    /* Payment Terms Form Group Styles */
    #paymentTermsModal .edit-form-group {
        margin-bottom: 15px;
    }

        #paymentTermsModal .edit-form-group label {
            display: block;
            margin-bottom: 6px;
            font-weight: 500;
            color: #404040;
            font-size: 14px;
        }

        #paymentTermsModal .edit-form-group input,
        #paymentTermsModal .edit-form-group select {
            width: 100%;
            padding: 10px 12px;
            border: 1px solid #d6d6d6;
            border-radius: 8px;
            font-size: 14px;
            font-family: 'Kanit', sans-serif;
            box-sizing: border-box;
            transition: border-color 0.3s, box-shadow 0.3s;
        }

            #paymentTermsModal .edit-form-group input:focus,
            #paymentTermsModal .edit-form-group select:focus {
                border-color: #0095da;
                outline: none;
                box-shadow: 0 0 0 3px rgba(0, 149, 218, 0.1);
            }

    /* Payment Terms Form Row Layout */
    #paymentTermsModal .edit-form-row {
        display: flex;
        gap: 15px;
        margin-bottom: 15px;
    }

        #paymentTermsModal .edit-form-row .edit-form-group {
            flex: 1;
            margin-bottom: 0;
        }

    /* Payment Terms Buttons */
    #paymentTermsModal .btn-address-cancel,
    #paymentTermsModal .btn-cancel {
        background-color: white;
        color: #404040;
        border: 1px solid #e0e0e0;
        border-radius: 8px;
        padding: 10px 20px;
        cursor: pointer;
        font-family: 'Kanit', sans-serif;
        font-weight: 500;
        transition: all 0.2s ease-in-out;
        display: flex;
        align-items: center;
        gap: 8px;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    }

        #paymentTermsModal .btn-address-cancel:hover,
        #paymentTermsModal .btn-cancel:hover {
            background-color: #f5f5f5;
            transform: translateY(-1px);
            box-shadow: 0 3px 6px rgba(0, 0, 0, 0.08);
        }

    #paymentTermsModal .btn-save {
        background-color: #0095da;
        color: white;
        border: none;
        border-radius: 8px;
        padding: 10px 20px;
        cursor: pointer;
        font-family: 'Kanit', sans-serif;
        font-weight: 500;
        transition: all 0.2s ease-in-out;
        display: flex;
        align-items: center;
        gap: 8px;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    }

        #paymentTermsModal .btn-save:hover {
            background-color: #0084c3;
            transform: translateY(-1px);
            box-shadow: 0 3px 8px rgba(0, 149, 218, 0.3);
        }

    /* Custom Select Arrow for Payment Terms */
    #paymentTermsModal .edit-form-group select {
        background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3e%3c/svg%3e");
        background-position: right 8px center;
        background-repeat: no-repeat;
        background-size: 16px;
        padding-right: 32px;
        -webkit-appearance: none;
        -moz-appearance: none;
        appearance: none;
    }

    /* Custom Select Color for Payment Terms */
    #paymentTermsModal .form-control.custom-select,
    #paymentTermsModal select {
        color: #0095da;
        font-weight: 500;
    }

        #paymentTermsModal .form-control.custom-select option:checked,
        #paymentTermsModal select option:checked {
            background-color: #0095da;
            color: white;
        }

        #paymentTermsModal .form-control.custom-select:focus,
        #paymentTermsModal select:focus {
            border-color: #0095da;
            box-shadow: 0 0 0 0.2rem rgba(0, 149, 218, 0.25);
        }

    /* Input placeholders */
    #paymentTermsModal input::placeholder {
        color: #6c757d;
        opacity: 0.7;
    }

    /* Readonly inputs */
    #paymentTermsModal input[readonly] {
        background-color: #f8f9fa;
        color: #6c757d;
    }

/* Responsive Design */
@media (max-width: 768px) {
    #paymentTermsModal .modal-dialog {
        width: 95%;
        max-width: 95%;
    }

    #paymentTermsModal .modal-header {
        padding: 12px 15px;
    }

    #paymentTermsModal .modal-title,
    #fileModal .modal-title {
        font-size: 16px;
    }

    #paymentTermsModal .edit-form-row {
        flex-direction: column;
    }

    #paymentTermsModal .edit-form-group {
        margin-bottom: 15px;
    }

    #paymentTermsModal .edit-address-actions {
        padding: 15px 20px;
    }
}

@media (max-width: 480px) {
    #paymentTermsModal .modal-dialog {
        width: 98%;
        max-width: 98%;
    }

    #paymentTermsModal .modal-header {
        padding: 10px 15px;
    }

    #paymentTermsModal .edit-address-actions {
        flex-direction: column;
        gap: 10px;
        align-items: stretch;
    }

        #paymentTermsModal .edit-address-actions .footer-actions {
            width: 100%;
            justify-content: center;
            margin-left: 0;
        }

    #paymentTermsModal .btn-address-cancel,
    #paymentTermsModal .btn-save,
    #paymentTermsModal .btn-cancel {
        width: 100%;
        justify-content: center;
    }

    #paymentTermsModal .edit-form-group input,
    #paymentTermsModal .edit-form-group select {
        font-size: 16px; /* Prevent zoom on iOS */
    }
}

/* สำหรับหน้าจอใหญ่มาก */
@media (min-width: 1200px) {
    #paymentTermsModal .modal-dialog {
        max-width: 650px; /* ขยายเล็กน้อยสำหรับหน้าจอใหญ่ */
    }
}

@media (max-height: 600px) {
    #paymentTermsModal .modal-dialog {
        top: 20px;
        transform: translateX(-50%);
        max-height: calc(100vh - 40px);
    }
}

/* Remove horizontal scrollbar from group tab content */
#group-tab-content {
    overflow-x: hidden !important;
}

#group-tab-content .product-group-section {
}

#group-tab-content .row {
    margin: 0;
    overflow: hidden;
    display: flex;
    height: 100%;
    align-items: stretch;
    flex: 1;
}

#group-tab-content .row .col-4,
#group-tab-content .row .col-8 {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    height: 100%;
}

#group-tab-content .row .col-4 .card,
#group-tab-content .row .col-8 .product-table-container {
    flex: 1;
    height: 100%;
}

/* Add scrollbar back to popup tree container */
#popup-tree-container {
    width: 100%;
    height: calc(100vh - 60px - 70px - 40px - 100px - 55px);
    max-height: calc(100vh - 60px - 70px - 40px - 100px - 55px);
    min-height: 200px;
    margin-top: 10px;
    overflow-y: scroll;
    overflow-x: hidden;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    padding: 10px;
    background-color: #fff;
    /* Scrollbar styling */
    scrollbar-width: thin;
    scrollbar-color: #0095da #f1f1f1;
}

#popup-tree-container::-webkit-scrollbar {
    width: 8px;
}

#popup-tree-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

#popup-tree-container::-webkit-scrollbar-thumb {
    background: #0095da;
    border-radius: 4px;
}

#popup-tree-container::-webkit-scrollbar-thumb:hover {
    background: #007bb5;
}

/* Remove scrollbar from product group section and add to table container */
#group-tab-content .product-group-section {
    width: 100%;
    flex: 1;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#group-tab-content .product-table-container {
    height: 100%;
    margin-top: 10px;
    overflow-y: auto;
    overflow-x: hidden;
    /* Scrollbar styling */
    scrollbar-width: thin;
    scrollbar-color: #0095da #e3f2fd;
}

#group-tab-content .product-table-container::-webkit-scrollbar {
    width: 8px;
}

#group-tab-content .product-table-container::-webkit-scrollbar-track {
    background: #e3f2fd;
    border-radius: 4px;
}

#group-tab-content .product-table-container::-webkit-scrollbar-thumb {
    background: #0095da;
    border-radius: 4px;
}

#group-tab-content .product-table-container::-webkit-scrollbar-thumb:hover {
    background: #0077b6;
}

/* Fix column-settings-popup footer disappearing at 768px */
@media (max-width: 768px) {
    #column-settings-popup .popup-content {
        max-height: 85vh !important;
        overflow-y: auto;
        display: flex;
        flex-direction: column;
    }
    
    #column-settings-popup .form-footer {
        position: sticky;
        bottom: 0;
        background: white;
        z-index: 10;
        margin-top: auto;
        box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
    }
}

/* Fix column-settings-popup footer disappearing at 768px height */
@media (max-height: 768px) {
    #column-settings-popup .popup-content {
        max-height: 85vh !important;
        overflow-y: auto;
        display: flex;
        flex-direction: column;
    }
    
    #column-settings-popup .form-footer {
        position: sticky;
        bottom: 0;
        background: white;
        z-index: 10;
        margin-top: auto;
        box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
    }
}

/* Fix lotno-popup footer disappearing at 768px */
@media (max-width: 768px) {
    #lotno-popup .popup-content {
        max-height: 85vh !important;
        overflow-y: auto;
        display: flex;
        flex-direction: column;
    }
    
    #lotno-popup .form-footer {
        position: sticky;
        bottom: 0;
        background: white;
        z-index: 10;
        margin-top: auto;
        box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
    }
}

/* Fix lotno-popup footer disappearing at 768px height */
@media (max-height: 768px) {
    #lotno-popup .popup-content {
        max-height: 85vh !important;
        overflow-y: auto;
        display: flex;
        flex-direction: column;
    }
    
    #lotno-popup .form-footer {
        position: sticky;
        bottom: 0;
        background: white;
        z-index: 10;
        margin-top: auto;
        box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
    }
}

/* Fix serialno-popup footer disappearing at 768px */
@media (max-width: 768px) {
    #serialno-popup .popup-content {
        max-height: 85vh !important;
        overflow-y: auto;
        display: flex;
        flex-direction: column;
    }
    
    #serialno-popup .form-footer {
        position: sticky;
        bottom: 0;
        background: white;
        z-index: 10;
        margin-top: auto;
        box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
    }
}

/* Fix serialno-popup footer disappearing at 768px height */
@media (max-height: 768px) {
    #serialno-popup .popup-content {
        max-height: 85vh !important;
        overflow-y: auto;
        display: flex;
        flex-direction: column;
    }
    
    #serialno-popup .form-footer {
        position: sticky;
        bottom: 0;
        background: white;
        z-index: 10;
        margin-top: auto;
        box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
    }
}

/* Bill Search Popup Modal - Match Product Popup */
.bill-search-modal .popup-content {
    max-width: 1400px;
    width: 98%;
    min-width: 1000px;
    max-height: 90vh;
    overflow: hidden;
}

/* Bill Search Container - Match Product Popup Container */
.bill-search-container {
    margin: 0 10px;
    overflow: hidden;
    height: fit-content;
    max-height: calc(90vh - 120px);
    display: flex;
    flex-direction: column;
}

/* Bill Content - Match Product Tab Content */
.bill-content {
    height: calc(100vh - 300px);
    overflow: hidden;
    padding: 0;
    margin-top: 0;
    max-height: calc(100vh - 300px);
    min-height: 400px;
    display: flex;
    flex-direction: column;
}

/* Search Filter Card - Fixed height */
.bill-content .search-filter-card {
    flex-shrink: 0;
    margin-bottom: 20px;
}

/* Table Container - Match Product Table Container */
.bill-table-container {
    width: 100%;
    padding: 0 10px;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    max-height: calc(100vh - 350px);
    min-height: 300px;
}

/* Loading Indicator for Infinite Scroll */
.loading-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    color: #666;
}

.loading-indicator .spinner {
    width: 30px;
    height: 30px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 10px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.bill-table-container::-webkit-scrollbar {
    width: 8px;
}

.bill-table-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.bill-table-container::-webkit-scrollbar-thumb {
    background: #0095da;
    border-radius: 4px;
}

.bill-table-container::-webkit-scrollbar-thumb:hover {
    background: #007bb5;
}

/* Bill Table */
.bill-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.bill-table th {
    padding: 12px;
    background-color: #f8f9fa;
    border: 1px solid #e0e0e0;
    position: sticky;
    top: 0;
    z-index: 10;
    font-weight: 500;
}

.bill-table td {
    padding: 12px;
    border: 1px solid #e0e0e0;
}

.bill-table tbody tr {
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.bill-table tbody tr:hover {
    background-color: #f8f9fa;
}

/* Checkbox Column */
.bill-checkbox-col {
    text-align: center;
    vertical-align: middle;
}

.bill-checkbox-col input[type="checkbox"] {
    margin: 0;
    transform: scale(1.2);
}

.bill-checkbox {
    cursor: pointer;
}

/* Footer */
.bill-search-footer {
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid #e0e0e0;
    background-color: #f8f9fa;
    flex-shrink: 0;
}

.bill-selected-info {
    font-size: 14px;
    color: #666;
}

.bill-footer-actions {
    display: flex;
    gap: 10px;
}

.bill-confirm-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Responsive adjustments for small screens - Match Product Popup */
@media (max-height: 768px) {
    .bill-content {
        height: calc(100vh - 250px);
        max-height: calc(100vh - 250px);
        min-height: 300px;
    }
}

@media (max-height: 700px) {
    .bill-search-modal .popup-content {
        max-height: 95vh;
        display: flex;
        flex-direction: column;
    }
    
    .bill-search-container {
        flex: 1;
        overflow: hidden;
        max-height: calc(95vh - 140px);
    }
    
    .bill-content {
        height: calc(100vh - 200px);
        max-height: calc(100vh - 200px);
        min-height: 250px;
    }
    
    .bill-search-footer {
        padding: 10px 20px;
        position: sticky;
        bottom: 0;
        background: white;
        z-index: 10;
        margin-top: auto;
        box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
        flex-shrink: 0;
    }
}

@media (max-height: 600px) {
    .bill-search-modal .popup-content {
        max-height: 98vh;
    }
    
    .bill-search-container {
        max-height: calc(98vh - 120px);
    }
    
    .bill-content {
        height: calc(100vh - 180px);
        max-height: calc(100vh - 180px);
        min-height: 200px;
    }
    
    .bill-search-footer {
        padding: 8px 15px;
    }
}

@media (max-width: 768px) {
    .bill-search-modal .popup-content {
        width: 95%;
        min-width: auto;
        margin: 10px;
    }
}

/* Input with Search Button Styles */
.input-with-button {
    display: flex;
    position: relative;
}

.input-with-button .input-with-btn {
    flex: 1;
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    border-right: none;
    padding-right: 10px;
}

.input-with-button .btn-action.btn-action-square {
    border-left: none;
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    border-top-right-radius: 4px;
    border-bottom-right-radius: 4px;
    min-width: 40px;
    height: auto;
}

.input-with-button .btn-action.btn-action-square svg {
    width: 16px;
    height: 16px;
}

/* Focus states */
.input-with-button .input-with-btn:focus {
    border-color: #80bdff;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
    z-index: 3;
}

.input-with-button .input-with-btn:focus + .btn-action.btn-action-square {
    border-color: #80bdff;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .input-with-button .btn-action.btn-action-square {
        min-width: 36px;
        padding: 0 8px;
    }
    
    .input-with-button .btn-action.btn-action-square svg {
        width: 14px;
        height: 14px;
    }
}

/* ===============================================
   PROMOTION MODAL STYLES
   =============================================== */

/* Promotion loading spinner */
.promotion-loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 15px auto;
}

/* Spinner animation */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ===============================================
   ADDITIONAL TRAN STYLES (MOVED FROM HTML)
   =============================================== */

/* Column display settings - inline styles to work with JavaScript toggle */
/* OCR Modal Styles */
.upload-area {
    border: 2px dashed #dee2e6;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    background-color: #f8f9fa;
    transition: border-color 0.3s ease;
}

.upload-area.dragover {
    border-color: #007bff;
    background-color: #e3f2fd;
}

.upload-content {
    padding: 20px;
}

.file-preview {
    text-align: center;
    padding: 10px;
}

.file-info {
    margin-top: 10px;
    font-size: 0.9em;
    color: #6c757d;
}

.upload-area:hover {
    border-color: #007bff;
    background-color: #f0f8ff;
}

.crop-container {
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 15px;
    background-color: #fff;
}

.crop-wrapper {
    max-height: 400px;
    overflow: hidden;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.crop-preview {
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 15px;
    background-color: #f8f9fa;
}

.preview-container {
    background-color: #fff;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.preview-container img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.ocr-results {
    height: 100%;
}

.loading-spinner {
    text-align: center;
    padding: 20px;
}

.extracted-data {
    background-color: #f8f9fa;
    padding: 15px;
    border-radius: 5px;
    margin-top: 10px;
}

/* Cropping Styles */
.crop-wrapper {
    max-height: 400px;
    overflow: hidden;
    border: 1px solid #ddd;
    border-radius: 5px;
}

.crop-container {
    margin-bottom: 20px;
}

.crop-controls button {
    margin-right: 5px;
}

.preview-container {
    background-color: #f8f9fa;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 5px;
}

.final-image-container {
    text-align: center;
    padding: 10px;
    background-color: #f8f9fa;
    border-radius: 5px;
    min-height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#cropSection {
    border-top: 1px solid #dee2e6;
    padding-top: 20px;
    margin-top: 20px;
}

#ocrSection {
    border-top: 1px solid #dee2e6;
    padding-top: 20px;
    margin-top: 20px;
}

.col-serial {
    min-width: 120px;
    width: 120px;
    display: none; /* Hidden by default, JavaScript will override with inline style */
}

.col-lot {
    min-width: 120px;
    width: 120px;
    display: none; /* Hidden by default, JavaScript will override with inline style */
}

.col-expire {
    min-width: 120px;
    width: 120px;
    display: none;
}

.col-comments {
    min-width: 150px;
    width: 150px;
    display: none;
}

.col-discount-item {
    min-width: 100px;
    width: 100px;
    display: none;
}

.col-taxtype {
    min-width: 100px;
    width: 100px;
    display: none;
}

/* Force blue scrollbar for product table */
.table-container-main::-webkit-scrollbar {
    height: 12px !important;
    width: 12px !important;
}

.table-container-main::-webkit-scrollbar-track {
    background: #f1f1f1 !important;
    border-radius: 6px !important;
}

.table-container-main::-webkit-scrollbar-thumb {
    background: #0095da !important;
    border-radius: 6px !important;
    border: 1px solid #ffffff !important;
}

.table-container-main::-webkit-scrollbar-thumb:hover {
    background: #007bb5 !important;
}

.table-container-main::-webkit-scrollbar-corner {
    background: #f1f1f1 !important;
}

/* Firefox scrollbar */
.table-container-main {
    scrollbar-width: thin !important;
    scrollbar-color: #0095da #f1f1f1 !important;
}

/* Center upload modal on screen */
#uploadModal .modal-dialog {
    margin: auto;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-height: 90vh;
    width: 90vw;
    max-width: 90vw;
}

#uploadModal .modal-content {
    height: auto;
    max-height: 90vh;
    overflow-y: auto;
}

/* Center OCR results modal on screen */
#ocrResultsModal .modal-dialog {
    margin: auto;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-height: 90vh;
    width: 90vw;
    max-width: 90vw;
}

#ocrResultsModal .modal-content {
    height: auto;
    max-height: 90vh;
    overflow-y: auto;
}

/* Make quick product modal appear in front of other modals */
#quickProductModal {
    z-index: 1060;
}

#quickProductModal .modal-dialog {
    margin: auto;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-height: 90vh;
    width: 90vw;
    max-width: 90vw;
}

#quickProductModal .modal-content {
    height: auto;
    max-height: 90vh;
    overflow-y: auto;
}

