/* Market Hub — Custom Styles */

/* ─── CSS Variables ─── */
:root {
  --accent: #818cf8;
  --accent-dim: rgba(99, 102, 241, 0.15);
  --accent-glow: rgba(99, 102, 241, 0.25);
  --card-bg: rgba(255, 255, 255, 0.05);
  --card-border: rgba(255, 255, 255, 0.09);
  --card-border-hover: rgba(129, 140, 248, 0.3);
}

/* ─── Body Background ─── */
body {
  background-color: #181832;
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(99, 102, 241, 0.22) 0%, transparent 60%),
    radial-gradient(ellipse 60% 40% at 80% 80%, rgba(139, 92, 246, 0.12) 0%, transparent 50%);
}

/* ─── Sidebar nav links ─── */
.nav-link {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.45rem 0.75rem;
  border-radius: 0.375rem;
  font-size: 0.8125rem;
  color: #9ca3af;
  transition: all 0.15s;
  text-decoration: none;
  border-left: 2px solid transparent;
}
.nav-link:hover {
  background: rgba(99, 102, 241, 0.08);
  color: #e5e7eb;
  border-left-color: rgba(99, 102, 241, 0.2);
}
.nav-link.active {
  background: linear-gradient(90deg, rgba(99, 102, 241, 0.2) 0%, rgba(99, 102, 241, 0.05) 100%);
  color: #a5b4fc;
  font-weight: 600;
  border-left: 2px solid #818cf8;
  box-shadow: inset 3px 0 12px rgba(99, 102, 241, 0.1);
}

/* ─── Nav group accordion ─── */
.nav-group-items {
  overflow: hidden;
  max-height: 500px;
  transition: max-height 0.25s ease-in-out, opacity 0.2s ease;
  opacity: 1;
}
.nav-group.collapsed .nav-group-items {
  max-height: 0;
  opacity: 0;
}
.nav-group.collapsed .nav-chevron {
  transform: rotate(-90deg);
}
.nav-group-toggle {
  border: none;
  background: none;
  cursor: pointer;
}

/* ─── Cards ─── */
.stat-card {
  background: var(--card-bg);
  backdrop-filter: blur(12px);
  border: 1px solid var(--card-border);
  border-radius: 1rem;
  padding: 1.25rem;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(129, 140, 248, 0.4), transparent);
  opacity: 0;
  transition: opacity 0.2s;
}
.stat-card:hover {
  border-color: var(--card-border-hover);
  box-shadow: 0 0 24px rgba(99, 102, 241, 0.08), 0 4px 20px rgba(0, 0, 0, 0.3);
  transform: translateY(-1px);
}
.stat-card:hover::before {
  opacity: 1;
}
.stat-card .label {
  color: #9ca3af;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.stat-card .value {
  font-size: 1.5rem;
  font-weight: 700;
  margin-top: 0.25rem;
}

/* ─── Chart containers ─── */
.chart-box {
  background: var(--card-bg);
  backdrop-filter: blur(12px);
  border: 1px solid var(--card-border);
  border-radius: 1rem;
  padding: 1.25rem;
  transition: border-color 0.2s;
}
.chart-box:hover {
  border-color: var(--card-border-hover);
}
.chart-box .chart-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: #d1d5db;
  margin-bottom: 1rem;
}

/* ─── Trade table ─── */
.trade-table { width: 100%; border-collapse: collapse; font-size: 0.8125rem; }
.trade-table th {
  padding: 0.625rem 0.75rem;
  text-align: left;
  color: #9ca3af;
  font-weight: 500;
  border-bottom: 1px solid rgba(107, 114, 128, 0.2);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.trade-table td {
  padding: 0.625rem 0.75rem;
  border-bottom: 1px solid rgba(107, 114, 128, 0.08);
}
.trade-table tr:hover td {
  background: rgba(99, 102, 241, 0.05);
}

/* ─── PnL colors ─── */
.pnl-positive { color: #22c55e; }
.pnl-negative { color: #ef4444; }
.pnl-zero { color: #9ca3af; }

/* ─── Badges ─── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.125rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.6875rem;
  font-weight: 600;
}
.badge-long   { background: rgba(34, 197, 94, 0.12);  color: #22c55e; }
.badge-short  { background: rgba(239, 68, 68, 0.12);  color: #ef4444; }
.badge-win    { background: rgba(34, 197, 94, 0.12);  color: #22c55e; }
.badge-loss   { background: rgba(239, 68, 68, 0.12);  color: #ef4444; }
.badge-be     { background: rgba(156, 163, 175, 0.12); color: #9ca3af; }
.badge-red    { background: rgba(239, 68, 68, 0.12);  color: #ef4444; }
.badge-green  { background: rgba(34, 197, 94, 0.12);  color: #22c55e; }
.badge-blue   { background: rgba(59, 130, 246, 0.12); color: #60a5fa; }
.badge-purple { background: rgba(168, 85, 247, 0.12); color: #c084fc; }
.badge-cyan   { background: rgba(6, 182, 212, 0.12);  color: #22d3ee; }
.badge-yellow { background: rgba(245, 158, 11, 0.12); color: #fbbf24; }
.badge-gray   { background: rgba(107, 114, 128, 0.12); color: #6b7280; }

/* ─── Buttons ─── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  border: none;
}
.btn-primary {
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  color: white;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35);
}
.btn-primary:hover {
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.45);
  transform: translateY(-1px);
}
.btn-primary:active {
  transform: translateY(0);
}
.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* ─── Date picker ─── */
.date-picker-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.date-picker-wrap input[type="date"] {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(107, 114, 128, 0.25);
  color: #e5e7eb;
  padding: 0.375rem 0.75rem;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  transition: border-color 0.15s;
}
.date-picker-wrap input[type="date"]:focus {
  border-color: rgba(99, 102, 241, 0.5);
  outline: none;
}
.date-picker-wrap button {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(107, 114, 128, 0.25);
  color: #e5e7eb;
  padding: 0.375rem 0.625rem;
  border-radius: 0.5rem;
  cursor: pointer;
  transition: all 0.15s;
}
.date-picker-wrap button:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(107, 114, 128, 0.4);
}

/* ─── Select dropdown ─── */
select.dark-select {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(107, 114, 128, 0.25);
  color: #e5e7eb;
  padding: 0.375rem 0.75rem;
  border-radius: 0.5rem;
  font-size: 0.875rem;
}

/* ─── Loading spinner ─── */
.spinner {
  display: inline-block;
  width: 1.25rem;
  height: 1.25rem;
  border: 2px solid rgba(99, 102, 241, 0.2);
  border-top-color: #818cf8;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Progress bar ─── */
.progress-bar {
  height: 0.5rem;
  border-radius: 9999px;
  background: rgba(107, 114, 128, 0.15);
  overflow: hidden;
}
.progress-bar .fill {
  height: 100%;
  border-radius: 9999px;
  transition: width 0.3s ease;
}

/* ─── Status indicators ─── */
.status-on { color: #22c55e; }
.status-off { color: #ef4444; }

/* ─── Calendar heatmap ─── */
.heatmap-cell {
  width: 14px;
  height: 14px;
  border-radius: 2px;
  cursor: pointer;
  transition: transform 0.1s;
}
.heatmap-cell:hover { transform: scale(1.3); }

/* ─── Scrollbar ─── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(107, 114, 128, 0.2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(107, 114, 128, 0.4); }

/* ─── Timeframe buttons ─── */
.tf-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.375rem 0.75rem;
  border-radius: 0.375rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: #9ca3af;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(107, 114, 128, 0.2);
  cursor: pointer;
  transition: all 0.15s;
  min-width: 2.5rem;
}
.tf-btn:hover {
  background: rgba(255, 255, 255, 0.07);
  color: #e5e7eb;
}
.tf-btn.active {
  background: rgba(99, 102, 241, 0.18);
  color: #a5b4fc;
  border-color: rgba(99, 102, 241, 0.4);
  font-weight: 600;
}

/* ─── Tab buttons ─── */
.tab-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.375rem 0.875rem;
  border-radius: 0.375rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: #9ca3af;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(107, 114, 128, 0.2);
  cursor: pointer;
  transition: all 0.15s;
}
.tab-btn:hover {
  background: rgba(255, 255, 255, 0.07);
  color: #e5e7eb;
}
.tab-btn.active {
  background: rgba(99, 102, 241, 0.18);
  color: #a5b4fc;
  border-color: rgba(99, 102, 241, 0.4);
  font-weight: 600;
}

/* ─── Mobile responsive sidebar ─── */
@media (max-width: 1023px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
  }
  .sidebar.open {
    transform: translateX(0);
  }
}

/* ─── Mobile bottom tab bar ─── */
.bottom-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.125rem;
  color: #6b7280;
  text-decoration: none;
  padding: 0.25rem 0.5rem;
  border-radius: 0.375rem;
  transition: color 0.15s;
  -webkit-tap-highlight-color: transparent;
  border: none;
  background: none;
  cursor: pointer;
}
.bottom-tab:hover,
.bottom-tab.active {
  color: #a5b4fc;
}
.bottom-tab.active svg {
  stroke: #a5b4fc;
}

/* ─── Plotly dark theme override ─── */
.js-plotly-plot .plotly .main-svg { background: transparent !important; }

/* ─── Glow utilities ─── */
.glow-text {
  text-shadow: 0 0 20px rgba(129, 140, 248, 0.5);
}
.glow-border {
  box-shadow: 0 0 0 1px rgba(99, 102, 241, 0.3), 0 0 20px rgba(99, 102, 241, 0.1);
}

/* ─── Glass card utility ─── */
.glass-card {
  background: rgba(255, 255, 255, 0.025);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 1rem;
  transition: all 0.2s ease;
}
.glass-card:hover {
  border-color: rgba(129, 140, 248, 0.2);
  box-shadow: 0 0 24px rgba(99, 102, 241, 0.06);
}

/* ─── Gradient text ─── */
.gradient-text {
  background: linear-gradient(135deg, #818cf8, #c084fc);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ─── Tailwind dark card override (global) ─── */
.rounded-xl.border.border-gray-700\/50 {
  border-color: rgba(255, 255, 255, 0.06) !important;
}

/* ═══════════════════════════════════════════════════════════════
   AI 리포트 렌더러 (formatAnalysis) 공통 스타일
   stock_analysis / market_analysis / coach / rockstar 등
   ═══════════════════════════════════════════════════════════════ */

/* 단락 */
.report-p {
  color: #d1d5db;
  font-size: 0.875rem;
  line-height: 1.75;
  margin-bottom: 0.5rem;
}

/* H1 — 대섹션 */
.report-h1 {
  font-size: 1.125rem;
  font-weight: 700;
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
  padding: 0.4rem 0.75rem;
  border-left: 3px solid currentColor;
  background: rgba(255,255,255,0.03);
  border-radius: 0 6px 6px 0;
}

/* H2 — 섹션 */
.report-h2 {
  font-size: 1rem;
  font-weight: 700;
  margin-top: 1.25rem;
  margin-bottom: 0.4rem;
  padding: 0.3rem 0.65rem;
  border-left: 3px solid currentColor;
  background: rgba(255,255,255,0.025);
  border-radius: 0 6px 6px 0;
}

/* H3 — 소섹션 */
.report-h3 {
  font-size: 0.875rem;
  font-weight: 600;
  color: #e5e7eb;
  margin-top: 1rem;
  margin-bottom: 0.25rem;
  padding-left: 0.5rem;
  border-left: 2px solid rgba(129,140,248,0.4);
}

/* bold 강조 — 흰색 볼드 */
mark.report-highlight {
  background: none;
  color: #f1f5f9;
  font-weight: 700;
}

/* 인라인 코드 */
.report-code {
  background: rgba(255,255,255,0.08);
  color: #6ee7b7;
  padding: 1px 5px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 0.82em;
}

/* +X% 숫자 배지 */
.report-num-pos {
  background: rgba(74,222,128,0.15);
  color: #4ade80;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.9em;
  white-space: nowrap;
}

/* -X% 숫자 배지 */
.report-num-neg {
  background: rgba(248,113,113,0.15);
  color: #f87171;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.9em;
  white-space: nowrap;
}

/* 리스트 항목 */
.report-li {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  color: #d1d5db;
  font-size: 0.875rem;
  line-height: 1.6;
  margin-bottom: 0.2rem;
  padding-left: 0.75rem;
}
.report-li::before {
  content: '▸';
  color: rgba(129,140,248,0.7);
  flex-shrink: 0;
  font-size: 0.7em;
  margin-top: 1px;
}
.report-li.report-li-num::before {
  content: none;
}
.report-li.report-li-num {
  list-style: decimal inside;
  padding-left: 0.5rem;
}

/* 구분선 */
.report-divider {
  border: none;
  border-top: 1px solid rgba(255,255,255,0.08);
  margin: 1rem 0;
}

/* 테이블 */
.report-table-wrap {
  overflow-x: auto;
  margin: 0.75rem 0;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.07);
}
.report-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}
.report-th {
  background: rgba(255,255,255,0.05);
  color: #e5e7eb;
  font-weight: 600;
  padding: 0.4rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  white-space: nowrap;
}
.report-td {
  color: #d1d5db;
  padding: 0.35rem 0.75rem;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  vertical-align: top;
}
.report-tr:last-child .report-td {
  border-bottom: none;
}
.report-tr:hover .report-td {
  background: rgba(255,255,255,0.02);
}
