/* ============================================================
   游戏建筑升级计时 - 深色游戏风主题
   说明：即使 Tailwind CDN 离线不可用，本文件也独立覆盖全部
   关键布局与组件样式，保证 PWA 离线时页面依然可用。
   ============================================================ */

:root {
  --bg: #171A23;
  --bg-soft: #1E2431;
  --card: #1E2431;
  --card-hover: #242C3D;
  --border: #2A3242;
  --border-strong: #38415A;
  --text: #E8ECF4;
  --text-muted: #8B94A7;
  --gold: #F5B942;
  --gold-soft: #FFD57A;
  --orange: #FF5A3C;
  --orange-soft: #FF8A2A;
  --green: #4ADE80;
  --cyan: #45C4FF;
  --danger: #FF5A3C;
  --radius: 12px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.6;
}

/* 标题字体（游戏感） */
h1, h2, h3, .app-title, .panel-title, .task-name, .btn {
  font-family: "Rajdhani", "Noto Sans SC", "Microsoft YaHei", sans-serif;
}

.hidden { display: none !important; }

/* ---------- 顶部 ---------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(23, 26, 35, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  padding: 10px 16px;
}

.app-title {
  font-weight: 700;
  font-size: 20px;
  letter-spacing: 1px;
  text-align: center;
  background: linear-gradient(90deg, var(--gold-soft), var(--gold));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.tab-nav {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-top: 10px;
}

.tab-btn {
  flex: 1;
  max-width: 200px;
  min-height: 42px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text-muted);
  border-radius: 10px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: all .18s ease;
}

.tab-btn:hover { color: var(--text); border-color: var(--border-strong); }

.tab-btn.active {
  background: linear-gradient(180deg, #2A3448, #222A3A);
  color: var(--gold);
  border-color: rgba(245, 185, 66, 0.5);
  box-shadow: 0 0 12px rgba(245, 185, 66, 0.15);
}

/* ---------- 主体 ---------- */
.app-main {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px 14px 80px;
}

.tab-page { animation: fadeIn .25s ease; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ---------- 全局加速状态栏 ---------- */
.boost-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 16px;
  transition: border-color .2s ease, box-shadow .2s ease;
}

.boost-bar.active {
  border-color: rgba(245, 185, 66, 0.6);
  box-shadow: 0 0 18px rgba(245, 185, 66, 0.18);
}

.boost-info { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.boost-status {
  font-weight: 700;
  font-size: 16px;
  color: var(--text-muted);
}

.boost-status.active { color: var(--gold); }

.boost-count {
  font-family: "Rajdhani", monospace;
  font-size: 16px;
  font-weight: 700;
  color: var(--gold);
  background: rgba(245, 185, 66, 0.12);
  border: 1px solid rgba(245, 185, 66, 0.35);
  border-radius: 8px;
  padding: 2px 10px;
}

.boost-actions { display: flex; gap: 8px; }

/* ---------- 按钮 ---------- */
.btn {
  min-height: 44px;
  padding: 8px 18px;
  border: 1px solid transparent;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: all .18s ease;
  color: #10131B;
}

.btn:active { transform: scale(0.97); }

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.btn-primary { background: linear-gradient(180deg, #6FD4FF, #45C4FF); }
.btn-primary:hover { box-shadow: 0 0 14px rgba(69, 196, 255, 0.35); }

.btn-gold { background: linear-gradient(180deg, var(--gold-soft), var(--gold)); }
.btn-gold:hover { box-shadow: 0 0 14px rgba(245, 185, 66, 0.4); }

.btn-ghost {
  background: transparent;
  border-color: var(--border-strong);
  color: var(--text);
}
.btn-ghost:hover { border-color: var(--text-muted); }

.btn-danger { background: linear-gradient(180deg, #FF7A5C, var(--danger)); }
.btn-danger:hover { box-shadow: 0 0 14px rgba(255, 90, 60, 0.4); }

.btn-lg { width: 100%; min-height: 52px; font-size: 17px; }

.btn-sm { min-height: 36px; padding: 4px 12px; font-size: 13px; }

.btn-new-task { margin-top: 6px; }

.btn-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; }

/* ---------- 分组面板 ---------- */
.groups { display: flex; flex-direction: column; gap: 14px; }

.group-panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 52px;
  padding: 0 16px;
  background: transparent;
  border: none;
  color: var(--text);
  cursor: pointer;
  font-size: 16px;
}

.group-header:hover { background: rgba(255, 255, 255, 0.03); }

.group-title { display: flex; align-items: center; gap: 10px; }

.group-name { font-weight: 700; }

.group-count {
  font-size: 12px;
  color: var(--text-muted);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 10px;
}

.group-count.full { color: var(--orange); border-color: rgba(255, 90, 60, 0.5); }

.group-chevron { color: var(--text-muted); transition: transform .2s ease; }

.group-panel.collapsed .group-chevron { transform: rotate(-90deg); }
.group-panel.collapsed .group-body { display: none; }

.group-body { padding: 10px 12px 14px; display: flex; flex-direction: column; gap: 10px; }

.group-empty {
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  padding: 14px 0 6px;
}

/* 工人空闲统计条 */
.worker-stat {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
}
.worker-stat b { color: var(--text); }
.worker-stat b.idle { color: var(--gold); }

/* ---------- 任务卡片 ---------- */
.task-card {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 12px 10px;
  transition: opacity .2s ease, border-color .2s ease;
}

.task-card:hover { border-color: var(--border-strong); }

/* 暂停：整体降透明置灰 */
.task-card.paused { opacity: 0.55; }
.task-card.paused .task-name,
.task-card.paused .task-meta { color: var(--text-muted); }

.task-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }

.task-name {
  font-weight: 700;
  font-size: 16px;
  word-break: break-all;
}

.task-badges { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex-shrink: 0; }

.badge {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 6px;
  border: 1px solid transparent;
  white-space: nowrap;
}

.badge-run { color: var(--green); border-color: rgba(74, 222, 128, 0.4); background: rgba(74, 222, 128, 0.08); }
.badge-pause { color: var(--text-muted); border-color: var(--border-strong); background: rgba(255, 255, 255, 0.04); }

.rate-none { color: var(--text-muted); border-color: var(--border); background: rgba(255, 255, 255, 0.03); }
.rate-global { color: var(--gold); border-color: rgba(245, 185, 66, 0.5); background: rgba(245, 185, 66, 0.1); }
.rate-single { color: var(--cyan); border-color: rgba(69, 196, 255, 0.5); background: rgba(69, 196, 255, 0.1); }
/* 叠加状态高亮橙红色 */
.rate-stack {
  color: #FFE9E2;
  border-color: var(--orange);
  background: linear-gradient(180deg, rgba(255, 138, 42, 0.55), rgba(255, 90, 60, 0.55));
  box-shadow: 0 0 8px rgba(255, 90, 60, 0.4);
}

/* 黄金令牌减免徽标 */
.badge-gold { color: var(--gold); border-color: rgba(245, 185, 66, 0.6); background: rgba(245, 185, 66, 0.14); }

/* 循环加速冷却徽标 */
.badge-ghost { color: var(--text-muted); border-color: var(--border-strong); background: rgba(255, 255, 255, 0.04); }

.task-meta {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 4px 10px;
  margin-top: 8px;
  font-size: 13px;
  color: var(--text-muted);
}

.task-meta > span { white-space: nowrap; }

.task-meta b { color: var(--text); font-family: "Rajdhani", monospace; font-size: 15px; }

/* 进度条 */
.progress-track {
  height: 12px;
  background: #141824;
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 8px;
}

.progress-fill {
  height: 100%;
  border-radius: 999px;
  transition: width .6s linear;
}

/* 普通运行：浅白色 */
.fill-normal { background: linear-gradient(90deg, #C9D1E0, var(--text)); }
/* 仅全局加速：金色 */
.fill-global { background: linear-gradient(90deg, #FFB92E, var(--gold-soft)); box-shadow: 0 0 8px rgba(245, 185, 66, 0.6); }
/* 存在单体叠加：亮橙红色 */
.fill-stack { background: linear-gradient(90deg, var(--orange), var(--orange-soft)); box-shadow: 0 0 8px rgba(255, 90, 60, 0.7); }
/* 暂停：置灰 */
.fill-paused { background: #3A4256; box-shadow: none; }

.task-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }

.task-actions .btn { flex: 1; min-width: 72px; }

/* ---------- 弹窗 ---------- */
.modal-root {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-mask { position: absolute; inset: 0; background: rgba(10, 12, 18, 0.75); backdrop-filter: blur(2px); }

.modal-box {
  position: relative;
  width: 100%;
  max-width: 440px;
  max-height: 86vh;
  overflow-y: auto;
  background: var(--card);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  padding: 18px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
  animation: popIn .18s ease;
}

@keyframes popIn { from { transform: scale(0.94); opacity: 0; } to { transform: none; opacity: 1; } }

.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }

.modal-head h3 { margin: 0; font-size: 18px; color: var(--gold); }

.modal-close {
  width: 34px; height: 34px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-soft);
  color: var(--text-muted);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}
.modal-close:hover { color: var(--text); }

.modal-foot { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }

.modal-warn {
  background: rgba(255, 90, 60, 0.1);
  border: 1px solid rgba(255, 90, 60, 0.4);
  color: #FFC2B5;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
  margin: 0 0 12px;
}

.modal-text { margin: 0; color: var(--text); }

/* ---------- 表单 ---------- */
.form-row { margin-bottom: 14px; }

.form-row label { display: block; font-size: 13px; color: var(--text-muted); margin-bottom: 6px; font-weight: 700; }

.form-row input[type="number"],
.form-row input[type="text"] {
  width: 100%;
  min-height: 44px;
  padding: 8px 12px;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  color: var(--text);
  font-size: 16px;
  font-family: "Rajdhani", monospace;
}
.form-row input:focus { outline: none; border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(69, 196, 255, 0.15); }

/* 设置页行式布局 */
.settings-row { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; font-size: 13px; color: var(--text-muted); }
.settings-row label { font-weight: 700; white-space: nowrap; }
.settings-row .toggle { display: flex; align-items: center; gap: 6px; cursor: pointer; color: var(--text); }
.settings-row input[type="number"] { width: 72px; min-height: 36px; padding: 6px 8px; background: var(--bg); border: 1px solid var(--border-strong); border-radius: 8px; color: var(--text); font-size: 15px; font-family: "Rajdhani", monospace; }
.settings-row input:focus { outline: none; border-color: var(--cyan); }
.settings-row input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--gold); }

/* 模板库 */
.tpl-picker { display: flex; gap: 10px; align-items: stretch; }
.tpl-picker select {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  padding: 8px 12px;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  color: var(--text);
  font-size: 15px;
  font-family: "Rajdhani", "Noto Sans SC", sans-serif;
}
.tpl-picker select:focus { outline: none; border-color: var(--cyan); }

.template-list { display: flex; flex-direction: column; gap: 8px; }
.template-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
}
.template-name { font-weight: 700; }
.template-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.template-actions { display: flex; gap: 8px; flex-shrink: 0; }
.tpl-empty-dur { font-style: normal; color: var(--orange); }

.dur-inputs { display: flex; gap: 8px; }
.dur-field { flex: 1; display: flex; align-items: center; gap: 6px; background: var(--bg); border: 1px solid var(--border-strong); border-radius: 10px; padding: 0 10px; }
.dur-field input { flex: 1; min-width: 0; border: none !important; background: transparent !important; box-shadow: none !important; padding: 10px 0 !important; }
.dur-field span { color: var(--text-muted); font-size: 13px; }

/* 单体加速模式选择 */
.sb-mode { display: flex; gap: 14px; }
.sb-mode-opt { display: flex; align-items: center; gap: 6px; cursor: pointer; font-size: 14px; color: var(--text); }
.sb-mode-opt input { width: 16px; height: 16px; accent-color: var(--gold); }

.group-select { display: flex; flex-direction: column; gap: 8px; }

.group-opt {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
  font-size: 14px;
  transition: border-color .15s ease;
}
.group-opt:hover { border-color: var(--cyan); }
.group-opt.full { opacity: 0.45; cursor: not-allowed; }
.group-opt input { accent-color: var(--gold); }
.group-opt small { color: var(--text-muted); margin-left: 4px; }

/* ---------- 历史归档 ---------- */
.history-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }

.panel-title { margin: 0; font-size: 18px; }

.history-list { display: flex; flex-direction: column; gap: 10px; }

.history-empty { text-align: center; color: var(--text-muted); padding: 40px 0; }

.history-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
}
.history-item:last-child { border-left: 3px solid var(--green); }
.history-item:first-child { border-left: 3px solid var(--gold); }

.history-name { font-weight: 700; }

.history-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ---------- 设置面板 ---------- */
.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}

.desc { margin: 8px 0 10px; font-size: 13px; color: var(--text-muted); }
.hint { font-size: 12px; color: var(--text-muted); margin: 8px 0 0; }

.rules { margin: 8px 0 0; padding-left: 18px; font-size: 13px; color: var(--text-muted); }
.rules li { margin-bottom: 6px; }

/* 存储空间进度条 */
.storage-bar {
  height: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
  margin: 6px 0;
}
#storageBar {
  height: 100%;
  width: 0%;
  background: var(--green);
  border-radius: 999px;
  transition: width .3s ease;
}
#storageBar.warn { background: var(--orange); }
.storage-warn { color: var(--orange); font-weight: 600; }

/* ---------- 通知引导横幅 ---------- */
.notif-banner {
  position: fixed;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  z-index: 90;
  width: calc(100% - 28px);
  max-width: 560px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: #20293A;
  border: 1px solid rgba(245, 185, 66, 0.5);
  border-radius: 12px;
  padding: 12px 14px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
  animation: popIn .2s ease;
}

.notif-banner-text { font-size: 13px; color: var(--text); flex: 1; min-width: 200px; }

.notif-banner-actions { display: flex; gap: 8px; }

/* ---------- Toast ---------- */
.toast-root {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 120;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: #20293A;
  border: 1px solid var(--border-strong);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 18px;
  font-size: 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  opacity: 0;
  transform: translateY(-8px);
  transition: all .25s ease;
  max-width: 90vw;
}

.toast.show { opacity: 1; transform: none; }

.toast.error { border-color: var(--orange); color: #FFC2B5; }

/* ---------- 移动端适配 ---------- */
@media (max-width: 480px) {
  .app-main { padding: 12px 10px 70px; }
  .task-actions .btn { flex: 1 1 40%; }
  .btn { padding: 8px 12px; }
  .boost-bar { flex-direction: column; align-items: stretch; }
  .boost-actions { justify-content: stretch; }
  .boost-actions .btn { flex: 1; }
  .task-top { flex-direction: column; }
  .task-badges { flex-direction: row; align-items: center; }
}
