/* Base layout styles */
html,
body {
    height: 100vh;
    margin: 0;
    padding: 0;
    overflow: hidden;
    /* Prevent page-level scrolling */
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans', Helvetica, Arial, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    transition: background-color 0.3s ease, color 0.3s ease;
}
body {
    display: flex;
    flex-direction: column;
}
/* Column Resizer */
.column-resizer {
    width: 1px;
    background-color: var(--border-color);
    cursor: col-resize;
    transition: background-color 0.2s ease, width 0.2s ease, box-shadow 0.2s ease;
    user-select: none;
    flex-shrink: 0;
    padding: 0 3px;
    /* Add invisible padding for easier grab */
    margin: 0 -3px;
    /* Compensate for padding */
    height: 100%;
    /* Take full height of parent */
    align-self: stretch;
    /* Ensure it stretches to full height */
}
.column-resizer:hover {
    background-color: var(--link-color);
    width: 1px;
    box-shadow: 0 0 6px rgba(13, 110, 253, 0.3);
    /* Visual feedback instead of width change */
}
.column-resizer.dragging {
    background-color: var(--link-color);
    box-shadow: 0 0 8px rgba(13, 110, 253, 0.5);
}
.column-resizer.dragging {
    background-color: var(--link-color);
}
/* Navbar */
.navbar {
    background-color: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    transition: background-color 0.3s ease;
    flex-shrink: 0;
    /* Prevent navbar from shrinking */
    padding: 0.5rem 1rem;
}
.navbar .container-fluid {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: 0;
    overflow: visible;
    /* Override the hidden overflow for navbar */
}
.navbar-brand {
    color: var(--text-primary) !important;
    font-weight: 600;
    font-size: 1.1rem;
    margin: 0;
    flex-shrink: 0;
}
.navbar-brand i {
    font-size: 1.2rem;
    margin-right: 0.5rem;
}
.navbar-center {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
}
.navbar-right {
    flex-shrink: 0;
}
/* Adjust container for flex layout */
.container-fluid {
    flex: 1;
    /* Take remaining space after navbar */
    padding: 0;
    overflow: hidden;
    /* Prevent container scrolling */
    display: flex;
    flex-direction: column;
}
.row {
    width: 100%;
    display: flex;
    flex-direction: row;
    margin: 0;
    height: 100%;
    overflow: hidden;
    /* Prevent row scrolling */
}
#sidebarPane {
    flex: 0 0 20%;
    min-width: 150px;
    max-width: 20%;
    padding: 0;
    height: 100%;
    overflow: hidden;
    /* Prevent pane scrolling */
    transition: flex 0.3s ease, min-width 0.3s ease, max-width 0.3s ease;
}
/* Collapsed sidebar state - mini sidebar */
#sidebarPane.collapsed {
    flex: 0 0 50px;
    min-width: 50px;
    max-width: 50px;
    border-right: 1px solid var(--border-color);
    position: relative;
    cursor: pointer;
}
/* Hide file tree content when collapsed */
#sidebarPane.collapsed #fileTree {
    display: none;
}
/* Hide collection selector when collapsed */
#sidebarPane.collapsed .collection-selector {
    display: none;
}
/* Visual indicator in the mini sidebar */
#sidebarPane.collapsed::before {
    content: '';
    display: block;
    width: 100%;
    height: 100%;
    background: var(--bg-secondary);
    transition: background 0.2s ease;
}
/* Hover effect on mini sidebar */
#sidebarPane.collapsed:hover::before {
    background: var(--hover-bg);
}
/* Right arrow icon in the center of mini sidebar */
#sidebarPane.collapsed::after {
    content: '\F285';
    /* Bootstrap icon chevron-right */
    font-family: 'bootstrap-icons';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 20px;
    color: var(--text-secondary);
    pointer-events: none;
    opacity: 0.5;
    transition: opacity 0.2s ease;
    cursor: pointer;
}
#sidebarPane.collapsed:hover::after {
    opacity: 1;
}
#editorPane {
    flex: 1 1 40%;
    min-width: 250px;
    max-width: 70%;
    padding: 0;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    /* Prevent pane scrolling */
}
/* Sidebar - improved */
.sidebar {
    background-color: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    height: 100%;
    transition: background-color 0.3s ease;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    /* Prevent sidebar container scrolling */
}
.sidebar h6 {
    margin: 12px 8px 6px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    flex-shrink: 0;
    /* Prevent header from shrinking */
}
/* Collection selector - fixed height */
.collection-selector {
    flex-shrink: 0;
    /* Prevent selector from shrinking */
    padding: 12px 10px;
    background-color: var(--bg-secondary);
}
#fileTree {
    flex: 1;
    /* Take remaining space */
    overflow-y: auto;
    /* Enable vertical scrolling */
    overflow-x: hidden;
    padding: 4px 10px;
    min-height: 0;
    /* Important: allows flex child to shrink below content size */
}
/* Scrollbar styling */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}
::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}
::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 5px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}
/* Preview Pane Styling */
#previewPane {
    min-width: 250px;
    max-width: 70%;
    padding: 0;
    background-color: var(--bg-primary);
    border-left: 1px solid var(--border-color);
    flex: 1;
    height: 100%;
    overflow-y: auto;
    /* Enable vertical scrolling for preview pane */
    overflow-x: hidden;
}
#preview {
    padding: 20px;
    overflow-wrap: break-word;
    word-wrap: break-word;
    color: var(--text-primary);
    min-height: 100%;
    /* Ensure content fills at least the full height */
}
#preview>p:first-child {
    margin-top: 0;
}
#preview>h1:first-child,
#preview>h2:first-child {
    margin-top: 0;
}
/* Iframe styles in preview - minimal defaults that can be overridden */
#preview iframe {
    border: none;
    /* Default to no border, can be overridden by inline styles */
    display: block;
    /* Prevent inline spacing issues */
}
/* View Mode Styles */
body.view-mode #editorPane {
    display: none;
}
body.view-mode #resizer1 {
    display: none;
}
body.view-mode #resizer2 {
    display: none;
}
body.view-mode #previewPane {
    max-width: 100%;
    min-width: auto;
}
body.view-mode #sidebarPane {
    display: flex;
    flex: 0 0 20%;
    height: 100%;
    /* Keep sidebar at 20% width in view mode */
}
body.edit-mode #editorPane {
    display: flex;
}
body.edit-mode #resizer1 {
    display: block;
}
body.edit-mode #resizer2 {
    display: block;
}
body.edit-mode #previewPane {
    max-width: 70%;
}
body.edit-mode #sidebarPane {
    display: flex;
    height: 100%;
}