/* =========================================
   Reset & Base Styles
   ========================================= */
body {
    font-family: 'Inter', ui-sans-serif, system-ui, -apple-system, sans-serif;
    margin: 0;
    padding: 0;
    color: #333;

    display: flex;
    flex-direction: column;
    min-height: 100vh;

    background-image: url('../background.jpg');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-attachment: fixed;
}

/* =========================================
   Footer Styles
   ========================================= */
.footer {
    background-color: #0f172a;
    color: #cbd5e1;
    padding: 30px 0;
    width: 100%;
    margin-top: auto;
    /* position: fixed;
    bottom: 0;
    left: 0;
    z-index: 1000; */
}

.footer-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    padding: 0 20px;
}

.footer-info p {
    margin: 0;
    font-size: 0.9rem;
    color: #94a3b8;
}

.footer-links {
    display: flex;
    gap: 20px;
}

.footer-links a {
    color: #cbd5e1;
    text-decoration: none;
    font-size: 0.85rem;
    transition: color 0.2s;
}

.footer-links a:hover {
    color: #38bdf8;
    /* สีฟ้าเมื่อเอาเมาส์ชี้ */
}

/* ปรับแต่งสำหรับมือถือ */
@media (max-width: 768px) {
    .footer-links {
        flex-direction: column;
        align-items: center;
        gap: 10px;
    }
}

/* =========================================
   Layout: Dashboard
   ========================================= */
.container {
    max-width: 96%;
    width: 100%;
    margin: 20px auto;
    background: transparent;
    padding: 0 20px;
    box-sizing: border-box;
    flex: 1;
}

h1 {
    text-align: center;
    margin-bottom: 20px;
    font-size: 1.5rem;
    color: #1e293b;
}

/* --- GRID SYSTEM: แบ่งซ้ายขวา --- */
.cards-vertical {
    display: grid;
    grid-template-columns: 1fr 1.3fr;
    gap: 15px;
    align-items: start;
}

.cards-vertical>section:nth-child(1) {
    grid-column: 1 / 2;
}

.cards-vertical>section:nth-child(2) {
    grid-column: 2 / 3;
}

@media (max-width: 1024px) {
    .cards-vertical {
        grid-template-columns: 1fr;
    }

    .cards-vertical>section:nth-child(1),
    .cards-vertical>section:nth-child(2) {
        grid-column: auto;
    }
}

/* =========================================
   Card Styles
   ========================================= */
.card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

h3 {
    margin-top: 0;
    margin-bottom: 12px;
    font-size: 1.1rem;
    color: #0f172a;
    border-bottom: 1px solid #f1f5f9;
    padding-bottom: 8px;
}

.form-group {
    margin-bottom: 10px;
}

label {
    display: block;
    margin-bottom: 4px;
    font-weight: 600;
    font-size: 0.85rem;
    color: #475569;
}

input,
select {
    width: 100%;
    height: 36px;
    padding: 6px 10px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 14px;
    box-sizing: border-box;
}

input[readonly] {
    background-color: #f8fafc;
    color: #64748b;
}

button {
    width: 100%;
    padding: 10px;
    background: #2563eb;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 5px;
}

button:hover {
    background: #1d4ed8;
}

/* =========================================
   Grid Helpers
   ========================================= */
.two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.three-col {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 10px;
}

.four-col {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    align-items: end;
}

.five-col {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
    align-items: end;
}

.six-col {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 10px;
    align-items: end;
}

.vendor-grid {
    display: grid;
    /* ปรับขนาดคอลัมน์ใหม่ให้พอดีกับ 7 ช่อง */
    grid-template-columns: 1fr 0.9fr 0.9fr 1.3fr 0.9fr 0.6fr 1fr;
    gap: 10px;
    align-items: end;
}

.weight-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    align-items: end;
}

.hstack {
    display: flex;
    gap: 5px;
    align-items: center;
}

.hstack>input,
.hstack>select {
    min-width: 0;
}

.dimension-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.dimension-group input {
    width: 100%;
    flex: none;
}

/* =========================================
   Sidebar & Layout Styles
   ========================================= */

/* โครงสร้างฝั่งขวา (เนื้อหาหลัก) */
.main-content {
    margin-left: 250px; /* ดันเนื้อหาหลบ Sidebar */
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ส่วนหัวสำหรับมือถือ */
.mobile-header {
    display: none;
    background: #0f172a;
    color: #fff;
    padding: 15px 24px;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 900;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.hamburger {
    background: transparent;
    border: none;
    color: white;
    font-size: 1.8rem;
    cursor: pointer;
    padding: 0;
}

/* =========================================
   Premium Sidebar Styles
   ========================================= */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 260px;
    height: 100dvh;
    background: #0f172a;
    color: #b2c1cd;
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: transform 0.3s ease;
    padding: 24px 12px;
    box-sizing: border-box;
}

/* ปุ่มปิด (X) จัดการให้สวยงามและซ่อนในจอคอม */
.close-sidebar {
    display: none;
    background: transparent;
    border: none;
    color: #b2c1cd;
    font-size: 1.5rem;
    cursor: pointer;
    position: absolute;
    top: 24px;
    right: 16px;
    padding: 4px;
}

@media (max-width: 768px) {
    .close-sidebar { display: block; } /* โชว์เฉพาะมือถือ */
}

/* ส่วนหัว Logo */
.sidebar-header {
    padding: 0 12px 32px 12px;
    display: flex;
    align-items: center;
    justify-content: center; /* เพิ่มบรรทัดนี้เพื่อจัดให้อยู่ตรงกลางแนวนอน */
    position: relative;     /* เพิ่มเพื่อให้ปุ่มปิด (X) อ้างอิงตำแหน่งได้ถูกต้อง */
}

.nav-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #ffffff;
    font-weight: 700;
}

/* --- เมนูหลัก --- */
.nav-menu {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.dropdown-toggle, .nav-menu li > a {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    color: #b2c1cd;
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 500;
    border-radius: 8px;
    transition: all 0.2s ease;
    cursor: pointer;
    border: none;
    background: transparent;
    width: 100%;
    box-sizing: border-box;
}

.dropdown-toggle:hover, .nav-menu li > a:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #38bdf8;
}

/* ไอคอนเมนู */
.nav-icon {
    margin-right: 12px;
    width: 20px;
    height: 20px;
    stroke: currentColor;
    flex-shrink: 0;
}

/* ลูกศร Dropdown (Chevron) */
.arrow-down {
    margin-left: auto;
    transition: transform 0.3s ease;
    opacity: 0.7;
    width: 16px;
    height: 16px;
}

.nav-item-dropdown.active .arrow-down {
    transform: rotate(180deg);
}

/* สีตัวหนังสือตอนเปิดเมนูย่อย */
.nav-item-dropdown.active .dropdown-toggle {
    color: #38bdf8;
    background: rgba(255, 255, 255, 0.1); /* เพิ่มพื้นหลังให้สว่างขึ้น */
}

/* --- Submenu (กล่องขาวลอยตัวตามรูป) --- */
.submenu {
    display: none;
    list-style: none;
    padding: 8px;
    margin: 4px 8px 16px 8px;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05), 0 1px 3px rgba(0,0,0,0.1);
}

.nav-item-dropdown.active .submenu {
    display: block;
    animation: fadeIn 0.3s ease;
}

.submenu li a {
    color: #475569 !important;
    padding: 10px 12px 10px 42px !important;
    font-size: 0.9rem;
    margin: 2px 0;
    border-radius: 8px;
    display: flex;
    align-items: center;
    position: relative;
    text-decoration: none;
}

/* จุดกลมๆ หน้า Submenu */
.submenu li a::before {
    content: '•';
    position: absolute;
    left: 24px;
    font-size: 1.2rem;
    color: #94a3b8;
}

.submenu li a:hover:not(.active-link) {
    background-color: #cbd5e1 !important; /* สีเทาที่เข้มและชัดเจนขึ้น */
    color: #0f172a !important; /* เปลี่ยนตัวหนังสือเป็นสีกรมท่าเข้มจัด เพื่อให้อ่านง่ายตัดกับพื้นเทา */
}

/* แถบสีฟ้า Active */
.submenu li a.active-link {
    background-color: #e0f2fe !important;
    color: #0284c7 !important;
    font-weight: 600;
}

.submenu li a.active-link::before {
    color: #0284c7; /* เปลี่ยนสีจุดให้เป็นสีฟ้าด้วย */
}

/* --- ส่วนเลือกภาษา (Language) --- */
.lang-dropdown {
    margin-top: auto; /* ดันลงล่างสุด */
    border-top: 1px solid rgba(255,255,255,0.1);
    padding-top: 16px;
    position: relative;
}

.selected-lang {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    color: #b2c1cd;
    cursor: pointer;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.1);
    transition: all 0.2s;
}

.selected-lang:hover {
    background: rgba(255,255,255,0.05);
}

.lang-list {
    display: none;
    list-style: none;
    padding: 8px;
    background: #1e293b;
    border-radius: 8px;
    position: absolute;
    top: 100%; /* เปลี่ยนจาก bottom เป็น top เพื่อให้หล่นลงมาด้านล่าง */
    left: 12px;
    right: 12px;
    margin-top: 8px; /* เปลี่ยนจาก margin-bottom เป็น margin-top */
    box-shadow: 0 4px 15px rgba(0,0,0,0.2); /* เปลี่ยนทิศทางเงาลงด้านล่าง */
    z-index: 1001; /* เผื่อกันโดนอะไรบังทับ */
}

/* --- ไฮไลท์ภาษาที่กำลังเลือกอยู่ (Active) --- */
.lang-list li a.active {
    background: rgba(255, 255, 255, 0.1); /* พื้นหลังสว่างขึ้นนิดหน่อย */
    color: #38bdf8 !important;            /* เปลี่ยนตัวอักษรเป็นสีฟ้า */
    font-weight: 600;
}

/* เพิ่ม Hover สำหรับภาษาที่เลือกอยู่ให้สว่างขึ้นอีกนิดเมื่อเอาเมาส์ชี้ */
.lang-list li a.active:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* ปรับระยะห่างข้างในเพื่อให้ดูสมดุล */
.lang-list li a {
    transition: all 0.2s ease;
}

.lang-dropdown.active .lang-list {
    display: flex !important;   /* เปลี่ยนจาก block เป็น flex */
    flex-direction: column;     /* จัดเรียงเป็นแนวตั้ง */
    gap: 5px;                  /* เพิ่มระยะห่างระหว่างแถวตรงๆ 5px */
}

.lang-list li a {
    display: flex;
    align-items: center;
    padding: 10px;
    color: #e2e8f0;
    text-decoration: none;
    border-radius: 6px;
    gap: 10px;
}

.lang-list li a:hover {
    background: rgba(255,255,255,0.1);
}

.flag-img {
    width: 24px;
    border-radius: 2px;
}

/* --- แถบสีสำหรับ Active State ของเมนูหลัก (เช่น Team Management) --- */
.nav-menu > li > a.active-link {
    background: rgba(255, 255, 255, 0.1);
    color: #38bdf8;
}

/* --- Logout --- */
#nav-logout {
    margin-top: 8px;
}
#nav-logout a {
    color: #94a3b8;
}
#nav-logout a:hover {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-5px); }
    to { opacity: 1; transform: translateY(0); }
}

/* =========================================
   Responsive สำหรับมือถือ (Sidebar)
   ========================================= */
@media (max-width: 768px) {
    .main-content {
        margin-left: 0;
    }
    
    .mobile-header {
        display: flex;
    }

    .sidebar {
        transform: translateX(-100%); /* ซ่อนออกไปด้านซ้าย */
    }

    /* คลาสที่สั่งให้ Sidebar แสดงผล */
    .sidebar.active {
        transform: translateX(0);
    }

    .close-sidebar {
        display: block;
    }
}

.lang-switch {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: 20px;
}

.lang-switch a {
    color: #94a3b8;
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
}

.lang-switch a:hover {
    color: #fff;
}

.lang-switch a.active {
    color: #38bdf8;
    font-weight: 700;
}

/* =========================================
   Table Styles (เพิ่มส่วนนี้สำหรับหน้า Table)
   ========================================= */
.table-wrapper {
    overflow-x: auto;
    margin-top: 20px;
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
    color: #333;
}

.data-table th,
.data-table td {
    border: 1px solid #cbd5e1;
    padding: 12px 15px;
    text-align: center;
    vertical-align: middle;
}

.data-table thead th {
    background-color: #f1f5f9;
    /* สีเทาอ่อนแบบ Slate */
    color: #1e293b;
    /* สีตัวอักษรเข้ม */
    font-weight: 600;
}

.data-table tbody tr:nth-child(even) td {
    background-color: #f8fafc;
    /* สลับสีแถว */
}

.data-table tbody tr:hover td {
    background-color: #e0f2fe;
    /* สีฟ้าอ่อนเมื่อเอาเมาส์ชี้ */
}

/* ช่องที่พิมพ์แก้ได้ */
[contenteditable="true"] {
    background: #fff;
    cursor: text;
}

[contenteditable="true"]:focus {
    outline: 2px solid #38bdf8;
    background: #fff;
}

/* =========================================
   Responsive
   ========================================= */
@media (max-width: 1200px) {
    .five-col {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 800px) {
    .five-col {
        grid-template-columns: repeat(2, 1fr);
    }

    .six-col {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 500px) {
    .five-col {
        grid-template-columns: 1fr;
    }

    .six-col {
        grid-template-columns: 1fr;
    }

    .three-col,
    .two-col,
    .weight-row {
        grid-template-columns: 1fr;
    }

    .nav-menu {
        display: none;
    }

    /* ซ่อนเมนูบนมือถือถ้าต้องการ หรือปรับเป็น hamburger */
}

/* =========================================
   Table Actions (Vendor Filter)
   ========================================= */
.table-actions {
    display: flex;
    justify-content: flex-end;
    /* ชิดขวา */
    align-items: center;
    gap: 15px;
    /* ระยะห่างระหว่าง Dropdown แต่ละตัว (ถ้ามีหลายตัว) */
    margin-bottom: 15px;
    flex-wrap: wrap;
}

/* กลุ่มก้อนของ Label + Select */
.filter-group {
    display: flex;
    align-items: center;
    gap: 8px;
    /* ระยะห่างระหว่างตัวหนังสือกับช่องเลือก */
}

.filter-group label {
    margin-bottom: 0;
    /* ลบ margin เดิมของ label ทั่วไป */
    white-space: nowrap;
}

.filter-group select {
    width: 200px;
    cursor: pointer;
}

/* =========================================
   Mobile / Responsive Styles
   ========================================= */

/* 1. ซ่อนปุ่ม Hamburger ในหน้าจอ PC (จอใหญ่กว่า 768px) */
@media screen and (min-width: 769px) {
    .hamburger {
        display: none !important;
    }
}

/* 2. แสดงปุ่ม Hamburger ในหน้าจอมือถือ (จอเล็กกว่า 768px) */
@media screen and (max-width: 768px) {
    .hamburger {
        display: block !important; /* บังคับให้แสดงผล */
        background: none;
        border: none;
        color: white;
        font-size: 1.8rem;
        cursor: pointer;
        padding: 0 10px;
        line-height: 1;
    }
}

/* =========================================
   Utility Classes
   ========================================= */
.hidden {
    display: none !important;
}

/* เพิ่มใหม่: จำกัดความกว้างของ Container สำหรับหน้า Table */
.container-narrow {
    max-width: 1000px;
    /* ปรับตัวเลขนี้ได้ตามความกว้างที่ชอบ (เช่น 800px, 1200px) */
}

.search-link {
    margin-left: 12px;
    /* เว้นระยะห่างจากช่อง Input */
    font-size: 0.9rem;
    /* ขนาดตัวอักษร */
    color: #2563eb;
    /* สีน้ำเงิน (หรือเปลี่ยนสีตามชอบ) */
    text-decoration: none;
    /* ไม่ขีดเส้นใต้ (ปกติ) */
    white-space: nowrap;
    /* บังคับไม่ให้ตัดคำ */
    cursor: pointer;
}

.search-link:hover {
    text-decoration: underline;
    /* ขีดเส้นใต้เมื่อเอาเมาส์ชี้ */
    color: #1d4ed8;
    /* สีเข้มขึ้นตอนชี้ */
}

.action-buttons {
    display: flex;
    gap: 8px;
    /* ระยะห่างระหว่างไอคอนกับปุ่ม */
    justify-content: center;
    /* จัดกึ่งกลางแนวนอน */
    align-items: center;
    /* จัดกึ่งกลางแนวตั้ง */
    width: 100%;
    /* ขยายเต็มความกว้างของ td */
    margin: 0;
    padding: 0;
}

.btn-move {
    width: 24px;
    height: 24px;
    margin: 0 !important;
    /* ล้าง margin เช่นกัน */
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #64748b;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.btn-move:hover {
    background-color: #475569;
}

.btn-move:disabled {
    background-color: #cbd5e1;
    cursor: not-allowed;
    opacity: 0.5;
}

/* ปรับปุ่มลบให้ขนาดเท่ากันเพื่อความสวยงาม */
.btn-delete {
    width: 24px !important;
    /* ฟิกซ์ความกว้าง */
    height: 24px !important;
    /* ฟิกซ์ความสูง */
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0 !important;

    /* *** จุดสำคัญที่แก้ปัญหา *** */
    margin: 0 !important;
    /* ล้าง margin-top: 5px ที่ติดมาจาก Global Button */
    flex: none;
    /* ป้องกันปุ่มบี้ถ้าหน้าจอเล็ก */
}

/* สไตล์สำหรับ Drag & Drop */
.drag-handle {
    width: 24px;
    /* ฟิกซ์ความกว้าง */
    height: 24px;
    /* ฟิกซ์ความสูง */
    display: flex;
    /* ใช้ Flex เพื่อจัดตัวหนังสือข้างใน */
    align-items: center;
    /* จัดแนวตั้งในกล่อง */
    justify-content: center;
    /* จัดแนวนอนในกล่อง */

    cursor: grab;
    font-size: 1.2rem;
    color: #94a3b8;
    user-select: none;
    line-height: 1;
    margin: 0;
    /* ล้าง margin */
    padding: 0;
    /* ล้าง padding */
}

.drag-handle:active {
    cursor: grabbing;
    color: #475569;
}

/* เอฟเฟกต์ตอนกำลังลากแถว */
tr.dragging {
    opacity: 0.5;
    background-color: #e2e8f0;
}

/* เอฟเฟกต์ตอนลากผ่าน (เป้าหมายที่จะวาง) */
tr.drag-over {
    border-bottom: 2px solid #2563eb;
    /* เส้นสีน้ำเงินแสดงตำแหน่งที่จะวาง */
}

/* =========================================
   Active / Inactive Input Styles
   ========================================= */

/* ช่องที่ถูกเลือกมาคำนวณ (Winner) */
.input-winner {
    border: 2px solid #22c55e !important;
    /* ขอบสีเขียว */
    background-color: #f0fdf4 !important;
    /* พื้นหลังเขียวอ่อน */
    color: #15803d !important;
    /* ตัวหนังสือเขียวเข้ม */
    font-weight: 700 !important;
}

/* ช่องที่ไม่ได้ถูกใช้ (Loser) */
.input-loser {
    border: 2px solid #ef4444 !important;
    /* ขอบสีแดง */
    background-color: #fef2f2 !important;
    /* พื้นหลังแดงอ่อน */
    color: #b91c1c !important;
    /* ตัวหนังสือแดงเข้ม */
    font-weight: 500 !important;
}

/* =========================================
   Part Number Autocomplete Styles
   ========================================= */
.suggestion-list {
    position: absolute;
    top: 100%;
    right: 0;             /* เปลี่ยนจาก left: 0 เป็น right: 0 */
    min-width: 100%;       /* กว้างอย่างน้อยเท่ากับช่อง Input */
    width: max-content;    /* ขยายตามเนื้อหา */
    max-width: 350px;      /* ลดความกว้างสูงสุดลงเล็กน้อยเพื่อให้พอดีหน้าจอ Notebook */
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 8px 0 8px 8px; /* ปรับมุมมนให้รับกับขอบขวา */
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    list-style: none;
    padding: 0;
    margin: 0;
    z-index: 1000;
    max-height: 250px;
    overflow-y: auto;
    box-sizing: border-box;
}

.suggestion-list li {
    padding: 10px 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;             /* เพิ่มระยะห่างระหว่างไอคอนกับตัวเลข */
    font-size: 0.9rem;
    color: #334155;
    border-bottom: 1px solid #f1f5f9;
    white-space: nowrap;   /* ป้องกันไม่ให้ตัวหนังสือตัดขึ้นบรรทัดใหม่ */
}

.suggestion-list li span:last-child {
    margin-left: auto;
    padding-left: 15px;
    color: #94a3b8;
    font-size: 0.8rem;
    max-width: 150px;       /* จำกัดความกว้างชื่อสินค้าไม่ให้ยาวจนเกินไป */
    overflow: hidden;
    text-overflow: ellipsis; /* ถ้าชื่อยาวเกินจะแสดง ... */
    white-space: nowrap;
}

.suggestion-list li:hover {
    background-color: #f1f5f9;
}

/* ไอคอนนาฬิกาหน้าข้อความ */
.suggestion-icon {
    color: #94a3b8;
    display: flex;
    align-items: center;
}

.suggestion-highlight {
    font-weight: bold;
    color: #0f172a;
}

/* =========================================
   Image Upload Styles (เพิ่มใหม่)
   ========================================= */
.input-with-image {
    display: flex;
    gap: 8px;
    /* ระยะห่างระหว่างช่องพิมพ์กับปุ่มรูป */
    align-items: center;
}

.input-wrapper-flex {
    flex: 1;
    /* ให้ช่องพิมพ์ยืดเต็มพื้นที่ที่เหลือ */
    position: relative;
}

.image-upload-container {
    width: 36px;
    /* ความสูงเท่ากับ Input ปกติ */
    height: 36px;
    flex: none;
    /* ห้ามยืดหด */
}

.image-upload-label {
    width: 100%;
    height: 100%;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    overflow: hidden;
    transition: all 0.2s;
    color: #64748b;
}

.image-upload-label:hover {
    border-color: #3b82f6;
    background: #f0f9ff;
    color: #3b82f6;
}

.image-upload-label svg {
    width: 20px;
    height: 20px;
}

#image-preview {
    width: 100%;
    height: 100%;
    object-fit: cover;
    /* ให้รูปเต็มกล่องโดยไม่เสียสัดส่วน */
    display: block;
}

/* ซ่อน Input File ของจริง */
.hidden-input {
    display: none;
}

/* =========================================
   History Image Styles
   ========================================= */

/* รูป thumbnail ในตาราง */
.history-thumb {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid #e2e8f0;
    cursor: pointer;
    transition: transform 0.2s;
    background: #fff;
}

.history-thumb:hover {
    transform: scale(1.1);
    border-color: #3b82f6;
}

/* Modal สำหรับดูรูปใหญ่ */
.modal-overlay {
    position: fixed;
    z-index: 2000;
    padding-top: 50px;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    margin: auto;
    display: block;
    max-width: 90%;
    max-height: 90%;
    border-radius: 8px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
    animation: zoom 0.3s;
}

@keyframes zoom {
    from {
        transform: scale(0)
    }

    to {
        transform: scale(1)
    }
}

.close-modal {
    position: absolute;
    top: 20px;
    right: 35px;
    color: #f1f1f1;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
    transition: 0.3s;
}

.close-modal:hover,
.close-modal:focus {
    color: #bbb;
    text-decoration: none;
    cursor: pointer;
}

/* =========================================
   Zoom Controls & Modal Updates
   ========================================= */

/* ปรับ Overlay ให้รองรับการเลื่อนถ้ารูปใหญ่เกิน */
.modal-overlay {
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    /* ซ่อน Scrollbar ของตัว Overlay หลัก */
}

/* Wrapper เพื่อคุมพื้นที่รูปภาพ */
.modal-image-wrapper {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: auto;
    /* ถ้าซูมใหญ่มาก ให้เลื่อนดูได้ */
}

/* ปรับปรุงรูปใน Modal ให้รองรับ Zoom */
.modal-content {
    max-width: 90%;
    max-height: 90%;
    transition: transform 0.2s ease-out;
    /* ซูมลื่นๆ */
    cursor: grab;
    /* เปลี่ยนเมาส์เป็นรูปมือจับ */
    transform-origin: center center;
}

/* แถบปุ่มควบคุมการซูม */
.zoom-controls {
    position: absolute;
    bottom: 80px;
    /* <<< แก้ตรงนี้ครับ ยิ่งเลขมาก ยิ่งสูงขึ้น (ของเดิม 30px) */
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.6);
    padding: 10px 20px;
    border-radius: 30px;
    display: flex;
    gap: 15px;
    z-index: 2001;
}

.zoom-controls button {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    /* ล้างค่าเดิม */
    transition: all 0.2s;
}

.zoom-controls button:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: white;
    transform: scale(1.1);
}

/* ปรับปุ่มปิด (Close) ให้ชัดขึ้น */
.close-modal {
    z-index: 2002;
    /* ให้อยู่เหนือปุ่มซูม */
    background: rgba(0, 0, 0, 0.5);
    width: 40px;
    height: 40px;
    text-align: center;
    line-height: 40px;
    border-radius: 50%;
}

/* =========================================
   Export PDF Button
   ========================================= */
.btn-export-pdf {
    background-color: #ef4444;
    /* สีแดง */
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    width: auto;
    /* ไม่ให้เต็มจอเหมือนปุ่มอื่น */
    transition: background-color 0.2s;
    margin-top: 0;
}

.btn-export-pdf:hover {
    background-color: #dc2626;
}

.btn-export-pdf svg {
    width: 18px;
    height: 18px;
}

.flag-img {
    width: 22px;/* ความกว้างธง */
    height: auto;/* ความสูงปรับอัตโนมัติ */
    border-radius: 2px;/* มุมมนนิดหน่อย */
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);/* เงาบางๆ ให้ดูมีมิติ */
    display: block;
}

/* ปรับให้ Dropdown สวยขึ้นอีกนิด */
.lang-list a {
    gap: 12px !important;
    /* เพิ่มระยะห่างระหว่างธงกับตัวหนังสือ */
}

/* =========================================
   NOTEBOOK & LAPTOP RESPONSIVE FIX
   ========================================= */
@media screen and (min-width: 769px) and (max-width: 1600px) { 
    
    body {
        zoom: 0.85; 
        min-height: 118vh !important; 
    }

    .sidebar {
        height: 118vh !important; 
    }

    .main-content {
        min-height: 118vh !important;
        margin-left: 260px;
    }

    /* กล่องปกติ (เช่นหน้า Freight ที่มี 2 ฝั่ง) */
    .container {
        width: 100% !important;
        max-width: 1450px !important; 
        margin: 20px auto !important;
        padding: 0 20px !important;
    }

    /* ล็อคความกว้างให้หน้ากล่องเดี่ยว (เช่น Duty, History, Table) ให้แคบลงสวยงาม */
    .container.container-narrow {
        max-width: 1000px !important; 
    }

    .cards-vertical {
        display: grid !important;
        grid-template-columns: 1fr 1.3fr !important; 
        align-items: start !important;
        gap: 20px !important;
    }
}

/* แก้ไข Autocomplete ให้กางเข้าหาด้านในจอ (ป้องกันล้นขอบขวา) */
.suggestion-list {
    position: absolute;
    top: 100%;
    right: 0;             
    left: auto;           
    min-width: 100%;
    width: max-content;
    max-width: 400px;
    border-radius: 8px 0 8px 8px; 
    box-shadow: 0 10px 25px rgba(0,0,0,0.15);
}

/* ช่วยให้การเปลี่ยนสีกรอบแดงดู Smooth ขึ้น */
input, select {
    transition: border-color 0.2s ease;
}