@import url('https://fonts.googleapis.com/css2?family=Sarabun:ital,wght@0,400;0,700;1,400;1,700&display=swap');

:root {
    --cui-sidebar-bg: #181818;
    --cui-sidebar-width: 16rem;
    --cui-sidebar-narrow-width: 5rem;
}

[data-bs-theme="dark"] body {
    background-color: #121212;
}

body {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Sarabun", sans-serif;
    background-color: #ebedef;
    font-size: 16px; 
    line-height: 1.6;
    overflow: hidden;
    margin: 0;
}

/* Layout Structure */
.main-wrapper {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
    height: 100vh;
}

.content-area {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
}

/* Sidebar Navigation */
.sidebar {
    width: var(--cui-sidebar-width);
    background-color: var(--cui-sidebar-bg);
    transition: width 0.3s ease-in-out;
    display: flex;
    flex-direction: column;
    color: #fff;
    height: 100vh;
    flex-shrink: 0;
    overflow: hidden;
    scrollbar-gutter: stable;

    /* สำหรับ Firefox */
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

.sidebar-nav {
    flex: 1;              /* สั่งให้เมนูกินพื้นที่ที่เหลือทั้งหมดจากบนลงล่าง */
    overflow-y: auto;     /* เปิดการสกอเฉพาะส่วนนี้ */
    overflow-x: hidden;    /* ป้องกันการเลื่อนซ้ายขวาที่ไม่ได้ตั้งใจ */
    scrollbar-gutter: stable; /* ป้องกันเมนูกระตุกเวลาแถบสกอโผล่มา */
}

/* ตกแต่งแถบสโครลสำหรับ Chrome, Edge, Safari */
.sidebar::-webkit-scrollbar {
    width: 6px; /* ปรับให้บางลงดูแพง */
}

.sidebar::-webkit-scrollbar-track {
    background: transparent; 
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2); /* สีขาวจางๆ ให้เข้ากับพื้นหลังมืด */
    border-radius: 10px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

.nav-link {
    color: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    text-decoration: none;
    transition: background-color 0.2s, color 0.2s;
    white-space: nowrap;
    gap: 0.75rem;
}

.nav-link:hover {
    color: #fff;
    background-color: rgba(255, 255, 255, 0.05);
}

.nav-link.active {
    color: #fff;
    background-color: rgba(255, 255, 255, 0.1);
}

/* Dropdown Arrow Animation */
.transition-icon {
    transition: transform 0.3s ease;
}
.nav-link[aria-expanded="true"] .transition-icon {
    transform: rotate(180deg);
}

.nav-header {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.6);
    padding: 1rem 1rem 0.5rem;
}

/* Sidebar Toggle (Narrow Mode) */
.sidebar-narrow {
    width: var(--cui-sidebar-narrow-width);
}

.sidebar-narrow .nav-label, 
.sidebar-narrow .nav-badge, 
.sidebar-narrow .sidebar-brand-text, 
.sidebar-narrow .nav-header,
.sidebar-narrow #importCollapse { 
    display: none !important;
}

.sidebar-narrow .nav-link {
    justify-content: center !important;
    padding: 0.75rem 0 !important;
}

/* Pagination & Table Styles */
.pagination .page-item .page-link {
    width: 35px; 
    height: 35px; 
    border-radius: 50% !important;
    display: flex; 
    align-items: center; 
    justify-content: center; 
    margin: 0 3px;
}

.table-light-header th {
    color: #495057 !important;
    font-weight: 700 !important;
    font-size: 0.9rem;
    letter-spacing: 0.5px;
}

/* Responsive Logic */
@media (max-width: 1279px) {
    .sidebar {
        width: var(--cui-sidebar-narrow-width) !important;
    }
    .sidebar .nav-label, .sidebar .nav-header, .sidebar .sidebar-brand-text {
        display: none !important;
    }
}

@media (max-width: 767px) {
    .sidebar {
        width: 100% !important;
        position: fixed;
        z-index: 1050;
        left: -100%; 
    }
    .sidebar.show { left: 0; }
}