/* ============================================================
   Base Layout
   ============================================================ */

html, body {
    margin: 0 !important;
    padding: 0 !important;
    background: #f5f6f7 !important;
    color: #222;
    font-family: Arial, sans-serif;
    line-height: 1.6;
}

body {
    max-width: none !important;
    width: 100% !important;
    overflow-x: hidden; /* prevent horizontal scroll */
}

/* ============================================================
   Layout with Sidebar
   ============================================================ */

.layout {
    display: block;
}

/* Sidebar */
.sidebar {
    position: fixed;        /* independent of layout */
    top: 0;
    left: 0;
    width: 300px;           /* fixed width */
    height: 100vh;          /* full viewport height */
    overflow-y: auto;       /* scroll when needed */
    background: #f0f0f0;
    padding: 30px 20px;
    border-right: 1px solid #ddd;
    box-sizing: border-box;
    z-index: 1000;          /* stays above main content */
}

/* Custom message above menu */
.sidebar-top-message {
    margin-bottom: 20px;
    font-size: 1rem;
    font-weight: 600;
    background: #d9e8ff; /* soft blue highlight */
    padding: 10px;
    border-radius: 4px;
}

.sidebar-top-message a {
    color: #0066cc;
    text-decoration: none;
}

.sidebar-top-message a:hover {
    text-decoration: underline;
}

.sidebar h2 {
    margin-top: 0;
    font-size: 1.3rem;
    margin-bottom: 1rem;
}

/* Sidebar hierarchy */
.sidebar ul {
    padding-left: 0;
    margin: 0;
}

.sidebar li {
    list-style: none;
    margin: 6px 0;
}

/* Top-level chapters */
.sidebar li.level-0 {
    margin-left: 0;
    font-weight: 600;
}

/* Sub-levels */
.sidebar li.level-1 {
    margin-left: 15px;
    font-weight: 400;
}

.sidebar li.level-2 {
    margin-left: 30px;
    font-weight: 400;
    font-size: 0.95rem;
}

.sidebar li.level-3 {
    margin-left: 45px;
    font-weight: 400;
    font-size: 0.9rem;
}


.sidebar a {
    color: #333;
    text-decoration: none;
    font-size: 1rem;
}

.sidebar a:hover {
    text-decoration: underline;
}

/* Main content area (right side) */
main {
    /* sit to the right of the sidebar */
    margin-left: 300px;                 /* same as sidebar width */
    max-width: calc(100% - 300px);      /* prevent overflow */
    width: auto;

    margin-top: 40px;
    padding: 40px !important;
    background: #fff;
    border-radius: 6px;
    box-shadow: 0 0 10px rgba(0,0,0,0.05);
    box-sizing: border-box;
}

/* ============================================================
   Header & Footer
   ============================================================ */

header {
    width: 100% !important;
    background: #333;
    color: #fff;
    padding: 20px 40px !important;
    margin: 0 !important;
}

header h1 {
    margin: 0 !important;
    font-size: 2rem !important;
}

footer {
    width: 100% !important;
    background: #eee;
    color: #444;
    padding: 20px !important;
    text-align: center;
    margin-top: 40px !important;
    font-size: 0.9rem;
}

/* ============================================================
   Typography
   ============================================================ */

h1, h2, h3, h4 {
    font-weight: 600;
    margin-top: 1.2em !important;
    margin-bottom: 0.5em !important;
}

h1 {
    font-size: 2rem !important;
    border-bottom: 2px solid #ddd;
    padding-bottom: 0.3em !important;
}

h2 {
    font-size: 1.6rem !important;
}

h3 {
    font-size: 1.3rem !important;
}

p {
    margin: 1em 0 !important;
}

/* ============================================================
   Links
   ============================================================ */

a {
    color: #0066cc !important;
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* ============================================================
   Images
   ============================================================ */

img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 20px 0;
}

/* ============================================================
   Tables
   ============================================================ */

table {
    width: 100% !important;
    border-collapse: collapse;
    margin: 20px 0 !important;
    display: block;
    overflow-x: auto;
}

table, th, td {
    border: 1px solid #ccc !important;
}

th, td {
    padding: 8px 12px !important;
    text-align: left !important;
}

/* ============================================================
   Code Blocks
   ============================================================ */

pre {
    background: #eee !important;
    padding: 12px !important;
    border-radius: 4px !important;
    overflow-x: auto !important;
}

code {
    font-family: Consolas, monospace !important;
}

/* ============================================================
   Lists
   ============================================================ */

ul, ol {
    margin: 1em 0 1em 1.5em !important;
}

/* ============================================================
   Blockquotes
   ============================================================ */

blockquote {
    margin: 1em 0 !important;
    padding-left: 1em !important;
    border-left: 3px solid #ddd !important;
    color: #555 !important;
}

/* ============================================================
   Responsive
   ============================================================ */

@media (max-width: 1200px) {
    /* slightly tighter layout on medium screens */
    .sidebar {
        width: 220px;
    }

    main {
        margin-left: 220px;
        max-width: calc(100% - 220px);
    }
}

@media (max-width: 1000px) {
    .sidebar {
        width: 180px;
    }

    main {
        margin-left: 180px;
        max-width: calc(100% - 180px);
    }
}

@media (max-width: 900px) {
    /* Mobile layout: sidebar moves on top */
    .sidebar {
        position: static;
        width: 100%;
        height: auto;
        overflow: visible;
        padding: 20px 15px;
        border-right: none;
        border-bottom: 1px solid #ddd;
        box-sizing: border-box;
    }

    .layout {
        display: block;
    }

    main {
        margin-left: 0;
        max-width: 100%;
        width: 100% !important;
        padding: 20px !important;
    }

    header {
        padding: 15px !important;
    }

    header h1 {
        font-size: 1.6rem !important;
    }
}
