/* ============================================================
   數據分析平台入口 — 全站樣式
   依《Gounitravel-AP 視覺風格規範》(peopleops-platform 為基準)
   單一 styles.css、純手寫 CSS + 自訂屬性、語意化 class、無框架
   ============================================================ */

/* ---- 1. 色彩 Token（淺色，規範第 1 節照抄）---- */
:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --border: #e2e6ea;
  --text: #1f2933;
  --muted: #66727d;
  --primary: #2563eb;
  --primary-ink: #1d4ed8;
  --danger: #dc2626;
  --ok: #059669;
  --chip: #eef2f7;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.1);
}

/* ---- 深色模式（比照 peopleops：只在 data-theme="dark" 生效，不跟隨系統）---- */
:root[data-theme="dark"] {
  --bg: #0f1420;
  --surface: #171e2b;
  --border: #2a3446;
  --text: #e6e9ef;
  --muted: #9aa6b5;
  --primary: #3b82f6;
  --primary-ink: #60a5fa;
  --danger: #f87171;
  --ok: #34d399;
  --chip: #232d3d;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 1px 3px rgba(0, 0, 0, 0.45);
}

/* ---- 2. 基礎 ---- */
* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Noto Sans TC", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1, h2, h3 { font-weight: 600; }

a { color: var(--primary); }

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

[hidden] { display: none !important; }

/* ---- 3. UNI Logo（規範第 3 節，色值/字體/尺寸不可更改）---- */
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}
.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: #eb5505;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Noto Sans TC", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}

/* ---- 4.1 Header（規範第 4.1 節，高度固定 56px）---- */
.topbar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 20px;
  height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar-spacer { flex: 1; }

.userbox {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.userbox .user-name {
  font-size: 13px;
  color: var(--muted);
}

.icon-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  font: inherit;
  line-height: 1;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
.icon-toggle:hover { background: var(--chip); }
.icon-toggle:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.icon-toggle svg { width: 16px; height: 16px; display: block; }

/* ---- 4.3 主內容區（寬度上限 1280、置中）---- */
main {
  flex: 1;
  padding: 20px;
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
}

/* ---- 5.2 按鈕 ---- */
button {
  font: inherit;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
button:hover { background: var(--chip); }

/* ---- 5.8 空狀態 / 載入中 ---- */
.spin { color: var(--muted); }

.empty-state {
  padding: 40px 24px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

@keyframes spin-rot { to { transform: rotate(360deg); } }
.board-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 60px 24px;
  color: var(--muted);
  font-size: 13px;
  grid-column: 1 / -1;
}
.board-loading .spinner-lg {
  width: 34px;
  height: 34px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin-rot .8s linear infinite;
}
@media (prefers-reduced-motion: reduce) {
  .board-loading .spinner-lg { animation-duration: 2.4s; }
}

/* ---- 權限閘門 / 無權限畫面 ---- */
.gate {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 60vh;
  text-align: center;
  color: var(--muted);
}
.gate h2 { margin: 0; color: var(--text); font-size: 18px; }
.gate p { margin: 0; max-width: 420px; }

footer {
  margin: 16px auto 0;
  max-width: 1280px;
  padding: 0 20px 24px;
  font-size: 11px;
  color: var(--muted);
  text-align: right;
}

/* ---- 平台選單 ---- */
.portal-hint {
  margin: 0 0 18px;
  font-size: 13px;
  color: var(--muted);
}

.platform-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

.platform-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  cursor: pointer;
  transition: border-color .15s, transform .15s;
}
.platform-card:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
}
.platform-card:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
.platform-card.locked {
  cursor: not-allowed;
  opacity: .6;
}
.platform-card.locked:hover {
  border-color: var(--border);
  transform: none;
}

.platform-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: var(--chip);
  color: var(--primary-ink);
  display: flex;
  align-items: center;
  justify-content: center;
}

.platform-name {
  margin: 0;
  font-size: 15px;
  color: var(--text);
}

.platform-desc {
  margin: 0;
  font-size: 12.5px;
  color: var(--muted);
  flex: 1;
}

.platform-status {
  font-size: 12.5px;
  font-weight: 600;
}
.platform-go { color: var(--primary-ink); }
.platform-lock {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
}
