/* --- Global Variables --- */
:root {
    --bg-body: #fdfbf7;      /* สีพื้นหลังครีมอ่อน */
    --bg-sidebar: #ffffff;   /* สีพื้นหลังเมนู */
    --primary-color: #0d6efd;
    --text-main: #333;
    --sidebar-width: 320px;
    --header-height: 60px;
}

body {
    font-family: 'Sarabun', sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    overflow-x: hidden;
}

/* --- Layout Structure (Wrapper) --- */
.wrapper {
    display: flex;
    width: 100%;
    align-items: stretch;
}

/* Sidebar Styling */
#sidebar {
    min-width: var(--sidebar-width);
    max-width: var(--sidebar-width);
    min-height: 100vh;
    background: var(--bg-sidebar);
    border-right: 1px solid #eee;
    transition: all 0.3s;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1000;
    overflow-y: auto;
}

#sidebar.active {
    margin-left: calc(var(--sidebar-width) * -1);
}

/* Main Content Styling */
#content {
    width: 100%;
    padding: 20px;
    min-height: 100vh;
    transition: all 0.3s;
    margin-left: var(--sidebar-width);
}

#content.full-width {
    margin-left: 0;
}

/* --- Menu Items & Components --- */
.sidebar-header {
    padding: 20px;
    background: var(--bg-sidebar);
    border-bottom: 1px solid #eee;
}

.menu-link {
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #555;
    text-decoration: none;
    font-weight: 600;
    border-left: 4px solid transparent;
    cursor: pointer;
}

.menu-link:hover {
    background-color: #f8f9fa;
    color: var(--primary-color);
}

.sub-menu {
    list-style: none;
    padding: 0;
    margin: 0;
    background-color: #fcfcfc;
}

.sub-menu li a {
    padding: 10px 20px 10px 45px;
    display: block;
    font-size: 0.9rem;
    color: #666;
    text-decoration: none;
    transition: 0.2s;
}

.sub-menu li a:hover {
    background-color: #e9ecef;
    color: var(--primary-color);
    padding-left: 50px;
}

.rotate-icon {
    transition: transform 0.3s;
}

.menu-link[aria-expanded="true"] .rotate-icon {
    transform: rotate(180deg);
}

.btn-toggle {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #333;
    cursor: pointer;
    padding: 5px 10px;
    border-radius: 5px;
}

.btn-toggle:hover {
    background-color: #e2e6ea;
}

:not(pre) > code {
    background-color: #e9ecef;  /* พื้นหลังสีเทาอ่อน สบายตา */
    color: #212529;             /* ตัวหนังสือสีดำเข้ม เพื่อความคมชัด */
    padding: 0.2rem 0.4rem;     /* เพิ่มระยะห่างรอบตัวอักษรนิดหน่อย */
    border-radius: 4px;         /* ลบเหลี่ยมมุมให้ดูนุ่มนวล */
    font-size: 0.9em;           /* ปรับขนาดให้เล็กกว่าข้อความปกตินิดเดียว */
    border: 1px solid #dce0e3;  /* ใส่ขอบจางๆ ให้ดูมีมิติขึ้น */
}

/* --- Responsive Behavior (Mobile) --- */
@media (max-width: 768px) {
    #sidebar { margin-left: calc(var(--sidebar-width) * -1); }
    #sidebar.active { margin-left: 0; }
    #content { margin-left: 0; }
    
    #overlay {
        display: none;
        position: fixed;
        width: 100vw;
        height: 100vh;
        background: rgba(0, 0, 0, 0.5);
        z-index: 998;
        top: 0;
        left: 0;
    }
    #overlay.active { display: block; }
}