/* =================================================================
 * SIDEBAR CSS - Navigation Sidebar Styles
 * FEATURE-001: Project Navigation
 * ================================================================= */

/* =================================================================
 * SIDEBAR LAYOUT
 * ================================================================= */
.sidebar {
    flex: 0 0 var(--sidebar-width);
    width: var(--sidebar-width);
    min-width: 200px;
    max-width: 500px;
    background-color: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0; /* Critical: allows scrolling inside */
}

/* Sidebar Resize Handle */
.sidebar-resize-handle {
    flex: 0 0 4px;
    width: 4px;
    background-color: transparent;
    cursor: col-resize;
    transition: background-color 0.2s ease;
    position: relative;
}

.sidebar-resize-handle:hover,
.sidebar-resize-handle.resizing {
    background-color: var(--bs-primary, #0d6efd);
}

.sidebar-resize-handle::before {
    content: '';
    position: absolute;
    top: 0;
    left: -3px;
    right: -3px;
    bottom: 0;
    /* Larger hit area for easier grabbing */
}

.sidebar-header {
    flex: 0 0 auto;
    padding: 1rem;
    border-bottom: 1px solid var(--sidebar-hover);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.sidebar-header .brand-container {
    display: flex;
    flex-direction: column;
}

.sidebar-header .brand-name {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: #fff;
}

.sidebar-header .brand-subtitle {
    font-size: 0.65rem;
    opacity: 0.7;
    letter-spacing: 0.3px;
}

.sidebar-header h5 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
}

.sidebar-content {
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0.5rem 0;
    min-height: 0; /* Critical: allows scrolling */
}

.sidebar-footer {
    flex: 0 0 auto;
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--sidebar-hover);
}

.sidebar-footer .settings-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 0.85rem;
    opacity: 0.7;
    transition: opacity 0.15s;
}

.sidebar-footer .settings-link:hover {
    opacity: 1;
    color: #fff;
}

.sidebar-footer .settings-link i {
    font-size: 1rem;
}

/* =================================================================
 * TREE NAVIGATION
 * ================================================================= */
.nav-section {
    margin-bottom: 0.25rem;
}

.nav-section-header {
    display: flex;
    align-items: center;
    padding: 0.5rem 1rem;
    cursor: pointer;
    user-select: none;
    transition: background-color 0.15s;
    background-color: rgba(49, 50, 68, 0.35);
    border-radius: 6px;
    margin: 2px 8px;
}

.nav-section-header:hover {
    background-color: var(--sidebar-hover);
}

/* Child items under sections - no background */
.nav-section-header.sidebar-child {
    background-color: transparent;
    border-radius: 0;
    margin: 0;
}

.nav-section-header i {
    margin-right: 0.5rem;
    font-size: 0.9rem;
}

.nav-section-header .chevron {
    margin-left: auto;
    transition: transform 0.2s;
}

.nav-section-header.collapsed .chevron {
    transform: rotate(-90deg);
}

/* Workplace header */
.nav-workplace-header {
    background-color: transparent;
    border-left: none;
}

.nav-workplace-header:hover {
    background-color: var(--sidebar-hover);
}

.nav-section-content {
    padding-left: 0.5rem;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 0.35rem 1rem;
    padding-left: 2rem;
    cursor: pointer;
    font-size: 0.875rem;
    transition: background-color 0.15s;
    text-decoration: none;
    color: var(--sidebar-text);
}

.nav-item:hover {
    background-color: var(--sidebar-hover);
    color: var(--sidebar-text);
}

.nav-item.active {
    background-color: var(--sidebar-active);
}

.nav-item i {
    margin-right: 0.5rem;
    font-size: 0.8rem;
    opacity: 0.8;
}

.nav-folder {
    font-weight: 500;
}

.nav-folder-content {
    padding-left: 1rem;
}

.nav-empty {
    padding: 0.5rem 2rem;
    font-size: 0.8rem;
    opacity: 0.6;
    font-style: italic;
}

/* =================================================================
 * FEATURE-009: File Change Indicator
 * ================================================================= */
.change-indicator {
    display: inline-block;
    width: 6px;
    height: 6px;
    background-color: var(--bs-warning, #ffc107);
    border-radius: 50%;
    margin-right: 6px;
    flex-shrink: 0;
    animation: changeIndicatorFadeIn 0.3s ease-in-out;
    box-shadow: 0 0 4px var(--bs-warning, #ffc107);
}

.nav-item.has-changes {
    display: flex;
    align-items: center;
}

@keyframes changeIndicatorFadeIn {
    from { opacity: 0; transform: scale(0.5); }
    to { opacity: 1; transform: scale(1); }
}

/* =================================================================
 * PINNED STATE (Click to keep open)
 * ================================================================= */
.nav-section-header.pinned::after,
.nav-folder.pinned::after {
    content: '\F588';  /* Bootstrap Icons pin-fill */
    font-family: 'bootstrap-icons';
    font-size: 0.65rem;
    margin-left: auto;
    padding-left: 0.5rem;
    color: var(--bs-warning, #ffc107);
    opacity: 0.9;
}

.nav-section-header.pinned .chevron,
.nav-folder.pinned .chevron {
    display: none;
}

/* =================================================================
 * PROJECT SWITCHER - FEATURE-006
 * ================================================================= */
.project-switcher {
    flex: 0 0 auto;
    padding: 0.5rem 1rem;
    border-bottom: 1px solid var(--sidebar-hover);
}

.project-switcher select {
    width: 100%;
    background-color: var(--sidebar-hover);
    color: var(--sidebar-text);
    border: 1px solid var(--sidebar-active);
    border-radius: 4px;
    padding: 0.375rem 0.5rem;
    font-size: 0.8rem;
}

/* =================================================================
 * FEATURE-004: Auto-refresh toggle styling
 * ================================================================= */
.auto-refresh-toggle {
    opacity: 0.7;
    transition: opacity 0.2s;
}

.auto-refresh-toggle:hover {
    opacity: 1;
}

.auto-refresh-toggle .form-check-input:checked {
    background-color: #28a745;
    border-color: #28a745;
}

/* =================================================================
 * CR-004: Sidebar Submenu Styles
 * ================================================================= */
.sidebar-parent {
    cursor: default;
}

.sidebar-parent[data-no-action="true"]:hover {
    background-color: transparent;
}

.submenu-indicator {
    margin-left: auto;
    font-size: 0.75em;
    opacity: 0.6;
}

.sidebar-submenu {
    display: flex;
    flex-direction: column;
}

.sidebar-child {
    padding-left: 2rem;
    font-size: 0.9em;
}

.sidebar-child:hover {
    background-color: var(--sidebar-hover, #2a2a3a);
}

.nav-link-item {
    text-decoration: none;
    color: inherit;
}

.nav-link-item:hover {
    color: inherit;
}

.sidebar-child.active,
.sidebar-parent.active-parent {
    background-color: var(--sidebar-active, #3a3a4a);
}

/* FEATURE-049-B: Knowledge Base sidebar styles */
.kb-folder.kb-drag-over {
    border: 2px dashed #10b981 !important;
    background: rgba(16, 185, 129, 0.1) !important;
    border-radius: 6px;
}

.kb-dragging {
    opacity: 0.5;
}

.kb-empty-state {
    font-style: italic;
    opacity: 0.7;
    padding: 0.5rem 1rem;
}

.kb-intake-placeholder {
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    margin-top: 0.25rem;
    padding-top: 0.5rem;
    cursor: default;
}
