/* ============================================================
   FgxHub 共用樣式
   ============================================================ */

:root {
  --bg: #0f172a;
  --bg-card: #1e293b;
  --bg-drawer: #0a1426;
  --border: #334155;
  --text: #e2e8f0;
  --text-dim: #94a3b8;
  --text-faint: #64748b;
  --primary: #3b82f6;
  --primary-light: #60a5fa;
  --green: #10b981;
  --red: #ef4444;
  --orange: #f59e0b;
  --coral: #fb7185;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang TC", "Microsoft JhengHei", sans-serif;
  color: var(--text);
  background: var(--bg);
  min-height: 100dvh;
  overflow-x: hidden;
}

/* TradingView-style 細 grid 背景 */
body::before {
  content: ""; position: fixed; inset: 0;
  background-image:
    linear-gradient(rgba(59,130,246,0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(59,130,246,0.06) 1px, transparent 1px);
  background-size: 28px 28px;
  z-index: -2; pointer-events: none;
}

/* ============================================================
   Topbar
   ============================================================ */
.topbar {
  position: fixed; top: 0; left: 0; right: 0;
  height: 56px;
  background: var(--bg-drawer);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 16px;
  z-index: 100;
}
.hamburger {
  background: none; border: none;
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  border-radius: 8px;
  color: var(--text);
}
.hamburger:hover { background: rgba(59,130,246,0.15); }
.hamburger svg { width: 24px; height: 24px; }
.topbar-title { font-size: 18px; font-weight: 700; margin-left: 12px; color: var(--text); }
.topbar-status {
  margin-left: auto;
  font-size: 12px;
  color: var(--green);
  display: flex; align-items: center; gap: 6px;
}
.topbar-status::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: var(--green);
}

/* ============================================================
   Drawer
   ============================================================ */
.drawer-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.55);
  opacity: 0; visibility: hidden;
  transition: opacity 0.25s, visibility 0.25s;
  z-index: 998;
}
.drawer-backdrop.open { opacity: 1; visibility: visible; }

.drawer {
  position: fixed; top: 0; left: 0;
  width: 78%; max-width: 320px;
  height: 100dvh;
  background: var(--bg-drawer);
  border-right: 1px solid var(--border);
  transform: translateX(-100%);
  transition: transform 0.28s;
  z-index: 999;
  display: flex; flex-direction: column;
}
.drawer.open { transform: translateX(0); }

.drawer-header {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}
.drawer-app-icon {
  width: 36px; height: 36px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  display: flex; align-items: center; justify-content: center;
  color: white;
}
.drawer-app-icon svg { width: 20px; height: 20px; }
.drawer-app-name { font-size: 16px; font-weight: 700; }
.drawer-close {
  margin-left: auto;
  background: none; border: none;
  color: var(--text-dim);
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  border-radius: 6px;
}
.drawer-close:hover { background: rgba(59,130,246,0.15); color: var(--text); }
.drawer-close svg { width: 18px; height: 18px; }

.drawer-scroll { flex: 1; overflow-y: auto; padding: 8px 0; }
.drawer-section-title {
  font-size: 11px; font-weight: 700;
  color: var(--text-faint);
  padding: 14px 18px 6px;
  letter-spacing: 1.5px;
}
.drawer-item {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 18px;
  cursor: pointer;
  color: var(--text-dim);
  border-left: 3px solid transparent;
  transition: background 0.15s, color 0.15s;
}
.drawer-item:hover { background: rgba(59,130,246,0.10); color: var(--text); }
.drawer-item.active {
  background: rgba(59,130,246,0.20);
  color: var(--primary-light);
  border-left-color: var(--primary);
}
.drawer-icon { font-size: 18px; }
.drawer-item-text { flex: 1; }
.drawer-item-title { font-size: 14px; font-weight: 600; }
.drawer-item-sub { font-size: 11px; color: var(--text-faint); margin-top: 2px; }
.drawer-item-arrow { color: var(--text-faint); font-size: 18px; }

.drawer-footer {
  border-top: 1px solid var(--border);
  padding: 14px 16px 18px;
  background: rgba(0,0,0,0.20);
}
.drawer-user {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 4px 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 10px;
}
.drawer-user-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}
.drawer-user-info { flex: 1; min-width: 0; }
.drawer-user-name { font-size: 13px; font-weight: 600; color: var(--text); }
.drawer-user-email { font-size: 11px; color: var(--text-faint); margin-top: 2px; }
.drawer-actions { display: flex; flex-direction: column; gap: 4px; }
.drawer-action {
  display: block;
  padding: 8px 10px;
  color: var(--text-dim);
  font-size: 13px;
  border-radius: 6px;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}
.drawer-action:hover { background: rgba(59,130,246,0.12); color: var(--text); }
.drawer-action-logout { color: var(--red); }
.drawer-action-logout:hover { background: rgba(239,68,68,0.15); color: var(--red); }

/* ============================================================
   Main / Radar iframe
   ============================================================ */
main {
  padding: 80px 20px 40px;
  min-height: 100dvh;
}
.radar-frame {
  width: 100%;
  min-height: 70vh;
  border: none;
  border-radius: 12px;
  background: transparent;
  display: none;
}
body.radar-mode .radar-frame { display: block; }

/* ============================================================
   通用 page (about / contact / login / signup)
   ============================================================ */
.page {
  max-width: 720px;
  margin: 80px auto 40px;
  padding: 32px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.page h1 {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--primary-light);
}
.page h2 { font-size: 18px; font-weight: 600; margin: 24px 0 8px; color: var(--text); }
.page p { font-size: 14px; line-height: 1.7; color: var(--text-dim); margin-bottom: 12px; }
.page ul { margin-left: 24px; color: var(--text-dim); line-height: 1.8; font-size: 14px; }
.page a { color: var(--primary-light); text-decoration: none; }
.page a:hover { text-decoration: underline; }

.back-home {
  display: inline-block;
  margin-bottom: 16px;
  font-size: 13px;
  color: var(--text-dim);
}

/* 表單 (login / signup) */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 6px;
}
.form-group input {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
}
.form-group input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.20);
}
.btn {
  width: 100%;
  padding: 12px;
  background: var(--primary);
  border: none;
  border-radius: 6px;
  color: white;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.btn:hover { background: var(--primary-light); }
.btn-secondary { background: var(--bg); border: 1px solid var(--border); color: var(--text); }
.btn-secondary:hover { background: var(--bg-drawer); }

.form-footer {
  text-align: center;
  margin-top: 16px;
  font-size: 13px;
  color: var(--text-dim);
}
.form-footer a { color: var(--primary-light); }
.error-msg {
  background: rgba(239,68,68,0.15);
  border: 1px solid var(--red);
  color: var(--red);
  padding: 10px;
  border-radius: 6px;
  font-size: 13px;
  margin-bottom: 12px;
  display: none;
}
.success-msg {
  background: rgba(16,185,129,0.15);
  border: 1px solid var(--green);
  color: var(--green);
  padding: 10px;
  border-radius: 6px;
  font-size: 13px;
  margin-bottom: 12px;
  display: none;
}

/* 404 頁 */
.notfound {
  text-align: center;
  padding: 80px 20px;
}
.notfound-code {
  font-size: 96px;
  font-weight: 700;
  color: var(--primary);
  line-height: 1;
}
.notfound-msg {
  font-size: 18px;
  color: var(--text-dim);
  margin: 16px 0 24px;
}

/* 響應式 */
@media (max-width: 480px) {
  .drawer { width: 86%; }
  .page { margin: 70px 16px 24px; padding: 24px; }
  .topbar-title { font-size: 16px; }
  .notfound-code { font-size: 72px; }
}