/* AI 量化交易系统 -- 全局自定义样式 (Tailwind 之外的补充) */

:root {
  --primary:        #4f46e5;   /* indigo-600 */
  --primary-dark:   #4338ca;
  --primary-light:  #eef2ff;
  --success:        #10b981;
  --warning:        #f59e0b;
  --danger:         #ef4444;
  --gray-50:        #f9fafb;
  --gray-100:       #f3f4f6;
  --gray-200:       #e5e7eb;
  --gray-400:       #9ca3af;
  --gray-600:       #4b5563;
  --gray-700:       #374151;
  --gray-900:       #111827;
}

html, body {
  font-family: -apple-system, "Inter", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: #f5f7fa;
  color: var(--gray-900);
  margin: 0;
  padding: 0;
}

/* ===================== 顶部导航 ===================== */
.app-nav {
  background: #fff;
  border-bottom: 1px solid var(--gray-200);
  padding: 0 24px;
  display: flex;
  align-items: center;
  height: 56px;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.app-nav .brand {
  font-size: 16px;
  font-weight: 700;
  color: var(--gray-900);
  margin-right: 32px;
}
.app-nav .brand .accent {
  color: var(--primary);
}
.app-nav .nav-tabs {
  display: flex;
  gap: 4px;
  flex: 1;
}
.app-nav .nav-tab {
  padding: 8px 14px;
  font-size: 13px;
  color: var(--gray-600);
  text-decoration: none;
  border-radius: 6px;
  transition: all 0.15s;
  font-weight: 500;
}
.app-nav .nav-tab:hover {
  background: var(--gray-100);
  color: var(--gray-900);
}
.app-nav .nav-tab.active {
  background: var(--primary-light);
  color: var(--primary);
}
.app-nav .meta {
  font-size: 11px;
  color: var(--gray-400);
  font-family: "Cascadia Code", "Consolas", monospace;
}

/* ===================== 主内容区 ===================== */
.app-main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px;
}

/* ===================== 卡片 ===================== */
.card {
  background: #fff;
  border-radius: 10px;
  border: 1px solid var(--gray-200);
  padding: 18px 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--gray-100);
}
.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-900);
}
.card-subtitle {
  font-size: 12px;
  color: var(--gray-400);
}

/* ===================== 按钮 ===================== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 500;
  border-radius: 6px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
  user-select: none;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-secondary {
  background: #fff;
  color: var(--gray-700);
  border-color: var(--gray-200);
}
.btn-secondary:hover:not(:disabled) { background: var(--gray-50); }
.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover:not(:disabled) { background: #dc2626; }
.btn-success {
  background: var(--success);
  color: #fff;
}
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-lg { padding: 10px 20px; font-size: 14px; }

/* ===================== 表格 ===================== */
.app-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
.app-table thead {
  background: var(--gray-50);
  border-bottom: 2px solid var(--gray-200);
}
.app-table th {
  text-align: left;
  padding: 8px 12px;
  font-weight: 600;
  color: var(--gray-700);
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.app-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--gray-100);
  color: var(--gray-700);
}
.app-table tbody tr:hover { background: var(--gray-50); }
.app-table tbody tr:last-child td { border-bottom: none; }
.app-table .text-right { text-align: right; }
.app-table .num { font-family: "Cascadia Code", "Consolas", monospace; font-size: 12px; }
.app-table .pos { color: var(--success); font-weight: 600; }
.app-table .neg { color: var(--danger); font-weight: 600; }

/* ===================== 表单 ===================== */
.form-row {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 10px;
}
.form-label {
  font-size: 12px;
  color: var(--gray-600);
  font-weight: 500;
  min-width: 110px;
}
.form-control, .form-input, .form-textarea, .form-select {
  flex: 1;
  padding: 6px 10px;
  font-size: 13px;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  background: #fff;
  outline: none;
  transition: border-color 0.15s;
}
.form-control:focus, .form-input:focus, .form-textarea:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(79,70,229,0.1);
}
.form-range {
  flex: 1;
  accent-color: var(--primary);
}

/* ===================== 状态徽章 ===================== */
.badge {
  display: inline-block;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.badge-success { background: #d1fae5; color: #065f46; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger  { background: #fee2e2; color: #991b1b; }
.badge-info    { background: #dbeafe; color: #1e40af; }
.badge-gray    { background: var(--gray-100); color: var(--gray-700); }

/* ===================== 三点跳动 loader ===================== */
.qa-loader {
  display: inline-flex;
  align-items: center;
  color: var(--gray-600);
  font-size: 13px;
  gap: 4px;
}
.qa-loader-dots {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-left: 4px;
}
.qa-loader-dots i {
  display: inline-block;
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--gray-600);
  animation: qa-bounce 1.4s ease-in-out infinite both;
}
.qa-loader-dots i:nth-child(1) { animation-delay: -0.32s; }
.qa-loader-dots i:nth-child(2) { animation-delay: -0.16s; }
@keyframes qa-bounce {
  0%, 80%, 100% { transform: scale(0); opacity: 0.4; }
  40%           { transform: scale(1); opacity: 1; }
}

/* ===================== Banner (Tab 顶部说明条) ===================== */
.banner {
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 12.5px;
  color: var(--gray-700);
  margin-bottom: 16px;
  border-left: 3px solid var(--primary);
  background: var(--primary-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.banner-red    { background: #fef2f2; border-left-color: var(--danger); color: #7f1d1d; }
.banner-orange { background: #fff7ed; border-left-color: var(--warning); color: #7c2d12; }
.banner-green  { background: #f0fdf4; border-left-color: var(--success); color: #14532d; }
.banner-blue   { background: #eff6ff; border-left-color: #3b82f6; color: #1e3a8a; }
.banner-text   { flex: 1; }

/* ===================== 帮助按钮 (?) ===================== */
.help-btn {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid currentColor;
  background: rgba(255,255,255,0.5);
  color: inherit;
  font-size: 12px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0.7;
  transition: all 0.15s;
}
.help-btn:hover {
  opacity: 1;
  background: rgba(255,255,255,0.9);
}

/* 浮动版 ? -- 没有 banner 时挂在右上角 */
.help-btn-floating {
  position: fixed;
  top: 68px;          /* nav 56px + 12px gap */
  right: 16px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--gray-300);
  background: rgba(255,255,255,0.95);
  color: var(--gray-500);
  font-size: 13px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0.7;
  transition: all 0.15s;
  z-index: 40;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.help-btn-floating:hover {
  opacity: 1;
  background: #fff;
  color: var(--gray-700);
}

/* ===================== Modal 弹窗 (使用说明) ===================== */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-card {
  background: #fff;
  border-radius: 12px;
  max-width: 640px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 10px 40px rgba(0,0,0,0.3);
  animation: modal-pop 0.2s ease-out;
}
@keyframes modal-pop {
  from { opacity: 0; transform: scale(0.95); }
  to   { opacity: 1; transform: scale(1); }
}
.modal-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--gray-900);
}
.modal-close {
  background: none;
  border: none;
  font-size: 22px;
  color: var(--gray-400);
  cursor: pointer;
  padding: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  line-height: 1;
}
.modal-close:hover { background: var(--gray-100); color: var(--gray-700); }
.modal-body {
  padding: 20px 22px;
  font-size: 13px;
  color: var(--gray-700);
  line-height: 1.7;
}
.modal-body h4 {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-900);
  margin: 14px 0 6px;
}
.modal-body h4:first-child { margin-top: 0; }
.modal-body ul, .modal-body ol {
  margin: 6px 0 10px;
  padding-left: 22px;
}
.modal-body li { margin-bottom: 3px; font-size: 12.5px; }
.modal-body code {
  background: var(--gray-100);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 11.5px;
}
/* 策略说明弹窗 — 场景 / 规则 / 示例 */
.strategy-help-modal .strategy-help-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--gray-900);
  margin: 0 0 18px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--gray-100);
  line-height: 1.35;
}
.strategy-help-modal .strategy-help-block {
  margin-bottom: 16px;
}
.strategy-help-modal .strategy-help-block:last-of-type {
  margin-bottom: 0;
}
.strategy-help-modal .strategy-help-label {
  font-size: 11px;
  font-weight: 600;
  color: #64748b;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}
.strategy-help-modal .strategy-help-text {
  font-size: 13px;
  color: #334155;
  line-height: 1.62;
  margin: 0;
}
.strategy-help-modal .strategy-help-foot {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--gray-100);
  font-size: 12px;
  color: var(--gray-500);
  line-height: 1.55;
}

.modal-body .example-block {
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  padding: 10px 12px;
  margin: 8px 0;
  font-size: 12px;
  color: var(--gray-700);
}

/* ===================== 网格布局 ===================== */
.grid-2 { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.flex-col { display: flex; flex-direction: column; gap: 14px; }

/* ===================== 折叠 details（全站默认：白底可读，勿用深色 summary 盖掉 Tailwind 文字色） ===================== */
details summary {
  background-color: transparent;
  color: var(--gray-800);
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 12px;
  cursor: pointer;
  list-style: none;
  display: block;
  margin-bottom: 4px;
  line-height: 1.45;
}
details summary:hover {
  background-color: var(--gray-100);
  color: var(--gray-900);
}
details summary::-webkit-details-marker { display: none; }
details > *:not(summary) {
  margin-left: 4px;
  padding-left: 10px;
  border-left: 2px solid var(--gray-200);
}
details pre {
  background: var(--gray-50) !important;
  padding: 8px 12px !important;
  border-radius: 4px;
  font-size: 11.5px;
  max-height: 280px;
  overflow-y: auto;
}
