/* ═══════════════════════════════════════════════════════════
   VAULT — layout.css
   页面结构 · 文件列表 · 响应式
   ═══════════════════════════════════════════════════════════ */

/* ── App 壳 ───────────────────────────────────────────────── */
#app {
  height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── 顶栏 ─────────────────────────────────────────────────── */
.topbar {
  height: 48px;
  background: var(--bg2);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  flex-shrink: 0;
  position: relative;
  z-index: 10;
}
.topbar-logo {
  font-size: 14px;
  font-weight: 500;
  letter-spacing: .22em;
  color: var(--bright);
  flex-shrink: 0;
}
.topbar-sep {
  width: 1px; height: 18px;
  background: var(--line2);
  flex-shrink: 0;
}

/* 面包屑 */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 2px;
  font-size: 12px;
  color: var(--muted);
  flex: 1;
  overflow: hidden;
  min-width: 0;
}
.breadcrumb-item {
  cursor: pointer;
  white-space: nowrap;
  padding: 2px 4px;
  border-radius: 2px;
  transition: color .1s, background .1s;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.breadcrumb-item:hover { color: var(--bright); background: var(--bg3); }
.breadcrumb-item.active { color: var(--text); cursor: default; }
.breadcrumb-item.active:hover { background: none; }
.breadcrumb-sep { color: var(--line2); user-select: none; flex-shrink: 0; font-size: 10px; }

/* 顶栏右侧操作区 */
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  flex-shrink: 0;
}
.icon-btn {
  background: none;
  border: 1px solid transparent;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  padding: 5px 8px;
  cursor: pointer;
  display: flex; align-items: center; gap: 5px;
  transition: all .15s;
  letter-spacing: .05em;
  white-space: nowrap;
  border-radius: 2px;
}
.icon-btn:hover { border-color: var(--line2); color: var(--bright); background: var(--bg3); }
.icon-btn.danger:hover { border-color: var(--red); color: var(--red); background: rgba(240,110,110,.06); }
.icon-btn.active { color: var(--accent); border-color: var(--accent); background: rgba(79,142,247,.08); }
.icon-btn svg { width: 14px; height: 14px; flex-shrink: 0; }
/* 手机上隐藏文字，只显示图标 */
.icon-btn .btn-label { display: inline; }

/* ── 主区域 ───────────────────────────────────────────────── */
.main {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ── 工具栏 ───────────────────────────────────────────────── */
.toolbar {
  height: 40px;
  background: var(--bg2);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 6px;
  flex-shrink: 0;
}
.tb-btn {
  background: none;
  border: 1px solid var(--line2);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  padding: 4px 10px;
  cursor: pointer;
  display: flex; align-items: center; gap: 5px;
  transition: all .12s;
  letter-spacing: .05em;
  white-space: nowrap;
  border-radius: 2px;
}
.tb-btn:hover { border-color: var(--accent); color: var(--accent); background: rgba(79,142,247,.06); }
.tb-btn svg { width: 13px; height: 13px; flex-shrink: 0; }
.tb-sep { width: 1px; height: 20px; background: var(--line); margin: 0 2px; flex-shrink: 0; }
.tb-info { font-size: 11px; color: var(--dim); margin-left: auto; white-space: nowrap; }

/* ── 文件区域 ─────────────────────────────────────────────── */
.file-area {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}

/* ── 文件列表（Grid 行结构）────────────────────────────────── */

/* 表头 + 数据行共用同一套 grid 列定义，保证对齐 */
.file-header,
.file-row {
  display: grid;
  grid-template-columns: 1fr 90px 160px 224px;
  align-items: center;
  border-bottom: 1px solid var(--line);
}

/* 表头 */
.file-header {
  position: sticky; top: 0; z-index: 2;
  background: var(--bg2);
}
.file-header-cell {
  padding: 8px 12px;
  font-size: 10px;
  font-weight: 400;
  letter-spacing: .14em;
  color: var(--dim);
  text-transform: uppercase;
  user-select: none;
  white-space: nowrap;
}
.file-header-cell:last-child { text-align: right; }

/* 数据行 */
.file-row {
  transition: background .08s;
  cursor: default;
}
.file-row:hover { background: var(--bg3); }

.file-row-cell {
  padding: 8px 12px;
  min-width: 0;          /* 让 grid item 可以收缩到 0 */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.file-row-cell.col-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  overflow: hidden;
  padding-right: 8px;
}

/* 文件图标+名称 */
.file-cell {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  width: 100%;
}
.file-cell svg { width: 16px; height: 16px; flex-shrink: 0; }
.file-cell-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  color: var(--text);
  font-size: 13px;
}
.folder-color { color: var(--amber); }
.file-size { color: var(--muted); font-size: 12px; }
.file-date { color: var(--dim);   font-size: 11px; }

/* 行操作按钮组 */
.row-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 3px;
}
.row-btn {
  background: none;
  border: 1px solid transparent;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
  padding: 3px 7px;
  cursor: pointer;
  letter-spacing: .04em;
  transition: all .1s;
  display: flex; align-items: center; gap: 3px;
  border-radius: 2px;
  white-space: nowrap;
  flex-shrink: 0;
}
.row-btn:hover        { border-color: var(--line2); color: var(--bright); background: var(--bg3); }
.row-btn.del:hover    { border-color: var(--red); color: var(--red); background: rgba(240,110,110,.06); }
.row-btn.share:hover  { border-color: var(--green); color: var(--green); background: rgba(62,207,142,.06); }
.row-btn svg { width: 11px; height: 11px; flex-shrink: 0; }
.row-btn-placeholder { display: inline-block; width: 36px; flex-shrink: 0; }

/* 桌面：hover 才显示行操作 */
@media (hover: hover) {
  .row-actions { opacity: 0; transition: opacity .12s; }
  .file-row:hover .row-actions { opacity: 1; }
}

/* ── 空目录 / 错误状态 ────────────────────────────────────── */
.state-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 64px 24px;
  gap: 12px;
  text-align: center;
}
.state-block svg { opacity: .25; }
.state-block p {
  font-size: 12px;
  letter-spacing: .1em;
  color: var(--dim);
  text-transform: uppercase;
}
.state-block.err p { color: var(--red); opacity: .7; }
.state-block .retry-btn {
  margin-top: 4px;
  background: none;
  border: 1px solid currentColor;
  color: var(--red);
  font-family: var(--mono);
  font-size: 11px;
  padding: 5px 16px;
  cursor: pointer;
  letter-spacing: .08em;
  transition: background .15s;
  border-radius: 2px;
}
.state-block .retry-btn:hover { background: rgba(240,110,110,.1); }

/* ── 加载行 ───────────────────────────────────────────────── */
.loading-row {
  padding: 40px;
  text-align: center;
  color: var(--dim);
  font-size: 12px;
  letter-spacing: .1em;
}
.loading-inner { display: inline-flex; align-items: center; gap: 10px; }

/* ── 拖放覆盖层 ───────────────────────────────────────────── */
.drop-overlay {
  position: fixed; inset: 0;
  background: rgba(13,14,17,.88);
  border: 2px dashed var(--accent);
  display: flex; align-items: center; justify-content: center;
  z-index: 50;
  pointer-events: none;
  opacity: 0;
  transition: opacity .15s;
}
[data-theme="light"] .drop-overlay { background: rgba(244,245,247,.9); }
.drop-overlay.active { opacity: 1; pointer-events: all; }
.drop-overlay-inner { text-align: center; }
.drop-overlay-inner p {
  font-size: 16px;
  letter-spacing: .15em;
  color: var(--accent);
  margin-top: 12px;
}
.drop-overlay-inner svg { color: var(--accent); opacity: .6; }

/* ── 上传进度面板 ─────────────────────────────────────────── */
#upload-panel {
  position: fixed;
  bottom: 20px; right: 20px;
  width: 300px;
  background: var(--bg2);
  border: 1px solid var(--line2);
  z-index: 60;
  display: none;
  box-shadow: var(--shadow-lg);
  animation: slideDown .2s ease;
}
#upload-panel.show { display: block; }
.up-header {
  padding: 9px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 11px;
  letter-spacing: .1em;
  color: var(--muted);
  display: flex; align-items: center; justify-content: space-between;
}
.up-list { max-height: 220px; overflow-y: auto; }
.up-item { padding: 10px 14px; border-bottom: 1px solid var(--line); }
.up-item:last-child { border-bottom: none; }
.up-name {
  font-size: 12px; color: var(--text);
  margin-bottom: 7px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.up-bar-bg { height: 2px; background: var(--line2); position: relative; border-radius: 1px; }
.up-bar {
  height: 2px; background: var(--accent);
  transition: width .2s;
  position: absolute; top: 0; left: 0;
  border-radius: 1px;
}
.up-stat {
  font-size: 10px; color: var(--dim);
  margin-top: 5px;
  display: flex; justify-content: space-between;
}
.up-stat .done { color: var(--green); }
.up-stat .err  { color: var(--red); }

/* ── 登录页 ───────────────────────────────────────────────── */
#login-screen {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
  z-index: 100;
  animation: fadeIn .3s ease;
}
#login-screen.hidden { display: none; }

.login-box {
  width: 100%;
  max-width: 340px;
  border: 1px solid var(--line2);
  background: var(--bg2);
  padding: 40px 32px 32px;
  position: relative;
  box-shadow: var(--shadow-lg);
  margin: 16px;
}
.login-box::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0;
  height: 2px; background: var(--accent);
}
.login-logo {
  font-size: 22px; font-weight: 500;
  letter-spacing: .28em; color: var(--bright);
  margin-bottom: 4px;
}
.login-sub {
  font-size: 10px; color: var(--dim);
  letter-spacing: .12em; margin-bottom: 28px;
}
.login-err {
  font-size: 11px; color: var(--red);
  margin-top: 10px; min-height: 16px;
  text-align: center; letter-spacing: .04em;
}

/* ── 管理员面板 ───────────────────────────────────────────── */
#admin-panel {
  position: fixed; inset: 0;
  background: var(--bg);
  z-index: 70;
  display: none;
  flex-direction: column;
  animation: fadeIn .2s ease;
}
#admin-panel.show { display: flex; }

.admin-header {
  height: 48px;
  background: var(--bg2);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center;
  padding: 0 20px; gap: 12px;
}
.admin-header h2 {
  font-size: 13px; font-weight: 500;
  letter-spacing: .15em; color: var(--bright);
}
.admin-body {
  flex: 1; overflow-y: auto; padding: 24px 20px;
  max-width: 800px; width: 100%; margin: 0 auto;
}
.admin-section { margin-bottom: 32px; }
.admin-section-title {
  font-size: 10px; letter-spacing: .16em;
  color: var(--dim); text-transform: uppercase;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

/* 用户列表表格 */
.user-table {
  width: 100%; border-collapse: collapse;
}
.user-table th {
  text-align: left; font-size: 10px;
  letter-spacing: .12em; color: var(--dim);
  text-transform: uppercase; font-weight: 400;
  padding: 6px 10px; border-bottom: 1px solid var(--line);
}
.user-table td {
  padding: 10px 10px; border-bottom: 1px solid var(--line);
  font-size: 12px; color: var(--text);
  vertical-align: middle;
}
.user-row:hover td { background: var(--bg3); }
.user-actions { display: flex; gap: 6px; justify-content: flex-end; }

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE — 手机端 ≤ 640px
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 640px) {

  /* 顶栏和工具栏精简 */
  .topbar { padding: 0 12px; gap: 8px; }
  .topbar-logo { font-size: 12px; letter-spacing: .18em; }
  .icon-btn .btn-label { display: none; }
  .icon-btn { padding: 6px 8px; }

  .toolbar { padding: 0 12px; gap: 4px; height: 44px; }
  .tb-btn { padding: 4px 8px; font-size: 10px; }
  .tb-btn .btn-label { display: none; }
  .tb-info { font-size: 10px; }

  /* 文件列表：隐藏表头，只保留 name + actions 两列 */
  .file-header { display: none; }

  .file-row {
    grid-template-columns: 1fr auto;
    min-height: 52px;
    padding: 0;
  }

  /* 隐藏 size / date 列 */
  .file-row-cell.col-size,
  .file-row-cell.col-date { display: none; }

  /* name 列：min-width:0 在 grid item 上对 Safari 完全有效 */
  .file-row-cell.col-name {
    padding: 10px 8px 10px 12px;
  }

  /* actions 列：auto 宽度由按钮撑开，不会被压缩 */
  .file-row-cell.col-actions {
    padding: 0 12px 0 0;
  }

  /* 手机上始终显示操作按钮，不需要 hover */
  .row-actions { opacity: 1; }

  /* 按钮只显示图标 */
  .row-btn { padding: 7px 8px; min-width: 32px; justify-content: center; }
  .row-btn svg { width: 15px; height: 15px; }
  .row-btn .btn-label { display: none; }

  /* 其他 */
  #upload-panel { width: calc(100vw - 24px); right: 12px; bottom: 12px; }
  .admin-body { padding: 16px 12px; }
  .modal { padding: 24px 20px 20px; }
  .breadcrumb-item { max-width: 70px; }
}

/* ── 平板适配 ─────────────────────────────────────────────── */
@media (max-width: 900px) and (min-width: 641px) {
  .file-header,
  .file-row {
    grid-template-columns: 1fr 90px 160px 224px;
  }
}