/* ================================
   101創富精靈 H5 應用
   核心樣式表
   ================================ */

/* --- CSS 變量（Design Tokens）--- */
:root {
  --primary: #6366f1;
  --primary-light: #818cf8;
  --primary-dark: #4f46e5;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --bg: #0f172a;
  --surface: #1e293b;
  --surface2: #334155;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --border: #475569;
  --radius: 12px;
  --shadow: 0 4px 24px rgba(0,0,0,0.3);
}

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: -apple-system, 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* --- 通用容器 --- */
.container { max-width: 480px; margin: 0 auto; padding: 0 16px; }

/* --- 頁面框架 --- */
.page { display: none; min-height: 100vh; }
.page.active { display: block; animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* --- 頂部導航 --- */
.top-bar {
  position: sticky; top: 0; z-index: 100;
  background: rgba(15,23,42,0.95);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
  display: flex; align-items: center; gap: 12px;
}
.top-bar h1 { font-size: 18px; font-weight: 700; flex: 1; }
.top-bar .back-btn {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text); font-size: 18px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.top-bar .back-btn:hover { background: var(--surface2); }

/* --- 主內容區 --- */
.main { padding: 20px 16px 100px; }

/* --- 按鈕 --- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 24px; border-radius: var(--radius);
  font-size: 15px; font-weight: 600; cursor: pointer;
  border: none; transition: all 0.2s; width: 100%;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.btn-ghost { background: transparent; color: var(--text-muted); padding: 8px 16px; width: auto; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* --- 卡片 --- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; margin-bottom: 12px;
}
.card-title { font-size: 15px; font-weight: 600; margin-bottom: 8px; }
.card-meta { font-size: 13px; color: var(--text-muted); }

/* --- 檔案卡片 --- */
.file-card {
  display: flex; align-items: center; gap: 12px;
  padding: 12px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border);
  cursor: pointer; transition: all 0.2s; margin-bottom: 8px;
}
.file-card:hover { border-color: var(--primary); background: rgba(99,102,241,0.1); }
.file-icon { font-size: 28px; flex-shrink: 0; }
.file-info { flex: 1; min-width: 0; }
.file-name { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.file-tag { font-size: 11px; padding: 2px 8px; border-radius: 99px; background: rgba(99,102,241,0.2); color: var(--primary-light); }

/* --- 底部 Tab 導航 --- */
.tab-bar {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: rgba(15,23,42,0.97);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  display: flex; padding: 8px 0; padding-bottom: max(8px, env(safe-area-inset-bottom));
  z-index: 100;
}
.tab-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: none; border: none; color: var(--text-muted);
  font-size: 11px; cursor: pointer; padding: 4px; transition: color 0.2s;
}
.tab-item.active { color: var(--primary); }
.tab-item .icon { font-size: 22px; }

/* --- 上傳區 --- */
.upload-zone {
  border: 2px dashed var(--border); border-radius: var(--radius);
  padding: 40px 20px; text-align: center; cursor: pointer;
  transition: all 0.2s; background: rgba(99,102,241,0.03);
}
.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--primary); background: rgba(99,102,241,0.08);
}
.upload-zone .icon { font-size: 48px; color: var(--text-muted); }
.upload-zone p { color: var(--text-muted); font-size: 14px; margin-top: 8px; }

/* --- 搜索框 --- */
.search-bar {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 99px; padding: 10px 16px; margin-bottom: 16px;
}
.search-bar input {
  flex: 1; background: none; border: none; outline: none;
  color: var(--text); font-size: 15px;
}
.search-bar input::placeholder { color: var(--text-muted); }

/* --- Toast 通知 --- */
.toast {
  position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%);
  background: var(--surface2); color: var(--text);
  padding: 12px 24px; border-radius: 99px; font-size: 14px;
  box-shadow: var(--shadow); z-index: 999;
  opacity: 0; transition: opacity 0.3s; pointer-events: none;
}
.toast.show { opacity: 1; }
.toast.success { background: var(--success); color: #fff; }
.toast.error { background: var(--danger); color: #fff; }

/* --- 狀態指示器 --- */
.status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.status-dot.online { background: var(--success); }
.status-dot.offline { background: var(--danger); }
.status-dot.syncing { background: var(--warning); animation: pulse 1.5s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }

/* --- 標籤晶片 --- */
.tag-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px; border-radius: 99px;
  font-size: 12px; background: rgba(99,102,241,0.15); color: var(--primary-light);
  border: 1px solid rgba(99,102,241,0.3);
}

/* --- 加載動畫 --- */
.loading { text-align: center; padding: 40px; color: var(--text-muted); }
.spinner {
  width: 32px; height: 32px; border: 3px solid var(--border);
  border-top-color: var(--primary); border-radius: 50%;
  animation: spin 0.8s linear infinite; margin: 0 auto 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --- 空狀態 --- */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-state .icon { font-size: 56px; margin-bottom: 16px; opacity: 0.5; }
.empty-state p { font-size: 14px; }

/* --- Modal 覆蓋層 --- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.7);
  z-index: 200; display: none; align-items: flex-end; justify-content: center;
}
.modal-overlay.active { display: flex; }
.modal {
  background: var(--surface); border-radius: 16px 16px 0 0;
  width: 100%; max-width: 480px; max-height: 80vh;
  overflow-y: auto; padding: 20px;
  animation: slideUp 0.3s ease;
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.modal-handle { width: 40px; height: 4px; background: var(--border); border-radius: 2px; margin: 0 auto 16px; }

/* --- 進度條 --- */
.progress-bar { height: 4px; background: var(--surface2); border-radius: 2px; overflow: hidden; margin: 8px 0; }
.progress-fill { height: 100%; background: var(--primary); border-radius: 2px; transition: width 0.3s; }

/* --- 分割線 --- */
.divider { height: 1px; background: var(--border); margin: 16px 0; }

/* --- Flex 工具 --- */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.flex-1 { flex: 1; }
.text-muted { color: var(--text-muted); font-size: 13px; }
.text-center { text-align: center; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.p-16 { padding: 16px; }
.rounded-xl { border-radius: var(--radius); }
