/* =========================================================
   navmenu.css — เมนูด้านซ้าย
   โลโก้ด้านบนและท้ายเมนูอยู่กับที่เสมอ เลื่อน (scroll) ได้เฉพาะรายการเมนูตรงกลาง
   ========================================================= */

.sidebar {
    height: 100%;
    display: flex;
    flex-direction: column;
    gap: var(--sb-gap);
    padding: var(--sb-pad);
    overflow: hidden;
    background: var(--c-sidebar);
    color: #fff;
}

/* ---------- โลโก้ + ชื่อระบบ ---------- */
.sidebar-brand {
    flex: none;
    display: flex;
    align-items: center;
    gap: var(--brand-gap);
    padding-top: 3px;
}

.sidebar-brand img {
    width: var(--brand-img-w);
    height: var(--brand-img-h);
    flex: none;
    object-fit: contain;
}

.sidebar-brand-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.sidebar-brand-title {
    font-family: var(--font-head);
    font-size: var(--brand-title-fs);
    font-weight: 500;
    letter-spacing: .2px;
    line-height: 1.2;
    white-space: nowrap;
}

.sidebar-brand-sub {
    font-family: var(--font-head);
    font-size: var(--brand-sub-fs);
    opacity: .9;
    white-space: nowrap;
}

/* ---------- รายการเมนู (ส่วนที่ scroll ได้) ---------- */
.nav {
    flex: 1;
    min-height: 0;          /* จำเป็น: ให้กล่องเมนูหดได้และเกิด scroll ภายในตัวเอง */
    overflow-y: auto;
    overscroll-behavior: contain;
    display: flex;
    flex-direction: column;
    gap: var(--nav-gap);
    margin: 0 -8px;         /* เว้นที่ให้แถบ scroll ไม่ไปเบียดปุ่มเมนู */
    padding: 0 8px;

    /* แถบ scroll แบบบาง สีกลืนกับเมนู (Firefox) */
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, .3) transparent;
}

/* แถบ scroll แบบบาง (Chrome / Edge) */
.nav::-webkit-scrollbar {
    width: 6px;
}

.nav::-webkit-scrollbar-track {
    background: transparent;
}

.nav::-webkit-scrollbar-thumb {
    border-radius: 3px;
    background: rgba(255, 255, 255, .3);
}

.nav::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, .5);
}

.nav-item {
    flex: none;             /* ไม่ให้ปุ่มเมนูถูกบีบเตี้ยลงเมื่อพื้นที่ไม่พอ */
    display: flex;
    align-items: center;
    gap: var(--nav-item-gap);
    width: 100%;
    height: var(--nav-h);
    padding: 0 var(--nav-pad-x);
    border: 0;
    border-radius: var(--nav-radius);
    background: transparent;
    color: #fff;
    font-size: var(--nav-fs);
    text-align: left;
    text-decoration: none;
    cursor: pointer;
}

.nav-item:hover {
    background: var(--c-sidebar-hover);
    color: #fff;
}

/* NavLink ใส่ class "active" ให้เองเมื่ออยู่หน้านั้น */
.nav-item.active {
    background: var(--c-sidebar-active);
}

.nav-item .ms {
    width: var(--nav-icon-w);
    font-size: var(--nav-icon);
    flex: none;
    text-align: center;
}

/* เมนูย่อย (ใต้ "ข้อมูลอุปกรณ์") */
.nav-item.nav-sub {
    height: var(--nav-sub-h);
    padding-left: var(--nav-sub-pad);
    font-size: var(--nav-sub-fs);
}

/* หัวกลุ่มเมนู */
.nav-group .nav-chevron {
    margin-left: auto;
    width: auto;
    opacity: .75;
    transition: transform .15s ease;
}

.nav-group.open .nav-chevron {
    transform: rotate(180deg);
}

/* อยู่ในหน้าย่อยของกลุ่ม แต่ปิดเมนูย่อยไว้: ไฮไลต์หัวกลุ่มแทน */
.nav-group.has-active:not(.open) {
    background: var(--c-sidebar-active);
}

/* ---------- ท้ายเมนู ---------- */
.sidebar-foot-logo {
    flex: none;
    align-self: flex-start;
    display: flex;
    align-items: center;
    padding: var(--foot-logo-pad);
    border-radius: var(--foot-logo-radius);
    background: #fff;
}

.sidebar-foot-logo img {
    display: block;
    height: var(--foot-logo-h);
    width: auto;
}

.sidebar-copyright {
    flex: none;
    margin: var(--copy-mt) -9px 0;
    font-size: var(--copy-fs);
    color: rgba(255, 255, 255, .6);
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

@media (prefers-reduced-motion: reduce) {
    .nav-group .nav-chevron { transition: none; }
}
