/* ============================================================
   量化交易管理系统 - 自定义样式
   浅色主题，补充 Tailwind 不足部分
   ============================================================ */

/* ---------- 基础变量 ---------- */
:root {
  --color-profit: #dc2626;   /* A股：涨/盈利 = 红 */
  --color-loss:   #16a34a;   /* A股：跌/亏损 = 绿 */
  --color-buy:    #16a34a;   /* 买入 = 绿 */
  --color-sell:   #dc2626;   /* 卖出 = 红 */
  --color-border: #e5e7eb;
  --color-bg:     #f9fafb;
  --color-card:   #ffffff;
  --color-text:   #111827;
  --color-muted:  #6b7280;
  --radius-card:  0.75rem;
  --shadow-card:  0 1px 3px 0 rgb(0 0 0 / .08), 0 1px 2px -1px rgb(0 0 0 / .06);
}

/* ---------- 数字等宽字体 ---------- */
.font-mono,
.price,
.amount,
.pnl,
.qty,
td.num {
  font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', 'Consolas',
               'SF Mono', 'Menlo', monospace;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}

/* ---------- 盈亏颜色（A股习惯） ---------- */
.text-profit,
.profit { color: var(--color-profit) !important; }

.text-loss,
.loss   { color: var(--color-loss) !important; }

.text-flat { color: var(--color-muted) !important; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 1.25rem 1.5rem;
  transition: box-shadow 0.2s ease;
}

.card:hover {
  box-shadow: 0 4px 12px 0 rgb(0 0 0 / .10);
}

.card-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}

.card-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--color-text);
  line-height: 1.2;
}

/* ---------- 表格 ---------- */
.table-base {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.table-base thead th {
  background: #f3f4f6;
  color: var(--color-muted);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.625rem 0.875rem;
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
  user-select: none;
}

.table-base tbody td {
  padding: 0.625rem 0.875rem;
  border-bottom: 1px solid #f3f4f6;
  color: var(--color-text);
  vertical-align: middle;
}

/* 斑马纹 */
.table-striped tbody tr:nth-child(even) td {
  background: #fafafa;
}

/* hover 效果 */
.table-hover tbody tr:hover td {
  background: #eff6ff;
  transition: background 0.15s ease;
}

/* 可排序列头 */
.table-base thead th.sortable {
  cursor: pointer;
}

.table-base thead th.sortable:hover {
  background: #e9eaec;
  color: #374151;
}

.table-base thead th.sort-asc::after  { content: ' ↑'; color: #3b82f6; }
.table-base thead th.sort-desc::after { content: ' ↓'; color: #3b82f6; }

/* ---------- Badge / 标签 ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2em 0.65em;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
}

/* 方向标签 */
.badge-buy {
  background: #dcfce7;
  color: #15803d;
  border: 1px solid #bbf7d0;
}

.badge-sell {
  background: #fee2e2;
  color: #b91c1c;
  border: 1px solid #fecaca;
}

/* 状态标签 */
.badge-pending {
  background: #fef9c3;
  color: #854d0e;
  border: 1px solid #fde68a;
}

.badge-filled {
  background: #dbeafe;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
}

.badge-cancelled {
  background: #f3f4f6;
  color: #6b7280;
  border: 1px solid #e5e7eb;
}

.badge-partial {
  background: #ede9fe;
  color: #6d28d9;
  border: 1px solid #ddd6fe;
}

.badge-error {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.badge-active {
  background: #d1fae5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}

.badge-inactive {
  background: #f3f4f6;
  color: #6b7280;
  border: 1px solid #e5e7eb;
}

/* ---------- 动画：淡入 ---------- */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInFast {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

.animate-fade-in       { animation: fadeIn 0.3s ease both; }
.animate-fade-in-fast  { animation: fadeInFast 0.15s ease both; }
.animate-slide-in      { animation: slideInRight 0.25s ease both; }

/* 列表项依次淡入 */
.stagger-children > * {
  animation: fadeIn 0.3s ease both;
}
.stagger-children > *:nth-child(1)  { animation-delay: 0.05s; }
.stagger-children > *:nth-child(2)  { animation-delay: 0.10s; }
.stagger-children > *:nth-child(3)  { animation-delay: 0.15s; }
.stagger-children > *:nth-child(4)  { animation-delay: 0.20s; }
.stagger-children > *:nth-child(5)  { animation-delay: 0.25s; }
.stagger-children > *:nth-child(6)  { animation-delay: 0.30s; }

/* ---------- Toast 轻提示 ---------- */
#toast-container {
  position: fixed;
  top: 1.25rem;
  right: 1.25rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.125rem;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: 0 4px 12px rgb(0 0 0 / .15);
  pointer-events: auto;
  animation: slideInRight 0.25s ease both;
  max-width: 320px;
}

.toast-success {
  background: #f0fdf4;
  color: #166534;
  border: 1px solid #bbf7d0;
}

.toast-error {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.toast-warning {
  background: #fffbeb;
  color: #92400e;
  border: 1px solid #fde68a;
}

.toast-info {
  background: #eff6ff;
  color: #1e40af;
  border: 1px solid #bfdbfe;
}

.toast-exit {
  animation: fadeInFast 0.2s ease reverse both;
}

/* ---------- 确认对话框 ---------- */
#confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgb(0 0 0 / .4);
  z-index: 9998;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeInFast 0.15s ease both;
}

#confirm-box {
  background: #fff;
  border-radius: 0.75rem;
  padding: 1.5rem;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 20px 40px rgb(0 0 0 / .2);
  animation: fadeIn 0.2s ease both;
}

/* ---------- 滚动条美化 ---------- */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: #f1f5f9;
  border-radius: 3px;
}

::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 #f1f5f9;
}

/* ---------- 表格容器横向滚动 ---------- */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius-card);
  border: 1px solid var(--color-border);
}

/* ---------- 加载骨架屏 ---------- */
@keyframes shimmer {
  0%   { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}

.skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 800px 100%;
  animation: shimmer 1.4s infinite linear;
  border-radius: 4px;
}

/* ---------- 响应式调整 ---------- */
@media (max-width: 768px) {
  .card {
    padding: 1rem;
  }

  .card-value {
    font-size: 1.375rem;
  }

  .table-base thead th,
  .table-base tbody td {
    padding: 0.5rem 0.625rem;
    font-size: 0.8125rem;
  }

  /* 移动端隐藏次要列 */
  .hide-mobile {
    display: none !important;
  }

  #toast-container {
    top: auto;
    bottom: 1rem;
    right: 0.75rem;
    left: 0.75rem;
  }

  .toast {
    max-width: 100%;
  }
}

@media (max-width: 480px) {
  .badge {
    font-size: 0.6875rem;
    padding: 0.15em 0.5em;
  }
}

/* ---------- 信号流 ---------- */
.signal-row-new {
  animation: fadeIn 0.4s ease both;
  background: #fffbeb !important;
}

/* ---------- 图表容器 ---------- */
.chart-container {
  width: 100%;
  min-height: 280px;
  position: relative;
}

/* ---------- 分页 ---------- */
.pagination {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex-wrap: wrap;
}

.page-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2rem;
  height: 2rem;
  padding: 0 0.5rem;
  border-radius: 0.375rem;
  font-size: 0.875rem;
  border: 1px solid var(--color-border);
  background: #fff;
  color: var(--color-text);
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
}

.page-btn:hover {
  background: #eff6ff;
  border-color: #93c5fd;
  color: #1d4ed8;
}

.page-btn.active {
  background: #3b82f6;
  border-color: #3b82f6;
  color: #fff;
  font-weight: 600;
}

.page-btn:disabled,
.page-btn.disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}
