/* QueryQuant — Scanner SPA Styles */

/* ── Variables ────────────────────────────────────────────────────────────── */
:root {
  --bg: #0b0d14;
  --bg-card: #13161f;
  --bg-elevated: #1a1e2a;
  --border: #1e2336;
  --text-primary: #e8eaf0;
  --text-secondary: #6b7194;
  --text-muted: #3d4263;
  --accent: #6366f1;
  --accent-hover: #7c7ff7;
  --accent-glow: rgba(99,102,241,0.15);
  --green: #22c55e;
  --red: #ef4444;
  --amber: #f59e0b;
  --radius: 12px;
  --radius-sm: 8px;
}

/* ── Reset / Base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; }

body.scanner-body {
  background: var(--bg);
  color: var(--text-primary);
  font-family: 'DM Sans', system-ui, sans-serif;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { cursor: pointer; border: none; background: none; font: inherit; }

/* ── Header ──────────────────────────────────────────────────────────────── */
.scanner-header {
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(11,13,20,0.85);
  backdrop-filter: blur(12px);
}
.header-inner {
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
}
.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text-primary);
}
.logo:hover { opacity: 0.8; }
.header-actions { display: flex; gap: 8px; }
.btn-ghost {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.15s;
}
.btn-ghost:hover { color: var(--text-primary); background: var(--bg-elevated); }

/* ── Search Hero ─────────────────────────────────────────────────────────── */
.search-hero {
  padding: 48px 24px 32px;
  text-align: center;
}
.search-container { max-width: 720px; margin: 0 auto; }
.search-tagline {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-bottom: 20px;
  font-weight: 500;
}
.search-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 8px 8px 8px 16px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.search-bar:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-glow);
}
.search-icon { color: var(--text-muted); flex-shrink: 0; }
#queryInput {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 1rem;
  font-family: 'DM Sans', sans-serif;
}
#queryInput::placeholder { color: var(--text-muted); }
.scan-btn {
  background: var(--accent);
  color: white;
  padding: 10px 22px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.9rem;
  transition: background 0.15s, transform 0.1s;
  flex-shrink: 0;
}
.scan-btn:hover { background: var(--accent-hover); }
.scan-btn:active { transform: scale(0.97); }

/* ── Quick Tags ──────────────────────────────────────────────────────────── */
.quick-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 16px;
}
.tag {
  padding: 6px 14px;
  border-radius: 100px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 0.8rem;
  transition: all 0.15s;
}
.tag:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-glow); }

/* ── Results Area ────────────────────────────────────────────────────────── */
.results-area { max-width: 1280px; margin: 0 auto; padding: 0 24px 48px; }

/* Empty / Loading / Error states */
.empty-state, .loading-state, .error-state { text-align: center; padding: 64px 24px; }
.empty-icon { margin-bottom: 20px; opacity: 0.4; }
.empty-title { font-size: 1.1rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 8px; }
.empty-sub { font-size: 0.875rem; color: var(--text-muted); }
.loading-state { display: flex; flex-direction: column; align-items: center; gap: 16px; color: var(--text-secondary); }
.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.error-state { padding: 48px; }
.error-title { font-size: 1.1rem; font-weight: 600; margin-bottom: 8px; }
.error-msg { color: var(--text-secondary); margin-bottom: 20px; }

/* Results container */
.results-container { }
.results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 12px;
}
.results-meta {
  font-size: 0.875rem;
  color: var(--text-secondary);
}
.results-meta strong { color: var(--text-primary); }
.results-actions { display: flex; gap: 8px; }
.btn-outline {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 500;
  transition: all 0.15s;
}
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }
.btn-sm { padding: 6px 12px; font-size: 0.75rem; }
.btn-primary {
  padding: 10px 20px;
  background: var(--accent);
  color: white;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.875rem;
  transition: background 0.15s;
}
.btn-primary:hover { background: var(--accent-hover); }

/* Explanation box */
.explanation-box {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 20px;
  line-height: 1.5;
}

/* Results Grid */
.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

/* Stock Card */
.stock-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.15s;
  position: relative;
}
.stock-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.stock-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}
.stock-symbol {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text-primary);
}
.stock-name { font-size: 0.75rem; color: var(--text-muted); margin-top: 2px; }
.stock-price-block { text-align: right; }
.stock-price { font-family: 'Space Grotesk', sans-serif; font-size: 1.25rem; font-weight: 700; }
.stock-change { font-size: 0.8rem; font-weight: 500; margin-top: 2px; }
.stock-change.up { color: var(--green); }
.stock-change.down { color: var(--red); }

.stock-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 12px;
}
.metric {
  background: var(--bg-elevated);
  border-radius: 8px;
  padding: 8px;
  text-align: center;
}
.metric-label { font-size: 0.65rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.08em; display: block; margin-bottom: 4px; }
.metric-value { font-size: 0.875rem; font-weight: 600; color: var(--text-primary); }
.metric-value.high { color: var(--green); }
.metric-value.low { color: var(--red); }

.stock-badge {
  position: absolute;
  top: 12px;
  right: 12px;
  font-size: 0.65rem;
  padding: 3px 8px;
  border-radius: 100px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.badge-breakout { background: rgba(34,197,94,0.15); color: var(--green); }
.badge-volume { background: rgba(99,102,241,0.15); color: var(--accent); }
.badge-rsi-low { background: rgba(245,158,11,0.15); color: var(--amber); }

/* Chart placeholder in card */
.stock-chart-placeholder {
  height: 48px;
  margin: 12px 0;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--bg-elevated), transparent);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.mini-chart-svg { width: 100%; height: 48px; }

/* Why box */
.stock-why {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* ── Stock Detail Slide-out ──────────────────────────────────────────────── */
.stock-detail {
  position: fixed;
  top: 0;
  right: 0;
  width: 480px;
  max-width: 95vw;
  height: 100vh;
  background: var(--bg-card);
  border-left: 1px solid var(--border);
  z-index: 200;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s ease;
  transform: translateX(100%);
}
.stock-detail.visible { transform: translateX(0); }
.detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}
.detail-symbol-info h2 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.3rem;
  font-weight: 700;
}
.detail-name { font-size: 0.8rem; color: var(--text-muted); }
.btn-icon { font-size: 1.2rem; color: var(--text-secondary); transition: color 0.15s; }
.btn-icon:hover { color: var(--text-primary); }
.detail-body { flex: 1; overflow-y: auto; padding: 24px; }
.detail-chart {
  height: 200px;
  background: var(--bg-elevated);
  border-radius: var(--radius);
  margin-bottom: 20px;
  overflow: hidden;
}
.detail-metrics {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}
.detail-metric {
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  padding: 14px;
}
.detail-metric .metric-label { font-size: 0.7rem; }
.detail-metric .metric-value { font-size: 1.1rem; }
.detail-why {
  background: var(--bg-elevated);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 14px;
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* ── Sidebar ────────────────────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0;
  right: 0;
  width: 380px;
  max-width: 90vw;
  height: 100vh;
  background: var(--bg-card);
  border-left: 1px solid var(--border);
  z-index: 200;
  display: flex;
  flex-direction: column;
  transition: transform 0.25s ease;
  transform: translateX(100%);
}
.sidebar.visible { transform: translateX(0); }
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}
.sidebar-header h3 { font-family: 'Space Grotesk', sans-serif; font-size: 1rem; font-weight: 700; }
.sidebar-body { flex: 1; overflow-y: auto; padding: 16px; }

.strategy-item, .watchlist-item {
  padding: 14px;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
  cursor: pointer;
  transition: border-color 0.15s;
  border: 1px solid transparent;
}
.strategy-item:hover, .watchlist-item:hover { border-color: var(--accent); }
.strategy-item-title { font-weight: 600; font-size: 0.875rem; margin-bottom: 4px; }
.strategy-item-query { font-size: 0.75rem; color: var(--text-muted); margin-bottom: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.strategy-item-actions { display: flex; gap: 6px; }
.action-btn {
  font-size: 0.7rem;
  padding: 4px 10px;
  border-radius: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  transition: all 0.15s;
}
.action-btn:hover { border-color: var(--accent); color: var(--accent); }
.action-btn.delete:hover { border-color: var(--red); color: var(--red); }

/* ── Overlay ────────────────────────────────────────────────────────────── */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 100;
  backdrop-filter: blur(4px);
}

/* ── Utilities ─────────────────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .search-hero { padding: 32px 16px 24px; }
  .results-grid { grid-template-columns: 1fr; }
  .stock-metrics { grid-template-columns: repeat(3, 1fr); }
  .header-actions .btn-ghost { display: none; }
  .stock-detail { width: 100%; }
}