/* ===== Base ===== */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: Arial, sans-serif;
  background: #f4f4f4;
  color: #111827;
}
a, a:visited, a:active { color: inherit; text-decoration: none; }

/* ===== Header ===== */
header { background: #000; color: #fff; padding: 1rem; }
.header-top { display: flex; align-items: center; gap: 10px; }
.header-top img { height: 150px; }
.header-top h2 { font-size: 2.5rem; margin: 0; color: #fff; }

.header-bottom { margin-top: 1rem; display: flex; flex-wrap: wrap; gap: 10px; }
.header-bottom select,
.header-bottom button {
  background: #007bff; color: #fff; border: none;
  padding: 6px 12px; border-radius: 4px; font-size: 14px; cursor: pointer;
}

/* ===== Main ===== */
main {
  max-width: 1200px;
  margin: 30px auto;
  padding: 30px;
  background: #fff;
  box-shadow: 0 0 10px rgba(0,0,0,0.1);
  font-size: 16px;
}
main h3 { font-size: 2rem; margin-top: 10px; }
main p, main ul, main label { font-size: 1.1rem; line-height: 1.6; }
section { margin-bottom: 60px; }

/* Page limit dropdown */
#pageLimitDropdown { margin-top: 10px; font-size: 1rem; padding: 6px 12px; }

/* ===== Search Bar ===== */
#searchHost { margin-top: 10px; display: flex; flex-direction: column; max-width: 320px; }
#searchHost .search-input {
  background: #fff; color: #000; border: 1px solid #007bff;
  padding: 6px 12px; border-radius: 4px; font-size: 14px; width: 100%;
}
#searchHost .search-input:focus {
  outline: none; border-color: #0056b3; box-shadow: 0 0 4px rgba(0,123,255,0.6);
}
#searchHost .search-results-host { position: relative; }
.search-results {
  position: absolute; top: 100%; left: 0; right: 0;
  background: #fff; border: 1px solid #ccc; border-radius: 4px;
  max-height: 260px; overflow-y: auto; z-index: 2000;
  box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}
.search-row { display: flex; justify-content: space-between; padding: 6px 10px; font-size: 14px; cursor: pointer; }
.search-row:nth-child(even) { background: #f9f9f9; }
.search-row:hover, .search-row.active { background: #007bff; color: #fff; }
.sr-left { display: flex; flex-direction: column; }
.sr-sym { font-weight: bold; }
.sr-name { opacity: 0.85; }
.sr-right { display: flex; align-items: center; gap: 6px; }
.sr-price { font-weight: 600; }
.sr-chart, .sr-fav {
  background: #007bff; color: #fff; border: none; padding: 3px 6px; border-radius: 3px; font-size: 12px; cursor: pointer;
}
.sr-chart:hover, .sr-fav:hover { background: #0056b3; }
.search-loading { padding: 8px; font-style: italic; color: #666; }

/* ===== Movers host (optional visual) ===== */
#top-movers-block { display: block; }
#moversInner {}

/* ===== Footer status (inline) ===== */
#backend-status { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; margin-right: 10px; }
#backend-status .dot { width: 10px; height: 10px; border-radius: 999px; display: inline-block; background: #9ca3af; }
#backend-status .dot.ok { background: #22c55e; }
#backend-status .dot.stale { background: #eab308; }
#backend-status .dot.down { background: #ef4444; }

/* Floating badge */
.status-badge {
  position: fixed; right: 14px; bottom: 14px; display: inline-flex; gap: 8px; align-items: center;
  padding: 8px 12px; border-radius: 999px; background: rgba(0,0,0,.06); backdrop-filter: blur(4px);
  font-size: 12px; line-height: 1; user-select: none; box-shadow: 0 4px 18px rgba(0,0,0,.08); z-index: 9999;
}
.status-dot { width: 10px; height: 10px; border-radius: 999px; display: inline-block; }
.status-online { background: #16a34a; }
.status-offline { background: #dc2626; }
.status-checking { background: #9ca3af; }
.status-text { font-weight: 600; }
.status-time { opacity: .7; margin-left: 2px; }
@media (max-width: 640px) { .status-time { display: none; } }

/* ===== Chart placeholder ===== */
#chart-area { position: relative; min-height: 320px; }
#chart-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  border: 1px dashed #bbb;
  border-radius: 10px;
  padding: 28px;
  height: 320px;               /* similar to canvas height */
  background: #fafafa;
  color: #666;
  font-size: 14px;
}
#chart-placeholder img { max-width: 100%; height: auto; object-fit: contain; }

/* ===== Signal box (hidden until content) ===== */
#signal-result { display: none; }
#signal-result.has-content { display: block; }

/* ===== Modal Styles (scrollable content) ===== */
#modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  display: none;
  z-index: 10000;
}

#modal-box {
  position: fixed;
  left: 50%;
  top: 5%;
  transform: translateX(-50%);
  width: min(680px, 92%);
  max-height: 90vh;        /* limit height to viewport */
  overflow-y: auto;        /* enable vertical scroll */
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
  padding: 12px;
  display: none;
  z-index: 10001;
}

#modal-head {
  position: sticky; top: 0; z-index: 1;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: #fff;
  border-bottom: 1px solid #eee;
  padding: 6px 4px 10px;
}

#modal-content { padding: 10px 4px; color: #374151; }

#modal-close {
  border: 1px solid #e5e7eb;
  background: #fff;
  border-radius: 6px;
  padding: 6px 10px;
  cursor: pointer;
}

/* Optional: nicer scrollbar in modal (supported browsers only) */
#modal-box::-webkit-scrollbar { width: 10px; }
#modal-box::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 8px; }
#modal-box::-webkit-scrollbar-thumb:hover { background: #9ca3af; }

/* ===== Detail panes (Overview/AI) used by script.js ===== */
.kv {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 8px 16px;
  margin: 10px 0 6px;
  font-size: 0.98rem;
}
.kv-row { display: contents; }

.kv .k {
  color: #111827;
  font-weight: 600;
}

.kv .v {
  color: #1d4ed8;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.ai-row {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 8px 16px;
  padding: 4px 0;
}
.ai-row .k { color: #111827; font-weight: 600; }
.ai-row .v {
  color: #1d4ed8;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.muted { color: #6b7280; font-size: 0.95rem; }
.error { color: #b91c1c; }

/* ===== Row highlight for search hit ===== */
.flash-row { animation: sm-flash 1s linear 0s 2; }
@keyframes sm-flash {
  0%, 100% { background: #fff; }
  50%      { background: #fff7c2; }
}

/* ===== Generic price / change helpers (other places) ===== */
.price-up,
.delta-up {
  color: #15803d;
  font-weight: 700;
}

.price-down,
.delta-down {
  color: #b91c1c;
  font-weight: 700;
}

.price-flat,
.delta-flat {
  color: #1d4ed8;
  font-weight: 700;
}

/* ===== Overview table styling (key fix) ===== */
/* Left column labels: Symbol, Name, Exchange, Price, Δ, Volume, Updated */
#ticker-overview-body tr > td:first-child {
  color: #111827;        /* dark label text */
  font-weight: 600;
}

/* Right column values: CHOW, ChowChow..., NYSE, volume, etc. */
#ticker-overview-body tr > td:last-child {
  color: #1d4ed8;        /* blue data text */
  font-weight: 600;
}

/* Overrides when movement classes are applied to the value cell */
#ticker-overview-body tr > td:last-child.price-up,
#ticker-overview-body tr > td:last-child.delta-up {
  color: #15803d;        /* green for up */
  font-weight: 700;
}

#ticker-overview-body tr > td:last-child.price-down,
#ticker-overview-body tr > td:last-child.delta-down {
  color: #b91c1c;        /* red for down */
  font-weight: 700;
}

#ticker-overview-body tr > td:last-child.price-flat,
#ticker-overview-body tr > td:last-child.delta-flat {
  color: #1d4ed8;        /* blue for flat/other */
  font-weight: 700;
}

/* --- Stock Chart help styles ---------------------------------------- */

.chart-help-toggle {
  border: 1px solid #bfdbfe;
  background: #eff6ff;
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 13px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: #1d4ed8;
  font-weight: 500;
}

.chart-help-toggle span {
  font-size: 13px;
}

.chart-help-toggle:hover {
  background: #dbeafe;
}

.chart-help-box {
  background: #eff6ff;          /* light blue */
  border-radius: 12px;
  padding: 10px 14px;
  border: 1px solid #bfdbfe;    /* blue border */
  max-width: 640px;
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: 10px;
  color: #1f2937;
}

.chart-help-box ul {
  list-style: none;             /* remove default bullets */
  margin: 6px 0 4px 0;
  padding: 0;
}

.chart-help-box li {
  margin-bottom: 4px;
  display: flex;
  align-items: flex-start;
}

.chart-help-note {
  margin-top: 6px;
  font-size: 12px;
  color: #6b7280;
}

.chart-help-icon {
  display: inline-block;
  width: 18px;
  text-align: center;
  margin-right: 6px;
  flex: 0 0 18px;
}

/* --- Technical Signals styling ----------------------------------- */

.signal-card {
  border: 1px solid #e5e7eb;
  background: #ffffff;
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 12px;
}

.signal-active {
  font-weight: 600;
  color: #1f2937;
  text-decoration: underline;
}

[data-signal-help] {
  background: #f3f4f6;
  padding: 12px 16px;
  border-radius: 6px;
  margin-bottom: 16px;
  font-size: 0.95rem;
}

[data-signal-results] {
  margin-top: 12px;
}
