/* Sidebar */
.main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
    min-height: 0;
}

.sidebar {
    display: flex;
    flex-shrink: 0;
    height: 100%;
    transition: width 0.2s ease;
}

.sidebar.collapsed {
    width: 48px;
}

.sidebar:not(.collapsed) {
    width: 328px; /* 48px icons + 280px panel */
}

.sidebar-icons {
    display: flex;
    flex-direction: column;
    width: 48px;
    background: var(--gray-100, #f3f4f6);
    border-right: 1px solid var(--gray-200, #e5e7eb);
    padding: 8px 0;
    gap: 4px;
    align-items: center;
}

.sidebar-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    border-radius: 8px;
    cursor: pointer;
    color: var(--gray-500, #6b7280);
    transition: all 0.15s ease;
}

.sidebar-icon:hover {
    background: var(--gray-200, #e5e7eb);
    color: var(--gray-700, #374151);
}

.sidebar-icon.active {
    background: var(--gray-200, #e5e7eb);
    color: var(--primary-dark, #5661b3);
    box-shadow: inset 3px 0 0 var(--primary-dark, #5661b3);
}

.sidebar-icon:focus-visible {
    outline: 2px solid var(--primary-dark, #5661b3);
    outline-offset: 2px;
}

.sidebar-panel {
    width: 280px;
    background: var(--gray-50, #f9fafb);
    border-right: 1px solid var(--gray-200, #e5e7eb);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar.collapsed .sidebar-panel {
    display: none;
}

.sidebar-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--gray-200, #e5e7eb);
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--gray-600, #4b5563);
}

.sidebar-panel-close {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: var(--gray-400, #9ca3af);
    padding: 0 4px;
    border-radius: 4px;
}

.sidebar-panel-close:hover {
    background: var(--gray-200, #e5e7eb);
    color: var(--gray-600, #4b5563);
}

.sidebar-panel-close:focus-visible {
    outline: 2px solid var(--primary-dark, #5661b3);
    outline-offset: 2px;
}

.sidebar-panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

/* Dark theme support */
body[class*="dark"] .sidebar-icons,
body[class*="dark"] .sidebar-panel {
    background: #1e1e1e;
    border-color: #333;
}

body[class*="dark"] .sidebar-icon {
    color: #888;
}

body[class*="dark"] .sidebar-icon:hover {
    background: #333;
    color: #ccc;
}

body[class*="dark"] .sidebar-icon.active {
    background: #333;
    color: #8b9aff;
    box-shadow: inset 3px 0 0 #8b9aff;
}

body[class*="dark"] .sidebar-panel-header {
    border-color: #333;
    color: #ccc;
}

/* Panel list items (templates, etc.) */
.panel-list-item {
    padding: 10px 12px;
    border-radius: 6px;
    cursor: pointer;
    margin-bottom: 4px;
}
.panel-list-item:hover {
    background: var(--gray-200, #e5e7eb);
}
.panel-list-item-title {
    font-size: 13px;
    font-weight: 500;
    color: var(--gray-800, #1f2937);
}
.panel-list-item-desc {
    font-size: 11px;
    color: var(--gray-500, #6b7280);
    margin-top: 2px;
}

body[class*="dark"] .panel-list-item:hover {
    background: #333;
}
body[class*="dark"] .panel-list-item-title {
    color: #ddd;
}
body[class*="dark"] .panel-list-item-desc {
    color: #888;
}

/* Explorer Panel */
.explorer-toolbar {
    display: flex;
    gap: 4px;
    margin-bottom: 8px;
}
.explorer-path {
    flex: 1;
    padding: 6px 8px;
    border: 1px solid var(--gray-300, #d1d5db);
    border-radius: 6px;
    font-size: 12px;
    background: white;
    overflow: hidden;
    text-overflow: ellipsis;
}
.explorer-browse-btn {
    border: 1px solid var(--gray-300, #d1d5db);
    border-radius: 6px;
    background: white;
    cursor: pointer;
    padding: 4px 8px;
}
.tree-item {
    padding: 3px 0;
    cursor: pointer;
    font-size: 13px;
    user-select: none;
}
.tree-item:hover {
    background: var(--gray-100, #f3f4f6);
    border-radius: 4px;
}
.tree-icon {
    margin-right: 4px;
    font-size: 12px;
}
.tree-children {
    padding-left: 16px;
}
.tree-folder.collapsed .tree-children {
    display: none;
}
.tree-name {
    font-size: 13px;
}

/* Git Panel */
.git-section { margin-bottom: 16px; }
.git-section-title { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--gray-500); margin-bottom: 8px; }
.git-file { display: flex; align-items: center; padding: 4px 6px; border-radius: 4px; font-size: 13px; gap: 6px; }
.git-file:hover { background: var(--gray-100, #f3f4f6); }
.git-file-status { font-weight: 700; font-family: monospace; width: 16px; text-align: center; }
.git-file-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.git-stage-btn { border: none; background: var(--gray-200); border-radius: 4px; cursor: pointer; font-size: 14px; width: 22px; height: 22px; }
.git-commit-input { width: 100%; padding: 8px; border: 1px solid var(--gray-300); border-radius: 6px; font-size: 13px; font-family: inherit; resize: vertical; box-sizing: border-box; }
.git-commit-btn { width: 100%; margin-top: 8px; padding: 8px; background: var(--primary-dark, #5661b3); color: white; border: none; border-radius: 6px; font-size: 13px; cursor: pointer; }
.git-commit-btn:hover { opacity: 0.9; }
.git-log-entry { padding: 6px 0; border-bottom: 1px solid var(--gray-100); }
.git-log-msg { font-size: 13px; }
.git-log-meta { font-size: 11px; color: var(--gray-500); margin-top: 2px; }
.git-info { font-size: 13px; color: var(--gray-500); padding: 8px 0; }
.git-loading { font-size: 13px; color: var(--gray-400); }

/* Snippets Panel */
.snippets-toolbar { display: flex; gap: 4px; margin-bottom: 8px; }
.snippets-search { flex: 1; padding: 6px 10px; border: 1px solid var(--gray-300); border-radius: 6px; font-size: 13px; }
.snippets-add-btn { width: 32px; border: 1px solid var(--gray-300); border-radius: 6px; background: white; font-size: 18px; cursor: pointer; }
.snippet-item { padding: 8px; border: 1px solid var(--gray-200); border-radius: 6px; margin-bottom: 6px; }
.snippet-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.snippet-name { font-size: 13px; font-weight: 500; }
.snippet-lang { font-size: 11px; background: var(--gray-100); padding: 2px 6px; border-radius: 4px; color: var(--gray-500); }
.snippet-preview { font-size: 12px; background: var(--gray-50); padding: 6px; border-radius: 4px; margin: 4px 0; overflow: hidden; max-height: 60px; }
.snippet-preview code { font-family: 'JetBrains Mono', monospace; }
.snippet-actions { display: flex; gap: 4px; }
.snippet-insert { font-size: 12px; padding: 4px 8px; border: 1px solid var(--gray-300); border-radius: 4px; background: white; cursor: pointer; }
.snippet-delete { font-size: 14px; padding: 4px 8px; border: 1px solid var(--gray-300); border-radius: 4px; background: white; cursor: pointer; color: #ef4444; }

/* Dark theme for sidebar panels */
body[class*="dark"] .explorer-path,
body[class*="dark"] .explorer-browse-btn,
body[class*="dark"] .snippets-search,
body[class*="dark"] .snippets-add-btn,
body[class*="dark"] .snippet-insert,
body[class*="dark"] .snippet-delete {
    background: #2d2d2d;
    border-color: #444;
    color: #ccc;
}
body[class*="dark"] .git-commit-input {
    background: #2d2d2d;
    border-color: #444;
    color: #ccc;
}
body[class*="dark"] .snippet-item {
    border-color: #444;
}
body[class*="dark"] .snippet-preview {
    background: #2d2d2d;
}
body[class*="dark"] .tree-item:hover,
body[class*="dark"] .git-file:hover {
    background: #333;
}

/* Outline Panel */
.outline-panel { display: flex; flex-direction: column; height: 100%; }
.outline-list { flex: 1; overflow-y: auto; padding: 4px 0; }
.outline-item { display: flex; align-items: center; justify-content: space-between; padding: 4px 12px; cursor: pointer; font-size: 13px; color: var(--text-secondary, #6b7280); transition: background 0.15s, color 0.15s; border-left: 2px solid transparent; }
.outline-item:hover { background: var(--bg-tertiary, #f3f4f6); color: var(--text-primary, #1f2937); }
.outline-item.active { color: var(--accent-blue, #3b82f6); background: rgba(59, 130, 246, 0.08); border-left-color: var(--accent-blue, #3b82f6); font-weight: 600; }
.outline-level-1 { padding-left: 12px; }
.outline-level-2 { padding-left: 24px; }
.outline-level-3 { padding-left: 36px; }
.outline-level-4 { padding-left: 48px; }
.outline-level-5 { padding-left: 56px; }
.outline-level-6 { padding-left: 64px; }
.outline-text { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.outline-badge { font-size: 10px; opacity: 0.5; margin-left: 8px; flex-shrink: 0; }
.outline-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 32px 16px; color: var(--text-muted, #9ca3af); text-align: center; }
.outline-empty p { margin: 4px 0; }
.outline-hint { font-family: monospace; font-size: 12px; opacity: 0.7; }
.outline-footer { padding: 8px 12px; border-top: 1px solid var(--border-color, #e5e7eb); font-size: 11px; color: var(--text-muted, #9ca3af); }

/* Outline dark mode */
body[class*="dark"] .outline-item { color: #9ca3af; }
body[class*="dark"] .outline-item:hover { background: #374151; color: #e5e7eb; }
body[class*="dark"] .outline-item.active { color: #8b9aff; background: rgba(139, 154, 255, 0.1); border-left-color: #8b9aff; }
body[class*="dark"] .outline-empty { color: #6b7280; }
body[class*="dark"] .outline-footer { border-color: #333; color: #6b7280; }
