/* FileViewer - 左右布局的文件预览器 */

:root {
  --primary: #7171EE;
  --primary-10: rgba(113,113,238,0.1);
  --t1: rgba(0,0,0,0.75);
  --t2: rgba(0,0,0,0.45);
  --t3: rgba(0,0,0,0.40);
  --t4: rgba(0,0,0,0.35);
  --td: rgba(0,0,0,0.85);
  --border: rgba(0,0,0,0.08);
  --r-lg: 12px;
  --r-sm: 6px;
  --page-bg: #F4F4F5;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* 主布局容器 */
.files-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 16px;
  /* 高度通过 inline style 传入 */
}

/* ===== 左侧目录 ===== */
.files-sidebar {
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: #fff;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.files-sidebar-head {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  color: var(--t2);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
  flex-shrink: 0;
  background: #fff;
}

.files-sidebar-body {
  flex: 1;
  overflow-y: auto;
}

.files-group {
  padding: 8px 6px;
}

.files-group-label {
  padding: 4px 10px;
  font-size: 10px;
  color: var(--t3);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  font-weight: 600;
}

.file-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  color: var(--t1);
  transition: background 0.15s;
}

.file-item:hover {
  background: var(--page-bg);
}

.file-item.active {
  background: var(--primary-10);
  color: var(--primary);
  font-weight: 500;
}

.file-item .fi-icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  color: var(--t3);
}

.file-item.active .fi-icon {
  color: var(--primary);
}

.file-item .fi-name {
  font-family: var(--mono);
  font-size: 12.5px;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-item .fi-size {
  font-size: 10px;
  color: var(--t4);
  font-family: var(--mono);
}

/* ===== 右侧预览 ===== */
.file-viewer {
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: #fff;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  height: 100%;
}

.file-viewer-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: #fafafa;
}

.file-viewer-head .fvh-name {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--td);
  font-weight: 600;
}

.file-viewer-head .fvh-meta {
  font-size: 11px;
  color: var(--t3);
  font-family: var(--mono);
  margin-left: auto;
}

.file-viewer-head .fvh-readonly {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--t3);
  padding: 2px 8px;
  border-radius: 100px;
  background: rgba(0,0,0,0.04);
}

.file-viewer-head .fvh-readonly svg {
  width: 10px;
  height: 10px;
}

.file-viewer-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.75;
  color: var(--t1);
  white-space: pre-wrap;
}

/* Markdown 样式 */
.file-viewer-body .md-h1 {
  font-family: ui-sans-serif, -apple-system, sans-serif;
  font-size: 20px;
  font-weight: 700;
  color: var(--td);
  margin: 0 0 12px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--border);
}

.file-viewer-body .md-h2 {
  font-family: ui-sans-serif, -apple-system, sans-serif;
  font-size: 16px;
  font-weight: 700;
  color: var(--td);
  margin: 16px 0 8px;
}

.file-viewer-body .md-h3 {
  font-family: ui-sans-serif, -apple-system, sans-serif;
  font-size: 14px;
  font-weight: 600;
  color: var(--td);
  margin: 12px 0 6px;
}

.file-viewer-body code {
  background: var(--primary-10);
  color: var(--primary);
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 11.5px;
}

/* 滚动条样式 */
.files-sidebar::-webkit-scrollbar,
.file-viewer-body::-webkit-scrollbar {
  width: 6px;
  background: transparent;
}

.files-sidebar::-webkit-scrollbar-thumb,
.file-viewer-body::-webkit-scrollbar-thumb {
  background: #e5e7eb;
  border-radius: 6px;
}
