/* --- CÀI ĐẶT CƠ BẢN --- */
:root {
    --header-height-initial: 60px;
    --header-height-scrolled: 50px;
    --sidebar-width-expanded: 20%;
    --sidebar-width-collapsed: 50px;
    --main-green: #28a745; /* Màu xanh lá cây bạn yêu cầu */
    --text-dark: #333;
    --text-light: #fff;
    --border-color: #ddd;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    line-height: 1.6;
    color: var(--text-dark);
    /* Đảm bảo nội dung luôn nằm bên dưới header cố định */
    padding-top: var(--header-height-initial);
}

h1, h2, h3, h4, h5, h6 {
    margin-bottom: 0.75rem;
    font-weight: 600;
}

ul {
    margin-left: 20px;
    margin-bottom: 1rem;
}

li {
    margin-bottom: 0.5rem;
}

/* --- HEADER --- */
#header {
    background-color: var(--main-green);
    color: var(--text-light);
    height: var(--header-height-initial);
    width: 100%;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 20px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    transition: height 0.3s ease;
}

#header.scrolled {
    height: var(--header-height-scrolled);
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 1400px; /* Giữ nội dung header ở trung tâm trên màn hình lớn */
}

.logo {
    height: 40px;
    width: auto;
    margin-right: 15px;
    transition: height 0.3s ease;
}

#header.scrolled .logo {
    height: 35px;
}

#header h1 {
    font-size: 1.25rem;
    margin: 0;
    font-weight: 500;
}

/* --- BỐ CỤC CHÍNH (Sidebar + Nội dung) --- */
.container {
    display: flex;
    width: 100%;
}

/* --- SIDEBAR MENU --- */
#sidebar {
    width: var(--sidebar-width-expanded);
    min-width: var(--sidebar-width-expanded);
    background: #f4f4f4;
    height: calc(100vh - var(--header-height-initial));
    position: sticky;
    top: var(--header-height-initial); /* Dính dưới header */
    overflow-y: auto;
    transition: width 0.3s ease, min-width 0.3s ease, top 0.3s ease;
    border-right: 1px solid var(--border-color);
}

#sidebar.scrolled {
    /* Đảm bảo sidebar dính dưới header đã thu nhỏ */
    height: calc(100vh - var(--header-height-scrolled));
    top: var(--header-height-scrolled);
}

#toggle-sidebar-btn {
    display: block;
    width: 100%;
    padding: 10px;
    background: #e0e0e0;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    text-align: left;
    padding-left: 15px;
    border-bottom: 1px solid var(--border-color);
}

#toggle-sidebar-btn:hover {
    background: #d5d5d5;
}

#menu-list {
    list-style: none;
    margin: 0;
}

#menu-list li {
    padding: 12px 15px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.9rem; /* Font chữ vừa phải như yêu cầu */
    font-weight: 500;
    display: flex;
    align-items: center;
    white-space: nowrap;
    overflow: hidden;
    margin-bottom: 0; /* Ghi đè margin-bottom mặc định của li */
}

#menu-list li:hover {
    background: #e9e9e9;
}

#menu-list li.active {
    background: var(--main-green);
    color: var(--text-light);
    font-weight: 700;
}

.menu-number {
    display: none; /* Ẩn số thứ tự khi mở rộng */
    font-weight: 700;
    width: 20px; /* Đảm bảo căn chỉnh */
    text-align: center;
}

.menu-text {
    margin-left: 10px;
}

/* Trạng thái thu gọn của Sidebar */
#sidebar.collapsed {
    width: var(--sidebar-width-collapsed);
    min-width: var(--sidebar-width-collapsed);
}

#sidebar.collapsed #toggle-sidebar-btn {
    text-align: center;
    padding-left: 0;
}

#sidebar.collapsed .menu-text {
    display: none; /* Ẩn chữ */
}

#sidebar.collapsed .menu-number {
    display: block; /* Hiện số */
    margin: 0;
    width: 100%;
}

#sidebar.collapsed #menu-list li {
    justify-content: center;
    padding: 12px 10px;
}


/* --- NỘI DUNG CHÍNH --- */
#content-display {
    width: calc(100% - var(--sidebar-width-expanded));
    padding: 30px;
    overflow-y: auto;
    transition: width 0.3s ease;
}

#content-display.expanded {
    width: calc(100% - var(--sidebar-width-collapsed));
}

#content-display h2 {
    color: var(--main-green);
    border-bottom: 2px solid var(--main-green);
    padding-bottom: 10px;
}

#content-display h3 {
    color: var(--text-dark);
    font-weight: 700;
    margin-top: 20px;
}

#content-display blockquote {
    background: #f9f9f9;
    border-left: 5px solid var(--main-green);
    margin: 15px 0;
    padding: 15px;
    font-style: italic;
}

#content-display table {
    width: 100%;
    border-collapse: collapse;
    margin: 15px 0;
}

#content-display th, #content-display td {
    border: 1px solid var(--border-color);
    padding: 8px;
    text-align: left;
}

#content-display th {
    background: #f4f4f4;
}

#content-display pre {
    background: #eee;
    padding: 15px;
    border-radius: 5px;
    font-family: "Courier New", Courier, monospace;
    overflow-x: auto;
}

/* --- FOOTER --- */
footer {
    background: #333;
    color: #aaa;
    padding: 15px;
    text-align: center;
    font-size: 0.85rem;
    max-height: 70px; /* Tăng nhẹ để chứa 2 dòng trên mobile */
    border-top: 3px solid var(--main-green);
}

footer p {
    margin: 0;
}

/* --- RESPONSIVE DESIGN (Cho di động & máy tính bảng) --- */
@media (max-width: 768px) {
    body {
        /* Trên di động, header luôn là 50px */
        padding-top: var(--header-height-scrolled);
    }
    
    #header {
        height: var(--header-height-scrolled);
        padding: 0 10px;
    }
    
    #header.scrolled {
        height: var(--header-height-scrolled);
    }
    
    .logo {
        height: 30px;
    }
    
    #header.scrolled .logo {
        height: 30px;
    }

    #header h1 {
        font-size: 0.85rem; /* Thu nhỏ tiêu đề cho vừa màn hình */
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .container {
        flex-direction: column; /* Xếp chồng sidebar và nội dung */
    }

    #sidebar {
        width: 100%;
        height: auto; /* Tự động co giãn theo nội dung */
        position: static; /* Không dính nữa */
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }

    #sidebar.collapsed {
        width: 100%;
    }

    /* Trên di động, menu luôn ở dạng thu gọn */
    #toggle-sidebar-btn {
        display: none; /* Ẩn nút toggle */
    }

    #menu-list {
        display: flex;
        flex-wrap: wrap; /* Cho các số tự động xuống hàng */
        justify-content: center;
    }

    #menu-list li {
        width: 40px; /* Kích thước của 1 ô số */
        height: 40px;
        padding: 0;
        margin: 5px;
        border: 1px solid var(--border-color);
        border-radius: 5px;
        justify-content: center;
        flex-shrink: 0;
    }

    .menu-text {
        display: none;
    }
    .menu-number {
        display: block;
        margin: 0;
        width: auto;
    }

    #content-display {
        width: 100%;
        padding: 20px 15px;
    }

    #content-display.expanded {
        width: 100%;
    }
    
    footer {
        max-height: 100px;
    }
}