/* AutoTrader Dark Terminal Theme */

/* OHLCV info bar classes used by charts.js */
.ohlcv-label { color: #6b7280; font-size: 11px; margin-right: 2px; }
.ohlcv-val   { font-family: 'Inter', 'Segoe UI', monospace; font-size: 12px; font-weight: 600; color: #e5e7eb; margin-right: 4px; }
.ohlcv-chg.up   { color: #26a269; }
.ohlcv-chg.down { color: #e5534b; }

:root {
  --at-bg: #0d0d0f;
  --at-surface: #141418;
  --at-card: #1a1a20;
  --at-border: #2a2a35;
  --at-text: #e0e0e8;
  --at-muted: #6b7280;
  --at-accent: #f59e0b;
  --at-green: #10b981;
  --at-red: #ef4444;
  --at-blue: #3b82f6;
}

body.at-dark {
  background: var(--at-bg);
  color: var(--at-text);
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
  font-size: 14px;
}

/* Navbar */
.at-navbar {
  background: var(--at-surface) !important;
  border-bottom: 1px solid var(--at-border);
  height: 56px;
}
.at-navbar .nav-link {
  color: var(--at-muted) !important;
  font-size: 13px;
  padding: 0.4rem 0.75rem !important;
  border-radius: 6px;
  transition: all 0.15s;
}
.at-navbar .nav-link:hover { color: var(--at-text) !important; background: rgba(255,255,255,0.05); }
.at-navbar .nav-link.active { color: var(--at-accent) !important; }

/* Main container */
.at-main { padding: 0 1rem 2rem; min-height: calc(100vh - 56px); }

/* Cards */
.at-card {
  background: var(--at-card) !important;
  border: 1px solid var(--at-border) !important;
  border-radius: 8px;
}
.at-card .card-header {
  background: rgba(255,255,255,0.03) !important;
  border-bottom: 1px solid var(--at-border) !important;
  padding: 0.6rem 1rem;
  font-size: 13px;
  font-weight: 500;
}

/* Tables */
.at-table { font-size: 13px; }
.at-table thead th {
  background: var(--at-surface) !important;
  color: var(--at-muted);
  border-color: var(--at-border) !important;
  font-weight: 500;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.5px;
  padding: 0.6rem 1rem;
}
.at-table tbody tr {
  border-color: var(--at-border) !important;
}
.at-table tbody tr:hover { background: rgba(255,255,255,0.03) !important; }
.at-table td { padding: 0.6rem 1rem; border-color: var(--at-border) !important; }

/* Form inputs */
.at-card form,
.modal form,
.modal-body {
  --at-control-height: 38px;
}

.form-label {
  display: block;
  width: 100%;
  margin-bottom: 0.35rem;
  color: var(--at-muted);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.2;
}

.mb-2 > .form-label,
.mb-3 > .form-label,
.col-md-4 > .form-label,
.col-md-6 > .form-label,
.col-12 > .form-label,
.flex-fill > .form-label {
  margin-top: 0;
}

.at-card input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
.at-card select,
.at-card textarea,
.modal input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
.modal select,
.modal textarea {
  display: block;
  width: 100%;
  max-width: 100%;
}

.at-input,
.at-card input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
.at-card select,
.at-card textarea,
.modal input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
.modal select,
.modal textarea {
  background: var(--at-surface) !important;
  border: 1px solid var(--at-border) !important;
  color: var(--at-text) !important;
  border-radius: 6px;
  min-height: var(--at-control-height, 38px);
  line-height: 1.4;
}
.at-input[type="file"],
.at-card input[type="file"] {
  padding-top: 0.45rem;
}
.at-input::placeholder,
.at-card input::placeholder,
.at-card textarea::placeholder,
.modal input::placeholder,
.modal textarea::placeholder {
  color: var(--at-muted);
  opacity: 0.85;
}
.at-input:focus,
.at-card input:not([type="hidden"]):focus,
.at-card select:focus,
.at-card textarea:focus,
.modal input:not([type="hidden"]):focus,
.modal select:focus,
.modal textarea:focus {
  border-color: var(--at-accent) !important;
  box-shadow: 0 0 0 2px rgba(245,158,11,0.2) !important;
  background: var(--at-surface) !important;
}
.at-input option,
.at-card select option,
.modal select option { background: var(--at-surface); }
.form-check {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 28px;
  padding-left: 0;
}
.form-check .form-check-input {
  flex: 0 0 auto;
  float: none;
  margin: 0;
}
.form-check .form-check-label {
  line-height: 1.25;
}
.d-flex > .flex-fill {
  min-width: 0;
}

/* Broker workspace */
.at-result-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  min-height: 32px;
}
.at-result-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  max-width: 100%;
}
.at-result-pill small {
  color: var(--at-muted);
}
.at-quote-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(110px, 1fr));
  gap: 0.6rem;
}
.at-quote-metric {
  border: 1px solid var(--at-border);
  background: rgba(255,255,255,0.025);
  border-radius: 6px;
  padding: 0.65rem 0.75rem;
}
.at-quote-metric span {
  display: block;
  color: var(--at-muted);
  font-size: 11px;
  text-transform: uppercase;
}
.at-quote-metric strong {
  display: block;
  margin-top: 0.2rem;
  color: var(--at-text);
  font-size: 14px;
}

/* Screener workspace */
.screener-shell {
  display: block;
}
.screener-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.9rem;
}
.screener-stats {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.5rem;
}
.screener-stats span,
.screener-badge,
.quick-scan {
  border: 1px solid var(--at-border);
  background: rgba(255,255,255,0.035);
  border-radius: 6px;
  color: var(--at-muted);
  font-size: 12px;
  line-height: 1.2;
}
.screener-stats span {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 32px;
  padding: 0.35rem 0.55rem;
}
.screener-stats strong {
  color: var(--at-text);
}
.screener-panel {
  overflow: hidden;
}
.quick-scans {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}
.quick-scan {
  min-height: 32px;
  padding: 0.4rem 0.6rem;
}
.quick-scan:hover,
.quick-scan.active {
  border-color: rgba(245,158,11,0.65);
  color: var(--at-accent);
  background: rgba(245,158,11,0.08);
}
.screener-section-title {
  color: var(--at-muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
  margin-bottom: 0.45rem;
  text-transform: uppercase;
}
.screener-list {
  max-height: 438px;
  overflow: auto;
}
.screener-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 0.9rem;
  border-bottom: 1px solid var(--at-border);
}
.screener-row:last-child {
  border-bottom: 0;
}
.screener-row:hover {
  background: rgba(255,255,255,0.025);
}
.screener-row-main,
.screener-row-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
}
.screener-row-actions {
  flex: 0 0 auto;
}
.screener-badge {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  padding: 0.28rem 0.45rem;
  white-space: nowrap;
}
.screener-search {
  width: min(220px, 42vw) !important;
}
.screener-jumpbar {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
  margin: 0.7rem 0 1rem;
}
.screener-jumpbar a {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  border: 1px solid var(--at-border);
  border-radius: 6px;
  background: rgba(255,255,255,0.035);
  color: var(--at-muted);
  padding: 0.35rem 0.65rem;
  font-size: 12px;
  text-decoration: none;
}
.screener-jumpbar a:hover {
  border-color: var(--at-accent);
  color: var(--at-text);
}
.screener-grid-card {
  overflow: hidden;
}
.screener-grid-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}
.screener-tabs {
  display: flex;
  gap: 0.2rem;
  overflow-x: auto;
  padding: 0.45rem 0.65rem 0;
  border-bottom: 1px solid var(--at-border);
  background: rgba(255,255,255,0.015);
}
.screener-tab {
  flex: 0 0 auto;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--at-muted);
  padding: 0.55rem 0.7rem;
  font-size: 13px;
  white-space: nowrap;
  appearance: none;
}
.screener-tab:hover,
.screener-tab.active {
  color: var(--at-text);
  border-bottom-color: var(--at-accent);
}
.screener-data-scroll {
  max-height: 64vh;
}
.screener-results-table th,
.screener-results-table td {
  white-space: nowrap;
}
.table-sort {
  display: inline-flex;
  align-items: center;
  border: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-transform: inherit;
  appearance: none;
}
.table-sort::after {
  content: "\F282";
  font-family: "bootstrap-icons";
  margin-left: 0.3rem;
  color: var(--at-muted);
  font-size: 10px;
}
.table-sort:hover {
  color: var(--at-accent);
}
#runProgress {
  min-width: 120px;
  text-align: right;
}
.filter-drawer {
  position: fixed;
  inset: 0;
  z-index: 1050;
  display: none;
  background: rgba(0,0,0,0.35);
}
.filter-drawer.open {
  display: block;
}
.filter-drawer-panel {
  width: min(360px, 92vw);
  height: 100%;
  margin-left: auto;
  background: var(--at-card);
  border-left: 1px solid var(--at-border);
  padding: 0.9rem;
  overflow-y: auto;
}
.filter-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}
.filter-group {
  border-top: 1px solid var(--at-border);
  padding: 0.75rem 0;
}
.filter-group strong {
  display: block;
  margin-bottom: 0.45rem;
  color: var(--at-text);
  font-size: 12px;
  text-transform: capitalize;
}
.filter-chip {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  margin: 0.15rem;
  border: 1px solid var(--at-border);
  border-radius: 6px;
  background: rgba(255,255,255,0.03);
  color: var(--at-muted);
  font-size: 12px;
  padding: 0.25rem 0.45rem;
}
.filter-chip:hover {
  color: var(--at-accent);
  border-color: rgba(245,158,11,0.65);
}
.active-filter {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  border: 1px solid var(--at-border);
  border-radius: 6px;
  padding: 0.4rem 0.45rem;
  margin-bottom: 0.35rem;
  font-size: 12px;
}
.sync-status-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr));
  gap: 0.6rem;
}
.sync-metric {
  border: 1px solid var(--at-border);
  border-radius: 6px;
  background: rgba(255,255,255,0.025);
  padding: 0.65rem 0.75rem;
}
.sync-metric span,
.sync-metric small,
.sync-job small {
  display: block;
  color: var(--at-muted);
  font-size: 11px;
}
.sync-metric strong {
  display: block;
  margin-top: 0.2rem;
  color: var(--at-text);
  font-size: 15px;
}
.sync-job-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.45rem 0.75rem;
}
.sync-job {
  display: flex;
  align-items: flex-start;
  gap: 0.45rem;
  min-width: 0;
}
.sync-job strong {
  display: block;
  color: var(--at-text);
  font-size: 12px;
}
.sync-dot {
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 0.35rem;
  background: var(--at-muted);
}
.sync-dot-success { background: var(--at-green); }
.sync-dot-running { background: var(--at-accent); }
.sync-dot-failed { background: var(--at-red); }
.sync-dot-pending { background: var(--at-blue); }

/* List group */
.at-list-item {
  background: transparent !important;
  border-color: var(--at-border) !important;
  color: var(--at-text);
}
.at-list-item:hover { background: rgba(255,255,255,0.03) !important; }

/* Dropdown */
.at-dropdown {
  background: var(--at-card) !important;
  border: 1px solid var(--at-border) !important;
}
.at-dropdown .dropdown-item { color: var(--at-text); font-size: 13px; }
.at-dropdown .dropdown-item:hover { background: rgba(255,255,255,0.07); }
.at-dropdown .dropdown-divider { border-color: var(--at-border); }

/* Buttons */
.btn-warning { color: #000 !important; font-weight: 600; }
.btn-outline-warning:hover { color: #000 !important; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--at-surface); }
::-webkit-scrollbar-thumb { background: var(--at-border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--at-muted); }

/* Toast */
#at-toast {
  position: fixed; bottom: 1.5rem; right: 1.5rem;
  background: var(--at-card);
  border: 1px solid var(--at-border);
  color: var(--at-text);
  padding: 0.75rem 1.25rem;
  border-radius: 8px;
  font-size: 13px;
  z-index: 9999;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}
#at-toast.show { opacity: 1; }

/* Responsive tweaks */
@media (max-width: 768px) {
  .screener-toolbar,
  .screener-row {
    align-items: stretch;
    flex-direction: column;
  }
  .screener-stats {
    justify-content: flex-start;
  }
  .screener-row-actions {
    justify-content: flex-end;
  }
  .screener-search {
    width: 150px !important;
  }
  .sync-status-grid,
  .sync-job-list {
    grid-template-columns: 1fr;
  }
  .at-main { padding: 0 0.5rem 1rem; }
  .at-quote-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
