/* ============================================================
   CST Cloud Gateway — 简约干净风格（对标 zfile）
   白底 · 浅灰边框 · 蓝色点缀 · 扁平卡片/表格 · 无毛玻璃/无动态背景
   ============================================================ */

/* ---------- Reset ---------- */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  /* 主色：干净的蓝 */
  --accent:       #2d8cf0;
  --accent-dark:  #1f7fe0;
  --accent-soft:  #eaf3ff;

  /* 中性色 */
  --bg:           #f4f5f7;
  --surface:      #ffffff;
  --border:       #e9ebef;
  --border-strong:#dfe3e8;

  --text:         #2b2f38;
  --text-secondary:#6b7280;
  --text-muted:   #9aa1ad;

  --green:        #19be6b;
  --red:          #ed4014;

  --radius:   8px;
  --radius-sm:6px;
  --shadow:   0 1px 3px rgba(20,30,50,0.06);
  --shadow-hover: 0 4px 16px rgba(45,140,240,0.12);

  --transition: 0.18s ease;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI",
    "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  background: var(--bg);
  min-height: 100vh;
  padding: 16px;
  font-size: 14px;
}

/* ---------- Layout ----------
   整页是一个统一面板：各模块不再各自成卡片，改用细分隔线衔接，
   内容区 flex:1 撑高、页脚 margin-top:auto 始终贴底。 */
.app {
  max-width: 1180px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 32px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
}
.topbar-left  { display: flex; align-items: center; gap: 10px; }
.topbar-right { display: flex; align-items: center; gap: 8px; }

.logo-icon {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
}
.logo-icon svg { width: 19px; height: 19px; }

.site-title {
  font-size: 16px; font-weight: 600;
  color: var(--text);
  letter-spacing: 0.2px;
}

.mode-badge {
  font-size: 12px; font-weight: 600;
  color: var(--accent-dark);
  background: var(--accent-soft);
  border: 1px solid #cfe5ff;
  padding: 3px 10px;
  border-radius: 999px;
  white-space: nowrap;
}

.icon-btn {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
}
.icon-btn svg { width: 17px; height: 17px; }
.icon-btn:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.icon-btn.sm { width: 28px; height: 28px; }
.icon-btn.sm svg { width: 15px; height: 15px; }

/* ---------- Breadcrumb ---------- */
.breadcrumb {
  display: flex; align-items: center; flex-wrap: wrap; gap: 4px;
  padding: 10px 16px;
  font-size: 13px;
}
.crumb {
  display: inline-flex; align-items: center; gap: 4px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 6px;
  transition: all var(--transition);
}
.crumb:hover { color: var(--accent); background: var(--accent-soft); }
.crumb.active { color: var(--accent-dark); font-weight: 600; cursor: default; }
.crumb.active:hover { background: none; }
.crumb-icon { width: 14px; height: 14px; }
.crumb-sep { color: var(--text-muted); margin: 0 2px; font-size: 11px; }

/* ---------- Toolbar ---------- */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 14px;
  flex-wrap: wrap;
}
.toolbar-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.toolbar-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.toolbar-count { font-size: 12px; color: var(--text-muted); white-space: nowrap; }

/* 搜索框 */
.search-box {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--border);
}
.search-box:focus-within { border-color: var(--accent); background: #fff; }
.search-box svg { width: 15px; height: 15px; color: var(--text-muted); flex-shrink: 0; }
.search-box input {
  border: none; background: transparent; outline: none;
  font: inherit; font-size: 13px; color: var(--text);
  width: 170px; min-width: 0;
}
.search-box input::placeholder { color: var(--text-muted); }

/* 排序选择器 */
.sort-select {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  cursor: pointer;
}
.sort-select svg { width: 15px; height: 15px; flex-shrink: 0; }
.sort-select select {
  border: none; background: transparent; outline: none;
  font: inherit; font-size: 13px; font-weight: 600;
  color: var(--text); cursor: pointer;
}
.sort-select select option { color: var(--text); }

/* 视图切换 */
.view-toggle {
  display: inline-flex; gap: 2px;
  padding: 3px;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--border);
}
.vt-btn {
  width: 28px; height: 28px;
  display: inline-grid; place-items: center;
  border: none; border-radius: 999px;
  background: transparent; color: var(--text-muted);
  cursor: pointer; transition: all var(--transition);
}
.vt-btn svg { width: 15px; height: 15px; }
.vt-btn:hover { color: var(--accent); }
.vt-btn.active { background: var(--accent); color: #fff; }

/* ---------- Content ---------- */
.content {
  padding: 16px;
  flex: 1 1 auto;
  min-height: 52vh;
}
.center-box {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 80px 0;
  gap: 14px;
}
.spinner {
  width: 34px; height: 34px;
  border: 3px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.empty-icon { width: 48px; height: 48px; color: var(--text-muted); }
.hint { color: var(--text-secondary); font-size: 14px; }
.hint-sub { color: var(--text-muted); font-size: 12px; line-height: 1.8; text-align: center; }
.hint-sub code { background: var(--bg); border: 1px solid var(--border); border-radius: 4px; padding: 1px 5px; font-size: 11px; color: var(--accent-dark); }

/* 配置缺失提示 */
.config-error { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 70px 0; }
.config-error .err-icon { width: 44px; height: 44px; color: var(--red); }
.config-error .hint { font-weight: 600; color: var(--text); }

/* ---------- Grid view ---------- */
.file-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 12px;
}
.grid-item {
  display: flex; flex-direction: column; align-items: center;
  gap: 6px;
  padding: 16px 8px 10px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all var(--transition);
  text-align: center;
  position: relative;
}
.grid-item:hover { border-color: var(--accent); box-shadow: var(--shadow-hover); transform: translateY(-2px); }
.grid-icon-wrap {
  width: 46px; height: 46px;
  display: grid; place-items: center;
  border-radius: 10px;
  background: var(--bg);
  transition: all var(--transition);
}
.grid-item:hover .grid-icon-wrap { background: var(--accent-soft); }
.grid-icon-wrap svg { width: 28px; height: 28px; }
.grid-name {
  font-size: 12px; color: var(--text);
  max-width: 100%; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
}
.grid-meta {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  opacity: 0; transition: opacity var(--transition);
}
.grid-item:hover .grid-meta { opacity: 1; }
.grid-size { font-size: 11px; color: var(--text-muted); }
.grid-actions { display: flex; gap: 4px; }
.grid-icon-btn {
  width: 24px; height: 24px;
  display: inline-grid; place-items: center;
  border-radius: 6px; border: none;
  background: var(--accent); color: #fff; cursor: pointer;
  transition: all var(--transition);
}
.grid-icon-btn:hover { background: var(--accent-dark); transform: scale(1.1); }
.grid-icon-btn svg { width: 12px; height: 12px; }

/* ---------- List view ---------- */
.file-list {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.file-list table { width: 100%; border-collapse: collapse; }
.file-list th {
  text-align: left;
  padding: 10px 16px;
  font-size: 12px; font-weight: 600;
  color: var(--text-secondary);
  background: #fafbfc;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.file-list td {
  padding: 9px 16px;
  font-size: 13px;
  border-bottom: 1px solid #f1f2f5;
}
.file-list tr:last-child td { border-bottom: none; }
.file-list tr:hover td { background: var(--accent-soft); }
.file-list th[data-sort] { cursor: pointer; user-select: none; transition: color var(--transition); }
.file-list th[data-sort]:hover { color: var(--accent); }
.sort-ind { width: 13px; height: 13px; margin-left: 3px; vertical-align: -2px; opacity: 0.4; transition: opacity var(--transition); }
.file-list th[data-sort].active .sort-ind,
.sort-ind[data-lucide="chevron-up"],
.sort-ind[data-lucide="chevron-down"] { opacity: 1; color: var(--accent); }

.col-size   { width: 110px; }
.col-date   { width: 170px; }
.col-action { width: 80px; text-align: center; }
.col-action .icon-btn.sm { display: inline-grid; margin: 0 2px; }

.list-name { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.list-name:hover { color: var(--accent); }
.list-name svg { width: 18px; height: 18px; flex-shrink: 0; }

/* ---------- 文件类型图标配色（网格 + 列表复用 .type-*） ---------- */
.type-folder          { color: #f5a623; }
.type-image           { color: #ec4899; }
.type-music           { color: #8b5cf6; }
.type-video           { color: #ef4444; }
.type-file-archive    { color: #f5a623; }
.type-file-spreadsheet{ color: #22c55e; }
.type-presentation    { color: #f97316; }
.type-file-text       { color: #3b82f6; }
.type-file-code       { color: #14b8a6; }
.type-file            { color: var(--accent); }

.grid-icon-wrap.type-folder           { background: rgba(245,166,35,0.12); }
.grid-icon-wrap.type-image            { background: rgba(236,72,153,0.12); }
.grid-icon-wrap.type-music            { background: rgba(139,92,246,0.12); }
.grid-icon-wrap.type-video            { background: rgba(239,68,68,0.12); }
.grid-icon-wrap.type-file-archive     { background: rgba(245,166,35,0.12); }
.grid-icon-wrap.type-file-spreadsheet { background: rgba(34,197,94,0.12); }
.grid-icon-wrap.type-presentation     { background: rgba(249,115,22,0.12); }
.grid-icon-wrap.type-file-text        { background: rgba(59,130,246,0.12); }
.grid-icon-wrap.type-file-code        { background: rgba(20,184,166,0.12); }
.grid-icon-wrap.type-file             { background: rgba(45,140,240,0.12); }

/* ---------- Download progress ---------- */
.progress-panel { padding: 14px 16px; }
.prog-title { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--accent-dark); margin-bottom: 10px; }
.prog-title svg { width: 15px; height: 15px; }
.prog-item { padding: 8px 0; border-top: 1px solid var(--border); }
.prog-head { display: flex; justify-content: space-between; gap: 10px; font-size: 12px; }
.prog-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.prog-status { color: var(--accent-dark); font-weight: 600; flex-shrink: 0; }
.prog-bar { margin: 6px 0 4px; height: 6px; border-radius: 999px; background: var(--bg); overflow: hidden; }
.prog-fill { height: 100%; width: 0%; background: var(--accent); border-radius: 999px; transition: width 0.2s ease-out; }
.prog-fill.done { background: var(--green); }
.prog-fill.err  { background: var(--red); }
.prog-meta { font-size: 11px; color: var(--text-muted); }

/* ---------- Footer ---------- */
.footer {
  margin-top: auto;
  padding: 14px 12px;
  text-align: center;
  font-size:12px;
  color: var(--text-muted);
}
.footer a { color: var(--accent); text-decoration: none; font-weight: 600; }
.footer a:hover { color: var(--accent-dark); text-decoration: underline; }

/* ---------- Toast ---------- */
.toasts { position: fixed; top: 18px; right: 18px; z-index: 9999; display: flex; flex-direction: column; gap: 10px; pointer-events: none; }
.toast {
  padding: 10px 16px; border-radius: var(--radius-sm);
  font-size: 13px; color: #fff;
  box-shadow: 0 4px 14px rgba(0,0,0,0.12);
  animation: slideIn 0.25s ease-out;
  pointer-events: auto;
}
.toast-success { background: var(--green); }
.toast-error   { background: var(--red); }
.toast-info    { background: var(--accent); }
@keyframes slideIn { from { transform: translateX(60px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ---------- Modal ---------- */
.modal {
  position: fixed; inset: 0; z-index: 10000;
  display: none; align-items: center; justify-content: center;
  padding: 20px;
  background: rgba(20,28,46,0.45);
}
.modal-card {
  width: min(560px, 100%);
  max-height: 88vh; overflow-y: auto;
  padding: 20px 22px;
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 12px 40px rgba(20,30,50,0.2);
  animation: popIn 0.2s ease-out;
}
@keyframes popIn { from { transform: translateY(12px) scale(0.98); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.modal-head h3 { display: flex; align-items: center; gap: 8px; font-size: 15px; color: var(--text); }
.modal-head h3 svg { width: 16px; height: 16px; color: var(--accent); }
.modal-hint { font-size: 12px; line-height: 1.7; color: var(--text-secondary); margin-bottom: 14px; }
.modal-foot { display: flex; align-items: center; gap: 8px; margin-top: 14px; }
.modal-foot .spacer { flex: 1; }

.btn {
  padding: 7px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  font: inherit; font-size: 13px; font-weight: 600;
  cursor: pointer; transition: all var(--transition);
}
.btn.ghost { background: var(--surface); color: var(--text-secondary); }
.btn.ghost:hover { color: var(--text); border-color: var(--border-strong); }
.btn.primary { background: var(--accent); border-color: transparent; color: #fff; }
.btn.primary:hover { background: var(--accent-dark); }

.tabs { display: flex; gap: 6px; margin-bottom: 10px; }
.tab-btn {
  padding: 5px 14px; border-radius: var(--radius-sm); cursor: pointer;
  font: inherit; font-size: 12px; font-weight: 600;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  transition: all var(--transition);
}
.tab-btn.active { background: var(--accent); border-color: transparent; color: #fff; }
.code {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 11.5px; line-height: 1.6;
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  background: var(--bg);
  color: var(--text);
  resize: vertical;
}

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  body { padding: 10px; }
  .app { min-height: calc(100vh - 20px); }
  .topbar { padding: 10px 14px; }
  .site-title { font-size: 15px; }
  .content { padding: 12px; min-height: 60vh; }
  .file-grid { grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 10px; }
  .grid-icon-wrap { width: 40px; height: 40px; }
  .grid-icon-wrap svg { width: 24px; height: 24px; }
  .col-date { display: none; }
  .search-box input { width: 120px; }
  .toolbar-count { display: none; }
  .footer { font-size: 11px; }
}
