/* ===== 全局样式 ===== */
* { box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

/* ===== 滚动条 ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ===== 导航项 ===== */
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 10px;
  font-size: 14px;
  color: #475569;
  cursor: pointer;
  transition: all 0.15s;
  user-select: none;
}
.nav-item:hover { background: #f1f5f9; color: #1e293b; }
.nav-item.active { background: #eef2ff; color: #4f46e5; font-weight: 600; }
.nav-item.active svg { color: #4f46e5; }
.nav-sub-item {
  padding: 7px 12px 7px 38px;
  font-size: 13px;
  color: #64748b;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
}
.nav-sub-item:hover { background: #f1f5f9; color: #334155; }
.nav-sub-item.active { color: #4f46e5; font-weight: 600; background: #eef2ff; }

/* ===== 卡片 ===== */
.card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  padding: 20px;
  transition: box-shadow 0.2s;
}
.card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.05); }

.stat-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  padding: 20px;
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  border-radius: 16px 16px 0 0;
}

/* ===== 按钮 ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  border: none;
  white-space: nowrap;
}
.btn-primary { background: #4f46e5; color: #fff; }
.btn-primary:hover { background: #4338ca; }
.btn-secondary { background: #f1f5f9; color: #475569; }
.btn-secondary:hover { background: #e2e8f0; }
.btn-danger { background: #ef4444; color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-success { background: #22c55e; color: #fff; }
.btn-success:hover { background: #16a34a; }
.btn-ghost { background: transparent; color: #64748b; }
.btn-ghost:hover { background: #f1f5f9; color: #334155; }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 8px; }

/* ===== 表单 ===== */
.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  font-size: 14px;
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
  color: #1e293b;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: #818cf8;
  box-shadow: 0 0 0 3px rgba(99,102,241,0.1);
}
.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: #475569;
  margin-bottom: 5px;
}

/* ===== 表格 ===== */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  text-align: left;
  padding: 10px 12px;
  font-size: 12px;
  font-weight: 600;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid #e2e8f0;
  white-space: nowrap;
}
.data-table td {
  padding: 12px;
  font-size: 14px;
  color: #334155;
  border-bottom: 1px solid #f1f5f9;
}
.data-table tr:hover td { background: #f8fafc; }

/* ===== 标签/徽章 ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
}
.badge-green { background: #dcfce7; color: #15803d; }
.badge-blue { background: #dbeafe; color: #1d4ed8; }
.badge-yellow { background: #fef3c7; color: #b45309; }
.badge-red { background: #fee2e2; color: #b91c1c; }
.badge-gray { background: #f1f5f9; color: #64748b; }
.badge-purple { background: #f3e8ff; color: #7e22ce; }

/* ===== 进度条 ===== */
.progress-bar {
  width: 100%;
  height: 8px;
  background: #e2e8f0;
  border-radius: 4px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.4s ease;
  background: linear-gradient(90deg, #6366f1, #818cf8);
}

/* ===== 模态框动画 ===== */
.modal-overlay { animation: fadeIn 0.2s; }
.modal-box { animation: slideUp 0.25s; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

/* ===== Toast ===== */
.toast {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 18px;
  border-radius: 12px;
  font-size: 14px;
  color: #fff;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  animation: toastIn 0.3s;
}
.toast-success { background: #22c55e; }
.toast-error { background: #ef4444; }
.toast-info { background: #3b82f6; }
@keyframes toastIn { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: translateX(0); } }

/* ===== 计时器 ===== */
.timer-display {
  font-family: 'SF Mono', 'Monaco', 'Cascadia Code', monospace;
  font-size: 3rem;
  font-weight: 700;
  letter-spacing: 2px;
  color: #1e293b;
}
.timer-display.active { color: #ef4444; }

/* ===== 空状态 ===== */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: #94a3b8;
}
.empty-state svg { margin: 0 auto 12px; opacity: 0.4; }

/* ===== 分段控件 ===== */
.tab-bar {
  display: inline-flex;
  background: #f1f5f9;
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
}
.tab-btn {
  padding: 7px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: #64748b;
  cursor: pointer;
  transition: all 0.15s;
  border: none;
  background: transparent;
}
.tab-btn.active { background: #fff; color: #4f46e5; box-shadow: 0 1px 3px rgba(0,0,0,0.08); }

/* ===== 加载屏幕 ===== */
.loading-screen {
  position: fixed; inset: 0; z-index: 9999;
  background: #f8fafc;
  display: flex; align-items: center; justify-content: center;
  flex-direction: column;
}
.loading-content { text-align: center; }
.loading-spinner {
  width: 40px; height: 40px;
  border: 3px solid #e2e8f0;
  border-top-color: #4f46e5;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { font-size: 15px; font-weight: 600; color: #475569; margin-bottom: 4px; }
.loading-sub { font-size: 13px; color: #94a3b8; }

/* ===== 离线横幅 ===== */
.offline-banner {
  position: fixed; top: 0; left: 0; right: 0; z-index: 1000;
  background: #fef3c7; color: #92400e;
  padding: 8px 16px; font-size: 13px;
  display: flex; align-items: center; justify-content: center;
  gap: 12px;
}
.retry-btn {
  padding: 4px 12px; background: #f59e0b; color: #fff;
  border: none; border-radius: 6px; font-size: 12px; cursor: pointer;
}

/* ===== 响应式 ===== */
@media (max-width: 768px) {
  .timer-display { font-size: 2.2rem; }

  /* 侧边栏宽度 */
  .sidebar { width: 260px; }

  /* 主内容内边距 */
  main .p-4, main .p-6 { padding: 12px !important; }
  main .lg\:p-6 { padding: 12px !important; }

  /* 卡片内边距缩小 */
  .card { padding: 14px; border-radius: 12px; }
  .stat-card { padding: 14px; border-radius: 12px; }

  /* 统计卡片 2 列变 2 列（原来是 4 列） */
  .grid-cols-2.lg\:grid-cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  /* 三列变两列 */
  .lg\:grid-cols-3 { grid-template-columns: repeat(1, minmax(0, 1fr)); }

  /* 表格横向滚动 */
  .overflow-x-auto { -webkit-overflow-scrolling: touch; }

  /* 按钮缩小 */
  .btn { padding: 7px 12px; font-size: 13px; }
  .btn-sm { padding: 4px 8px; font-size: 11px; }

  /* 表单 */
  .form-input, .form-select, .form-textarea { padding: 8px 10px; font-size: 13px; }

  /* 模态框全屏 */
  .modal-box { border-radius: 16px 16px 0 0; margin-top: auto; margin-bottom: 0; max-height: 85vh; }

  /* 浮动计时器缩小 */
  .float-timer { bottom: 12px; left: 12px; padding: 10px 14px; font-size: 12px; border-radius: 12px; }

  /* Toast 底部留间距 */
  #toast-container { bottom: 12px; right: 12px; left: 12px; }
  .toast { font-size: 13px; padding: 10px 14px; }

  /* 导航 */
  .nav-item { padding: 8px 10px; font-size: 13px; }
  .nav-sub-item { padding: 6px 10px 6px 34px; font-size: 12px; }

  /* 分类网格 4 列变 3 列 */
  .grid-cols-4.lg\:grid-cols-8 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid-cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  /* 表格文字缩小 */
  .data-table th { padding: 8px 8px; font-size: 11px; }
  .data-table td { padding: 8px 8px; font-size: 12px; }

  /* 奖励卡片 2 列变 1 列 */
  .lg\:grid-cols-2 { grid-template-columns: repeat(1, minmax(0, 1fr)); }

  /* 已领取奖励 3 列变 1 列 */
  .lg\:grid-cols-3 { grid-template-columns: repeat(1, minmax(0, 1fr)); }

  /* 标签栏滚动 */
  .tab-bar { overflow-x: auto; display: flex; white-space: nowrap; width: 100%; }
  .tab-btn { flex-shrink: 0; }
}

@media (max-width: 480px) {
  .stat-card .text-2xl { font-size: 1.25rem; }
  .timer-display { font-size: 1.8rem; }
  .card { padding: 12px; }
  .stat-card { padding: 12px; }

  /* 工具栏换行 */
  .flex-wrap .btn { margin-top: 4px; }
}

/* ===== 图标 ===== */
[data-lucide] { width: 18px; height: 18px; flex-shrink: 0; }

/* ===== 悬浮计时器 ===== */
.float-timer {
  position: fixed;
  bottom: 20px;
  left: 20px;
  z-index: 90;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  padding: 12px 18px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.1);
  display: flex;
  align-items: center;
  gap: 12px;
  animation: slideUp 0.3s;
}
