/* ── Files Tab Layout ─────────────────────────────────────────── */

#view-files {
    display: flex;
    height: 100%;
    overflow: hidden;
}

/* ── Folder tree panel ────────────────────────────────────────── */

.files-sidebar {
    width: 220px;
    min-width: 220px;
    background: var(--color-bg-secondary);
    border-right: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.files-sidebar-header {
    padding: 16px 16px 8px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--color-text-muted);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.folder-tree {
    flex: 1;
    overflow-y: auto;
    padding: 4px 0 8px;
}

.folder-tree-item {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 5px 8px 5px 0;
    cursor: pointer;
    border-radius: var(--radius);
    font-size: 13px;
    color: var(--color-text);
    user-select: none;
    white-space: nowrap;
    overflow: hidden;
    transition: background var(--transition);
    position: relative;
}

.folder-tree-item:hover { background: var(--color-border); }
.folder-tree-item.active {
    background: var(--color-accent);
    color: #fff;
}
.folder-tree-item.active .folder-tree-icon,
.folder-tree-item.active .folder-toggle { color: #fff; }

.folder-toggle {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--color-text-muted);
    border-radius: 4px;
    font-size: 10px;
    transition: transform var(--transition);
}
.folder-toggle:hover { background: rgba(0,0,0,.08); }
.folder-toggle.open { transform: rotate(90deg); }
.folder-toggle.leaf { cursor: default; pointer-events: none; visibility: hidden; }

.folder-tree-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    color: var(--color-text-muted);
}
.folder-tree-item.active .folder-tree-icon { color: #fff; }

.folder-tree-label {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
}

.folder-tree-children {
    display: none;
}
.folder-tree-children.open { display: block; }

.files-sidebar-footer {
    padding: 10px 12px;
    border-top: 1px solid var(--color-border);
}

/* ── File list panel ──────────────────────────────────────────── */

.files-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--color-bg);
}

.files-toolbar {
    padding: 12px 16px;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    gap: 8px;
}

.files-breadcrumb {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    color: var(--color-text-muted);
    overflow: hidden;
}

.files-breadcrumb span {
    cursor: pointer;
    white-space: nowrap;
}
.files-breadcrumb span:hover { color: var(--color-accent); }
.files-breadcrumb span.current {
    color: var(--color-text);
    font-weight: 500;
    cursor: default;
}
.files-breadcrumb .bc-sep {
    color: var(--color-border);
    cursor: default;
    flex-shrink: 0;
}

.files-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

.files-list-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    gap: 8px;
    color: var(--color-text-muted);
    font-size: 13px;
}
.files-list-empty i { width: 40px; height: 40px; opacity: .3; }

.file-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    cursor: pointer;
    transition: background var(--transition);
    border-radius: var(--radius);
    margin: 0 8px;
}
.file-row:hover { background: var(--color-bg-secondary); }
.file-row.active { background: color-mix(in srgb, var(--color-accent) 12%, transparent); }

.file-row-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    background: var(--color-bg-secondary);
    flex-shrink: 0;
    overflow: hidden;
}
.file-row-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.file-row-icon i { width: 18px; height: 18px; color: var(--color-text-muted); }

.file-row-name {
    flex: 1;
    font-size: 13px;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.file-row-meta {
    font-size: 11px;
    color: var(--color-text-muted);
    white-space: nowrap;
    display: flex;
    gap: 12px;
}
.file-row-links {
    font-size: 11px;
    color: var(--color-text-muted);
    display: flex;
    align-items: center;
    gap: 3px;
    white-space: nowrap;
}
.file-row-links i { width: 12px; height: 12px; }

/* ── Detail panel ─────────────────────────────────────────────── */

.files-detail {
    width: 300px;
    min-width: 300px;
    border-left: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--color-bg);
}

.files-detail-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: var(--color-text-muted);
    font-size: 13px;
    text-align: center;
    padding: 24px;
}
.files-detail-empty i { width: 40px; height: 40px; opacity: .3; }

.files-detail-preview {
    height: 160px;
    background: var(--color-bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid var(--color-border);
    flex-shrink: 0;
    overflow: hidden;
}
.files-detail-preview img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}
.files-detail-preview i { width: 56px; height: 56px; color: var(--color-text-muted); opacity: .5; }

.files-detail-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.files-detail-name {
    font-size: 14px;
    font-weight: 600;
    word-break: break-word;
    line-height: 1.3;
}

.files-detail-meta {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 12px;
    color: var(--color-text-muted);
}

.files-detail-section {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.files-detail-section-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--color-text-muted);
}

.detail-move-row {
    display: flex;
    align-items: center;
    gap: 8px;
}
.detail-move-row select {
    flex: 1;
    padding: 5px 8px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-bg);
    color: var(--color-text);
    font: inherit;
    font-size: 12px;
    outline: none;
    cursor: pointer;
}
.detail-move-row select:focus { border-color: var(--color-accent); }

.linked-note-row {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    padding: 4px 0;
    border-bottom: 1px solid var(--color-border);
}
.linked-note-row:last-child { border-bottom: none; }
.linked-note-row span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.linked-note-row button {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--color-text-muted);
    padding: 2px;
    font-size: 12px;
    line-height: 1;
    border-radius: 4px;
    flex-shrink: 0;
}
.linked-note-row button:hover { color: var(--color-danger); }

.files-detail-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--color-border);
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

/* folder context actions */
.folder-tree-item .folder-actions {
    display: none;
    gap: 2px;
    margin-left: auto;
    flex-shrink: 0;
}
.folder-tree-item:hover .folder-actions { display: flex; }
.folder-tree-item.active .folder-actions { display: flex; }
.folder-action-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 4px;
    color: inherit;
    opacity: .7;
    font-size: 11px;
    line-height: 1;
}
.folder-action-btn:hover { opacity: 1; background: rgba(0,0,0,.1); }
