* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

html {
    scroll-behavior: smooth;
}

body {
    background-color: #f8fafc;
    color: #334155;
    display: flex;
    min-height: 100vh;
    width: 100vw;
    overflow-x: hidden;
}

/* --- Layout โครงสร้างหลัก --- */
.app-container {
    display: flex;
    width: 100%;
    min-height: 100vh;
}

/* --- Sidebar เมนูด้านซ้าย --- */
.sidebar {
    width: 320px;
    background-color: #ffffff;
    border-right: 1px solid #e2e8f0;
    height: 100vh;
    position: sticky;
    top: 0;
    overflow-y: auto;
    overflow-x: hidden;
    flex-shrink: 0;
    transition: width 0.3s ease;
    white-space: nowrap;
}

.sidebar.collapsed {
    width: 0;
    border-right: none;
}

.brand {
    padding: 20px;
    border-bottom: 1px solid #f1f5f9;
}

.brand h2 {
    font-size: 1.2rem;
    color: #0f172a;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.brand span {
    color: #2563eb;
}

/* Accordion Menu */
.menu-container {
    padding: 12px 0;
}

.accordion-item {
    border-bottom: 1px solid #f1f5f9;
}

.accordion-header {
    width: 100%;
    padding: 14px 20px;
    background: none;
    border: none;
    text-align: left;
    font-size: 0.9rem;
    font-weight: 600;
    color: #1e293b;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background-color 0.2s, color 0.2s;
}

.accordion-header:hover {
    background-color: #f8fafc;
    color: #2563eb;
}

.accordion-header .icon {
    font-size: 0.75rem;
    transition: transform 0.3s ease;
    color: #94a3b8;
}

.accordion-item.active .accordion-header .icon {
    transform: rotate(180deg);
    color: #2563eb;
}

.accordion-content {
    max-height: 0;
    overflow: hidden;
    background-color: #fafafa;
    transition: max-height 0.3s cubic-bezier(0, 1, 0, 1);
}

.accordion-item.active .accordion-content {
    max-height: 1000px;
    transition: max-height 0.3s ease-in-out;
}

.menu-link {
    display: block;
    padding: 8px 20px 8px 32px;
    color: #64748b;
    text-decoration: none;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.menu-link:hover {
    color: #2563eb;
    background-color: #f1f5f9;
}

/* --- Main Content เนื้อหาด้านขวา --- */
.main-content {
    flex-grow: 1;
    padding: 32px 48px;
    width: 100%;
    max-width: none;
}

.toggle-sidebar-btn {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    color: #334155;
    font-size: 1.2rem;
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.toggle-sidebar-btn:hover {
    background-color: #f1f5f9;
    color: #2563eb;
}

.header-title {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 32px;
}

.header-title h1 {
    font-size: 1.75rem;
    color: #0f172a;
}

/* --- บล็อกเนื้อหา --- */
.lesson-section {
    background-color: #ffffff;
    padding: 32px;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    margin-bottom: 24px;
    width: 100%;
    scroll-margin-top: 24px;
}

.lesson-section h2 {
    font-size: 1.3rem;
    color: #0f172a;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 2px solid #eff6ff;
}

.lesson-section p {
    font-size: 1.1rem;
    line-height: 1.7;
    color: #475569;
    margin-bottom: 12px;
}

.lesson-section ul {
    margin-left: 24px;
    margin-bottom: 16px;
}

.lesson-section li {
    font-size: 1.1rem;
    line-height: 1.8;
    color: #475569;
}

/* --- ช่องแสดงโค้ดสีดำขนาดใหญ่ --- */
.code-block {
    background-color: #0f172a;
    color: #38bdf8;
    padding: 24px 28px;
    border-radius: 10px;
    font-family: "Consolas", "Courier New", Courier, monospace;
    font-size: 1.2rem;
    line-height: 1.6;
    overflow-x: auto;
    width: 100%;
    margin: 16px 0;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.code-block pre {
    font-family: inherit;
}