/* css/styles.css */

/* --- General & Login Page Body Style --- */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    /* พื้นหลัง Gradient สวยงามตามที่คุณชอบ */
    background: linear-gradient(135deg, #74ebd5, #ACB6E5);
    margin: 0;
    padding: 20px;
    display: flex;
    flex-direction: column;
    /* จัดเรียงแนวตั้ง */
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    box-sizing: border-box;
}

/* --- Main Title (POS อะไหล่มอเตอร์ไซค์) --- */
.main-title {
    font-size: 40px;
    font-weight: bold;
    color: #fff;
    margin-bottom: 20px;
    text-shadow: 1px 1px 4px rgba(0, 0, 0, 0.3);
}

/* --- Login Container --- */
.login-container {
    background-color: white;
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.login-container h2 {
    margin-bottom: 25px;
    color: #333;
    font-size: 24px;
}

.login-form .form-group {
    margin-bottom: 20px;
    text-align: left;
}

.login-form label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
    color: #555;
}

.login-form input[type="text"],
.login-form input[type="password"] {
    width: 100%;
    padding: 12px;
    border: 1px solid #ccc;
    border-radius: 8px;
    font-size: 16px;
    box-sizing: border-box;
    transition: border-color 0.3s;
}

.login-form input[type="text"]:focus,
.login-form input[type="password"]:focus {
    border-color: #4A90E2;
    /* สีฟ้าเมื่อ focus */
    outline: none;
}

.login-btn {
    width: 100%;
    background-color: #4A90E2;
    color: white;
    border: none;
    padding: 12px;
    border-radius: 8px;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.3s;
}

.login-btn:hover {
    background-color: #357ABD;
    /* สีเข้มขึ้นเมื่อ hover */
}

.error-message {
    color: #D8000C;
    /* สีแดงที่ชัดขึ้น */
    background-color: #FFD2D2;
    border: 1px solid #D8000C;
    border-radius: 8px;
    padding: 10px;
    margin-bottom: 20px;
    text-align: center;
}

/* =========================================
--- Responsive Design (ยังคงอยู่) ---
=========================================
*/

/* สำหรับหน้าจอขนาดเล็ก (กว้างไม่เกิน 480px) */
@media (max-width: 480px) {
    .main-title {
        font-size: 32px;
        /* ลดขนาดหัวข้อใหญ่ในมือถือ */
    }

    .login-container {
        padding: 25px;
        /* ลด padding ในมือถือ */
    }

    .login-container h2 {
        font-size: 20px;
    }
}

.pos-body {
    /* Override a few body styles for the POS page */
    background-color: #eef1f5;
    /* A slightly different background */
    display: block;
    /* No need for flex centering here */
    padding: 0;
    min-height: 100vh;
}

.pos-container {
    display: flex;
    height: 100vh;
}

/* --- Left Panel --- */
.pos-left {
    width: 55%;
    padding: 20px;
    display: flex;
    flex-direction: column;
}

.pos-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.user-info {
    font-size: 1.1em;
}

.logout-btn {
    background-color: #f44336;
    color: white;
    padding: 8px 15px;
    text-decoration: none;
    border-radius: 5px;
    font-weight: bold;
}

.logout-btn:hover {
    background-color: #d32f2f;
}


.search-container input[type="text"] {
    width: 100%;
    padding: 15px;
    font-size: 1.2em;
    border: 2px solid #ddd;
    border-radius: 8px;
    box-sizing: border-box;
}

.search-results-list {
    margin-top: 10px;
    max-height: 70vh;
    overflow-y: auto;
}

.search-result-item {
    padding: 15px;
    background: #fff;
    border-bottom: 1px solid #eee;
    cursor: pointer;
}

.search-result-item:hover {
    background: #f0f8ff;
}

.no-results {
    padding: 15px;
    color: #777;
}

/* --- Right Panel (Cart) --- */
.pos-right {
    width: 45%;
    background-color: #ffffff;
    box-shadow: -5px 0 15px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
}

.cart-header {
    padding: 20px;
    border-bottom: 1px solid #eee;
}

.cart-header h3 {
    margin: 0;
    font-size: 1.5em;
}

.cart-items-container {
    flex-grow: 1;
    overflow-y: auto;
    padding: 10px;
}

.empty-cart-message {
    text-align: center;
    color: #999;
    margin-top: 50px;
    font-size: 1.2em;
}

.cart-item {
    display: grid;
    grid-template-columns: 3fr 1fr 1fr 1fr auto;
    gap: 10px;
    align-items: center;
    padding: 15px;
    border-bottom: 1px solid #f5f5f5;
}

.item-name {
    font-weight: bold;
}

.item-qty input {
    width: 60px;
    padding: 5px;
    text-align: center;
    border: 1px solid #ccc;
    border-radius: 4px;
}

.item-price,
.item-subtotal {
    text-align: right;
}

.item-remove .remove-btn {
    background: #ff4d4d;
    color: white;
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    font-size: 1.2em;
    line-height: 1;
    cursor: pointer;
}

.cart-summary {
    padding: 20px;
    border-top: 2px solid #ddd;
    background-color: #f9f9f9;
}

.total-row {
    display: flex;
    justify-content: space-between;
    font-size: 1.8em;
    font-weight: bold;
    margin-bottom: 15px;
}

.action-buttons {
    display: flex;
    gap: 10px;
}

.action-buttons button {
    flex-grow: 1;
    padding: 15px;
    border: none;
    border-radius: 8px;
    font-size: 1.2em;
    font-weight: bold;
    cursor: pointer;
}

.btn-clear {
    background-color: #ffc107;
    color: #333;
}

.btn-clear:hover {
    background-color: #e0a800;
}

.btn-process {
    background-color: #28a745;
    color: white;
}

.btn-process:hover {
    background-color: #218838;
}

.btn-log {
    background-color: #17a2b8;
    color: white;
}

.btn-log:hover {
    background-color: #138496;
}

/* Responsive adjustments for POS */
@media (max-width: 1024px) {
    .pos-container {
        flex-direction: column;
        height: auto;
    }

    .pos-left,
    .pos-right {
        width: 100%;
        box-sizing: border-box;
    }

    .pos-right {
        height: 50vh;
        /* Give cart a fixed height on smaller screens */
    }
}

/* =========================================
--- Animation for POS ---
=========================================
*/
.search-container input.shake {
    animation: shake 0.5s;
}

@keyframes shake {

    10%,
    90% {
        transform: translate3d(-1px, 0, 0);
    }

    20%,
    80% {
        transform: translate3d(2px, 0, 0);
    }

    30%,
    50%,
    70% {
        transform: translate3d(-4px, 0, 0);
    }

    40%,
    60% {
        transform: translate3d(4px, 0, 0);
    }
}

.history-btn {
    background-color: #007bff;
    color: white;
    padding: 8px 15px;
    text-decoration: none;
    border-radius: 5px;
    font-weight: bold;
    margin-right: 10px;
}

.history-btn:hover {
    background-color: #0056b3;
}


/* =========================================
--- Manage Products Page Styles ---
=========================================
*/
.page-body {
    background-color: #f4f7f6;
    padding: 20px;
    display: block !important;
}

/* === ส่วนที่แก้ไข: ปรับปรุง .container สำหรับหน้าที่มีหลายเมนู === */
.container {
    width: 100%;
    /* << เปลี่ยน: ให้ container กว้างเต็มพื้นที่ที่ได้รับมา */
    max-width: 1200px;
    margin: auto;
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.search-form input {
    padding: 8px;
    min-width: 300px;
}

.btn-success {
    background-color: #28a745;
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 5px;
    cursor: pointer;
}

.btn-success:hover {
    background-color: #218838;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 12px;
    border: 1px solid #ddd;
    text-align: left;
}

.data-table th {
    background-color: #f2f2f2;
}

.btn-edit,
.btn-delete,
.btn-edit-user,
.btn-deactivate-user {
    padding: 5px 10px;
    border: none;
    border-radius: 4px;
    color: white;
    cursor: pointer;
    margin-right: 5px;
}

.btn-edit,
.btn-edit-user {
    background-color: #ffc107;
    color: #212529;
}

.btn-delete,
.btn-deactivate-user {
    background-color: #6c757d;
}

.pagination {
    margin-top: 20px;
}

.pagination a {
    color: black;
    float: left;
    padding: 8px 16px;
    text-decoration: none;
    border: 1px solid #ddd;
}

.pagination a.active {
    background-color: #007bff;
    color: white;
    border: 1px solid #007bff;
}

.pagination a:hover:not(.active) {
    background-color: #ddd;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.4);
}

.modal-content {
    background-color: #fefefe;
    margin: 10% auto;
    padding: 20px;
    border: 1px solid #888;
    width: 80%;
    max-width: 500px;
    border-radius: 8px;
}

.close-btn {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
}

.close-btn:hover,
.close-btn:focus {
    color: black;
    text-decoration: none;
    cursor: pointer;
}

#product-form label {
    display: block;
    margin-top: 10px;
}

#product-form input[type=text],
#product-form input[type=number] {
    width: 100%;
    padding: 8px;
    box-sizing: border-box;
}

#product-form button {
    background-color: #007bff;
    color: white;
    padding: 10px 15px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    margin-top: 20px;
}

#product-modal .modal-content {
    /* เพิ่มความกว้างเพื่อให้มีพื้นที่สำหรับ 2 คอลัมน์ */
    max-width: 850px;
    width: 90%;
}

/* === ส่วนที่เพิ่มเข้ามา: สไตล์สำหรับส่วน Barcode === */
.barcode-section {
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    padding: 15px;
    border-radius: 5px;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
}

.input-with-button {
    display: flex;
}

.input-with-button input {
    flex-grow: 1;
    border-radius: 4px 0 0 4px !important;
}

.input-with-button button {
    border-radius: 0 4px 4px 0 !important;
    white-space: nowrap;
}

.btn-secondary {
    background-color: #6c757d;
    color: white;
    border: 1px solid #6c757d;
}

.btn-secondary:hover {
    background-color: #5a6268;
}

.barcode-generator {
    margin-top: 10px;
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.barcode-generator .generator-inputs {
    display: flex;
    align-items: center;
    gap: 10px;
}

.barcode-generator .latest-info {
    font-size: 0.9em;
    color: #555;
}

#barcode-prefix {
    width: 60px;
}

.btn-info {
    background-color: #17a2b8;
    color: white;
    padding: 5px 10px;
    border-radius: 4px;
    border: none;
    cursor: pointer;
}

.btn-info:hover {
    background-color: #138496;
}

/* === ส่วนที่เพิ่มเข้ามา: สไตล์สำหรับ Preview Area === */
#barcode-preview-area {
    margin-top: 15px;
    padding: 10px;
    min-height: 80px;
    /* ทำให้มีพื้นที่แม้จะยังไม่มีรูป */
    background-color: #fff;
    border: 1px dashed #ccc;
    display: flex;
    justify-content: center;
    align-items: center;
}

#barcode-preview-area svg {
    max-width: 100%;
    height: 60px;
}

/* =========================================
--- Dashboard Page Styles ---
=========================================
*/
.dashboard-header {
    text-align: center;
    margin-bottom: 40px;
}

.dashboard-header h1 {
    margin-bottom: 10px;
}

.dashboard-header .user-info {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
}

.dashboard-menu {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.menu-card {
    background-color: #ffffff;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    text-decoration: none;
    color: #333;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.05);
    transition: transform 0.2s, box-shadow 0.2s;
}

.menu-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
}

.menu-card .menu-icon {
    font-size: 3em;
    margin-bottom: 10px;
}

.menu-card h2 {
    margin: 0 0 10px 0;
    color: #007bff;
}

.menu-card p {
    margin: 0;
    font-size: 0.9em;
    color: #666;
}

.menu-card.disabled {
    background-color: #f8f9fa;
    cursor: not-allowed;
    opacity: 0.6;
}

.menu-card.disabled:hover {
    transform: none;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.05);
}

/* =========================================
--- General Button Styles Overrides ---
=========================================
*/
/* Reset and base style for all navigation/action buttons */
button.history-btn,
button.logout-btn,
button.back-link-btn,
.btn,
.btn-info {
    border: none;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-weight: bold;
    font-size: 14px;
    /* Consistent font size */
    line-height: 1.5;
    text-align: center;
    vertical-align: middle;
}

/* Specific button styles that were previously for <a> tags */
button.logout-btn {
    background-color: #f44336;
    color: white;
    padding: 8px 15px;
    border-radius: 5px;
}

button.logout-btn:hover {
    background-color: #d32f2f;
}

button.history-btn {
    background-color: #007bff;
    color: white;
    padding: 8px 15px;
    border-radius: 5px;
}

button.history-btn:hover {
    background-color: #0056b3;
}

button.back-link-btn {
    display: inline-block;
    margin-bottom: 20px;
    background-color: #6c757d;
    color: white;
    padding: 8px 12px;
    border-radius: 4px;
}

button.back-link-btn:hover {
    background-color: #5a6268;
}

.btn-info {
    background-color: #17a2b8;
    color: white;
    padding: 5px 10px;
    border-radius: 4px;
}

.btn-info:hover {
    background-color: #138496;
}


/* Dashboard Menu Card */
.menu-card {
    /* ... existing styles ... */
    cursor: pointer;
    /* Add cursor pointer to show it's clickable */
}


/* Pagination Buttons */
.pagination button {
    color: black;
    float: left;
    padding: 8px 16px;
    text-decoration: none;
    border: 1px solid #ddd;
    background-color: white;
    cursor: pointer;
    margin: 0 2px;
    border-radius: 4px;
}

.pagination button.active {
    background-color: #007bff;
    color: white;
    border: 1px solid #007bff;
}

.pagination button:hover:not(.active) {
    background-color: #ddd;
}

/* =========================================
--- Manage Products Page Styles (Updated) ---
=========================================
*/
.page-body {
    background-color: #f4f7f6;
    padding: 20px;
}

.container {
    max-width: 1200px;
    margin: auto;
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

/* === Top Navigation (Added) === */
.top-navigation {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #f8f9fa;
    padding: 10px;
    border-radius: 5px;
    margin-bottom: 20px;
    border: 1px solid #dee2e6;
}

.top-navigation .page-info {
    color: #333;
    font-weight: 500;
}

.top-navigation button {
    padding: 8px 16px;
    border: 1px solid #ccc;
    background-color: white;
    cursor: pointer;
    border-radius: 4px;
}

.top-navigation button:disabled {
    background-color: #e9ecef;
    cursor: not-allowed;
    opacity: 0.7;
}

.top-navigation button:not(:disabled):hover {
    background-color: #ddd;
}


/* === Toolbar & Search Form Styles === */
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 10px;
}

.search-form {
    display: flex;
}

.search-form input {
    padding: 8px 12px;
    min-width: 300px;
    border: 1px solid #ccc;
    border-right: none;
    border-radius: 5px 0 0 5px;
    font-size: 14px;
}

.search-form button {
    padding: 8px 15px;
    border: 1px solid #007bff;
    background-color: #007bff;
    color: white;
    border-radius: 0 5px 5px 0;
    cursor: pointer;
    font-size: 14px;
}

.search-form button:hover {
    background-color: #0056b3;
}


/* === Data Table and Buttons === */
.btn-success {
    background-color: #28a745;
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
}

.btn-success:hover {
    background-color: #218838;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
}

.data-table th,
.data-table td {
    padding: 12px;
    border: 1px solid #ddd;
    text-align: left;
}

.data-table th {
    background-color: #f2f2f2;
}

.btn-edit,
.btn-delete {
    padding: 5px 10px;
    border: none;
    border-radius: 4px;
    color: white;
    cursor: pointer;
}

.btn-edit {
    background-color: #ffc107;
    color: #212529;
}

.btn-delete {
    background-color: #dc3545;
}

/* ปุ่มปิดใช้งาน */
.btn-deactivate {
    background-color: #6c757d;
    color: white;
    padding: 5px 10px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.btn-deactivate:hover {
    background-color: #5a6268;
}

/* ปุ่มลบถาวร */
.btn-delete-permanent {
    background-color: #c82333;
    color: white;
    padding: 5px 10px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.btn-delete-permanent:hover {
    background-color: #bd2130;
}

/* === Numeric Pagination (Bottom) === */
.pagination {
    margin-top: 20px;
    text-align: center;
}

.pagination button {
    color: black;
    padding: 8px 16px;
    text-decoration: none;
    border: 1px solid #ddd;
    background-color: white;
    cursor: pointer;
    margin: 0 2px;
    border-radius: 4px;
}

.pagination button.active {
    background-color: #007bff;
    color: white;
    border: 1px solid #007bff;
}

.pagination button:hover:not(.active) {
    background-color: #ddd;
}


/* === Modal Styles (Fix for 2 columns) === */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.4);
}

.modal-content {
    background-color: #fefefe;
    margin: 5% auto;
    padding: 20px;
    border: 1px solid #888;
    width: 90%;
    max-width: 700px;
    border-radius: 8px;
}

.close-btn {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
}

.close-btn:hover,
.close-btn:focus {
    color: black;
    text-decoration: none;
    cursor: pointer;
}

#product-form {
    display: grid;
    /* This rule creates 2 columns and makes it responsive */
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
    margin-bottom: 15px;
}

.form-grid {
    /* ใช้ CSS Grid เพื่อสร้าง 2 คอลัมน์ที่มีความกว้างเท่ากัน */
    display: grid;
    grid-template-columns: 1fr 1fr;
    /* 1fr 1fr คือการแบ่งพื้นที่เป็น 2 ส่วนเท่าๆ กัน */
    gap: 15px 30px;
    /* ระยะห่างระหว่างแถวและคอลัมน์ */
    margin-bottom: 15px;
}

/* --- 4. จัดรูปแบบ Input แต่ละคู่ --- */
.form-grid>div {
    /* ตรวจสอบว่าแต่ละ div ใช้พื้นที่เต็มคอลัมน์ของตัวเอง */
    width: 100%;
    /* ไม่ต้องใช้ display: grid หรือ flex ภายใน div ย่อย ถ้ามันมีแค่ label และ input */
}

/* ปรับ label และ input ให้จัดเรียงแนวตั้งได้ง่ายขึ้น */
.form-grid label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
}

.form-grid input[type="text"],
.form-grid input[type="number"] {
    width: 100%;
    box-sizing: border-box;
}

/* Class สำหรับทำให้ช่อง Input ขยายเต็ม 2 คอลัมน์ */
.form-grid .grid-span-2 {
    grid-column: 1 / -1;
    /* สั่งให้ขยายเต็มพื้นที่ Grid (span 2 columns) */
}

#product-form label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
}

#product-form input[type=text],
#product-form input[type=number],
#product-form textarea {
    width: 100%;
    padding: 8px;
    box-sizing: border-box;
    border: 1px solid #ccc;
    border-radius: 4px;
}

#product-form textarea {
    resize: vertical;
}

#product-form .checkbox-label {
    display: flex;
    align-items: center;
    margin-top: 15px;
    font-weight: normal;
}

#product-form .checkbox-label input {
    margin-right: 10px;
}

#product-form button {
    background-color: #007bff;
    color: white;
    padding: 10px 15px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    margin-top: 20px;
}

/* หากจำเป็น: ทำให้ textarea และปุ่ม Save/checkbox อยู่ด้านล่างแบบเต็มความกว้าง */
/* เนื่องจากองค์ประกอบเหล่านี้อยู่นอก form-grid เราจึงไม่จำเป็นต้องแก้ไขมากนัก */
#product-form>label[for="note"],
#product-form>textarea,
#product-form>button[type="submit"],
#product-form>.checkbox-label {
    grid-column: 1 / -1;
    /* ครอบคลุมทุกคอลัมน์ (Full Width) */
}

.required {
    color: #dc3545;
}

/* === General Button Styles Overrides === */
button.back-link-btn {
    display: inline-block;
    margin-bottom: 20px;
    background-color: #6c757d;
    color: white;
    padding: 8px 12px;
    border-radius: 4px;
    border: none;
    cursor: pointer;
}

button.back-link-btn:hover {
    background-color: #5a6268;
}

/* =========================================
--- Sales Report Page Styles ---
=========================================
*/
.report-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin-bottom: 30px;
}

.report-controls {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.report-filter {
    background-color: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    border: 1px solid #dee2e6;
}

.report-filter form {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

.report-filter label {
    font-weight: 500;
}

.report-filter input[type="date"] {
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
}

.report-filter button {
    padding: 8px 20px;
    font-size: 14px;
}

.summary-cards {
    display: grid;
    grid-template-columns: 1fr;
    gap: 15px;
}

.summary-cards .card {
    background-color: #fff;
    padding: 20px;
    border-radius: 8px;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    border: 1px solid #eee;
}

.summary-cards .card h3 {
    margin-top: 0;
    font-size: 1em;
    color: #555;
}

.summary-cards .card p {
    margin-bottom: 0;
    font-size: 2em;
    font-weight: bold;
    color: #007bff;
}

.report-table-container h2 {
    text-align: center;
    margin-bottom: 15px;
    font-size: 1.2em;
}

.report-table-container .data-table td {
    padding: 8px;
}

.charts-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-top: 20px;
    grid-column: 1 / -1;
    /* Make charts section span full width */
}

.chart-container {
    background-color: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.05);
}

.chart-container h2 {
    text-align: center;
    margin-top: 0;
    margin-bottom: 20px;
    font-size: 1.2em;
}

@media (max-width: 992px) {

    .report-layout,
    .charts-section {
        grid-template-columns: 1fr;
    }
}

/* =========================================
   8. Post-Sale Modal Styles (New)
========================================= */
.post-sale-content {
    max-width: 450px;
    text-align: center;
}

.post-sale-content h2 {
    color: #28a745;
    margin-top: 0;
}

.post-sale-content p {
    color: #555;
    margin-bottom: 20px;
}

#qrcode-container {
    padding: 15px;
    background-color: #fff;
    border: 1px solid #ddd;
    display: inline-block;
    margin-bottom: 20px;
}

.post-sale-actions {
    display: flex;
    justify-content: center;
    gap: 15px;
}

/* ในไฟล์ css/styles.css (ปรับปรุงสไตล์เดิมที่คุณเพิ่มเข้าไป) */

.stock-in-header-row,
.cart-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 10px;
    font-weight: bold;
    color: #495057;
    background-color: #e9ecef;
    border-bottom: 2px solid #ced4da;
    font-size: 0.85em;
    margin-bottom: 5px;
}

/* --- POS Cart Header Row (สำหรับหน้า sale.php) --- */
.cart-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 10px;
    font-weight: bold;
    color: #495057;
    /* Darker text */
    background-color: #e9ecef;
    /* Light gray background */
    border-bottom: 2px solid #ced4da;
    font-size: 0.9em;
    margin-bottom: 5px;
    /* Space between header and first item */
}

.cost-code-display {
    display: block;
    /* ขึ้นบรรทัดใหม่ */
    font-size: 0.8em;
    color: #6c757d;
    /* สีเทาอ่อนๆ */
    margin-top: 2px;
}

/* --- การจัดเรียงรายการสินค้า (Item rows) ให้ตรงกับ Header --- */
.pos-right .cart-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 10px;
    /* เพิ่ม padding ด้านซ้าย-ขวา ให้ตรงกับ Header */
    border-bottom: 1px solid #eee;
}

/* กำหนดสัดส่วนความกว้างให้ตรงกับ Header */
.pos-right .cart-item .item-name {
    width: 45%;
    /* line-height: 1.2; */
}

.pos-right .cart-item .item-qty {
    width: 15%;
    text-align: center;
}

.pos-right .cart-item .item-price {
    width: 15%;
    text-align: right;
    font-size: 0.95em;
}

.pos-right .cart-item .item-subtotal {
    width: 20%;
    text-align: right;
    font-size: 0.95em;
    font-weight: bold;
}

.pos-right .cart-item .item-remove {
    width: 5%;
    text-align: center;
}

/* สไตล์สำหรับช่อง Input จำนวน */
.pos-right .cart-item .quantity-input {
    text-align: center;
    width: 80%;
    box-sizing: border-box;
    padding: 3px;
    max-width: 60px;
    /* จำกัดความกว้างของช่องจำนวน */
    margin: 0 auto;
    /* จัดกึ่งกลาง Input */
}

/* จัดตำแหน่งปุ่มลบให้อยู่ตรงกลางตามแนวตั้ง */
.pos-right .cart-item .item-remove button {
    line-height: 1;
    /* ทำให้ปุ่มมีขนาดเล็กลง */
}

/* ปรับความกว้างของคอลัมน์ในรายการสินค้าให้กว้างขึ้น */
.pos-right .cart-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 0;
    border-bottom: 1px solid #eee;
}

/* กำหนดสัดส่วนความกว้างใหม่ */
.pos-right .cart-item .item-name {
    width: 35%;
    /* ลดชื่อสินค้าลงเล็กน้อย */
}

.pos-right .cart-item .item-qty {
    width: 15%;
    /* คงที่หรือเพิ่มเล็กน้อย */
    text-align: center;
}

.pos-right .cart-item .item-price {
    width: 25%;
    /* เพิ่มความกว้างให้ราคาทุน */
    text-align: right;
}

.pos-right .cart-item .item-subtotal {
    width: 20%;
    /* ลดความกว้างรวม (ทุน) */
    text-align: right;
}

.pos-right .cart-item .item-remove {
    width: 5%;
    text-align: center;
}

.stock-in-header-row div {
    padding: 0 5px;
}

/* กำหนดสัดส่วนคอลัมน์ใหม่ (รวม 100%) */
/* 1. สินค้า (30%) */
.stock-in-header-row div:nth-child(1),
.cart-item .item-name { 
    width: 30%; 
}

/* 2. จำนวน (10%) */
.stock-in-header-row div:nth-child(2),
.cart-item .item-qty { 
    width: 10%; 
    text-align: center;
}

/* 3. ราคาทุน/หน่วย (15%) - ช่องรับเข้า */
.stock-in-header-row div:nth-child(3),
.cart-item .item-cost-price { 
    width: 15%; 
    text-align: right;
}

/* 4. อัปเดต: รหัสทุน (15%) */
.stock-in-header-row div:nth-child(4),
.cart-item .item-cost-code { 
    width: 15%; 
    text-align: center;
}

/* 5. อัปเดต: ราคาขาย (15%) */
.stock-in-header-row div:nth-child(5),
.cart-item .item-sale-price { 
    width: 15%; 
    text-align: right;
}

/* 6. รวมทุน (10%) */
.stock-in-header-row div:nth-child(6),
.cart-item .item-subtotal { 
    width: 10%; 
    text-align: right;
}

/* 7. ปุ่มลบ (5%) */
.stock-in-header-row div:nth-child(7),
.cart-item .item-remove { 
    width: 5%; 
    text-align: center;
}


/* *** สำคัญมาก: ขยายช่อง Input ให้เต็มพื้นที่คอลัมน์ *** */
.pos-right .cart-item .quantity-input,
.pos-right .cart-item .cost-input {
    text-align: right;
    width: 100%;
    /* ทำให้ Input กว้าง 100% ของพื้นที่ Item */
    box-sizing: border-box;
    padding: 3px;
    /* เพิ่ม padding เล็กน้อย */
    height: auto;
    /* ไม่กำหนดความสูงคงที่ */
    /* *** เพิ่ม max-width เพื่อป้องกันการขยายเกินไป *** */
    max-width: 100px;
    /* สำหรับ quantity */
}

/* ปรับให้ช่องราคาทุนกว้างขึ้น */
.pos-right .cart-item .item-price .cost-input {
    max-width: 130px;
    /* สำหรับ cost price */
}

.pos-right .cart-item .item-qty {
    display: flex;
    justify-content: center;
    /* จัด Input ให้อยู่ตรงกลางคอลัมน์ */
}

.pos-right .cart-item .item-price {
    display: flex;
    justify-content: flex-end;
    /* จัด Input ให้อยู่ทางขวาของคอลัมน์ */
}

/* ในไฟล์ css/styles.css */

/* สไตล์พื้นฐานของส่วน Form */
.form-section {
    padding: 15px;
    background-color: #f8f9fa;
    /* สีพื้นหลังอ่อนๆ */
    border-radius: 8px;
    margin-bottom: 15px;
    /* เพิ่มระยะห่างด้านล่าง */
    border: 1px solid #dee2e6;
}

.form-section h3 {
    margin-top: 0;
    font-size: 1.1em;
    color: #343a40;
    border-bottom: 1px solid #adb5bd;
    padding-bottom: 5px;
    margin-bottom: 10px;
}

/* สไตล์เฉพาะสำหรับ Textarea หมายเหตุ */
#sale-note {
    width: 100%;
    /* ปรับปรุงให้ Textarea ดูดีขึ้น */
    padding: 8px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    box-sizing: border-box;
    /* สำคัญ: รวม padding ในความกว้าง 100% */
    resize: vertical;
    /* อนุญาตให้ขยายแนวตั้งเท่านั้น */
    font-size: 0.9em;
}

/* ในไฟล์ css/styles.css */

/* ปรับความกว้างของคอลัมน์ใน Header ให้เหมาะสม */
.cart-header-row div:nth-child(1) {
    width: 40%;
}

/* สินค้า */
.cart-header-row div:nth-child(2) {
    width: 10%;
    text-align: center;
}

/* จำนวน */
.cart-header-row div:nth-child(3) {
    width: 25%;
    text-align: right;
}

/* ราคา/หน่วย (เพิ่มพื้นที่) */
.cart-header-row div:nth-child(4) {
    width: 20%;
    text-align: right;
}

/* ราคารวม */

/* ปรับความกว้างของคอลัมน์ใน Cart Item */
.pos-right .cart-item .item-name {
    width: 40%;
}

.pos-right .cart-item .item-qty {
    width: 10%;
}

.pos-right .cart-item .item-price {
    width: 25%;
}

/* เพิ่มพื้นที่ให้ช่องราคา */
.pos-right .cart-item .item-subtotal {
    width: 20%;
}

/* สไตล์สำหรับช่อง Input ราคา/หน่วยใหม่ */
.pos-right .cart-item .price-input {
    text-align: right;
    width: 95%;
    box-sizing: border-box;
    padding: 3px;
    max-width: 120px;
    /* จำกัดความกว้างไม่ให้ใหญ่เกินไป */
    margin-left: auto;
    /* จัดชิดขวา */
}

.cart-item input {
    width: 90%; /* ให้มีขอบเล็กน้อย */
    box-sizing: border-box; /* รวม padding ใน width */
}

/* Modal Base */
.modal {
    display: none;
    /* ซ่อนไว้ตั้งแต่แรก */
    position: fixed;
    z-index: 2000;
    /* ให้ Modal อยู่ด้านบนสุด */
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.4);
}

.modal-content {
    background-color: #fefefe;
    margin: 10% auto;
    /* อยู่ตรงกลางหน้าจอแนวตั้ง */
    padding: 20px;
    border: 1px solid #888;
    width: 90%;
    max-width: 450px;
    /* จำกัดความกว้าง */
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    text-align: center;
}

.close-btn {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
}

.close-btn:hover,
.close-btn:focus {
    color: #000;
    text-decoration: none;
    cursor: pointer;
}

/* Payment Specific Styles */
.payment-summary {
    margin: 15px 0;
    padding: 10px;
    background: #e6f7ff;
    border-radius: 6px;
}

.payment-summary p {
    font-size: 1.1em;
    margin: 0;
    color: #333;
}

.payment-summary h1 {
    font-size: 2.2em;
    margin: 5px 0;
}

.payment-input-group,
.payment-method-group {
    text-align: left;
    margin-bottom: 15px;
}

.payment-input-group input,
.payment-method-group select {
    width: 100%;
    padding: 10px;
    margin-top: 5px;
    font-size: 1.2em;
    border: 2px solid #ced4da;
    border-radius: 4px;
    box-sizing: border-box;
}

.payment-result-group {
    margin: 20px 0;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    text-align: left;
}

.payment-result-group h2 {
    font-size: 1.8em;
    margin: 5px 0 0 0;
    text-align: right;
}

#confirm-payment-btn {
    width: 100%;
    padding: 15px;
    font-size: 1.2em;
    margin-top: 20px;
}

/* ในไฟล์ css/styles.css */

/* สไตล์สำหรับช่องที่แก้ไขได้ */
.data-table td.editable {
    /* ให้มีขอบหรือสีพื้นหลังอ่อนๆ เมื่อเมาส์ชี้ */
    cursor: text;
}

.data-table td.editable:hover {
    background-color: #fff9c4;
    /* สีเหลืองอ่อนๆ */
}

/* สไตล์เมื่อกำลังแก้ไข */
.data-table td[contenteditable="true"]:focus {
    outline: 2px solid #007bff;
    /* ขอบสีน้ำเงิน */
    background-color: #fff;
}

/* สไตล์สำหรับแจ้งเตือนสถานะ */
.data-table .status-saving {
    background-color: #ffc107;
    /* เหลือง */
}

.data-table .status-success {
    background-color: #28a745;
    /* เขียว */
    color: white;
}

.data-table .status-error {
    background-color: #dc3545;
    /* แดง */
    color: white;
}

/* ซ่อนปุ่มลูกศร (spinners) ในช่อง input type="number" */
/* สำหรับ Chrome, Safari, Edge */
input[type=number]::-webkit-outer-spin-button,
input[type=number]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* สำหรับ Firefox */
input[type=number] {
    -moz-appearance: textfield;
}

/* ปรับ Padding และ Line-height ของรายการค้นหา */
.search-result-item {
    padding: 10px 15px;
    line-height: 1.4;
}

/* สไตล์บรรทัดแรก (บาร์โค้ด + ชื่อ) */
.search-result-line1 {
    font-size: 1.05em;
    /* อาจปรับขนาดตามความเหมาะสม */
}

/* สไตล์บาร์โค้ด */
.search-result-barcode {
    color: #0056b3;
    /* สีน้ำเงินเข้ม */
    margin-right: 8px;
}

/* สไตล์รายละเอียด (บรรทัด <small>) */
.search-result-details {
    display: block;
    /* *** สำคัญ: ทำให้ขึ้นบรรทัดใหม่ *** */
    font-size: 0.85em;
    color: #555;
    /* สีเทาเข้ม */
    margin-top: 3px;
}

.btn-copy {
    background-color: #17a2b8;
    /* สีน้ำเงิน (Info) */
    color: white;
    padding: 5px 10px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    margin-right: 5px;
    /* เพิ่มระยะห่างเหมือนปุ่มอื่น */
}

.btn-copy:hover {
    background-color: #138496;
}

.btn-print-barcode {
    background-color: #b66214;
    /* สีน้ำเงิน (Info) */
    color: white;
    padding: 5px 10px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    margin-right: 5px;
    /* เพิ่มระยะห่างเหมือนปุ่มอื่น */
}

.btn-print-barcode:hover {
    background-color: #864406;
}

/* ในไฟล์ css/styles.css */

/* ซ่อนปุ่มลูกศรใน input type="number" */
input[type=number]::-webkit-outer-spin-button,
input[type=number]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
input[type=number] {
    -moz-appearance: textfield;
}

/* --- Access Style Layout --- */
.access-container {
    display: flex;
    flex-direction: column;
    height: 100vh; /* เต็มความสูงหน้าจอ */
    overflow: hidden;
    background-color: #f0f0f0;
}

.access-header {
    padding: 10px;
    background-color: #e0e0e0;
    border-bottom: 1px solid #ccc;
    flex-shrink: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.access-body {
    display: flex;
    flex: 1;
    overflow: hidden; /* ซ่อน Scrollbar ของ body หลัก */
}

/* ส่วนตาราง (ด้านซ้าย) */
.access-list-pane {
    flex: 7; /* กว้าง 70% */
    border-right: 5px solid #ccc;
    overflow-y: auto; /* ให้เลื่อนเฉพาะตาราง */
    background: white;
    position: relative;
}

.access-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px; /* ตัวหนังสือกระชับแบบ Access */
}

.access-table th {
    position: sticky;
    top: 0;
    background-color: #d6d6d6; /* สีหัวตารางแบบโปรแกรมเก่า */
    color: #333;
    padding: 5px;
    border: 1px solid #999;
    font-weight: bold;
    text-align: left;
    white-space: nowrap;
    z-index: 10;
}

.access-table td {
    padding: 4px 8px; /* บรรทัดแคบลง */
    border: 1px solid #ddd;
    cursor: pointer;
    white-space: nowrap;
}

/* แถวที่ถูกเลือก (Highlight) */
.access-table tr.selected {
    background-color: #ffe082 !important; /* สีเหลืองส้มแบบ Access */
    color: black;
    outline: 2px solid #ff6f00; /* เส้นขอบเน้น */
}

.access-table tr:hover {
    background-color: #f5f5f5;
}

/* ส่วนฟอร์ม (ด้านขวา) */
.access-form-pane {
    flex: 3; /* กว้าง 30% */
    background-color: #f8f9fa;
    padding: 15px;
    overflow-y: auto;
    border-left: 1px solid white;
    box-shadow: -2px 0 5px rgba(0,0,0,0.05);
}

.access-form-pane h2 {
    margin-top: 0;
    font-size: 16px;
    border-bottom: 2px solid #007bff;
    padding-bottom: 5px;
    color: #0056b3;
}

/* Form Styles แบบ Compact */
.form-group-sm {
    margin-bottom: 8px;
}
.form-group-sm label {
    display: block;
    font-size: 12px;
    font-weight: bold;
    margin-bottom: 2px;
    color: #555;
}
.form-group-sm input, .form-group-sm select, .form-group-sm textarea {
    width: 100%;
    padding: 4px;
    font-size: 13px;
    border: 1px solid #ccc;
    border-radius: 2px; /* เหลี่ยมขึ้นนิดนึงให้ดู Pro */
}
.form-group-sm input:focus {
    border-color: #007bff;
    background-color: #fffde7; /* เวลาพิมพ์ช่องไหนให้ช่องนั้นเหลือง */
}

/* ปุ่ม Action ด้านล่างฟอร์ม */
.form-actions {
    margin-top: 15px;
    padding-top: 10px;
    border-top: 1px solid #ddd;
    text-align: right;
}

.status-indicator {
    display: inline-block;
    width: 10px; 
    height: 10px; 
    border-radius: 50%; 
    margin-right: 5px;
}
.status-active { background-color: #28a745; }
.status-inactive { background-color: #dc3545; }

/* --- สไตล์สำหรับช่องสต็อกให้โดดเด่น --- */
.input-stock-highlight {
    font-size: 24px !important;  /* ตัวเลขใหญ่ */
    font-weight: bold !important;
    color: #d35400;              /* ตัวหนังสือสีส้มเข้ม */
    background-color: #fff8e1 !important; /* พื้นหลังสีครีม/เหลืองอ่อน */
    border: 2px solid #ff9800 !important; /* ขอบสีส้มชัดเจน */
    text-align: center;          /* จัดกึ่งกลาง */
    height: 45px;                /* เพิ่มความสูงช่อง */
    border-radius: 5px;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.1);
    transition: all 0.3s ease;
}

/* เมื่อคลิกแก้ไข ให้เรืองแสง */
.input-stock-highlight:focus {
    background-color: #ffffff !important;
    border-color: #e65100 !important;
    box-shadow: 0 0 10px rgba(255, 152, 0, 0.5);
    transform: scale(1.02); /* ขยายขึ้นเล็กน้อย */
}