/* ==========================================================================
   GameConnect — Neumorphic (Soft UI) 主題
   參考上傳之 neumorphic dashboard UI kit:紫色漸層背景 + 淺薰衣草面板,
   柔和雙向陰影(凸起 / 內凹)、藥丸狀控制項、紫/粉/綠漸層強調色。
   ========================================================================== */

:root {
  /* 介面底色(整個 app 內部統一,凸起/內凹陰影才成立) */
  --surface: #e8eaf3;
  --surface-2: #eef0f8;

  /* 雙向陰影色 */
  --shadow-dark: #c4c7da;
  --shadow-light: #ffffff;

  /* 文字 */
  --text: #51517a;
  --muted: #9a9bbb;

  /* 強調 */
  --accent: #7b5cf0;
  --accent-2: #b14ddb;
  --accent-grad: linear-gradient(135deg, #b14ddb 0%, #7b5cf0 100%);
  --green-grad: linear-gradient(135deg, #46e0a0 0%, #1fb97e 100%);
  --pink: #e0489b;
  --danger: #e5547a;
  --ok: #1fb97e;

  /* 圓角 */
  --r-lg: 24px;
  --r-md: 16px;
  --r-sm: 12px;
  --r-pill: 999px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, "PingFang TC", "Microsoft JhengHei", sans-serif;
  color: var(--text);
  font-size: 14px;
  min-height: 100vh;
  background: linear-gradient(135deg, #8b6cf0 0%, #a877f0 55%, #c178e8 100%);
  background-attachment: fixed;
}

/* 背景柔光圓點 */
body::before,
body::after {
  content: "";
  position: fixed;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  filter: blur(6px);
  z-index: 0;
  pointer-events: none;
}
body::before { width: 420px; height: 420px; top: -120px; right: -80px; }
body::after { width: 320px; height: 320px; bottom: -120px; left: -60px; }

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

/* --------------------------------------------------------------------------
   App 外框:浮在紫色背景上的大圓角面板(sidebar + main)
   -------------------------------------------------------------------------- */
.app {
  position: relative;
  z-index: 1;
  display: flex;
  /* 桌面版盡量用滿螢幕寬度,讓結果表格不必左右滑動 */
  max-width: 1760px;
  width: calc(100% - 56px);
  margin: 28px auto;
  min-height: calc(100vh - 56px);
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: 18px 18px 40px rgba(60, 40, 110, 0.35),
    -10px -10px 30px rgba(255, 255, 255, 0.15);
  overflow: hidden;
}

/* --------------------------------------------------------------------------
   Sidebar
   -------------------------------------------------------------------------- */
.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--surface);
  padding: 26px 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: inset -8px 0 16px -10px var(--shadow-dark);
}
.sidebar .logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
  padding: 4px;
}
.sidebar .logo .mark {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: var(--accent-grad);
  color: #fff;
  font-weight: 800;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 5px 5px 12px var(--shadow-dark), -5px -5px 12px var(--shadow-light);
}
.sidebar .logo .name { font-weight: 800; font-size: 17px; letter-spacing: 0.5px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--r-sm);
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
  transition: color 0.15s, box-shadow 0.15s;
}
.nav-item .icon { display: flex; align-items: center; justify-content: center; width: 18px; height: 18px; }
.nav-item .icon svg { display: block; }
button svg { display: block; }
.nav-item:hover { color: var(--text); }
.nav-item.active {
  color: var(--accent);
  background: var(--surface);
  box-shadow: inset 5px 5px 10px var(--shadow-dark),
    inset -5px -5px 10px var(--shadow-light);
}

.sidebar .spacer { flex: 1; }

.side-card {
  margin-top: 12px;
  padding: 18px 16px;
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow: 6px 6px 14px var(--shadow-dark), -6px -6px 14px var(--shadow-light);
  text-align: center;
}
.side-card .title { font-weight: 700; font-size: 13px; margin-bottom: 6px; }
.side-card .sub { color: var(--muted); font-size: 12px; margin-bottom: 14px; line-height: 1.5; }

/* --------------------------------------------------------------------------
   Main / Topbar
   -------------------------------------------------------------------------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 30px;
}
.topbar .page-title { font-size: 20px; font-weight: 800; }
.topbar .right { display: flex; align-items: center; gap: 16px; }
.topbar .user {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 600;
}
.topbar .avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--accent-grad);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  box-shadow: 4px 4px 10px var(--shadow-dark), -4px -4px 10px var(--shadow-light);
}

.content { padding: 6px 22px 30px; }

/* --------------------------------------------------------------------------
   Cards / panels
   -------------------------------------------------------------------------- */
.panel {
  background: var(--surface);
  border-radius: var(--r-lg);
  padding: 20px;
  margin-bottom: 22px;
  box-shadow: 8px 8px 20px var(--shadow-dark), -8px -8px 20px var(--shadow-light);
}

h1 { font-size: 18px; margin: 0 0 18px; font-weight: 800; }
h2 { font-size: 15px; margin: 0 0 12px; font-weight: 700; }

/* --------------------------------------------------------------------------
   Forms
   -------------------------------------------------------------------------- */
label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 7px; font-weight: 600; }

input[type="text"],
input[type="password"],
input[type="date"],
input[type="number"],
select {
  width: 100%;
  padding: 11px 15px;
  border: none;
  border-radius: var(--r-pill);
  font-size: 14px;
  background: var(--surface);
  color: var(--text);
  box-shadow: inset 5px 5px 10px var(--shadow-dark),
    inset -5px -5px 10px var(--shadow-light);
  outline: none;
}
input::placeholder { color: #b6b7d0; }
input:focus,
select:focus {
  box-shadow: inset 6px 6px 12px var(--shadow-dark),
    inset -6px -6px 12px var(--shadow-light);
}
select { appearance: none; -webkit-appearance: none; cursor: pointer; }

.filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 18px;
  align-items: end;
}
.field { display: flex; flex-direction: column; }

button {
  cursor: pointer;
  border: none;
  border-radius: var(--r-pill);
  padding: 11px 26px;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  background: var(--accent-grad);
  box-shadow: 5px 5px 12px var(--shadow-dark), -5px -5px 12px var(--shadow-light);
  transition: transform 0.08s, box-shadow 0.12s, filter 0.12s;
}
button:hover { filter: brightness(1.05); }
button:active {
  transform: translateY(1px);
  box-shadow: inset 4px 4px 8px rgba(80, 50, 140, 0.35),
    inset -2px -2px 6px rgba(255, 255, 255, 0.25);
}
button.secondary {
  background: var(--surface);
  color: var(--text);
  box-shadow: 5px 5px 12px var(--shadow-dark), -5px -5px 12px var(--shadow-light);
}
button.secondary:active {
  box-shadow: inset 5px 5px 10px var(--shadow-dark),
    inset -5px -5px 10px var(--shadow-light);
}
button.green { background: var(--green-grad); }
button:disabled { opacity: 0.55; cursor: not-allowed; }

.actions { display: flex; gap: 12px; margin-top: 18px; flex-wrap: wrap; }

.brand-empty { color: var(--muted); font-size: 13px; }

/* --------------------------------------------------------------------------
   chip 下拉多選元件(.ms)— BRAND 篩選器
   -------------------------------------------------------------------------- */
.ms { position: relative; }

.ms-control {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 6px 8px 6px 12px;
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow: inset 5px 5px 10px var(--shadow-dark),
    inset -5px -5px 10px var(--shadow-light);
  cursor: pointer;
  outline: none;
}
.ms.open .ms-control,
.ms-control:focus {
  box-shadow: inset 6px 6px 12px var(--shadow-dark),
    inset -6px -6px 12px var(--shadow-light);
}

.ms-tags {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.ms-placeholder { color: var(--muted); font-size: 14px; }

/* 已選標籤 */
.ms-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 4px 3px 10px;
  border-radius: var(--r-pill);
  background: rgba(123, 92, 240, 0.12);
  color: var(--accent);
  border: 1px solid rgba(123, 92, 240, 0.28);
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.4;
}
.ms-tag-x {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2px;
  border-radius: 50%;
  background: none;
  box-shadow: none;
  color: var(--accent);
}
.ms-tag-x:hover { background: rgba(123, 92, 240, 0.18); color: var(--accent-2); }
.ms-tag-x:active { transform: none; box-shadow: none; }

/* +N 收合徽章 */
.ms-more {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: var(--r-pill);
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}

/* 清除鈕 / 箭頭 */
.ms-clear,
.ms-arrow {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  color: var(--muted);
}
.ms-clear {
  padding: 4px;
  border-radius: 50%;
  background: none;
  box-shadow: none;
}
.ms-clear:hover { background: rgba(120, 120, 160, 0.12); color: var(--text); }
.ms-clear:active { transform: none; box-shadow: none; }
.ms-arrow { padding-right: 4px; transition: transform 0.15s; }
.ms.open .ms-arrow { transform: rotate(180deg); }

/* 下拉選單(凸起卡片,絕對定位浮層) */
.ms-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  z-index: 50;
  padding: 6px;
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow: 8px 8px 20px var(--shadow-dark), -8px -8px 20px var(--shadow-light);
  max-height: 264px;
  overflow-y: auto;
}
.ms-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--r-sm);
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
}
.ms-option:hover { background: rgba(123, 92, 240, 0.08); }
.ms-option.selected { color: var(--accent); font-weight: 600; }
.ms-opt-check { display: none; color: var(--accent); flex-shrink: 0; }
.ms-option.selected .ms-opt-check { display: flex; }
.ms-empty { padding: 10px 12px; color: var(--muted); font-size: 13px; }

/* --------------------------------------------------------------------------
   Table
   -------------------------------------------------------------------------- */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow: inset 4px 4px 10px var(--shadow-dark),
    inset -4px -4px 10px var(--shadow-light);
  padding: 4px;
}
table { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 12px; }
th, td { padding: 7px 6px; text-align: left; vertical-align: top; }
th {
  color: var(--muted);
  font-weight: 700;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.2px;
  /* 標頭允許換行,讓較長的欄名(如 PLATFORM_TX_ID)折行而非撐寬整表 */
  white-space: normal;
  overflow-wrap: break-word;
  border-bottom: 1px solid rgba(150, 150, 190, 0.18);
}
/* 數字欄標頭不折行,維持與數值對齊 */
th.num { white-space: nowrap; }
/* 內容欄位允許在自然斷點(空白)換行:日期時間斷成「日期 / 時間」兩行、
   遊戲名稱在空白處換行;但 ID、ROUND_ID、TX 等連續字串維持完整不硬斷,避免逐字斷行。 */
tbody td {
  color: var(--text);
  white-space: normal;
  word-break: normal;
  overflow-wrap: normal;
  border-bottom: 1px solid rgba(150, 150, 190, 0.1);
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: rgba(123, 92, 240, 0.06); }
/* 數字欄位保持不換行、右對齊 */
td.num, th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
/* 以 <br> 強制兩行的欄位(如時間):每行各自不再換行 */
td.nowrap { white-space: nowrap; }

/* 分頁 */
.pagination {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 18px;
  flex-wrap: wrap;
}
.pagination button { padding: 9px 20px; font-size: 13px; }
.pagination .info { color: var(--muted); font-weight: 600; }

/* 訊息 */
.msg { margin-top: 14px; font-size: 13px; min-height: 18px; font-weight: 600; }
.msg.error { color: var(--danger); }
.msg.ok { color: var(--ok); }

/* --------------------------------------------------------------------------
   登入頁 / 置中卡片
   -------------------------------------------------------------------------- */
.login-wrap {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  width: 380px;
  background: var(--surface);
  border-radius: var(--r-lg);
  padding: 40px 34px;
  box-shadow: 16px 16px 40px rgba(60, 40, 110, 0.35),
    -10px -10px 30px rgba(255, 255, 255, 0.18);
}
.login-card .brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  margin-bottom: 28px;
}
.login-card .brand .mark {
  width: 60px;
  height: 60px;
  border-radius: 18px;
  background: var(--accent-grad);
  color: #fff;
  font-weight: 800;
  font-size: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 6px 6px 14px var(--shadow-dark), -6px -6px 14px var(--shadow-light);
}
.login-card .brand h1 { margin: 0; font-size: 22px; }
.login-card .field { margin-bottom: 18px; }
.login-card button { width: 100%; padding: 13px; }

.hint { color: var(--muted); font-size: 12px; margin-top: 16px; text-align: center; line-height: 1.6; }
.hint:empty { margin-top: 0; } /* 無提示(非 mock)時不留空白間隙 */

/* 窄螢幕:sidebar 收為水平列 */
@media (max-width: 820px) {
  .app { flex-direction: column; width: auto; margin: 14px; min-height: auto; }
  .sidebar {
    width: auto;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    box-shadow: inset 0 -8px 16px -10px var(--shadow-dark);
  }
  .sidebar .logo { margin-bottom: 0; margin-right: 8px; }
  .sidebar .spacer, .sidebar .side-card { display: none; }
}
