:root {
  --app-primary: #0d6efd;
  --app-primary-light: #f0f7ff;
  --app-primary-dark: #0056b3;
  --app-text: #1e293b;
  --app-muted: #64748b;
  --app-bg: #f8fafc;
  --app-white: #ffffff;
  --app-border: #e2e8f0;
  --app-header-height: 64px;
  --app-radius-lg: 16px;
  --app-radius-md: 12px;
  --app-shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --app-shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --app-font: 'Inter', system-ui, -apple-system, sans-serif;
  --app-glass: rgba(255, 255, 255, 0.8);
  --app-max-width: 1440px;
}

/* ── Container ───────────────────────────────────── */
.app-container {
    width: 100%;
    max-width: var(--app-max-width);
    margin: 0 auto;
    padding-left: 24px;
    padding-right: 24px;
    padding-top: 0;
}

/* ── Global Layout ───────────────────────────────── */
.app-wrapper {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: var(--app-bg);
}

/* ── Shared Header ───────────────────────────────── */
.app-header {
  height: var(--app-header-height);
  background: var(--app-glass);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--app-border);
  position: sticky;
  top: 0;
  z-index: 1040; /* Above documentation sidebar overlay */
  display: flex;
  align-items: center;
  transition: all 0.3s ease;
}

.app-header-container {
  width: 100%;
  max-width: var(--app-max-width);
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.app-header-left, .app-header-right {
  display: flex;
  align-items: center;
  gap: 20px;
}

.app-brand {
  display: flex;
  align-items: center;
  text-decoration: none;
  font-weight: 700;
  font-size: 20px;
  gap: 0;
  color: var(--app-text);
}

.app-brand-primary { color: var(--app-primary); }
.app-brand-divider { color: var(--app-border); margin: 0 8px; font-weight: 300; }
.app-brand-secondary { color: var(--app-text); font-weight: 500; }

.app-brand:hover { text-decoration: none; color: var(--app-text); }

.app-header-nav {
  display: flex;
  gap: 4px;
  margin-left: 12px;
}

.app-nav-link {
  text-decoration: none !important;
  color: var(--app-muted);
  font-size: 14px;
  font-weight: 500;
  padding: 8px 12px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.app-nav-link:hover, .app-nav-link.active {
  color: var(--app-primary) !important;
  background: var(--app-primary-light);
}

/* Adjustments for fixed/sticky behavior */
.layout-fixed-header .app-header {
  position: fixed;
  width: 100%;
  left: 0;
  top: 0;
}

/* Breadcrumb area in header (for documentation) */
.app-header-breadcrumb {
  display: flex;
  flex-direction: column;
  justify-content: center;
  margin-left: 10px;
  border-left: 1px solid var(--app-border);
  padding-left: 20px;
  height: 32px;
  flex: 1;
  min-width: 0;
}

@media (max-width: 768px) {
  .app-header-breadcrumb, .app-header-nav {
    display: none;
  }
}

/* Left Sidebar - Treeview */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-light);
    color: var(--text-main);
    overflow-y: auto;
    border-right: 1px solid var(--border-color);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
    height: calc(100vh - var(--header-height));
    position: sticky;
    top: var(--header-height);
}
.treeview {
    padding: 10px 0;
}

.treeview-item {
    padding: 8px 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
    user-select: none;
    display: flex;
    flex-direction: column;
}

    .treeview-item:hover {
        background: var(--primary-light);
        border-left-color: var(--primary-color);
    }

    .treeview-item.active {
        background: var(--primary-light);
        border-left-color: var(--primary-color);
        color: var(--primary-color);
        font-weight: 600;
    }

.treeview-item-content {
    display: flex;
    align-items: center;
    gap: 6px;
}

.treeview-item-icon {
    width: 16px;
    height: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: #6c757d;
    cursor: pointer;
    flex-shrink: 0;
}

    .treeview-item-icon:hover {
        color: #333333;
    }

    .treeview-item-icon.expanded::before {
        content: '▼';
    }

    .treeview-item-icon.collapsed::before {
        content: '▶';
    }

    .treeview-item-icon.leaf {
        width: 16px;
    }

.treeview-item .item-name {
    font-size: 14px;
    display: flex;
    align-items: center;
    flex: 1;
    color: #333333;
    pointer-events: none;
    /* Let click bubble to treeview-item */
}

.treeview-item.active .item-name {
    color: #0056b3;
    font-weight: bold;
}
.treeview-item .item-module {
    font-size: 11px;
    color: #6c757d;
    margin-top: 2px;
    margin-left: 22px;
}

.treeview-item.active .item-module {
    color: #0056b3;
}

.treeview-children {
    display: none;
    margin-left: 15px;
}

    .treeview-children.expanded {
        display: block;
    }

.treeview-item[data-level="0"] {
    padding-left: 10px;
}

.treeview-item[data-level="1"] {
    padding-left: 15px;
}

.treeview-item[data-level="2"] {
    padding-left: 15px;
}

.treeview-item[data-level="3"] {
    padding-left: 15px;
}

.treeview-item[data-level="4"] {
    padding-left: 15px;
}

.treeview-group {
    margin-top: 15px;
}

.treeview-group-header {
    padding: 10px 15px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    color: #6c757d;
    background: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
}

/* ========== Treeview Item Improvements ========== */
.treeview-item.active {
    background: linear-gradient(135deg, #e7f1ff, #f0f7ff);
    border-left: 3px solid #007bff;
}

.treeview-item:hover:not(.active) {
    background: #f8f9fa;
}

.item-name {
    font-weight: 500;
    color: #333;
}

.treeview-item.active .item-name {
    color: #0056b3;
    font-weight: 600;
}

/* Loading status at bottom of treeview */
.treeview-status {
    padding: 10px 15px;
    font-size: 12px;
    color: #6c757d;
    text-align: center;
    border-top: 1px solid #e9ecef;
    background: #f8f9fa;
}
