/* --- Reset --- */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html, body {
    height: 100%; overflow: hidden;
    font-family: "Segoe UI", sans-serif;
    background: var(--bg-primary); color: var(--text-primary);
}

/* --- Shell --- */
#shell { display: none; height: 100vh; }
#shell.active { display: flex; }

/* --- Sidebar --- */
#sidebar {
    width: 220px; min-width: 220px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex; flex-direction: column;
    transition: margin-left 0.25s ease, opacity 0.25s ease;
    overflow: hidden; z-index: 20;
}
#sidebar.collapsed {
    margin-left: -220px; opacity: 0; pointer-events: none;
}
.sidebar-header {
    background: var(--brand); padding: 16px 16px; font-size: 20px;
    font-weight: 700; letter-spacing: 0.5px; white-space: nowrap;
    color: #fff;
}
.nav-list {
    list-style: none;
    padding: 8px 0;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}
.nav-list li {
    padding: 12px 16px; cursor: pointer; font-size: 14px;
    font-weight: 500; display: flex; align-items: center; gap: 10px;
    transition: background 0.15s; white-space: nowrap;
    color: var(--text-primary);
}
.nav-list li:hover { background: var(--bg-tertiary); }
.nav-list li.active { background: var(--brand); color: #fff; }
.nav-list li .nav-icon {
    width: 24px; height: 24px;
    flex-shrink: 0;
}

/* === Collapsible Nav - Parent Items === */

.nav-parent-item {
    user-select: none;
}

/* Chevron on parent items */
.nav-chevron {
    margin-left: auto;
    font-size: 20px;
    color: var(--text-muted);
    transition: transform 0.2s ease;
}

.nav-parent-item.expanded .nav-chevron {
    transform: rotate(90deg);
}

/* === Collapsible Nav - Child Items === */

#nav-list > li.nav-child-item {
    padding: 8px 16px 8px 52px;
    font-size: 13px;
}

/* === Nav Group Headers (collapsible) === */

.nav-group-header {
    padding: 12px 16px 4px 16px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    user-select: none;
    transition: color 0.15s;
}

.nav-group-header:hover {
    color: var(--text-primary);
}

.nav-group-header-text {
    flex: 1;
}

.nav-group-header-chevron {
    font-size: 20px;
    color: var(--text-muted);
    transition: transform 0.2s ease;
}

.nav-group-header.expanded .nav-group-header-chevron {
    transform: rotate(90deg);
}

/* === Hide/Show === */

#nav-list > li.nav-group-hidden {
    display: none;
}

#nav-list > li.nav-child-hidden {
    display: none;
}

/* --- Bottom nav item --- */
.nav-bottom {
    margin-top: auto;
    border-top: 1px solid var(--border-color);
    padding: 4px 0;
    flex: 0 0 auto;
    overflow: visible;
}
.nav-bottom li {
    padding: 12px 16px;
    cursor: pointer;
    font-size: 20px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: background 0.15s;
    white-space: nowrap;
    color: var(--text-muted);
}
.nav-bottom li:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}
.nav-bottom li .nav-icon {
    width: 24px; height: 24px;
    flex-shrink: 0;
}

/* --- Nav mode switching --- */
.nav-mode {
    display: none;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.nav-mode.active {
    display: flex;
}

/* --- Main panel --- */
#main-panel {
    flex: 1; display: flex; flex-direction: column;
    overflow: hidden; min-width: 0;
}

/* --- Top bar --- */
#topbar {
    height: 48px; min-height: 48px;
    background: var(--bg-secondary);
    display: flex; align-items: center; padding: 0 16px; gap: 12px;
    border-bottom: 1px solid var(--border-color);
}
.hamburger {
    background: none; border: none; color: var(--text-primary);
    font-size: 20px; cursor: pointer; padding: 4px 8px; line-height: 1;
}
.hamburger:hover { color: var(--brand); }
.view-title {
    font-size: 15px; font-weight: 600; flex: 1;
    color: var(--text-primary);
}


/* --- Content area --- */
#content-area { flex: 1; overflow: hidden; position: relative; }
.view { display: none; width: 100%; height: 100%; }
.view.active { display: block; overflow: auto; height: 100%; }

/* --- App iframe --- */
#mda-frame { width: 100%; height: 100%; border: none; }

/* --- Responsive --- */
@media (max-width: 768px) {
    #sidebar {
        position: fixed; top: 0; left: 0; height: 100vh;
        margin-left: -220px; opacity: 0; pointer-events: none;
    }
    #sidebar.mobile-open {
        margin-left: 0; opacity: 1; pointer-events: auto;
    }
}
