/* =============================================
   PWV 暗色 Finder 风格 - 完整高度自适应
   ============================================= */

:root {
  --bg-primary: #0d1117;
  --bg-secondary: #161b22;
  --bg-card: #1c2333;
  --bg-hover: #252d3f;
  --bg-active: #1f2a3f;
  --bg-elevated: #21262d;
  --border-color: #30363d;
  --border-light: #3d4452;
  --text-primary: #f0f6fc;
  --text-secondary: #c9d1d9;
  --text-muted: #8b949e;
  --text-dim: #484f58;
  --accent: #58a6ff;
  --accent-hover: #79c0ff;
  --accent-dim: rgba(88, 166, 255, 0.12);
  --green: #3fb950;
  --red: #f85149;
  --orange: #d29922;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  --radius: 10px;
  --radius-sm: 6px;
  --transition: all 0.2s cubic-bezier(0.3, 0, 0.5, 1);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --topbar-height: 52px;
  --toolbar-height: 48px;
  --statusbar-height: 32px;
  --font-size-base: 15px;
  --font-size-sm: 13px;
  --font-size-xs: 12px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: var(--font-size-base);
  line-height: 1.6;
}

/* =============================================
   #app - 100vh 固定
   ============================================= */
#app {
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-primary);
  overflow: hidden;
}

/* =============================================
   顶部栏
   ============================================= */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  height: var(--topbar-height);
  min-height: var(--topbar-height);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
  user-select: none;
}

.topbar-left { display: flex; align-items: center; gap: 14px; }
.topbar-title { font-size: 1.1rem; font-weight: 600; color: var(--text-primary); letter-spacing: -0.3px; }
.topbar-title span { color: var(--accent); }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.topbar-user {
  color: var(--text-muted);
  font-size: var(--font-size-sm);
  padding: 4px 14px;
  background: var(--bg-primary);
  border-radius: 20px;
  border: 1px solid var(--border-color);
}
.topbar-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  transition: var(--transition);
}
.topbar-btn:hover { background: var(--bg-hover); color: var(--text-primary); }

/* =============================================
   🔥 核心修复：app-main 撑满剩余高度
   ============================================= */
.app-main {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* =============================================
   🔥 核心修复：侧边栏容器 100% 高度
   ============================================= */
#sidebar-container {
  display: flex;
  height: 100%;
  flex-shrink: 0;
}

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

.sidebar-header {
  padding: 14px 16px 8px 16px;
  color: var(--text-dim);
  font-size: var(--font-size-xs);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  font-weight: 600;
  flex-shrink: 0;
}

.sidebar-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 8px;
  min-height: 0;
}

.sidebar-item {
  padding: 8px 12px;
  cursor: pointer;
  color: var(--text-muted);
  font-size: var(--font-size-sm);
  display: flex;
  align-items: center;
  gap: 10px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}
.sidebar-item:hover { background: var(--bg-hover); color: var(--text-secondary); }
.sidebar-item.active { background: var(--accent-dim); color: var(--accent); }
.sidebar-item .icon { font-size: 1rem; width: 20px; text-align: center; flex-shrink: 0; }
.sidebar-item .label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-item .badge {
  font-size: 0.5rem;
  background: var(--bg-primary);
  padding: 2px 8px;
  border-radius: 10px;
  color: var(--text-dim);
  border: 1px solid var(--border-color);
  flex-shrink: 0;
}

.sidebar-add {
  padding: 10px 16px;
  cursor: pointer;
  color: var(--accent);
  font-size: var(--font-size-sm);
  display: flex;
  align-items: center;
  gap: 10px;
  border-top: 1px solid var(--border-color);
  transition: var(--transition);
  flex-shrink: 0;
}
.sidebar-add:hover { background: var(--bg-hover); }

.sidebar-footer {
  padding: 6px 16px;
  border-top: 1px solid var(--border-color);
  font-size: var(--font-size-xs);
  color: var(--text-dim);
  display: flex;
  justify-content: space-between;
  flex-shrink: 0;
}

/* =============================================
   🔥 核心修复：内容区域 100% 高度
   ============================================= */
.content-area {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  height: 100%;
  background: var(--bg-primary);
  overflow: hidden;
}

/* =============================================
   工具栏
   ============================================= */
.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 16px;
  height: var(--toolbar-height);
  min-height: var(--toolbar-height);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.toolbar-path {
  flex: 1;
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 100px;
  overflow: hidden;
}
.toolbar-path .sep { color: var(--text-dim); opacity: 0.5; }
.toolbar-path .crumb {
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  transition: var(--transition);
  white-space: nowrap;
}
.toolbar-path .crumb:hover { color: var(--accent); background: var(--bg-hover); }
.toolbar-path .crumb.current { color: var(--text-primary); cursor: default; }

.toolbar-actions { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }
.toolbar-btn {
  padding: 5px 14px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: var(--font-size-xs);
  cursor: pointer;
  transition: var(--transition);
  font-weight: 500;
  font-family: var(--font);
  background: transparent;
  color: var(--text-muted);
}
.toolbar-btn.primary { background: var(--accent); color: #0d1117; }
.toolbar-btn.primary:hover { background: var(--accent-hover); }
.toolbar-btn.secondary { background: var(--bg-hover); color: var(--text-secondary); }
.toolbar-btn.secondary:hover { background: var(--bg-elevated); }
.toolbar-btn.icon {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.05rem;
  padding: 4px 8px;
  border-radius: 4px;
}
.toolbar-btn.icon:hover { background: var(--bg-hover); color: var(--text-secondary); }

/* =============================================
   🔥 核心修复：文件列表撑满剩余高度
   ============================================= */
#filelist-container {
  flex: 1;
  min-height: 0;
  padding: 0 12px 12px 12px;
  overflow: hidden;
}

.file-table {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.file-table-header {
  display: grid;
  grid-template-columns: minmax(140px, 1.6fr) minmax(90px, 0.8fr) minmax(90px, 0.8fr) 70px 80px;
  padding: 6px 14px;
  color: var(--text-dim);
  font-size: var(--font-size-xs);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-primary);
  flex-shrink: 0;
  font-weight: 600;
  gap: 10px;
}

.file-list-body {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

.file-row {
  display: grid;
  grid-template-columns: minmax(140px, 1.6fr) minmax(90px, 0.8fr) minmax(90px, 0.8fr) 70px 80px;
  padding: 6px 14px;
  align-items: center;
  border-bottom: 1px solid rgba(48, 54, 61, 0.3);
  min-height: 44px;
  transition: var(--transition);
  gap: 10px;
  cursor: default;
  border-radius: 4px;
}
.file-row:hover { background: var(--bg-secondary); }
.file-row.dir { cursor: pointer; }
.file-row.dir:hover .file-name { color: var(--accent); }

.file-name { color: var(--text-secondary); font-size: var(--font-size-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-size { text-align: right; color: var(--text-muted); font-size: var(--font-size-sm); }
.file-date { color: var(--text-muted); font-size: var(--font-size-xs); }
.file-actions { display: flex; gap: 4px; justify-content: flex-end; }
.file-actions button {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 0.9rem;
  padding: 2px 6px;
  border-radius: 4px;
  transition: var(--transition);
  opacity: 0.5;
}
.file-row:hover .file-actions button { opacity: 0.8; }
.file-actions button:hover { background: var(--bg-hover); color: var(--text-secondary); opacity: 1; }

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  padding: 40px 20px;
}
.empty-state .icon { font-size: 3.2rem; margin-bottom: 16px; opacity: 0.6; }
.empty-state .title { font-size: 1.1rem; color: var(--text-secondary); }
.empty-state .desc { font-size: var(--font-size-sm); color: var(--text-dim); margin-top: 6px; }

/* =============================================
   状态栏
   ============================================= */
#statusbar-container { flex-shrink: 0; }
.statusbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  height: var(--statusbar-height);
  min-height: var(--statusbar-height);
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  font-size: var(--font-size-xs);
  color: var(--text-dim);
  flex-shrink: 0;
}

/* =============================================
   登录页
   ============================================= */
.login-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 24px;
  width: 100%;
  background: radial-gradient(ellipse at 50% 30%, #161b22, #0d1117 70%);
}
.login-box {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  padding: 48px 44px;
  border-radius: var(--radius);
  border: 1px solid var(--border-color);
  max-width: 400px;
  width: 100%;
  text-align: center;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
}
.login-box h1 { font-size: 2rem; font-weight: 700; color: var(--text-primary); margin-bottom: 4px; letter-spacing: -0.5px; }
.login-box .subtitle { color: var(--text-muted); margin-bottom: 32px; font-size: 0.95rem; }
.login-box .login-options { display: flex; flex-direction: column; gap: 12px; }
.login-box .security-badge {
  display: flex; justify-content: center; gap: 18px;
  font-size: var(--font-size-xs);
  color: var(--text-dim);
  padding-top: 20px; margin-top: 20px;
  border-top: 1px solid var(--border-color);
}
.security-badge span { display: flex; align-items: center; gap: 4px; }

/* =============================================
   通用
   ============================================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 500;
  transition: var(--transition);
  font-family: var(--font);
  padding: 10px 20px;
  font-size: 0.9rem;
}
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-sm { padding: 6px 14px; font-size: 0.8rem; }
.btn-lg { padding: 14px 32px; font-size: 1rem; }
.btn-primary { background: var(--accent); color: #0d1117; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); transform: scale(1.02); }
.btn-secondary { background: var(--bg-hover); color: var(--text-secondary); border: 1px solid var(--border-color); }
.btn-secondary:hover:not(:disabled) { background: var(--bg-elevated); border-color: var(--text-muted); }

.form-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 14px;
  text-align: left;
}
.form-group label { font-size: var(--font-size-sm); font-weight: 500; color: var(--text-secondary); }
.input {
  padding: 8px 12px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.9rem;
  font-family: var(--font);
  transition: var(--transition);
  width: 100%;
}
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }
.input::placeholder { color: var(--text-dim); }

/* =============================================
   Toast
   ============================================= */
#toast-container {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 380px;
  width: 100%;
  pointer-events: none;
}
#toast-container .toast {
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
  animation: toastSlideIn 0.3s ease;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(12px);
  pointer-events: auto;
}
#toast-container .toast.success { border-left: 3px solid var(--green); color: var(--green); }
#toast-container .toast.error { border-left: 3px solid var(--red); color: var(--red); }
#toast-container .toast.warning { border-left: 3px solid var(--orange); color: var(--orange); }
#toast-container .toast.info { border-left: 3px solid var(--accent); color: var(--accent); }

@keyframes toastSlideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-light); }

@media (max-width: 768px) {
  .sidebar { width: 48px; min-width: 48px; max-width: 48px; }
  .sidebar-item .label, .sidebar-item .badge,
  .sidebar-header, .sidebar-add span, .sidebar-footer span:last-child { display: none; }
  .sidebar-item { justify-content: center; padding: 10px 0; }
  .sidebar-add { justify-content: center; padding: 10px 0; }
  .sidebar-add span { display: none; }
  .file-table-header, .file-row {
    grid-template-columns: 1fr 0 0 50px 50px;
    gap: 4px;
  }
  .file-date { display: none; }
  .topbar-title { font-size: 0.95rem; }
  .login-box { padding: 32px 24px; }
  .login-box h1 { font-size: 1.6rem; }
}
