/* QuantFox Dashboard Skin
   ------------------------------------------------------------------------
   Visual overlay for the 實盤概覽 / 策略管理 SPA pages (chunk 246).
   Source SPA is in a private Vue repo we can't modify, so this is the
   surgical CSS we layer on top. Uses qf-tokens.css for all colors so the
   skin matches the rest of the brand when the tokens change.

   Touch only classes the dashboard actually uses (kpi-*, chart-panel,
   stat-card, panel-header, …) — keep specificity low so it doesn't
   collide with Ant Design's own rules elsewhere in the app.
*/

/* ========================================================================
   ROOT CONTAINER — sets the canvas for the dashboard
   ====================================================================== */
.dashboard-pro {
  position: relative;
  isolation: isolate;
}

.dashboard-pro::before {
  /* Ambient grid backdrop — same vibe as the login page's loading screen. */
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(56, 189, 248, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(56, 189, 248, 0.025) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(ellipse 80% 60% at 50% 40%, #000 30%, transparent 100%);
  -webkit-mask-image: radial-gradient(ellipse 80% 60% at 50% 40%, #000 30%, transparent 100%);
}

/* ========================================================================
   KPI CARDS (top row: 總權益 / 勝率 / 盈虧比 / 最大回撤 / 總交易 / 運行中策略)
   ====================================================================== */
.dashboard-pro .kpi-grid {
  gap: 16px;
}

.dashboard-pro .kpi-card {
  position: relative;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.04) 0%, rgba(255, 255, 255, 0.01) 100%),
    rgba(15, 23, 42, 0.72);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  border: 1px solid rgba(148, 163, 184, 0.12);
  border-radius: 18px;
  padding: 22px 24px;
  overflow: hidden;
  transition:
    transform 220ms cubic-bezier(0.4, 0, 0.2, 1),
    box-shadow 220ms cubic-bezier(0.4, 0, 0.2, 1),
    border-color 220ms ease;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.04) inset,
    0 18px 48px -24px rgba(0, 0, 0, 0.6);
}

.dashboard-pro .kpi-card::after {
  /* Top edge highlight — subtle gleam */
  content: '';
  position: absolute;
  top: 0; left: 10%; right: 10%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(56, 189, 248, 0.45), transparent);
  opacity: 0.6;
  transition: opacity 220ms ease;
}

.dashboard-pro .kpi-card:hover {
  transform: translateY(-2px);
  border-color: rgba(56, 189, 248, 0.28);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.06) inset,
    0 28px 64px -28px rgba(2, 132, 199, 0.4),
    0 0 0 1px rgba(56, 189, 248, 0.08);
}

.dashboard-pro .kpi-card:hover::after {
  opacity: 1;
}

/* Primary KPI (總權益) — extra emphasis */
.dashboard-pro .kpi-card.kpi-primary {
  background:
    radial-gradient(circle at 0% 0%, rgba(56, 189, 248, 0.18) 0%, transparent 50%),
    linear-gradient(135deg, rgba(56, 189, 248, 0.10) 0%, rgba(99, 102, 241, 0.06) 100%),
    rgba(15, 23, 42, 0.82);
  border-color: rgba(56, 189, 248, 0.28);
}

.dashboard-pro .kpi-card.kpi-primary::after {
  background: linear-gradient(90deg, transparent, rgba(56, 189, 248, 0.75), transparent);
  opacity: 1;
}

.dashboard-pro .kpi-label {
  font-size: 12.5px;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: rgba(203, 213, 225, 0.78);
  text-transform: none;
  margin-bottom: 6px;
}

.dashboard-pro .kpi-value {
  font-family: 'Inter', -apple-system, 'JetBrains Mono', system-ui, sans-serif;
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1.05;
  color: #f8fafc;
  text-shadow: 0 0 24px rgba(56, 189, 248, 0.18);
}

.dashboard-pro .kpi-card.kpi-primary .kpi-value {
  background: linear-gradient(135deg, #f0f9ff 0%, #7dd3fc 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 0 32px rgba(56, 189, 248, 0.35);
}

.dashboard-pro .kpi-sub {
  font-size: 12px;
  color: rgba(148, 163, 184, 0.75);
  margin-top: 8px;
}

.dashboard-pro .kpi-icon {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(56, 189, 248, 0.08);
  border: 1px solid rgba(56, 189, 248, 0.18);
}

.dashboard-pro .kpi-glow {
  filter: blur(28px);
  opacity: 0.5;
}

/* ========================================================================
   POSITIVE / NEGATIVE NUMBER HIGHLIGHTING
   Win / loss colour cues — covers both Ant's amount classes and inline
   coloured spans used by the SPA.
   ====================================================================== */
.dashboard-pro .amount,
.dashboard-pro .pnl-card .stat-value {
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum';
}

.dashboard-pro .amount.negative,
.dashboard-pro [class*="text-loss"],
.dashboard-pro [style*="color: rgb(245, 34, 45)"],
.dashboard-pro [style*="color:#f5222d"] {
  color: var(--qf-danger, #f5222d) !important;
  text-shadow: 0 0 16px rgba(245, 34, 45, 0.25);
}

.dashboard-pro [class*="text-profit"],
.dashboard-pro [style*="color: rgb(82, 196, 26)"],
.dashboard-pro [style*="color:#52c41a"] {
  color: var(--qf-success, #52c41a) !important;
  text-shadow: 0 0 16px rgba(82, 196, 26, 0.25);
}

/* ========================================================================
   CHART PANELS (收益日歷 / 策略分布 / 回撤曲線 etc.)
   ====================================================================== */
.dashboard-pro .chart-panel {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.02) 0%, transparent 60%),
    rgba(15, 23, 42, 0.74);
  backdrop-filter: blur(18px) saturate(135%);
  -webkit-backdrop-filter: blur(18px) saturate(135%);
  border: 1px solid rgba(148, 163, 184, 0.10);
  border-radius: 18px;
  padding: 20px 24px;
  transition: border-color 220ms ease, box-shadow 220ms ease;
  box-shadow: 0 18px 48px -32px rgba(0, 0, 0, 0.5);
}

.dashboard-pro .chart-panel:hover {
  border-color: rgba(148, 163, 184, 0.20);
  box-shadow:
    0 22px 56px -32px rgba(2, 132, 199, 0.30),
    0 0 0 1px rgba(148, 163, 184, 0.05);
}

.dashboard-pro .panel-header {
  padding-bottom: 14px;
  margin-bottom: 14px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.08);
}

.dashboard-pro .panel-title {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-size: 15px;
  font-weight: 600;
  color: #e2e8f0;
  letter-spacing: 0.01em;
}

.dashboard-pro .panel-title .anticon {
  color: var(--qf-sky-400, #38bdf8);
  font-size: 16px;
}

.dashboard-pro .panel-badge {
  background: rgba(56, 189, 248, 0.10);
  color: var(--qf-sky-300, #7dd3fc);
  border: 1px solid rgba(56, 189, 248, 0.22);
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 11.5px;
  font-weight: 500;
}

/* ========================================================================
   STAT CARDS (策略管理 / 詳情頁 一般 metric)
   ====================================================================== */
.dashboard-pro .stat-card {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(148, 163, 184, 0.10);
  border-radius: 14px;
  padding: 16px 18px;
  transition: transform 180ms ease, border-color 180ms ease;
}

.dashboard-pro .stat-card:hover {
  transform: translateY(-1px);
  border-color: rgba(148, 163, 184, 0.20);
}

.dashboard-pro .stat-icon {
  border-radius: 10px;
  width: 38px;
  height: 38px;
}

.dashboard-pro .stat-icon.equity {
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.16), rgba(99, 102, 241, 0.10));
  border: 1px solid rgba(56, 189, 248, 0.22);
}

.dashboard-pro .stat-icon.pnl {
  background: linear-gradient(135deg, rgba(82, 196, 26, 0.16), rgba(82, 196, 26, 0.04));
  border: 1px solid rgba(82, 196, 26, 0.24);
}

.dashboard-pro .stat-icon.investment {
  background: linear-gradient(135deg, rgba(250, 173, 20, 0.16), rgba(250, 173, 20, 0.04));
  border: 1px solid rgba(250, 173, 20, 0.24);
}

.dashboard-pro .stat-label {
  font-size: 12.5px;
  color: rgba(148, 163, 184, 0.85);
  margin-bottom: 4px;
}

.dashboard-pro .stat-value {
  font-family: 'Inter', system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: #f1f5f9;
}

/* ========================================================================
   CALENDAR + DAY CELLS (收益日歷)
   ====================================================================== */
.dashboard-pro .calendar-day {
  border-radius: 8px;
  transition: transform 140ms ease, box-shadow 140ms ease;
}

.dashboard-pro .calendar-day:hover {
  transform: scale(1.06);
  box-shadow: 0 4px 14px -4px rgba(0, 0, 0, 0.4);
  z-index: 1;
}

/* ========================================================================
   TABLES (Ant Design overrides for the dashboard scope)
   ====================================================================== */
.dashboard-pro .ant-table-tbody > tr:nth-child(even) > td {
  background: rgba(148, 163, 184, 0.025);
}

.dashboard-pro .ant-table-tbody > tr:hover > td {
  background: rgba(56, 189, 248, 0.06) !important;
}

.dashboard-pro .ant-table-thead > tr > th {
  background: rgba(15, 23, 42, 0.6) !important;
  color: rgba(203, 213, 225, 0.88) !important;
  font-weight: 600;
  letter-spacing: 0.01em;
  border-bottom: 1px solid rgba(148, 163, 184, 0.12) !important;
}

/* ========================================================================
   STRATEGY MANAGEMENT — list cards
   ====================================================================== */
.dashboard-pro .ant-card,
.dashboard-pro .ant-collapse-item {
  border-radius: 14px;
  border-color: rgba(148, 163, 184, 0.10);
  transition: border-color 200ms ease, transform 200ms ease;
}

.dashboard-pro .ant-collapse-item:hover {
  border-color: rgba(56, 189, 248, 0.22);
}

/* ========================================================================
   SCROLLBARS — subtle, themed
   ====================================================================== */
.dashboard-pro *::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.dashboard-pro *::-webkit-scrollbar-track {
  background: transparent;
}

.dashboard-pro *::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.18);
  border-radius: 999px;
}

.dashboard-pro *::-webkit-scrollbar-thumb:hover {
  background: rgba(56, 189, 248, 0.40);
}

/* ========================================================================
   ACTION BUTTONS (start / stop)
   ====================================================================== */
.dashboard-pro .action-btn {
  border-radius: 10px;
  font-weight: 500;
  letter-spacing: 0.02em;
  transition: transform 140ms ease, box-shadow 140ms ease;
}

.dashboard-pro .action-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px -6px rgba(0, 0, 0, 0.5);
}

.dashboard-pro .action-btn.start-btn {
  background: linear-gradient(135deg, var(--qf-sky-500, #0ea5e9), var(--qf-indigo-500, #6366f1));
  border: none;
  color: white;
}

.dashboard-pro .action-btn.stop-btn {
  background: rgba(245, 34, 45, 0.12);
  border: 1px solid rgba(245, 34, 45, 0.32);
  color: #fecaca;
}

/* ========================================================================
   MOBILE — slightly tighter spacing
   ====================================================================== */
@media (max-width: 768px) {
  .dashboard-pro .kpi-card {
    padding: 16px 18px;
    border-radius: 14px;
  }
  .dashboard-pro .kpi-value {
    font-size: 24px;
  }
  .dashboard-pro .chart-panel {
    padding: 16px;
    border-radius: 14px;
  }
}

/* ========================================================================
   LIGHT THEME ADJUSTMENT
   The SPA can switch between dark / realdark / light. When the body is
   light, fall back to softer surfaces.
   ====================================================================== */
body[data-theme="light"] .dashboard-pro .kpi-card,
body[data-theme="light"] .dashboard-pro .chart-panel,
body[data-theme="light"] .dashboard-pro .stat-card {
  background: rgba(255, 255, 255, 0.85);
  border-color: rgba(15, 23, 42, 0.08);
  backdrop-filter: blur(12px);
}

body[data-theme="light"] .dashboard-pro .kpi-value,
body[data-theme="light"] .dashboard-pro .stat-value {
  color: #0f172a;
  text-shadow: none;
}
