/*!
 * Innomis K-Tree - Professional Navigation Tree Plugin
 * Version: 1.0.0
 * Description: Clean, modern navigation tree with enhanced user experience
 * Author: Innomis (Dennis Kasper)
 */

/* ==========================================================================
   RESET & BASE STYLES
   ========================================================================== */

.ktree-container * {
    box-sizing: border-box;
}

/* ==========================================================================
   CSS CUSTOM PROPERTIES (DESIGN TOKENS)
   ========================================================================== */

:root {
    /* Brand Colors */
    --ktree-primary: #45598f;
    --ktree-primary-hover: #3a4a7a;
    --ktree-primary-light: #f0f2f7;
    --ktree-primary-dark: #2d3965;
    
    /* Neutral Colors */
    --ktree-white: #ffffff;
    --ktree-gray-50: #f8f9fa;
    --ktree-gray-100: #f2f4f8;
    --ktree-gray-200: #e0e0e0;
    --ktree-gray-300: #d0d0d0;
    --ktree-gray-400: #1a1a1a;
    --ktree-gray-500: #1a1a1a;
    --ktree-gray-600: #1a1a1a;
    --ktree-gray-900: #1a1a1a;
    
    /* Additional color definitions */
    --ktree-bg: var(--ktree-white);
    --ktree-bg-alt: var(--ktree-gray-50);
    --ktree-text: #1a1a1a;
    --ktree-text-muted: #1a1a1a;
    --ktree-text-light: #1a1a1a;
    --ktree-border: var(--ktree-gray-200);
    --ktree-border-light: var(--ktree-gray-100);
    
    /* Semantic Colors */
    --ktree-success: #28a745;
    --ktree-warning: #ffc107;
    --ktree-error: #dc3545;
    --ktree-info: #17a2b8;
    
    /* Typography Scale */
    --ktree-font-size-xs: 0.75rem;    /* 12px */
    --ktree-font-size-sm: 0.8125rem;  /* 13px */
    --ktree-font-size-base: 0.875rem; /* 14px */
    --ktree-font-size-lg: 1rem;       /* 16px */
    --ktree-font-size-xl: 1.125rem;   /* 18px */
    --ktree-font-size-2xl: 1.25rem;   /* 20px */
    
    /* Font Weights */
    --ktree-font-weight-normal: 400;
    --ktree-font-weight-medium: 500;
    --ktree-font-weight-semibold: 600;
    --ktree-font-weight-bold: 700;
    
    /* Line Heights */
    --ktree-line-height-tight: 1.25;
    --ktree-line-height-normal: 1.5;
    --ktree-line-height-relaxed: 1.625;
    
    /* Spacing Scale (8px base unit) */
    --ktree-space-1: 0.25rem;  /* 4px */
    --ktree-space-2: 0.5rem;   /* 8px */
    --ktree-space-3: 0.75rem;  /* 12px */
    --ktree-space-4: 1rem;     /* 16px */
    --ktree-space-5: 1.25rem;  /* 20px */
    --ktree-space-6: 1.5rem;   /* 24px */
    --ktree-space-8: 2rem;     /* 32px */
    --ktree-space-10: 2.5rem;  /* 40px */
    --ktree-space-11: 2.75rem; /* 44px */
    --ktree-space-12: 3rem;    /* 48px */
    
    /* Additional spacing aliases */
    --ktree-space-xs: var(--ktree-space-1); /* 4px */
    --ktree-space-sm: var(--ktree-space-2); /* 8px */
    --ktree-space-md: var(--ktree-space-4); /* 16px */
    --ktree-space-lg: var(--ktree-space-6); /* 24px */
    --ktree-space-xl: var(--ktree-space-8); /* 32px */
    
    /* Border Radius */
    --ktree-radius-sm: 0.12rem;  /* 1.92px */
    --ktree-radius: 0.12rem;     /* 1.92px */
    --ktree-radius-md: 0.12rem;  /* 1.92px */
    --ktree-radius-lg: 0.12rem;  /* 1.92px */
    
    /* Border Width */
    --ktree-border-width: 1px;
    --ktree-border-width-thick: 2px;
    
    /* Shadows */
    --ktree-shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --ktree-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --ktree-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --ktree-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --ktree-shadow-print: 0 4px 18px rgba(0, 0, 0, 0.05);
    
    /* Transitions */
    --ktree-transition-fast: 0.15s ease;
    --ktree-transition-normal: 0.25s ease;
    --ktree-transition-slow: 0.3s ease;
    --ktree-transition: var(--ktree-transition-normal);
    
    /* Enhanced Animations */
    --ktree-easing-smooth: cubic-bezier(0.4, 0, 0.2, 1);
    --ktree-easing-bounce: cubic-bezier(0.68, -0.55, 0.265, 1.55);
    --ktree-easing-elastic: cubic-bezier(0.175, 0.885, 0.32, 1.275);
    --ktree-animation-tree-expand: 0.3s var(--ktree-easing-smooth);
    --ktree-animation-content-fade: 0.2s var(--ktree-easing-smooth);
    --ktree-animation-hover: 0.15s var(--ktree-easing-smooth);
    
    /* Z-Index Scale */
    --ktree-z-dropdown: 50;
    --ktree-z-sticky: 100;
    --ktree-z-overlay: 200;
    --ktree-z-modal: 1000;
    
    /* Font Family */
    --ktree-font-family: 'Open Sans', Arial, Helvetica, sans-serif;
}

/* Global input height override */
input[type="text"], 
input[type="number"], 
input[type="email"], 
input[type="url"], 
input[type="password"], 
input[type="search"], 
input[type="reset"], 
input[type="tel"], 
input[type="date"], 
select {
    height: 32px !important;
    font-size: 0.8rem !important;
}

/* Global SVG icon sizing */
svg {
    width: 20px !important;
    height: 20px !important;
}

/* ==========================================================================
   MAIN CONTAINER
   ========================================================================== */

.ktree-container {
    /* Layout */
    display: flex;
    width: 100%;
    min-height: 100vh;
    overflow: visible;
    position: relative;
    
    /* Visual */
    background: var(--ktree-white);
    border: var(--ktree-border-width) solid var(--ktree-gray-200);
    border-radius: var(--ktree-radius-sm);
    box-shadow: var(--ktree-shadow-print);
    
    /* Typography */
    font-family: var(--ktree-font-family);
    font-size: var(--ktree-font-size-base);
    line-height: var(--ktree-line-height-normal);
    color: var(--ktree-gray-900);
    
    /* Isolation */
    isolation: isolate;
}

/* ==========================================================================
   SIDEBAR LAYOUT
   ========================================================================== */

.ktree-sidebar {
    /* Layout */
    display: flex;
    flex-direction: column;
    width: 20%;
    min-width: 250px;
    height: 100vh;
    position: sticky;
    top: 98px;
    
    /* Visual */
    background: #f3f4f6 !important;
    border-right: var(--ktree-border-width) solid var(--ktree-gray-200);
    
    /* Performance */
    will-change: transform;
}

/* ==========================================================================
   SEARCH COMPONENT
   ========================================================================== */

.ktree-search {
    height: 49px;
    padding: 0 var(--ktree-space-sm);
    border-bottom: var(--ktree-border-width) solid var(--ktree-gray-200);
    display: flex;
    align-items: center;
    justify-content: center;
}


.ktree-search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}

.ktree-search-input {
    /* Layout */
    width: 100%;
    height: 28px;
    padding: var(--ktree-space-1) var(--ktree-space-11) var(--ktree-space-1) var(--ktree-space-3);
    
    /* Visual */
    background: var(--ktree-white);
    border: var(--ktree-border-width) solid var(--ktree-gray-200);
    border-radius: var(--ktree-radius-sm) !important;
    
    /* Typography */
    font-size: var(--ktree-font-size-sm);
    font-family: inherit;
    color: var(--ktree-gray-600);
    line-height: var(--ktree-line-height-normal);
    
    /* Interaction */
    transition: var(--ktree-transition-fast);
    
    /* Remove default styles */
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

.ktree-search-input:focus {
    outline: none;
    border-color: var(--ktree-primary);
    box-shadow: 0 0 0 3px var(--ktree-primary-light);
    background: var(--ktree-white);
}

.ktree-search-input::placeholder {
    color: var(--ktree-gray-400);
    opacity: 1; /* Firefox */
}

/* Search Icons */
.ktree-search-icon {
    position: absolute;
    right: var(--ktree-space-3);
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: var(--ktree-gray-600);
    pointer-events: none;
    z-index: 1;
}

.ktree-search-clear {
    display: none !important;
}




/* Breadcrumbs in content header */
.ktree-content-header .ktree-breadcrumb-trail {
    flex: 1;
    margin-right: var(--ktree-space-md);
}

.ktree-breadcrumb-trail {
    display: flex;
    align-items: center;
    gap: var(--ktree-space-xs);
    font-size: var(--ktree-font-size-sm);
    color: var(--ktree-text-muted);
}

.ktree-breadcrumb-separator {
    width: 14px;
    height: 14px;
    color: var(--ktree-text-light);
    transition: transform var(--ktree-animation-hover);
}

.ktree-breadcrumb-item {
    cursor: pointer;
    padding: var(--ktree-space-1) var(--ktree-space-2);
    border-radius: var(--ktree-radius-sm);
    transition: all var(--ktree-animation-hover);
    color: var(--ktree-text-muted);
    text-decoration: none;
}

.ktree-breadcrumb-item:hover {
    background: var(--ktree-primary-light);
    color: var(--ktree-primary);
}

.ktree-breadcrumb-current {
    color: var(--ktree-text);
    font-weight: 500;
    padding: var(--ktree-space-1) var(--ktree-space-2);
    background: var(--ktree-gray-100);
    border-radius: var(--ktree-radius-sm);
}

/* Menu */
.ktree-menu {
    flex: 1;
    overflow-y: auto;
    padding: var(--ktree-space-xs) var(--ktree-space-sm);
    outline: none; /* Remove default focus outline */
}

.ktree-menu:focus {
    box-shadow: inset 0 0 0 2px var(--ktree-primary-light);
}

/* JSTree Custom Styling */
#ktree-jstree {
    font-family: inherit;
    font-size: var(--ktree-font-size-base);
}

/* Override JSTree default styles */
#ktree-jstree .jstree-anchor {
    min-height: 28px;
    height: auto;
    line-height: 1.4;
    padding: var(--ktree-space-xs);
    color: var(--ktree-text);
    text-decoration: none;
    border-radius: var(--ktree-radius-sm);
    font-weight: 400;
    transition: all var(--ktree-animation-hover);
    border: var(--ktree-border-width) solid transparent;
    margin: 0;
    white-space: normal;
    word-wrap: break-word;
    overflow-wrap: break-word;
    display: inline-block;
    vertical-align: top;
    width: calc(100% - 16px);
}

#ktree-jstree .jstree-anchor:hover {
    background: #45598f;
    color: white;
    border-color: #45598f;
    text-decoration: none;
}

#ktree-jstree .jstree-anchor.jstree-clicked {
    background: #45598f;
    color: white;
    font-weight: 500;
    border-color: #45598f;
}

#ktree-jstree .jstree-node {
    margin: 0;
    padding: 0;
}

/* Hide JSTree connection lines and reduce indentation */
#ktree-jstree .jstree-default .jstree-wholerow-hovered,
#ktree-jstree .jstree-default .jstree-wholerow-clicked {
    background: none;
}

#ktree-jstree .jstree-node, 
#ktree-jstree .jstree-children {
    background-image: none !important;
    background-repeat: no-repeat;
    background-color: transparent;
}

/* Reduce child node indentation */
#ktree-jstree .jstree-children {
    padding-left: 8px !important; /* Minimal indentation for child levels */
}

/* Hide the connecting lines */
#ktree-jstree .jstree-default .jstree-node {
    background-image: none !important;
}

#ktree-jstree .jstree-default .jstree-last {
    background-image: none !important;
}

/* Level 0 starts at zero, child levels get minimal indentation */
#ktree-jstree .jstree-container-ul {
    margin-left: 0 !important;
    padding-left: 0 !important;
}

/* Only child levels get indentation */
#ktree-jstree .jstree-children {
    margin-left: 0 !important;
    padding-left: 8px !important; /* Minimal but visible indentation for children */
}

#ktree-jstree .jstree-no-dots,
#ktree-jstree .jstree-no-icons {
    margin-left: 0 !important;
    padding-left: 0 !important;
}

#ktree-jstree .jstree-children {
    margin-left: 8px;
    border-left: none; /* Remove left border */
    padding-left: var(--ktree-space-xs);
    overflow: hidden;
    transition: var(--ktree-animation-tree-expand);
}

#ktree-jstree .jstree-open > .jstree-ocl,
#ktree-jstree .jstree-closed > .jstree-ocl {
    width: 24px;
    height: 32px;
    background: none;
    border: none;
    color: #1a1a1a;
    cursor: pointer;
    transition: all var(--ktree-animation-hover);
    border-radius: var(--ktree-radius-sm);
    margin-right: var(--ktree-space-xs);
    display: inline-block;
    vertical-align: top;
    text-align: center;
    line-height: 32px;
    position: relative;
}

/* Lucide Chevron Icons */
#ktree-jstree .jstree-closed > .jstree-ocl::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 16px;
    height: 16px;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="%23444444" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="9 18 15 12 9 6"></polyline></svg>');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

#ktree-jstree .jstree-open > .jstree-ocl::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 16px;
    height: 16px;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="%23444444" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="6 9 12 15 18 9"></polyline></svg>');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

#ktree-jstree .jstree-open > .jstree-ocl:hover::after,
#ktree-jstree .jstree-closed > .jstree-ocl:hover::after {
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="%231a1a1a" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="9 18 15 12 9 6"></polyline></svg>');
}

#ktree-jstree .jstree-open > .jstree-ocl:hover::after {
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="%231a1a1a" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="6 9 12 15 18 9"></polyline></svg>');
}

#ktree-jstree .jstree-open > .jstree-ocl:hover,
#ktree-jstree .jstree-closed > .jstree-ocl:hover {
    background: var(--ktree-border-light);
    color: var(--ktree-text);
}

#ktree-jstree .jstree-open > .jstree-ocl:before,
#ktree-jstree .jstree-closed > .jstree-ocl:before {
    content: '';
    display: none;
}

#ktree-jstree .jstree-leaf > .jstree-ocl {
    width: 24px;
    height: 32px;
}

/* Level-specific styling */
#ktree-jstree > .jstree-container-ul {
    padding: 0;
    margin: 0;
}

#ktree-jstree > .jstree-container-ul > .jstree-node {
    padding: 0;
    margin-left: 0;
}

/* All nodes have consistent styling */
#ktree-jstree .jstree-anchor {
    font-size: var(--ktree-font-size-base) !important;
    color: #1a1a1a !important;
}

#ktree-jstree .jstree-anchor.jstree-clicked {
    color: white !important;
}

#ktree-jstree .jstree-anchor:hover {
    color: white !important;
}

/* Search highlighting in JSTree */
#ktree-jstree .jstree-search {
    background: #fff3cd;
    color: #856404;
    padding: 1px 2px;
    border-radius: 2px;
    font-weight: 500;
}

/* Remove JSTree default themer styles we don't want */
#ktree-jstree .jstree-default .jstree-node {
    min-height: auto;
    margin-left: 0 !important;
}

#ktree-jstree .jstree-default .jstree-anchor {
    line-height: 28px;
    height: 28px;
}

#ktree-jstree .jstree-default .jstree-wholerow {
    height: 28px;
}

/* Force inline display for JSTree components */
#ktree-jstree .jstree-icon.jstree-ocl {
    float: none !important;
    display: inline-block !important;
    vertical-align: middle !important;
}

#ktree-jstree .jstree-anchor {
    display: inline-block !important;
    vertical-align: middle !important;
}

#ktree-jstree li > .jstree-icon {
    margin-right: 0 !important;
}

/* Hide JSTree loading animation */
#ktree-jstree .jstree-loading {
    background: transparent;
}

/* Fix JSTree inline display */
#ktree-jstree .jstree-icon {
    display: inline-block;
    vertical-align: top;
}

#ktree-jstree > ul > li {
    white-space: nowrap;
}

#ktree-jstree .jstree-wholerow-ul .jstree-leaf > .jstree-ocl {
    background: transparent;
    width: 24px;
    height: 32px;
}

#ktree-jstree .jstree-default .jstree-icon {
    background-image: none;
}

#ktree-jstree .jstree-default > .jstree-container-ul > .jstree-node {
    margin-left: 0;
    margin-right: 0;
}

/* JSTree container adjustments */
#ktree-jstree ul, #ktree-jstree li {
    list-style: none;
    margin: 0;
    padding: 0;
}

.ktree-menu::-webkit-scrollbar {
    width: 6px;
}

.ktree-menu::-webkit-scrollbar-track {
    background: transparent;
}

.ktree-menu::-webkit-scrollbar-thumb {
    background: var(--ktree-border);
    border-radius: 2px;
}

/* Content Area */
.ktree-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--ktree-bg);
    transition: width var(--ktree-transition-normal);
    min-height: 100vh;
    overflow: visible;
    width: 60%;
}

/* Container with outline panel - 20% / 60% / 20% layout */
.ktree-container.with-outline .ktree-content {
    width: 60%;
}

.ktree-container.with-outline .ktree-outline-panel {
    display: flex;
}

.ktree-container:not(.with-outline) .ktree-outline-panel {
    display: none;
}

.ktree-container:not(.with-outline) .ktree-content {
    width: 80%; /* Take full remaining space when outline is hidden (100% - 20% sidebar) */
}

/* Content Header */
.ktree-content-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--ktree-space-sm) var(--ktree-space-lg);
    border-bottom: var(--ktree-border-width) solid var(--ktree-border);
    background: #f3f4f6 !important;
    min-height: 44px;
}


.ktree-toolbar {
    display: flex;
    gap: var(--ktree-space-sm);
}

.ktree-btn {
    display: flex;
    align-items: center;
    gap: var(--ktree-space-xs);
    height: 32px;
    padding: 0 var(--ktree-space-sm);
    border: var(--ktree-border-width) solid var(--ktree-border);
    border-radius: var(--ktree-radius-sm);
    background: var(--ktree-bg);
    color: var(--ktree-text-muted);
    font-size: var(--ktree-font-size-sm);
    font-weight: 500;
    cursor: pointer;
    transition: var(--ktree-transition);
    text-decoration: none;
}

.ktree-btn:hover {
    border-color: var(--ktree-primary);
    color: var(--ktree-primary);
}

.ktree-btn.active,
.ktree-outline-toggle.active {
    background: var(--ktree-primary) !important;
    color: white !important;
    border-color: var(--ktree-primary) !important;
}

/* Ensure inactive button has normal styling */
.ktree-outline-toggle:not(.active) {
    background: var(--ktree-bg) !important;
    color: var(--ktree-text-muted) !important;
    border-color: var(--ktree-border) !important;
}

.ktree-btn i {
    width: 16px;
    height: 16px;
}

/* Override for print button */
.ktree-print-btn i {
    width: 10px !important;
    height: 10px !important;
    font-size: 10px !important;
    transform: scale(0.6) !important;
}

.ktree-print-btn {
    width: 32px;
    padding: 0;
    justify-content: center;
}


.ktree-print-btn:hover {
    background: #45598f;
    color: white;
    border-color: #45598f;
}

.ktree-print-btn:active {
    background: #45598f;
    color: white;
    border-color: #45598f;
    opacity: 0.9;
}

/* ==========================================================================
   OUTLINE PANEL
   ========================================================================== */

.ktree-outline-panel {
    /* Layout */
    width: 20%;
    min-width: 200px;
    height: 100vh;
    position: sticky;
    top: 98px;
    z-index: var(--ktree-z-sticky);
    
    /* Visual */
    background: #f3f4f6 !important;
    border-left: var(--ktree-border-width) solid var(--ktree-gray-200);
    
    /* Layout structure */
    display: flex;
    flex-direction: column;
    
    /* Typography */
    font-size: 0.85rem;
}

.ktree-outline-header {
    /* Layout */
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--ktree-space-sm) var(--ktree-space-md);
    
    /* Visual */
    border-bottom: var(--ktree-border-width) solid var(--ktree-border);
    background: #f3f4f6 !important;
    min-height: 49px;
}

.ktree-outline-title {
    /* Typography */
    font-size: 0.85rem !important;
    font-weight: 300;
    color: #1a1a1a;
    margin: 0;
    margin-bottom: 0 !important;
}

/* Override Fusion Typography for outline title */
.ktree-outline-title.fusion-responsive-typography-calculated {
    font-size: 0.85rem !important;
}

.ktree-outline-close {
    display: none !important;
}



.ktree-outline-content {
    /* Layout */
    flex: 1;
    overflow-y: auto;
    padding: var(--ktree-space-sm) var(--ktree-space-md);
    padding-left: 0 !important;
    
    /* Typography */
    font-size: 0.85rem;
}

.ktree-outline-empty {
    /* Layout */
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100px;
    
    /* Typography */
    color: #1a1a1a;
    font-style: italic;
    text-align: center;
    font-size: 0.85rem;
    font-weight: 300;
}

.ktree-outline-list {
    /* Reset */
    list-style: none;
    margin: 0;
    padding: 0;
    padding-left: 1rem !important;
}

.ktree-outline-item {
    /* Layout */
    margin-bottom: var(--ktree-space-xs);
}

.ktree-outline-link {
    /* Layout */
    display: block;
    padding: var(--ktree-space-xs) var(--ktree-space-sm);
    
    /* Visual */
    color: #1a1a1a;
    text-decoration: none;
    border-radius: var(--ktree-radius-sm);
    border-left: 3px solid transparent;
    
    /* Typography */
    font-size: 0.85rem;
    font-weight: 300;
    line-height: var(--ktree-line-height-normal);
    
    /* Interaction */
    cursor: pointer;
    transition: all var(--ktree-transition);
}

.ktree-outline-link:hover {
    background: var(--ktree-primary-light);
    color: #1a1a1a;
    border-left-color: var(--ktree-primary);
}

.ktree-outline-link.active {
    background: var(--ktree-primary-light);
    color: #1a1a1a;
    border-left-color: var(--ktree-primary);
    font-weight: 300;
}

/* Heading level styling */
.ktree-outline-link.level-1 {
    font-weight: 300;
    font-size: 0.85rem;
    margin-bottom: var(--ktree-space-xs);
}

.ktree-outline-link.level-2 {
    padding-left: var(--ktree-space-md);
    font-weight: 300;
    font-size: 0.85rem;
}

.ktree-outline-link.level-3 {
    padding-left: var(--ktree-space-lg);
    font-size: 0.85rem;
    font-weight: 300;
}

.ktree-outline-link.level-4,
.ktree-outline-link.level-5,
.ktree-outline-link.level-6 {
    padding-left: var(--ktree-space-xl);
    font-size: 0.85rem;
    color: #1a1a1a;
    font-weight: 300;
}

/* Scrollbar styling for outline content */
.ktree-outline-content::-webkit-scrollbar {
    width: 6px;
}

.ktree-outline-content::-webkit-scrollbar-track {
    background: transparent;
}

.ktree-outline-content::-webkit-scrollbar-thumb {
    background: var(--ktree-border);
    border-radius: 2px;
}


/* Mobile Toggle */
.ktree-mobile-toggle {
    display: none;
    position: fixed;
    top: var(--ktree-space-md);
    left: var(--ktree-space-md);
    z-index: 1000;
    width: 40px;
    height: 40px;
    background: var(--ktree-primary);
    color: white;
    border: none;
    border-radius: var(--ktree-radius);
    cursor: pointer;
    box-shadow: var(--ktree-shadow);
    transition: var(--ktree-transition);
}

.ktree-mobile-toggle:hover {
    background: var(--ktree-primary-hover);
}

.ktree-mobile-toggle i {
    width: 20px;
    height: 20px;
}

/* Content Body */
.ktree-content-area {
    flex: 1;
    padding: 5px 5px var(--ktree-space-xl) 5px;
    overflow: visible;
    background: var(--ktree-bg);
    position: relative;
    transition: opacity var(--ktree-animation-content-fade);
}

/* Normal padding for chapter dummy pages */
.ktree-content-area:has(.ktree-clean-toc),
.ktree-content-area:has(.ktree-auto-toc-placeholder) {
    padding: var(--ktree-space-lg) var(--ktree-space-lg) var(--ktree-space-xl) var(--ktree-space-lg);
}

/* Remove empty state styles - no longer needed */

/* Content Area Loading */
.ktree-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(2px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.ktree-loading.show {
    opacity: 1;
}

.ktree-loading-icon {
    width: 60px;
    height: 60px;
    border: 8px solid transparent;
    border-top: 8px solid #45598f;
    border-right: 8px solid #45598f;
    border-bottom: 8px solid #45598f;
    border-radius: 50%;
    animation: ktree-spin 0.8s linear infinite;
}

@keyframes ktree-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Alternative inline loading for smaller contexts */
.ktree-loading-inline {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60px;
    height: 60px;
    background: white;
    border-radius: 2px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.ktree-loading-inline .ktree-loading-spinner {
    width: 24px;
    height: 24px;
    border: 3px solid #e0e0e0;
    border-top: 3px solid #45598f;
    border-radius: 50%;
    animation: ktree-spin 0.8s linear infinite;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .ktree-loading-inline {
        width: 50px;
        height: 50px;
    }
    
    .ktree-loading-inline .ktree-loading-spinner {
        width: 20px;
        height: 20px;
        border-width: 2px;
    }
}

/* Error State */
.ktree-error {
    display: flex;
    align-items: center;
    gap: var(--ktree-space-sm);
    padding: var(--ktree-space-md);
    margin: var(--ktree-space-md);
    background: #f8d7da;
    color: #721c24;
    border: var(--ktree-border-width) solid #f5c6cb;
    border-radius: var(--ktree-radius);
    font-size: var(--ktree-font-size-sm);
}

.ktree-error-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* Clean TOC styling */
.ktree-clean-toc {
    list-style-type: disc;
    margin: var(--ktree-space-md) 0;
    padding-left: var(--ktree-space-xl);
    font-size: var(--ktree-font-size-lg);
}

.ktree-clean-toc ul {
    list-style-type: circle;
    margin: var(--ktree-space-sm) 0;
    padding-left: var(--ktree-space-xl);
    font-size: var(--ktree-font-size-base);
}

.ktree-clean-toc ul ul {
    list-style-type: square;
    font-size: var(--ktree-font-size-base);
}

.ktree-clean-toc ul ul ul {
    list-style-type: disc;
    font-size: var(--ktree-font-size-sm);
}

.ktree-clean-toc li {
    margin-bottom: var(--ktree-space-sm);
    line-height: var(--ktree-line-height-relaxed);
}

.ktree-clean-toc li::marker {
    font-size: 1.2em;
}

.ktree-toc-link {
    color: var(--ktree-primary);
    text-decoration: none;
    cursor: pointer;
    transition: color var(--ktree-transition-fast);
    font-weight: var(--ktree-font-weight-medium);
}

.ktree-toc-link:hover {
    color: var(--ktree-primary-hover);
    text-decoration: underline;
}

.ktree-no-content {
    color: var(--ktree-text-muted);
    font-style: italic;
    text-align: center;
    padding: var(--ktree-space-lg);
}

/* Content Typography */
.ktree-content-area h1,
.ktree-content-area h2,
.ktree-content-area h3,
.ktree-content-area h4,
.ktree-content-area h5,
.ktree-content-area h6 {
    color: var(--ktree-text);
    font-weight: 600;
    line-height: 1.3;
    margin: var(--ktree-space-lg) 0 var(--ktree-space-md) 0;
}

.ktree-content-area h1:first-child,
.ktree-content-area h2:first-child,
.ktree-content-area h3:first-child {
    margin-top: 0;
}

.ktree-content-area h1 {
    font-size: 28px;
    border-bottom: var(--ktree-border-width) solid var(--ktree-border);
    padding-bottom: var(--ktree-space-sm);
}

.ktree-content-area h2 {
    font-size: 24px;
}

/* Only the KTree-generated node title gets the special color */
.ktree-content-area h1.ktree-node-title {
    display: none; /* Hidden by default */
    color: #2c385b;
    text-align: left;
    border-bottom: 1px solid #e0e0e0;
    padding-bottom: 8px;
    margin-bottom: -21px !important;
    font-size: 1.7rem !important;
    font-weight: 600 !important;
}

/* Show title only on chapter pages (with TOC) */
.ktree-content-area:has(.ktree-clean-toc) h1.ktree-node-title,
.ktree-content-area:has(.ktree-auto-toc-placeholder) h1.ktree-node-title {
    display: block !important; /* Show for chapter dummies */
    margin-bottom: 1rem !important;
}

.ktree-content-area h3 {
    font-size: 20px;
}

.ktree-content-area p {
    margin-bottom: var(--ktree-space-md);
    color: var(--ktree-text);
    line-height: 1.6;
}

.ktree-content-area ul,
.ktree-content-area ol {
    margin-bottom: var(--ktree-space-md);
    padding-left: var(--ktree-space-lg);
}

.ktree-content-area li {
    margin-bottom: var(--ktree-space-xs);
    line-height: 1.6;
}

.ktree-content-area img {
    max-width: 100%;
    height: auto;
    border-radius: var(--ktree-radius);
    margin: var(--ktree-space-md) 0;
}

.ktree-content-area blockquote {
    margin: var(--ktree-space-md) 0;
    padding: var(--ktree-space-md);
    background: var(--ktree-bg-alt);
    border-left: 4px solid var(--ktree-primary);
    border-radius: 0 2px 2px 0;
    color: var(--ktree-text-muted);
}

.ktree-content-area code {
    background: var(--ktree-bg-alt);
    padding: 2px 4px;
    border-radius: var(--ktree-radius-sm);
    font-size: 85%;
    color: var(--ktree-error);
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
}

.ktree-content-area pre {
    background: var(--ktree-bg-alt);
    padding: var(--ktree-space-md);
    border-radius: var(--ktree-radius);
    overflow-x: auto;
    margin: var(--ktree-space-md) 0;
    border: var(--ktree-border-width) solid var(--ktree-border);
}

.ktree-content-area pre code {
    background: transparent;
    padding: 0;
    color: var(--ktree-text);
}

/* Print Styles */
.ktree-print-view {
    display: none;
}

/* Mobile Responsive */
@media (max-width: 1200px) {
    .ktree-container {
        position: relative;
    }
    
    .ktree-sidebar {
        position: absolute;
        top: 0;
        left: 0;
        height: 100%;
        width: 70%;
        max-width: 350px;
        z-index: 1001;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        box-shadow: var(--ktree-shadow);
        border-radius: 0 2px 2px 0;
    }
    
    .ktree-sidebar.ktree-open {
        transform: translateX(0);
    }
    
    .ktree-content {
        width: 100%;
    }
    
    .ktree-content-area {
        padding-top: 80px;
    }
    
    .ktree-mobile-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .ktree-sidebar-toggle {
        display: flex !important;
    }
    
    /* Hide outline panel on mobile */
    .ktree-outline-panel {
        display: none;
    }
    
    .ktree-container.with-outline .ktree-content {
        width: 100%;
    }
    
    .ktree-overlay {
        display: none !important;
    }
}

@media (max-width: 1200px) {
    /* Hide outline panel on smaller screens */
    .ktree-outline-panel {
        display: none !important;
    }
    
    .ktree-container.with-outline {
        padding-right: 0 !important; /* Remove reserved space for outline panel */
    }
    
    .ktree-container.with-outline .ktree-content {
        width: 80% !important; /* Take full space when outline is hidden */
    }
    
    .ktree-outline-toggle {
        display: none !important; /* Hide toggle button */
    }
}

@media (max-width: 480px) {
    .ktree-sidebar {
        width: 280px;
        min-width: 280px;
    }
    
    .ktree-content-area {
        padding: var(--ktree-space-md);
        padding-top: 80px;
    }
    
    .ktree-search {
        padding: var(--ktree-space-sm);
    }
}

/* Hide overlay completely */
.ktree-overlay {
    display: none !important;
}

/* ==========================================================================
   CONTEXT MENU
   ========================================================================== */

.ktree-context-menu {
    position: fixed;
    z-index: var(--ktree-z-modal);
    background: var(--ktree-white);
    border: var(--ktree-border-width) solid var(--ktree-border);
    border-radius: var(--ktree-radius);
    box-shadow: var(--ktree-shadow-lg);
    padding: var(--ktree-space-xs);
    min-width: 150px;
    display: none;
    opacity: 0;
    transform: scale(0.95);
    transition: all var(--ktree-transition-fast);
    pointer-events: none;
}

.ktree-context-menu.show {
    display: block;
    opacity: 1;
    transform: scale(1);
    pointer-events: auto;
}

.ktree-context-menu-item {
    display: flex;
    align-items: center;
    gap: var(--ktree-space-xs);
    padding: var(--ktree-space-xs) var(--ktree-space-sm);
    border-radius: var(--ktree-radius-sm);
    cursor: pointer;
    font-size: var(--ktree-font-size-sm);
    color: var(--ktree-text);
    transition: all var(--ktree-transition-fast);
    border: var(--ktree-border-width) solid transparent;
}

.ktree-context-menu-item:hover {
    background: var(--ktree-primary-light);
    color: var(--ktree-primary);
    border-color: var(--ktree-primary);
}

.ktree-context-menu-item i {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.ktree-context-menu-item.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.ktree-context-menu-item.disabled:hover {
    background: transparent;
    color: var(--ktree-text);
    border-color: transparent;
}

.ktree-context-menu-separator {
    height: 1px;
    background: var(--ktree-border);
    margin: var(--ktree-space-xs) 0;
}


/* Print Media */
@media print {
    body * {
        visibility: hidden;
    }
    
    .ktree-print-view,
    .ktree-print-view * {
        visibility: visible;
    }
    
    .ktree-print-view {
        display: block !important;
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        padding: 20pt;
        font-family: 'Times New Roman', serif;
        font-size: 12pt;
        line-height: 1.4;
        color: #000;
        background: white;
    }
    
    /* Title Page */
    .ktree-print-title-page {
        page-break-after: always;
        text-align: center;
        padding-top: 200pt;
    }
    
    .ktree-print-main-title {
        font-size: 36pt;
        font-weight: bold;
        margin-bottom: 20pt;
    }
    
    .ktree-print-subtitle {
        font-size: 18pt;
        color: #666;
        margin-bottom: 30pt;
        font-style: italic;
    }
    
    .ktree-print-date {
        font-size: 14pt;
        color: #666;
    }
    
    /* Table of Contents */
    .ktree-print-toc-page {
        page-break-after: always;
    }
    
    .ktree-print-toc-title {
        font-size: 24pt;
        font-weight: bold;
        margin-bottom: 30pt;
        text-align: center;
    }
    
    .ktree-print-toc-item {
        display: flex;
        align-items: baseline;
        margin-bottom: 12pt;
        font-size: 12pt;
    }
    
    .ktree-print-toc-number {
        margin-right: 10pt;
        min-width: 30pt;
    }
    
    .ktree-print-toc-text {
        flex: 0 0 auto;
    }
    
    .ktree-print-toc-dots {
        flex: 1;
        border-bottom: 1pt dotted #666;
        margin: 0 5pt;
        height: 1em;
    }
    
    .ktree-print-toc-page-number {
        flex: 0 0 auto;
        text-align: right;
        min-width: 20pt;
    }
    
    /* Content Pages */
    .ktree-print-page {
        page-break-before: always;
        position: relative;
        min-height: 100vh;
    }
    
    .ktree-print-page-header {
        margin-bottom: 20pt;
        border-bottom: 1pt solid #ddd;
        padding-bottom: 10pt;
    }
    
    .ktree-print-page-header h2 {
        font-size: 20pt;
        margin: 0;
    }
    
    .ktree-print-page-content {
        font-size: 11pt;
        line-height: 1.6;
    }
    
    .ktree-print-page-footer {
        position: absolute;
        bottom: 20pt;
        left: 0;
        right: 0;
        text-align: center;
        font-size: 10pt;
        color: #666;
    }
    
    /* Content styling within pages */
    .ktree-print-page-content h1,
    .ktree-print-page-content h2,
    .ktree-print-page-content h3 {
        margin-top: 15pt;
        margin-bottom: 10pt;
    }
    
    .ktree-print-page-content p {
        margin-bottom: 10pt;
    }
    
    .ktree-print-page-content ul,
    .ktree-print-page-content ol {
        margin-bottom: 10pt;
        padding-left: 20pt;
    }
    
    .ktree-print-page-content img {
        max-width: 100%;
        height: auto;
    }
}