/* =================================================================
   screener.css — Stock Screener page styles v2
   Depends on: theme.css
================================================================= */

.screener-page {
  max-width: 1440px;
  margin: 0 auto;
  padding: 24px 20px 80px;
}
.screener-header h1 {
  font-family: var(--display);
  font-size: 24px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.5px;
  margin-bottom: 14px;
}

/* ── Filter bar ─────────────────────────────────────────────── */
.sc-filter-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 10px;
  overflow: visible;
}

/* ── Tabs ────────────────────────────────────────────────────── */
.sc-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
}
.sc-tabs::-webkit-scrollbar { display: none; }

.sc-tab {
  padding: 9px 15px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text2);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  font-family: var(--body);
  transition: color 0.12s;
  margin-bottom: -1px;
}
.sc-tab:hover { color: var(--text); }
.sc-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.sc-tab-alpha.active { color: #BA7517; border-bottom-color: #BA7517; }

/* ── Panels ──────────────────────────────────────────────────── */
.sc-panel { display: none; }
.sc-panel.active { display: block; }

/* ── Filter grid — horizontal wrap ──────────────────────────── */
.sc-filter-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 12px;
  padding: 12px 14px 10px;
  align-items: flex-end;
}

.sc-fg {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.sc-label {
  font-size: 10px;
  font-weight: 500;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: .05em;
  white-space: nowrap;
}
.sc-label-alpha { color: #854F0B; }

/* ── Search ──────────────────────────────────────────────────── */
.screener-search {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  height: 32px;
}
.screener-search input {
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  font-family: var(--body);
  outline: none;
  width: 180px;
}
.screener-search input::placeholder { color: var(--text3); }

/* ── Filter selects ──────────────────────────────────────────── */
.filter-select {
  height: 32px;
  padding: 0 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 12px;
  font-family: var(--body);
  cursor: pointer;
  outline: none;
  transition: border-color 0.12s;
  width: auto;
  min-width: 110px;
}
.filter-select:hover,
.filter-select:focus { border-color: var(--accent-border); }
.filter-select-alpha { border-color: rgba(186,117,23,0.35); }
.filter-select-alpha:hover { border-color: #BA7517; }

/* ── Alpha panel extras ───────────────────────────────────────── */
.sc-alpha-intro {
  padding: 8px 14px 0;
  font-size: 11px;
  color: var(--text3);
}
.sc-alpha-intro a { color: var(--accent); text-decoration: none; }
.sc-alpha-hint {
  font-size: 10px;
  color: var(--text3);
  line-height: 1.4;
  max-width: 170px;
}

/* ── Bottom bar ──────────────────────────────────────────────── */
.sc-filter-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  border-top: 1px solid var(--border);
  gap: 8px;
  flex-wrap: wrap;
}
.screener-meta { font-size: 11px; color: var(--text3); font-family: var(--mono); }
.screener-reset {
  height: 28px;
  padding: 0 12px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text2);
  font-size: 12px;
  cursor: pointer;
  font-family: var(--body);
  transition: all 0.12s;
}
.screener-reset:hover { border-color: var(--accent-border); color: var(--text); }
.sc-active-badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--surface2);
  color: var(--accent);
  border: 1px solid var(--accent-border);
  font-family: var(--mono);
}

/* ── Active filter tags ──────────────────────────────────────── */
.sc-active-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 2px 4px;
}
.sc-filter-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px 3px 10px;
  background: var(--surface);
  border: 1px solid var(--accent-border);
  border-radius: 20px;
  font-size: 11px;
  color: var(--accent);
  font-family: var(--mono);
  white-space: nowrap;
}
.sc-filter-tag button {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 11px;
  padding: 0;
  line-height: 1;
  opacity: 0.6;
  transition: opacity 0.1s;
}
.sc-filter-tag button:hover { opacity: 1; }

/* ── Table controls ──────────────────────────────────────────── */
.sc-table-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
  padding: 0 2px;
}
.sc-showing { font-size: 12px; color: var(--text2); font-family: var(--mono); }
.sc-col-btn {
  height: 28px;
  padding: 0 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text2);
  font-size: 12px;
  cursor: pointer;
  font-family: var(--body);
  transition: all 0.12s;
}
.sc-col-btn:hover { border-color: var(--accent-border); color: var(--text); }

/* ── Column picker dropdown ──────────────────────────────────── */
.sc-col-picker {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
  z-index: 200;
  width: 640px;
  max-width: 90vw;
}
.sc-col-picker-inner {
  padding: 16px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px 12px;
}
.sc-col-group { min-width: 0; }
.sc-col-group-title {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text3);
  margin-bottom: 7px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}
.sc-col-check {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text2);
  cursor: pointer;
  padding: 3px 0;
  transition: color 0.1s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sc-col-check input[type="checkbox"] {
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  cursor: pointer;
}
.sc-col-check:hover { color: var(--text); }
.sc-col-on { color: var(--accent); font-weight: 500; }
.sc-col-close {
  width: 100%;
  height: 30px;
  background: var(--accent);
  border: none;
  border-radius: 6px;
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  font-family: var(--body);
  margin-top: 4px;
}

/* ── Table ───────────────────────────────────────────────────── */
.screener-table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow-x: auto;
  overflow-y: auto;
  max-height: calc(100vh - 280px);
}
.screener-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  min-width: 700px;
}
.screener-table thead th {
  padding: 9px 10px;
  text-align: right;
  font-size: 11px;
  font-weight: 500;
  color: var(--text2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  background: var(--surface2);
  transition: color 0.12s;
  position: sticky;
  top: 0;
  z-index: 10;
}
.screener-table thead th:hover { color: var(--text); }
.screener-table thead th.sorted { color: var(--accent); }

/* ── Sticky Company column ───────────────────────────────────── */
.sc-col-sticky {
  position: sticky;
  left: 0;
  z-index: 2;
  background: var(--surface2);
}
/* Corner cell: sticky both top and left — must be above everything */
.screener-table thead th.sc-col-sticky {
  z-index: 20;
}
.screener-table tbody td.sc-col-sticky {
  background: var(--surface);
  z-index: 1;
}
.screener-table tbody tr:hover td.sc-col-sticky {
  background: var(--surface2);
}
/* subtle shadow to indicate more content to the right */
.sc-col-sticky::after {
  content: '';
  position: absolute;
  top: 0; right: -8px; bottom: 0;
  width: 8px;
  background: linear-gradient(to right, rgba(0,0,0,0.08), transparent);
  pointer-events: none;
}

.screener-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.08s;
  cursor: pointer;
}
.screener-table tbody tr:last-child { border-bottom: none; }
.screener-table tbody tr:hover { background: var(--surface2); }
.screener-table tbody td {
  padding: 8px 10px;
  text-align: right;
  color: var(--text);
  white-space: nowrap;
}

/* ── Company cell ────────────────────────────────────────────── */
.company-cell { display: flex; align-items: center; gap: 8px; }
.company-logo {
  width: 22px; height: 22px;
  border-radius: 4px;
  background: var(--surface2);
  display: flex; align-items: center; justify-content: center;
  font-size: 8px; font-weight: 600; color: var(--text2);
  flex-shrink: 0; overflow: hidden;
}
.company-logo img { width: 100%; height: 100%; object-fit: contain; }
.company-info { min-width: 0; }
.company-ticker { font-weight: 600; font-size: 12px; color: var(--accent); }
.company-name {
  font-size: 11px; color: var(--text2);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  max-width: 140px;
}

/* ── Sector / Industry tags ──────────────────────────────────── */
.sector-tag {
  display: inline-block;
  padding: 2px 7px; border-radius: 4px;
  font-size: 10px;
  background: var(--surface2); color: var(--text2);
  border: 1px solid var(--border); white-space: nowrap;
}
.industry-tag {
  display: inline-block;
  padding: 2px 7px; border-radius: 4px;
  font-size: 10px;
  background: transparent; color: var(--text3);
  border: 1px solid var(--border); white-space: nowrap;
}

/* ── Score badge ─────────────────────────────────────────────── */
.score-cell { display: inline-flex; align-items: center; gap: 5px; justify-content: flex-end; }
.score-num { font-weight: 600; font-size: 12px; font-family: var(--mono); min-width: 28px; text-align: right; }
.score-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.score-strong .score-num { color: #22c55e; } .score-strong .score-dot { background: #22c55e; }
.score-mixed  .score-num { color: #f59e0b; } .score-mixed  .score-dot { background: #f59e0b; }
.score-weak   .score-num { color: #ef4444; } .score-weak   .score-dot { background: #ef4444; }

/* ── Watchlist star ──────────────────────────────────────────── */
.wl-star {
  width: 24px; height: 24px;
  border: 1px solid var(--border); border-radius: 5px;
  background: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; color: var(--text3);
  transition: all 0.12s; flex-shrink: 0;
}
.wl-star:hover, .wl-star.on { border-color: #f0a500; color: #f0a500; }

/* ── Values ──────────────────────────────────────────────────── */
.val-pos { color: #22c55e; }
.val-neg { color: #ef4444; }
.val-na  { color: var(--text3); }

/* ── Loading / empty ─────────────────────────────────────────── */
.screener-loading, .screener-empty {
  text-align: center; padding: 60px 20px; color: var(--text2); font-size: 14px;
}
.spinner {
  width: 28px; height: 28px;
  border: 2px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 0.7s linear infinite;
  margin: 0 auto 14px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Pagination ──────────────────────────────────────────────── */
.screener-pagination {
  display: flex; align-items: center; justify-content: center;
  gap: 8px; margin-top: 16px; flex-wrap: wrap;
}
.page-btn {
  height: 28px; padding: 0 12px;
  border: 1px solid var(--border); border-radius: 6px;
  background: var(--surface); color: var(--text2);
  font-size: 12px; cursor: pointer; transition: all 0.12s; font-family: var(--body);
}
.page-btn:hover:not(:disabled) { border-color: var(--accent-border); color: var(--text); }
.page-btn:disabled { opacity: 0.4; cursor: default; }
.page-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.page-info { font-size: 12px; color: var(--text2); font-family: var(--mono); }

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 768px) {
  .screener-page { padding: 16px 12px 60px; }
  .screener-search input { width: 130px; }
  .sc-col-picker { width: 100%; right: -60px; }
}
