/* ─────────────────────────────────────────────
   layout.css — Workspace layout and chrome
   ───────────────────────────────────────────── */

/* ── Title Bar ──────────────────────────────── */
.titlebar {
    height: var(--titlebar-h);
    background: var(--bg-titlebar);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 12px;
    flex-shrink: 0;
    -webkit-app-region: drag;
    user-select: none;
}

.window-controls {
    display: flex;
    height: 100%;
    margin-left: auto;
    -webkit-app-region: no-drag;
}

.win-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: var(--win-btn-w);
    height: 100%;
    font-family: var(--font-ui);
    font-size: 11px;
    color: var(--text);
    transition: background 0.1s;
}

.win-btn:hover {
    background: rgba(255, 255, 255, 0.08);
}

.win-btn.close:hover {
    background: #c42b1c;
}

.titlebar-title {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    font-family: var(--font-ui);
    font-size: 12px;
    color: var(--text-muted);
    pointer-events: none;
}

/* ── Workspace ──────────────────────────────── */
.workspace {
    display: flex;
    height: calc(100vh - var(--titlebar-h) - var(--statusbar-h));
    overflow: hidden;
}

.hide-titlebar .workspace {
    height: calc(100vh - var(--statusbar-h));
}

/* ── Activity Bar ───────────────────────────── */
.activity-bar {
    width: var(--activitybar-w);
    background: var(--bg-titlebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 0;
    gap: 2px;
    flex-shrink: 0;
}

.act-btn {
    width: var(--act-btn-size);
    height: var(--act-btn-size);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    color: var(--text-dim);
    position: relative;
    transition:
        color 0.1s,
        background 0.1s;
}

.act-btn:hover {
    color: var(--text);
    background: rgba(128, 128, 128, 0.08);
}
.act-btn.active {
    color: var(--text);
    background: rgba(128, 128, 128, 0.15);
}

.act-btn.settings {
    margin-top: auto;
}

/* ── Custom tooltips ───────────────────────── */
.act-btn::after {
    content: attr(data-tip);
    position: absolute;
    left: calc(100% + 8px);
    top: 50%;
    transform: translateY(-50%);
    padding: 3px 8px;
    background: var(--bg-titlebar);
    color: var(--text);
    font-family: var(--font-ui);
    font-size: 12px;
    white-space: nowrap;
    border: 1px solid var(--border);
    border-radius: 4px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.1s;
    z-index: 100;
}

.act-btn:hover::after {
    opacity: 1;
}

/* ── Sidebar ────────────────────────────────── */
.sidebar {
    width: var(--sidebar-w);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow: hidden;
}

.section-label {
    display: flex;
    align-items: center;
    gap: 4px;
    width: 100%;
    font-family: var(--font-ui);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    padding: 6px 12px;
    cursor: pointer;
    text-align: left;
    background: none;
    border: none;
    transition: color 0.1s;
}

.section-label:hover {
    color: var(--text);
}

.section-label .chevron {
    flex-shrink: 0;
    color: var(--text-dim);
    transition: transform 0.15s;
}

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

.file-tree {
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding: 4px 0;
}

.file-tree.collapsed {
    display: none;
}

.file-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 8px 5px 28px;
    cursor: pointer;
    font-family: var(--font-ui);
    font-size: 13px;
    color: var(--text-muted);
    border: none;
    background: none;
    text-align: left;
    width: 100%;
    transition:
        background 0.1s,
        color 0.1s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-item:hover {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
}
.file-item.active {
    background: rgba(88, 166, 255, 0.08);
    color: var(--c-blue);
}

.file-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    display: inline-block;
    text-align: center;
    font-size: 15px;
    line-height: 1;
    transition: transform 0.15s;
}

/* ── Folder items ───────────────────────────── */
.folder-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 8px 5px 28px;
    cursor: pointer;
    font-family: var(--font-ui);
    font-size: 13px;
    color: var(--text-muted);
    background: none;
    border: none;
    text-align: left;
    width: 100%;
    transition: color 0.1s;
    user-select: none;
}

.folder-item:hover {
    color: var(--text);
}

.folder-item.collapsed .file-icon {
    transform: rotate(-90deg);
}

.folder-label {
    flex: 1;
    min-width: 0;
}

.folder-children {
    display: flex;
    flex-direction: column;
}

.folder-item.collapsed + .folder-children {
    display: none;
}

.folder-children .file-item {
    padding-left: 42px;
}

/* ── Editor Area ────────────────────────────── */
.editor-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

/* ── Tab Bar ────────────────────────────────── */
.tab-bar {
    display: flex;
    background: var(--bg-sidebar);
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    flex-shrink: 0;
}

.tab-bar::-webkit-scrollbar {
    height: 0;
}

.tab {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 16px;
    height: var(--tab-h);
    cursor: pointer;
    border-right: 1px solid var(--border);
    color: var(--text-muted);
    font-family: var(--font-ui);
    font-size: 13px;
    white-space: nowrap;
    flex-shrink: 0;
    background: none;
    border-top: none;
    border-left: none;
    border-bottom: 2px solid transparent;
    transition: color 0.1s;
}

.tab:hover {
    color: var(--text);
}

.tab.active {
    background: var(--bg);
    color: var(--text);
    border-bottom-color: var(--c-blue);
}

.tab-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 3px;
    color: var(--text-dim);
    font-size: 12px;
    line-height: 1;
    opacity: 0;
    transition:
        opacity 0.1s,
        background 0.1s;
}

.tab:hover .tab-close,
.tab.active .tab-close {
    opacity: 1;
}
.tab-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text);
}

.tab.dragging {
    opacity: 0.3;
}

.tab.drag-over {
    outline: 1px dashed var(--c-blue);
    outline-offset: -1px;
}

/* ── Editor Panels ──────────────────────────── */
.editor-panels {
    flex: 1;
    overflow: hidden;
    position: relative;
}

.panel {
    display: none;
    height: 100%;
    overflow-y: auto;
    padding: 32px 0 64px;
}

.panel::-webkit-scrollbar {
    width: 8px;
}
.panel::-webkit-scrollbar-track {
    background: transparent;
}
.panel::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}
.panel::-webkit-scrollbar-thumb:hover {
    background: #484f58;
}

.panel.active {
    display: block;
}

/* ── Status Bar ─────────────────────────────── */
.status-bar {
    height: var(--statusbar-h);
    background: var(--status-bg);
    display: flex;
    align-items: center;
    padding: 0 12px;
    gap: 12px;
    font-family: var(--font-ui);
    font-size: 11px;
    color: var(--status-text);
    flex-shrink: 0;
}

.status-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

.status-spacer {
    margin-left: auto;
}
