:root {
    /* --- Modern Palette --- */
    --base-font: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

    /* Neutrals */
    --white: #ffffff;
    --slate-50: #f8fafc;
    --slate-100: #f1f5f9;
    --slate-200: #e2e8f0;
    --slate-300: #cbd5e1;
    --slate-400: #94a3b8;
    --slate-500: #64748b;
    --slate-600: #475569;
    --slate-700: #334155;
    --slate-800: #1e293b;
    --slate-900: #0f172a;

    /* Primary (Indigo) */
    --primary-50: #eef2ff;
    --primary-100: #e0e7ff;
    --primary-500: #6366f1;
    --primary-600: #4f46e5;
    --primary-700: #4338ca;

    /* Semantic */
    --bg-body: var(--slate-50);
    --bg-sidebar: var(--white);
    --bg-content: var(--slate-50);

    --text-primary: var(--slate-900);
    --text-secondary: var(--slate-500);
    --text-muted: var(--slate-400);

    --border-color: var(--slate-200);

    /* Layout */
    --sidebar-width: 280px;
    --header-height: 64px;
    --radius-md: 8px;
    --radius-lg: 12px;

    /* Effects */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}

/* --- Reset & Global --- */
* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: var(--base-font);
    background-color: var(--bg-body);
    color: var(--text-primary);
    overflow: hidden;
    /* Fix: Use dynamic viewport height for mobile browsers */
    height: 100vh;
    height: 100dvh;
    -webkit-font-smoothing: antialiased;
}

body {
    margin: 0;
    padding: 0;
    overflow: hidden;
}

.container {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    display: grid;

    /* DESKTOP LAYOUT (Default) */
    grid-template-columns: 280px 1fr;
    grid-template-rows: 64px 1fr auto;
    grid-template-areas:
                "sidebar header"
                "sidebar content"
                "sidebar footer";
}


.sidebar {
    grid-area: sidebar;
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 20;
}

.header {
    grid-area: header;
    background-color: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    padding: 40px 40px;
    z-index: 10;
    height: fit-content;
    flex-wrap: wrap;
}

.content {
    grid-area: content;
    background-color: var(--bg-content);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    margin-top: 3rem;
}

.footer {
    grid-area: footer;
    background-color: var(--white);
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    z-index: 10;
    height: auto;
}

/* --- Responsive Logic --- */

/* Utility classes for toggling elements */
.mobile-only {
    display: none;
}

.desktop-only {
    display: flex;
}

@media (max-width: 1024px) {
    .container {
        /* Tablet: Shrink sidebar slightly if needed, or keep standard */
        grid-template-columns: 260px 1fr;
    }

    .header {
        padding: 24px 24px;
    }

    .content {
        margin-top: 1rem;
        margin-left: 1rem;
    }
}

@media (max-width: 768px) {
    /* MOBILE LAYOUT */
    .container {
        /* Switch to single column */
        grid-template-columns: 1fr;
        grid-template-rows: 60px 1fr auto;
        grid-template-areas:
                    "header"
                    "content"
                    "footer";
    }

    .sidebar {
        /* Break out of grid flow for Off-Canvas behavior */
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 280px;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15);
        z-index: 100; /* Above everything */
    }

    /* The 'open' class is toggled by Vue */
    .sidebar.open {
        transform: translateX(0);
    }

    .header {
        padding: 16px 16px;
        gap: 12px;
    }

    .footer {
        height: auto;
    }

    .content {
        margin-top: 1rem;
    }

    /* Show Mobile Controls */
    .mobile-only {
        display: flex;
    }

    .desktop-only {
        display: none;
    }

    /* Hide Desktop-specific logo in sidebar to avoid duplication if desired */
    .sidebar .sidebar-header {
        display: flex; /* Keep showing logo inside sidebar too */
    }
}

/* --- Internal Component Styles --- */

.sidebar-header {
    height: 64px;
    padding: 0 24px;
    display: flex;
    align-items: center;
    flex-shrink: 0;
    border-bottom: 1px solid transparent;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    width: 32px;
    height: 32px;
    background-image: url('logo.jpg');
    background-size: cover;
    border-radius: 6px;
    box-shadow: 0 2px 4px rgba(99, 102, 241, 0.2);
}

.logo-text {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--slate-900);
}

.menu-btn {
    background: transparent;
    border: none;
    padding: 8px;
    margin-left: -8px; /* Align with edge */
    color: var(--slate-600);
    cursor: pointer;
    border-radius: 6px;
}

.menu-btn:hover {
    background: var(--slate-100);
    color: var(--slate-900);
}

.breadcrumbs {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    color: var(--text-muted);
    overflow: hidden;
    white-space: nowrap;
    flex-wrap: wrap;
}

.iframe-container {
    width: 100%;
    height: 100%;
    border: none;
    background: white;
}

.nav-controls {
    flex-grow: 1;
    display: flex;
    justify-content: space-between;
    gap: 16px;
    margin: 16px 20px;
}

/* Mobile Backdrop */
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(2px);
    z-index: 90;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
}

.sidebar-backdrop.active {
    display: block;
    opacity: 1;
    pointer-events: auto;
}

[v-cloak] {
    display: none;
}

/* --- Layout Structure --- */
.layout-container {
    display: flex;
    height: 100%; /* Inherits from body's 100dvh */
    width: 100%;
}

/* --- Sidebar --- */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    z-index: 50;
    flex-shrink: 0;
    height: 100%;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-header {
    height: var(--header-height);
    padding: 0 24px;
    display: flex;
    align-items: center;
    border-bottom: 1px solid transparent;
    flex-shrink: 0;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    width: 32px;
    height: 32px;
    background-image: url('logo.jpg');
    background-size: cover;
    border-radius: 4px;
    position: relative;
    box-shadow: 0 2px 4px rgba(99, 102, 241, 0.3);
}

.logo-text {
    font-weight: 700;
    font-size: 1.125rem;
    letter-spacing: -0.01em;
    color: var(--slate-900);
}

/* --- TOC Navigation --- */
.toc-nav {
    flex: 1;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--slate-300) transparent;
}

.toc-nav::-webkit-scrollbar {
    width: 4px;
}

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

.toc-nav::-webkit-scrollbar-thumb {
    background-color: var(--slate-300);
    border-radius: 4px;
}

.toc-section {
    margin: 16px;
}

/* Section Header (Flex container for top level items) */
.toc-section-header {
    display: flex;
    align-items: center;
    padding: 6px 8px;
    border-radius: 6px;
    cursor: default;
    margin-bottom: 4px;
}

/* Section Title Style */
.toc-section-title {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    flex: 1;
}

.toc-section-title.clickable {
    cursor: pointer;
    transition: color 0.2s;
}

.toc-section-title.clickable:hover {
    color: var(--primary-600);
}

.toc-root-list {
    margin-bottom: 20px !important;
}

/* --- Recursive Nav Items (Tree) --- */

/* Lists Reset */
.toc-nav ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.toc-nav li {
    margin-bottom: 2px;
}

/* Indentation logic */
.nav-children {
    margin-left: 10px;
    border-left: 1px solid var(--slate-200);
    padding-left: 0;
    overflow: hidden;
}

/* Nav Row: The click target for nested items (and used for top level container) */
.nav-row {
    display: flex;
    align-items: center;
    padding: 6px 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.2s;
    color: var(--slate-500);
    font-size: 0.9rem;
    font-weight: 500;
}

.nav-row:hover {
    background-color: var(--slate-50);
    color: var(--slate-900);
}

/* Active State logic */
.nav-row.active {
    background-color: var(--primary-50);
    color: var(--primary-700);
}

.nav-row.active .toc-section-title {
    color: var(--primary-700);
}

/* Icon (Chevron) */
.nav-toggle-btn {
    background: none;
    border: none;
    padding: 0;
    margin-right: 8px;
    cursor: pointer;
    color: var(--slate-400);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, color 0.2s;
    width: 16px;
    height: 16px;
}

.nav-toggle-btn:hover {
    color: var(--slate-600);
    background: rgba(0, 0, 0, 0.05);
    border-radius: 4px;
}

.nav-toggle-btn i {
    width: 14px;
    height: 14px;
}

/* Rotation State */
.nav-toggle-btn.expanded {
    transform: rotate(90deg);
}

/* Spacer for items without children so text aligns */
.nav-indent-spacer {
    width: 24px;
    display: inline-block;
}

.nav-text {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}


/* --- Main Content Area --- */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-content);
    position: relative;
    min-width: 0;
    /* Fix: Ensure it doesn't overflow flex container */
    overflow: hidden;
}

.glass-effect {
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
}

.content-header {
    height: var(--header-height);
    padding: 0 40px;
    display: flex;
    align-items: center;
    flex-shrink: 0;
    z-index: 10;
}


.crumb-link {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.2s;
    padding: 4px 6px;
    border-radius: 4px;
}

.crumb-link:hover {
    color: var(--primary-600);
    background: var(--slate-100);
}

.crumb-text.current {
    color: var(--slate-800);
    font-weight: 600;
    background: var(--white);
    padding: 4px 8px;
    border-radius: 4px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--slate-200);
}

.breadcrumb-separator {
    color: var(--slate-300);
    display: flex;
    align-items: center;
}

.breadcrumb-separator i {
    width: 14px;
    height: 14px;
}

.iframe-wrapper {
    flex: 1;
    position: relative;
    width: 100%;
    padding: 0;
    overflow: hidden;
    background: var(--slate-50);
    /* Fix: Prevent flex child from overflowing parent */
    min-height: 0;
}

.iframe-container {
    width: 100%;
    height: 100%;
    background: white;
    border: none;
}

.doc-iframe {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
}

.content-footer {
    border-top: 1px solid var(--border-color);
    padding: 24px 40px;
    background: var(--white);
    flex-shrink: 0;
    z-index: 10;
}

.nav-btn {
    background: var(--white);
    border: 1px solid var(--slate-200);
    border-radius: var(--radius-lg);
    padding: 16px 20px;
    cursor: pointer;
    text-align: left;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 240px;
    box-shadow: var(--shadow-sm);
}

.nav-btn:hover {
    border-color: var(--primary-100);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.nav-btn:hover .title {
    color: var(--primary-600);
}

.nav-btn.next {
    text-align: right;
    align-items: flex-end;
}

.nav-btn .label {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.nav-btn .title {
    font-weight: 600;
    color: var(--slate-700);
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: color 0.2s;
}

.nav-btn i {
    width: 18px;
    height: 18px;
}

.nav-spacer {
    flex: 1;
}

/* --- Mobile --- */
.mobile-header {
    display: none;
    height: var(--header-height);
    background: var(--white);
    padding: 0 20px;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
    z-index: 60;
    position: relative;
    /* Fix: Prevent shrinking */
    flex-shrink: 0;
}

.mobile-header .logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    color: var(--slate-900);
}

.menu-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 8px;
    color: var(--slate-600);
    border-radius: 6px;
}

.menu-btn:hover {
    background: var(--slate-100);
}

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(4px);
    z-index: 45;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
}

.sidebar-backdrop.active {
    display: block;
    opacity: 1;
    pointer-events: auto;
}

@media (max-width: 1024px) {
    .nav-btn {
        min-width: auto;
        flex: 1;
    }

    .content-header, .content-footer {
        padding: 0 24px;
    }

    .content-footer {
        padding-top: 24px;
        padding-bottom: 24px;
    }
}

@media (max-width: 768px) {
    .mobile-header {
        display: flex;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        transform: translateX(-100%);
        box-shadow: 2px 0 20px rgba(0, 0, 0, 0.1);
        width: 85%;
        max-width: 320px;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .layout-container {
        flex-direction: column;
        /* Fix: Use dvh for mobile height to account for address bar */
        height: calc(100vh - var(--header-height));
        height: calc(100dvh - var(--header-height));
    }

    .main-content {
        width: 100%;
        margin-left: 0;
    }

    .content-header {
        padding: 0 20px;
        height: 50px;
        overflow-x: auto;
    }

    /* Fix: Add Safe Area Inset for modern mobile devices (iPhone Home Bar) */
    .content-footer {
        padding: 20px;
        padding-bottom: calc(20px + env(safe-area-inset-bottom));
    }

    .nav-controls {
        gap: 12px;
    }

    .nav-btn {
        padding: 12px 16px;
    }
}