/* ==========================================================================
   MC 日志便捷上传工具 —— 样式
   深色 / 紧凑 / 两栏布局，桌面优先，窄屏自动堆叠
   ========================================================================== */

:root {
  --bg: #0b0f18;
  --bg-elevated: #121826;
  --panel: #151c2b;
  --panel-hover: #1b2334;
  --border: #232d40;
  --border-strong: #33405a;

  --text: #e6ebf5;
  --text-dim: #94a3b8;
  --text-faint: #64748b;

  --accent: #4ade80;
  --accent-strong: #22c55e;
  --accent-ink: #052e16;
  --danger: #f87171;
  --warn: #fbbf24;
  --info: #60a5fa;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 8px 28px rgba(0, 0, 0, .35);

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei",
          "PingFang SC", "Hiragino Sans GB", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

body {
  /* 一点点氛围光，避免大面积死黑 */
  background-image:
    radial-gradient(900px 500px at 15% -10%, rgba(74, 222, 128, .07), transparent 60%),
    radial-gradient(800px 500px at 100% 0%, rgba(96, 165, 250, .06), transparent 55%);
  background-attachment: fixed;
}

code {
  font-family: var(--mono);
  font-size: .88em;
  background: rgba(148, 163, 184, .12);
  padding: .1em .35em;
  border-radius: 4px;
}

/* ---------- 布局 ---------- */

.app {
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 14px 18px 18px;
  gap: 12px;
  max-width: 1480px;
  margin: 0 auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-shrink: 0;
}

.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-logo { border-radius: 9px; flex-shrink: 0; }
.brand-text { min-width: 0; }
.brand h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.brand-sub { margin: 0; font-size: 12px; color: var(--text-faint); }

.topbar-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.install-slot { display: flex; align-items: center; gap: 8px; }

.layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(260px, 320px) 1fr;
  gap: 12px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.panel-head h2 { margin: 0; font-size: 13px; font-weight: 600; letter-spacing: .02em; color: var(--text-dim); }

.count {
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--text-faint);
  background: rgba(148, 163, 184, .1);
  border-radius: 999px;
  padding: 1px 9px;
}

/* ---------- 提示条 ---------- */

.banner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  flex-shrink: 0;
  animation: slide-down .18s ease-out;
}
.banner[hidden] { display: none; }
.banner-info { border-color: rgba(96, 165, 250, .35); background: rgba(96, 165, 250, .08); }
.banner-warn { border-color: rgba(251, 191, 36, .35); background: rgba(251, 191, 36, .08); }
.banner-danger { border-color: rgba(248, 113, 113, .35); background: rgba(248, 113, 113, .08); }

.banner-icon {
  width: 18px; height: 18px;
  flex-shrink: 0;
  margin-top: 1px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 700;
  font-style: normal;
  background: var(--info);
  color: #04121f;
}
.banner-warn .banner-icon { background: var(--warn); }
.banner-danger .banner-icon { background: var(--danger); }

.banner-body { flex: 1; min-width: 0; }
.banner-body strong { display: block; font-size: 13px; font-weight: 600; }
.banner-body p { margin: 1px 0 0; font-size: 12.5px; color: var(--text-dim); }

.banner-close {
  background: none;
  border: 0;
  color: var(--text-faint);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
  border-radius: 4px;
}
.banner-close:hover { color: var(--text); }

/* ---------- 按钮 ---------- */

.btn {
  appearance: none;
  cursor: pointer;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  padding: 8px 14px;
  font: inherit;
  font-size: 13px;
  font-weight: 550;
  transition: background .14s, border-color .14s, color .14s, opacity .14s;
  white-space: nowrap;
}
.btn:disabled { cursor: not-allowed; opacity: .45; }
.btn-sm { padding: 5px 10px; font-size: 12px; }

.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}
.btn-primary:hover:not(:disabled) { background: var(--accent-strong); }

.btn-ghost {
  background: rgba(148, 163, 184, .08);
  color: var(--text);
  border-color: var(--border-strong);
}
.btn-ghost:hover:not(:disabled) { background: rgba(148, 163, 184, .16); }

.btn-danger-ghost {
  background: transparent;
  color: var(--danger);
  border-color: rgba(248, 113, 113, .35);
}
.btn-danger-ghost:hover:not(:disabled) { background: rgba(248, 113, 113, .1); }

.btn-text {
  background: none;
  border: none;
  color: var(--accent);
  padding: 2px 0;
  font-size: 12.5px;
  cursor: pointer;
}
.btn-text:hover { text-decoration: underline; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  color: var(--text-dim);
}
.pill-ok { color: var(--accent); border-color: rgba(74, 222, 128, .35); background: rgba(74, 222, 128, .08); }
.pill-warn { color: var(--warn); border-color: rgba(251, 191, 36, .35); background: rgba(251, 191, 36, .08); }

/* ---------- 文件夹状态卡片 ---------- */

.folder-state { padding: 12px 14px; border-bottom: 1px solid var(--border); }

.folder-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
}
.folder-card .folder-name {
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--text);
  word-break: break-all;
  display: flex;
  align-items: center;
  gap: 6px;
}
.folder-card .folder-meta { font-size: 11.5px; color: var(--text-faint); }
.folder-card .folder-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.perm-row { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-dim); }
.perm-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-faint); flex-shrink: 0; }
.perm-dot.granted { background: var(--accent); box-shadow: 0 0 8px rgba(74, 222, 128, .7); }
.perm-dot.prompt { background: var(--warn); }
.perm-dot.denied { background: var(--danger); }

/* ---------- 实例列表 ---------- */

.instance-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.instance {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  text-align: left;
  background: none;
  color: inherit;
  font: inherit;
  width: 100%;
  transition: background .12s, border-color .12s;
}
.instance:hover { background: var(--panel-hover); }
.instance.active {
  background: rgba(74, 222, 128, .09);
  border-color: rgba(74, 222, 128, .35);
}
.instance:disabled { cursor: not-allowed; opacity: .55; }

.instance-icon {
  width: 34px;
  height: 34px;
  border-radius: 7px;
  flex-shrink: 0;
  object-fit: cover;
  background: #1f2937;
  /* 32px 的草方块要像素风放大 */
  image-rendering: pixelated;
}

.instance-body { flex: 1; min-width: 0; }
.instance-name {
  font-size: 13px;
  font-weight: 550;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.instance-meta {
  font-size: 11.5px;
  color: var(--text-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.instance-badge {
  font-size: 10.5px;
  padding: 1px 7px;
  border-radius: 999px;
  background: rgba(148, 163, 184, .12);
  color: var(--text-dim);
  flex-shrink: 0;
}
.instance-badge.warn { background: rgba(251, 191, 36, .12); color: var(--warn); }

/* ---------- 日志列表 ---------- */

.logs-title { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.logs-instance {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.logs-actions { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }

.checkbox-inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--text-dim);
  cursor: pointer;
  user-select: none;
}

.logs-scroll {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

/* 表头 */
.logs-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: grid;
  grid-template-columns: 32px 1fr 96px 150px;
  gap: 10px;
  align-items: center;
  padding: 8px 14px;
  font-size: 11.5px;
  color: var(--text-faint);
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

.log-row {
  display: grid;
  grid-template-columns: 32px 1fr 96px 150px;
  gap: 10px;
  align-items: center;
  padding: 9px 14px;
  border-bottom: 1px solid rgba(35, 45, 64, .55);
  cursor: pointer;
  transition: background .1s;
}
.log-row:hover { background: var(--panel-hover); }
.log-row.checked { background: rgba(74, 222, 128, .06); }
.log-row.disabled { cursor: not-allowed; opacity: .5; }

.log-name {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  font-family: var(--mono);
  font-size: 12.5px;
}
.log-name-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.tag {
  font-family: var(--font);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .03em;
  padding: 1px 6px;
  border-radius: 4px;
  flex-shrink: 0;
  text-transform: uppercase;
}
.tag-live { background: rgba(74, 222, 128, .16); color: var(--accent); }
.tag-gz { background: rgba(96, 165, 250, .16); color: var(--info); }
.tag-other { background: rgba(148, 163, 184, .14); color: var(--text-faint); }
.tag-crash { background: rgba(248, 113, 113, .16); color: var(--danger); }

.log-size, .log-time {
  font-size: 12px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}

.rel { color: var(--text-faint); }
.rel-fresh { color: var(--accent); font-weight: 600; }

/* 原生 checkbox 统一一下观感 */
input[type="checkbox"] {
  accent-color: var(--accent);
  width: 15px;
  height: 15px;
  cursor: pointer;
  margin: 0;
}
input[type="checkbox"]:disabled { cursor: not-allowed; }

/* ---------- 空状态 ---------- */

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 220px;
  padding: 32px 24px;
  text-align: center;
  color: var(--text-dim);
}
.empty-title { font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.empty p { margin: 0; font-size: 12.5px; max-width: 420px; }
.empty-sm { min-height: 120px; padding: 18px 10px; }
.empty-sm p { font-size: 12px; }

/* ---------- 操作栏 ---------- */

.actionbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  background: var(--bg-elevated);
  flex-shrink: 0;
}
.actionbar[hidden] { display: none; }
.actionbar-info { display: flex; align-items: baseline; gap: 10px; font-size: 12.5px; color: var(--text-dim); }
.actionbar-size { font-variant-numeric: tabular-nums; color: var(--text-faint); }
.actionbar-buttons { display: flex; align-items: center; gap: 8px; }

/* ---------- 进度 ---------- */

.progress-wrap { padding: 10px 14px 12px; border-top: 1px solid var(--border); flex-shrink: 0; }
.progress-wrap[hidden] { display: none; }
.progress-head {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 6px;
}
.progress-track {
  height: 6px;
  border-radius: 999px;
  background: rgba(148, 163, 184, .15);
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent-strong), var(--accent));
  transition: width .2s ease-out;
}

/* ---------- Toast ---------- */

.toasts {
  position: fixed;
  /* 放左下角：右下角是「上传」按钮和进度条，不能被提示挡住 */
  left: 18px;
  bottom: 18px;
  z-index: 50;
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
  pointer-events: none;
  max-width: min(380px, calc(100vw - 36px));
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: #1a2233;
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow);
  font-size: 12.5px;
  animation: toast-in .18s ease-out;
}
.toast.out { animation: toast-out .18s ease-in forwards; }
.toast-dot { width: 7px; height: 7px; border-radius: 50%; margin-top: 6px; flex-shrink: 0; background: var(--info); }
.toast-ok .toast-dot { background: var(--accent); }
.toast-err .toast-dot { background: var(--danger); }
.toast-warn .toast-dot { background: var(--warn); }
.toast-msg { flex: 1; min-width: 0; word-break: break-word; }

/* ---------- 弹窗 ---------- */

.modal {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
  padding: 0;
  width: min(440px, calc(100vw - 32px));
  box-shadow: var(--shadow);
}
.modal::backdrop { background: rgba(4, 7, 13, .66); backdrop-filter: blur(2px); }
.modal-inner { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.modal-inner h2 { margin: 0; font-size: 16px; font-weight: 650; }

.field { display: flex; flex-direction: column; gap: 5px; }
.field-label { font-size: 12.5px; font-weight: 550; color: var(--text-dim); }
.field input {
  font: inherit;
  font-size: 13px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg);
  color: var(--text);
  outline: none;
}
.field input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(74, 222, 128, .15); }
.field-hint { font-size: 11.5px; color: var(--text-faint); }

.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }

/* ---------- 滚动条 ---------- */

* { scrollbar-width: thin; scrollbar-color: #2c374b transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb {
  background: #2c374b;
  border-radius: 999px;
  border: 3px solid var(--panel);
}
::-webkit-scrollbar-thumb:hover { background: #3a4761; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- 动画 ---------- */

@keyframes slide-down { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(4px); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- 窄屏 ---------- */

@media (max-width: 860px) {
  .app { padding: 10px; gap: 10px; height: auto; min-height: 100%; }
  .layout { grid-template-columns: 1fr; }
  .panel-instances { max-height: 40vh; }
  .panel-logs { min-height: 52vh; }
  .brand-sub { display: none; }
  .logs-head, .log-row { grid-template-columns: 28px 1fr 80px; }
  .logs-head .log-time, .log-row .log-time { display: none; }
  .actionbar { flex-wrap: wrap; }
}
