/**
 * More Brains — Sidebar Accordion + Files Tree Styles
 */

/* ========================================
   Right Sidebar Flex Container
   ======================================== */
.cortex__sidebar--right {
    display: flex;
    flex-direction: column;
}

/* ========================================
   Accordion Section States
   ======================================== */
.sidebar-section[data-accordion-id] {
    transition: flex 0.2s ease, max-height 0.2s ease;
}

.sidebar-section--collapsed {
    flex: 0 0 auto !important;
    max-height: none !important;
    min-height: 0 !important;
    overflow: hidden;
}

.sidebar-section--expanded {
    flex: 1 1 auto !important;
    max-height: none !important;
    overflow: hidden;
}

/* Chevron in header */
.sidebar-section__chevron {
    margin-left: auto;
    font-size: var(--text-xs);
    color: var(--text-muted);
    transition: transform 0.2s ease;
    user-select: none;
    flex-shrink: 0;
}

/* Count badge in header */
.sidebar-section__count {
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    color: var(--text-muted);
    background-color: var(--bg-elevated);
    padding: 1px 6px;
    border-radius: 9999px;
    min-width: 20px;
    text-align: center;
    flex-shrink: 0;
}

/* Accordion body wrapper */
.sidebar-section__body {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}

/* Accordion footer wrapper */
.sidebar-section__footer {
    flex-shrink: 0;
}

/* ========================================
   Files Sidebar Tree
   ======================================== */
.files-sidebar__empty {
    color: var(--text-muted);
    font-style: italic;
    font-size: var(--text-sm);
    padding: var(--space-2);
    text-align: center;
}

/* Folder */
.files-sidebar__folder {
    margin-bottom: var(--space-1);
}

.files-sidebar__folder-header {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2);
    font-size: var(--text-sm);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background-color var(--transition-fast);
    user-select: none;
}

.files-sidebar__folder-header:hover {
    background-color: var(--bg-elevated);
}

.files-sidebar__folder-chevron {
    font-size: var(--text-xs);
    color: var(--text-muted);
    width: 12px;
    text-align: center;
    flex-shrink: 0;
}

.files-sidebar__folder-icon {
    flex-shrink: 0;
    font-size: var(--text-sm);
}

.files-sidebar__folder-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 500;
}

.files-sidebar__folder-contents {
    padding-left: var(--space-3);
}

/* Divider between folders and root files */
.files-sidebar__divider {
    height: 1px;
    background: var(--border-muted);
    margin: var(--space-2) 0;
}

/* File row */
.files-sidebar__file {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-1) var(--space-2);
    font-size: var(--text-sm);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background-color var(--transition-fast);
    user-select: none;
}

.files-sidebar__file:hover {
    background-color: var(--bg-elevated);
}

.files-sidebar__file--selected {
    background-color: var(--bg-elevated);
    border-left: 3px solid var(--accent-primary);
    padding-left: calc(var(--space-2) - 3px);
}

.files-sidebar__file--selected .files-sidebar__file-name {
    font-weight: 500;
}

.files-sidebar__file--indented {
    /* Already indented by folder-contents padding */
}

.files-sidebar__file-icon {
    flex-shrink: 0;
    font-size: var(--text-sm);
    width: 18px;
    text-align: center;
}

.files-sidebar__file-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ========================================
   Context Menu
   ======================================== */
.files-sidebar__context-menu {
    background: var(--bg-panel);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 10000;
    padding: var(--space-1) 0;
    min-width: 160px;
}

.files-sidebar__context-menu button {
    display: block;
    width: 100%;
    padding: var(--space-2) var(--space-3);
    text-align: left;
    background: none;
    border: none;
    cursor: pointer;
    font-family: var(--font-sans);
    font-size: var(--text-sm);
    color: var(--text-primary);
    transition: background-color var(--transition-fast);
}

.files-sidebar__context-menu button:hover {
    background-color: var(--bg-elevated);
}

.files-sidebar__ctx-danger {
    color: var(--accent-danger) !important;
}

.files-sidebar__ctx-danger:hover {
    background-color: rgba(157, 0, 6, 0.1) !important;
}

[data-theme="dark"] .files-sidebar__ctx-danger:hover {
    background-color: rgba(249, 38, 114, 0.1) !important;
}
