/* ========================================================== */
/*  1. General & Basic Styles
/* ========================================================== */
body {
    font-family: 'Noto Sans Lao', sans-serif;
    background-color: #f3f3f3; /* ສີພື້ນຫຼັງອ່ອນໆ */
}

/* ເພື່ອໃຫ້ມີພື້ນທີ່ສຳລັບ Top Bar ແລະ Bottom Nav ທີ່ຕິດຢູ່ກັບທີ່ */
.body-with-nav {
    padding-top: 75px; /* ເພີ່ມ padding ເທິງເລັກນ້ອຍ ເພື່ອບໍ່ໃຫ້ Top Bar ຕິດເກີນໄປ */
    padding-bottom: 80px; /* (ປັບປຸງ) ເພີ່ມ padding ລຸ່ມໃຫ້ຫຼາຍຂຶ້ນ */
}
/* ========================================================== */
/*  2. Top Bar (ແຖບເທິງ)
/* ========================================================== */
.top-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background-color: #c82333; /* ສີແດງ */
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
    z-index: 1040; /* ໃຫ້ຢູ່ເທິງສຸດ */
}

.top-bar-item {
    flex: 1 0 0;
}

.top-bar-item:last-child {
    text-align: right;
}

.top-bar-item-center {
    flex: 2 0 0;
    text-align: center;
}

.app-logo {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
}

.app-title {
    font-weight: bold;
    font-size: 1.2rem;
    color: white;
}

.scan-button {
    max-width: 350px;
    width: 100%;
    font-weight: 500;
}

/* ========================================================== */
/*  3. Bottom Navigation (ແຖບລຸ່ມ)
/* ========================================================== */
/*  3. Bottom Navigation (ແຖບລຸ່ມ) - ສະບັບປັບປຸງ
/* ========================================================== */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    /* (ປັບປຸງ) ປ່ຽນສີພື້ນຫຼັງ */
    background-color: #c82333; /* ສີແດງ */
    /* (ລຶບອອກ) ບໍ່ຈຳເປັນຕ້ອງມີເສັ້ນຂອບເທິງອີກ */
    /* border-top: 1px solid #e0e0e0; */
    display: flex;
    justify-content: space-around;
    z-index: 1040;
    box-shadow: 0 -2px 5px rgba(0,0,0,0.1); /* ເພີ່ມເງົາດ້ານເທິງ */
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex-grow: 1;
    /* (ປັບປຸງ) ປ່ຽນສີຕົວໜັງສືເລີ່ມຕົ້ນ */
    color: rgba(255, 255, 255, 0.7); /* ສີຂາວ ແຕ່ຈາງລົງເລັກນ້ອຍ */
    text-decoration: none;
    font-size: 1rem;
    transition: all 0.2s ease;
}

.nav-item i {
    font-size: 1.8rem;
    margin-bottom: 2px;
}

/* (ປັບປຸງ) ສະຖານະ Active */
.nav-item.active {
    color: #ffffff; /* ສີຂາວເຂັ້ມ */
    font-weight: bold;
    background-color: rgba(0, 0, 0, 0.1); /* ເພີ່ມສີພື້ນຫຼັງເຂັ້ມຂຶ້ນເລັກນ້ອຍ */
}

/* (ປັບປຸງ) ສະຖານະ Hover */
.nav-item:hover {
    color: #ffffff;
    background-color: rgba(0, 0, 0, 0.05);
}


/* ========================================================== */
/*  4. POS Page Layout
/* ========================================================== */

/* ================== NEW POS LAYOUT (Horizontal Categories) ================== */

.pos-page-container {
    display: grid;
    /* (Desktop First) ຄ່າເລີ່ມຕົ້ນສຳລັບຈໍໃຫຍ່ */
    grid-template-columns: 1fr 400px;
    gap: 1rem;
    height: calc(100vh - 80px); /* ຄວາມສູງເຕັມຈໍ ລົບ Top Bar ແລະ Padding */
    padding: 1rem;
}

/* ຖັນກາງ/ຊ້າຍ (ໝວດໝູ່ + ສິນຄ້າ) */
.pos-main-panel {
    display: flex;
    flex-direction: column; /* ໃຫ້ໝວດໝູ່ຢູ່ເທິງ, ສິນຄ້າຢູ່ລຸ່ມ */
    overflow: hidden; /* ສຳຄັນ: ປ້ອງກັນບໍ່ໃຫ້ຖັນນີ້ມີ scrollbar ຂອງຕົນເອງ */
}
#product-list {
    font-size: 1rem;
    flex-grow: 1;
    overflow-y: auto;
    padding-right: 8px;
    
}
/* ຖັນຊ້າຍ/ກາງ (ໝວດໝູ່ + ສິນຄ້າ) */
.pos-main-panel {
    display: flex;
    flex-direction: column;
    padding-right: 1rem;
    overflow: hidden; /* ສຳຄັນ */
}

#product-list {
    flex-grow: 1; /* ໃຫ້ມັນຍืดເຕັມທີ່ */
    overflow-y: auto; /* ສ້າງ scrollbar */
    padding-right: 5px;
}

/* ຖັນຂວາ (ກະຕ່າ) */
.pos-right-panel {
    width: 400px; /* ກຳນົດຄວາມກວ້າງຄົງທີ່ */
    flex-shrink: 0; /* ບໍ່ໃຫ້ມັນຫຍໍ້ຕົວເອງ */
    display: flex;
    flex-direction: column;
    height: 100%; /* ໃຫ້ມັນສູງເຕັມ container */
}

.pos-right-panel .card {
    border: none;
    box-shadow: none;
}

.pos-right-panel .card:last-child {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}


#cart-items {
    flex-grow: 1; /* (ສຳຄັນ) ໃຫ້ສ່ວນລາຍການໃນກະຕ້າຍืด */
    overflow-y: auto; /* ແລະ ມີ scrollbar ຂອງຕົນເອງ */
}


/* --- Responsive --- */
@media (max-width: 1199.98px) {
    .pos-right-panel {
        display: none; /* ເຊື່ອງກະຕ່າໃນຈໍ Tablet */
    }
    .mobile-cart-btn {
        display: flex !important;
    }
}
/* ... CSS ຂອງ Horizontal Category Scrollbar ຄືເກົ່າ ... */


/* ================== (ປັບປຸງໃໝ່) RESPONSIVE ================== */

/* --- ຈໍ Tablet (ນ້ອຍກວ່າ 1200px) --- */
@media (max-width: 1199.98px) {
    .pos-page-container {
        /* ປ່ຽນເປັນ 1 ຖັນ ແລະ ເຊື່ອງຖັນຂວາ */
        grid-template-columns: 1fr;
    }
    .pos-right-panel {
        display: none;
    }
}

/* --- ຈໍມືຖື (ນ້ອຍກວ່າ 768px) --- */
@media (max-width: 767.98px) {
    /* ເມື່ອເປັນຈໍມືຖື, Bottom Navigation ຈະເປັນເມນູຫຼັກ */
    /* ເຮົາສາມາດເຊື່ອງໝວດໝູ່ແບບເລື່ອນຂ້າງເທິງໄດ້ ເພື່ອເພີ່ມພື້ນທີ່ */
    .category-horizontal-scroll {
        display: none;
    }
    .pos-page-container {
        padding: 0.5rem;
        gap: 0.5rem;
    }
}

/* --- Horizontal Category Scrollbar --- */
.category-horizontal-scroll {
    width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    white-space: nowrap;
    background-color: #ffffff;
    padding: 8px 0;
    border-radius: 0.375rem;
}
.category-items-wrapper {
    display: inline-block;
}
.category-item {
    display: inline-flex;
    align-items: center;
    padding: 8px 16px;
    margin: 0 4px;
    border-radius: 50px;
    background-color: #f1f1f1;
    color: #333;
    text-decoration: none;
    font-size: 1rem;
    font-weight: 500;
    transition: all 0.2s ease;
    cursor: pointer;
}
.category-item i {
    margin-right: 6px;
}
.category-item:hover {
    background-color: #e0e0e0;
}
.category-item.active {
    background-color: #c82333;
    color: #ffffff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.category-horizontal-scroll::-webkit-scrollbar {
    height: 4px;
}
.category-horizontal-scroll::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 2px;
}


/* ========================================================== */
/*  5. Other Styles (Dashboard, etc.)
/* ========================================================== */
.management-card {
    color: #212529;
    transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
}
.management-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15) !important;
}

.management-card-danger {
    color: #dc3545;
    border-color: #f5c2c7;
    transition: all 0.2s ease-in-out;
}
.management-card-danger:hover {
    color: #ffffff;
    background-color: #dc3545;
    border-color: #dc3545;
    transform: translateY(-5px);
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15) !important;
}
/* ================== Custom Product Grid (8 Columns) ================== */

/* ================== Custom Product Grid (Responsive) ================== */

#product-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.75rem;
    align-content: start;
}

/* (ປັບປຸງ) ບັງຄັບໃຫ້ຊື່ສິນຄ້າໃຫຍ່ຂຶ້ນ */
.product-card .product-name {
    font-size: 16px !important; /* <<-- ປັບຂະໜາດເປັນ 16px */
    font-weight: 700; /* <<-- ເພີ່ມຄວາມໜາ */
    line-height: 1.3; /* ຄວາມສູງຂອງແຕ່ລະແຖວ */
    
    /* 
     *  ປັບຄວາມສູງໃຫ້ພໍດີກັບ 2 ແຖວຂອງ font-size 16px
     *  ຄຳນວນ: 16px * 1.3 (line-height) * 2 (จำนวนบรรทัด) ≈ 42px
     */
    height: 42px; 
    
    /* CSS ສຳລັບຕັດຂໍ້ຄວາມທີ່ຍາວເກີນ 2 ແຖວ */
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* ປັບລາຄາໃຫ້ມີຂະໜາດເໝາະສົມ */
.product-card .product-price {
    font-size: 14px !important; 
    font-weight: 700;
    color: #dc3545; /* ສີແດງຂອງ Bootstrap */
}
/* (ປັບປຸງ) ລາຍການສັ່ງຊື້ - ສະບັບກະທັດຮັດ */
.cart-item {
    margin-bottom: 6px; /* ຫຼຸດຊ່ອງວ່າງ */
}
.cart-item .fw-bold {
    font-size: 0.8rem; /* ຫຼຸດຂະໜາດຊື່ສິນຄ້າ */
}
.cart-item .text-danger {
    font-size: 0.8rem; /* ຫຼຸດຂະໜາດລວມ */
}
.cart-item small {
    font-size: 0.7rem; /* ຫຼຸດຂະໜາດລາຄາຕໍ່ໜ່ວຍ */
}
.cart-item .input-group-sm {
    width: 90px; /* ຫຼຸດຂະໜາດປຸ່ມ +/- */
}
/* ========================================================== */
/*  Floating Cart Button
/* ========================================================== */

.floating-cart-btn {
    position: fixed; /* ຕຳແໜ່ງຄົງທີ່, ເລື່ອນຕາມໜ້າຈໍ */
    bottom: 80px; /* ໄລຍະຫ່າງຈາກຂອບລຸ່ມ (ໃຫ້ຢູ່ເທິງ Bottom Nav) */
    right: 20px; /* ໄລຍະຫ່າງຈາກຂອບຂວາ */
    width: 60px;
    height: 60px;
    background-color: #c82333; /* ສີແດງ */
    color: white;
    border-radius: 50%; /* ເຮັດໃຫ້ເປັນວົງກົມ */
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem; /* ຂະໜາດໄອຄອນ */
    cursor: pointer;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    z-index: 1045; /* ໃຫ້ຢູ່ເທິງເນື້ອຫາ, ແຕ່ຕ່ຳກວ່າ Modal */
    transition: transform 0.2s ease;
}

.floating-cart-btn:hover {
    transform: scale(1.1);
}

.floating-cart-btn .badge {
    position: absolute;
    top: 0;
    right: 0;
    font-size: 0.8rem;
    padding: 4px 7px;
    border: 2px solid white;
    display: none; /* ເຊື່ອງໄວ້ກ່ອນ */
}

/* ສະແດງ Badge ເມື່ອມີ class 'show' */
.floating-cart-btn .badge.show {
    display: block;
}