/*
 * AI Trade Bot — Design System
 *
 * Single source of truth for all visual tokens and component styles.
 * Templates use these CSS classes for appearance; Tailwind handles layout
 * (flex, grid, padding, margin, responsive breakpoints).
 *
 * When migrating to React/Vue/etc, copy this file and replace Tailwind
 * layout utilities with CSS modules or your framework's layout system.
 */

/* ==========================================================================
   1. Design Tokens (CSS Custom Properties)
   ========================================================================== */

:root {
  /* Surfaces */
  --bg-body:   #09090b;   /* zinc-950  — page background */
  --bg-card:   #18181b;   /* zinc-900  — cards, sidebar, header */
  --bg-inset:  #09090b;   /* zinc-950  — inputs, nested elements */
  --bg-hover:  #27272a;   /* zinc-800  — hover states, active nav */

  /* Borders */
  --border:     #27272a;                /* zinc-800  — card/table borders */
  --border-row: rgba(39, 39, 42, 0.5); /* zinc-800/50 — table row dividers */

  /* Text */
  --text-primary:   #fafafa;  /* zinc-50  — headings, strong values */
  --text-secondary: #a1a1aa;  /* zinc-400 — body text, descriptions */
  --text-muted:     #71717a;  /* zinc-500 — labels, timestamps */
  --text-faint:     #52525b;  /* zinc-600 — disabled, meta info */

  /* Semantic colors */
  --color-profit:  #10b981;  /* emerald-500 */
  --color-loss:    #ef4444;  /* red-500 */
  --color-warning: #f59e0b;  /* amber-500 */
  --color-info:    #60a5fa;  /* blue-400 */
  --color-violet:  #a78bfa;  /* violet-400 */
  --color-cyan:    #06b6d4;  /* cyan-500 */

  /* Chart.js tokens (read via getComputedStyle in JS) */
  --chart-grid:      #18181b;
  --chart-line:      #a1a1aa;
  --chart-line-fill: rgba(161, 161, 170, 0.05);
  --chart-palette-1: #a1a1aa;
  --chart-palette-2: #10b981;
  --chart-palette-3: #f59e0b;
  --chart-palette-4: #ef4444;
  --chart-palette-5: #8b5cf6;
  --chart-palette-6: #06b6d4;
}


/* ==========================================================================
   2. Semantic Text Colors
   ========================================================================== */

.text-profit  { color: var(--color-profit); }
.text-loss    { color: var(--color-loss); }
.text-warning { color: var(--color-warning); }
.text-info    { color: var(--color-info); }


/* ==========================================================================
   3. Card Component
   ========================================================================== */

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 1rem;
}

.card-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.card-value {
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.025em;
  color: var(--text-primary);
}

.card-value-lg {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.025em;
  color: var(--text-primary);
}

.card-title {
  font-size: 0.875rem;
  font-weight: 500;
  color: #d4d4d8;
  margin-bottom: 0.75rem;
}


/* ==========================================================================
   4. Badge Component
   ========================================================================== */

.badge {
  font-size: 11px;
  font-weight: 500;
  padding: 0.125rem 0.375rem;
  border-radius: 0.375rem;
  display: inline-block;
}

.badge-profit  { background: rgba(16, 185, 129, 0.1); color: var(--color-profit); }
.badge-loss    { background: rgba(239, 68, 68, 0.1);   color: var(--color-loss); }
.badge-warning { background: rgba(245, 158, 11, 0.1);  color: var(--color-warning); }
.badge-info    { background: rgba(59, 130, 246, 0.1);   color: var(--color-info); }
.badge-neutral { background: var(--bg-hover);            color: var(--text-secondary); }
.badge-violet  { background: rgba(139, 92, 246, 0.1);   color: var(--color-violet); }


/* ==========================================================================
   5. Table Component
   ========================================================================== */

.table-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  overflow: hidden;
}

.table-header {
  padding: 0.625rem 1rem;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
}

.table-header-right {
  padding: 0.625rem 1rem;
  text-align: right;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
}

.table-row:hover {
  background: rgba(39, 39, 42, 0.3);
}

.table-cell {
  padding: 0.625rem 1rem;
}

.table-cell-right {
  padding: 0.625rem 1rem;
  text-align: right;
}

.table-head-border {
  border-bottom: 1px solid var(--border);
}

.table-divider > * + * {
  border-top: 1px solid var(--border-row);
}


/* ==========================================================================
   6. Form Components
   ========================================================================== */

.filter-bar {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 1rem;
  margin-bottom: 1.5rem;
}

.form-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 0.375rem;
}

.form-input,
.form-select {
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  padding: 0.375rem 0.75rem;
  font-size: 0.875rem;
  color: var(--text-primary);
}

.form-input:focus,
.form-select:focus {
  outline: none;
  box-shadow: 0 0 0 1px var(--text-faint);
}


/* ==========================================================================
   7. Button Components
   ========================================================================== */

.btn-primary {
  background: var(--text-primary);
  color: var(--bg-body);
  padding: 0.375rem 1rem;
  border-radius: 0.375rem;
  font-size: 0.875rem;
  font-weight: 500;
  transition: background 150ms;
  cursor: pointer;
  border: none;
}

.btn-primary:hover {
  background: #e4e4e7;
}

.btn-secondary {
  background: var(--bg-hover);
  color: #d4d4d8;
  padding: 0.25rem 0.75rem;
  border-radius: 0.375rem;
  font-size: 0.875rem;
  transition: background 150ms;
  text-decoration: none;
}

.btn-secondary:hover {
  background: #3f3f46;
}


/* ==========================================================================
   8. Pagination
   ========================================================================== */

.pagination {
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border);
}


/* ==========================================================================
   9. Status Indicators
   ========================================================================== */

.status-dot {
  width: 0.375rem;
  height: 0.375rem;
  border-radius: 9999px;
  display: inline-block;
}

.status-dot-running { background: var(--color-profit); }
.status-dot-paused  { background: var(--color-loss); animation: pulse 2s infinite; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}


/* ==========================================================================
   10. Sidebar & Navigation
   ========================================================================== */

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  border-radius: 0.375rem;
  font-size: 0.875rem;
  color: var(--text-secondary);
  text-decoration: none;
  transition: background 150ms, color 150ms;
}

.nav-link:hover {
  background: rgba(39, 39, 42, 0.5);
  color: #e4e4e7;
}

.nav-link-active {
  background: var(--bg-hover);
  color: var(--text-primary);
  font-weight: 500;
}


/* ==========================================================================
   11. Scrollbar
   ========================================================================== */

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #3f3f46; }


/* ==========================================================================
   12. Utility helpers
   ========================================================================== */

.text-primary   { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-muted     { color: var(--text-muted); }
.text-faint     { color: var(--text-faint); }

.empty-state {
  padding: 3rem 1rem;
  text-align: center;
  color: var(--text-muted);
}

/* Clear/reset filter link */
.link-muted {
  color: var(--text-muted);
  text-decoration: none;
  transition: color 150ms;
}

.link-muted:hover {
  color: var(--text-secondary);
}

/* Sortable table header */
.table-header-sort {
  cursor: pointer;
  transition: color 150ms;
}

.table-header-sort:hover {
  color: var(--text-secondary);
}

/* Iron condor indicator (left border accent) */
.ic-border {
  border-left: 2px solid var(--color-violet);
}

.ic-label {
  font-size: 11px;
  color: var(--color-violet);
}

/* Expandable detail panel (decisions page) */
.detail-panel {
  background: var(--bg-body);
}

.detail-card {
  border-radius: 0.375rem;
  border: 1px solid var(--border);
  background: var(--bg-card);
  padding: 0.75rem;
}

.detail-item {
  border-radius: 0.375rem;
  background: var(--bg-hover);
  padding: 0.625rem;
}

/* Section header inside table-wrap */
.table-section-header {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
}

/* Time range selector (performance page) */
.time-range-active {
  background: var(--text-primary);
  color: var(--bg-body);
}

.time-range-inactive {
  background: var(--bg-hover);
  color: var(--text-secondary);
  transition: background 150ms, color 150ms;
}

.time-range-inactive:hover {
  background: #3f3f46;
  color: var(--text-primary);
}

/* IV Heatmap */
.heatmap-header {
  color: var(--text-muted);
}

.heatmap-date {
  color: var(--text-faint);
}

.heatmap-symbol {
  color: var(--text-secondary);
  background: var(--bg-card);
  border-right: 1px solid var(--border);
}

.heatmap-cell {
  border: 1px solid var(--bg-card);
}

.heatmap-legend {
  color: var(--text-muted);
}

/* IV Rank color scale — defined here so templates don't need hardcoded Tailwind colors */
.iv-low       { background: rgba(30, 58, 138, 0.6); color: var(--color-info); }
.iv-mid       { background: var(--bg-hover);         color: var(--text-secondary); }
.iv-high      { background: rgba(154, 52, 18, 0.7);  color: var(--color-warning); }
.iv-very-high { background: rgba(127, 29, 29, 0.8);  color: var(--color-loss); }
