/* ETF Screener styles */

.screener-page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
}

.screener-header {
  margin-bottom: 1rem;
}

.screener-header h1 {
  font-size: 1.6rem;
  margin-bottom: 0.25rem;
}

.screener-subtitle {
  color: #666;
  font-size: 0.9rem;
  margin: 0;
}

/* ── Category pills ─────────────────────────────────────────── */

.category-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
  margin-bottom: 0.5rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid #e0e0e0;
}

.subcategory-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
  margin-bottom: 0.5rem;
  padding: 0.4rem 0 0.6rem;
  border-bottom: 1px solid #eee;
}

.pills-label {
  font-size: 0.8rem;
  color: #666;
  font-weight: 600;
  margin-right: 0.25rem;
}

.pill {
  display: inline-block;
  padding: 0.25rem 0.65rem;
  font-size: 0.78rem;
  border: 1px solid #ccc;
  border-radius: 100px;
  color: #333;
  text-decoration: none;
  background: #fafafa;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.pill:hover {
  background: #e8e8e8;
  border-color: #999;
  text-decoration: none;
}

.pill-sub {
  font-size: 0.74rem;
  padding: 0.2rem 0.55rem;
  border-color: #ddd;
}

.pill-active {
  background: #1a1a2e;
  color: #fff;
  border-color: #1a1a2e;
}

.pill-active:hover {
  background: #2a2a4e;
  border-color: #2a2a4e;
}

/* ── Filters bar ────────────────────────────────────────────── */

.filters-bar {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
}

.filter-toggle {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  background: none;
  border: 1px solid #ccc;
  border-radius: 4px;
  padding: 0.4rem 0.75rem;
  font-size: 0.85rem;
  cursor: pointer;
  color: #333;
}

.filter-toggle:hover {
  background: #f5f5f5;
}

.chevron {
  transition: transform 0.2s;
}

.chevron-open {
  transform: rotate(180deg);
}

.search-box {
  flex: 1;
  min-width: 180px;
  max-width: 350px;
}

.search-input {
  width: 100%;
  padding: 0.4rem 0.6rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 0.85rem;
}

.search-input:focus {
  outline: none;
  border-color: #666;
}

.results-count {
  font-size: 0.85rem;
  color: #666;
  white-space: nowrap;
}

/* ── Filter panel ───────────────────────────────────────────── */

.filters-panel {
  background: #f8f8f8;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  padding: 1rem;
  margin-bottom: 1rem;
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.75rem;
}

.filter-group label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: #555;
  margin-bottom: 0.2rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.filter-group select {
  width: 100%;
  padding: 0.35rem 0.5rem;
  border: 1px solid #ccc;
  border-radius: 3px;
  font-size: 0.83rem;
  background: white;
}

.filter-actions {
  margin-top: 0.75rem;
  padding-top: 0.5rem;
  border-top: 1px solid #e0e0e0;
}

.btn-clear {
  background: none;
  border: none;
  color: #666;
  font-size: 0.8rem;
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
}

.btn-clear:hover {
  color: #333;
}

/* ── Results table ──────────────────────────────────────────── */

.results-section {
  margin-top: 0.5rem;
}

.results-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.83rem;
  line-height: 1.4;
}

.results-table thead th {
  text-align: left;
  padding: 0.5rem 0.6rem;
  border-bottom: 2px solid #333;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #333;
  white-space: nowrap;
  user-select: none;
}

.results-table thead th.sortable {
  cursor: pointer;
}

.results-table thead th.sortable:hover {
  color: #000;
  background: #f0f0f0;
}

.sort-arrow {
  font-size: 0.65rem;
  margin-left: 0.2rem;
}

.results-table tbody td {
  padding: 0.45rem 0.6rem;
  border-bottom: 1px solid #eee;
  vertical-align: middle;
}

.results-table tbody tr:hover {
  background: #f8f8f8;
}

.col-ticker {
  width: 70px;
}

.col-name {
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.col-type {
  width: 50px;
}

.col-category {
  width: 180px;
  color: #666;
}

.col-nav, .col-expense, .col-return {
  text-align: right;
  white-space: nowrap;
}

.col-nav {
  width: 80px;
}

.col-expense {
  width: 80px;
}

.col-return {
  width: 80px;
}

.ticker-link {
  font-weight: 700;
  color: #1a1a2e;
  text-decoration: none;
}

.ticker-link:hover {
  text-decoration: underline;
}

.col-name a {
  color: #333;
  text-decoration: none;
}

.col-name a:hover {
  text-decoration: underline;
}

.type-badge {
  display: inline-block;
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.badge-etf {
  background: #e3f2fd;
  color: #1565c0;
}

.badge-fund {
  background: #f3e5f5;
  color: #7b1fa2;
}

.positive {
  color: #2e7d32;
}

.negative {
  color: #c62828;
}

/* ── Pagination ─────────────────────────────────────────────── */

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 1rem 0;
  margin-top: 0.5rem;
}

.page-btn {
  padding: 0.35rem 0.75rem;
  border: 1px solid #ccc;
  border-radius: 3px;
  background: white;
  cursor: pointer;
  font-size: 0.83rem;
}

.page-btn:hover:not(:disabled) {
  background: #f0f0f0;
}

.page-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.page-info {
  font-size: 0.83rem;
  color: #666;
}

/* ── Loading / empty states ─────────────────────────────────── */

.loading-state, .empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: #888;
  font-size: 0.95rem;
}

/* ── Responsive ─────────────────────────────────────────────── */

@media (max-width: 768px) {
  .screener-header h1 {
    font-size: 1.3rem;
  }

  .filter-grid {
    grid-template-columns: 1fr 1fr;
  }

  .col-category, .col-type {
    display: none;
  }

  .col-name {
    min-width: 120px;
  }

  .results-table {
    font-size: 0.78rem;
  }
}

@media (max-width: 480px) {
  .filter-grid {
    grid-template-columns: 1fr;
  }

  .filters-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .search-box {
    max-width: 100%;
  }

  .results-count {
    text-align: right;
  }

  .col-expense {
    display: none;
  }
}

/* Column selector */
.column-selector {
  margin: 0.5rem 0;
  font-size: 0.85rem;
}

.btn-columns {
  background: none;
  border: 1px solid #ccc;
  border-radius: 4px;
  padding: 0.3rem 0.7rem;
  font-size: 0.8rem;
  cursor: pointer;
  color: #555;
}

.btn-columns:hover {
  border-color: #888;
  color: #222;
}

.column-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  padding: 0.5rem 0;
}

.column-options label {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.82rem;
  color: #555;
  cursor: pointer;
  white-space: nowrap;
}

.column-options input[type="checkbox"] {
  accent-color: #0a2540;
}

/* Return disclaimer */
.screener-disclaimer {
  font-size: 0.75rem;
  color: #999;
  font-style: italic;
  margin: 0.75rem 0 0;
  padding: 0;
}

/* ── Stock filter chips + autocomplete ─────────────────────── */

.stock-filter-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid #e0e0e0;
}

.filter-group-wide {
  position: relative;
}

.chip-input-wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem;
  padding: 0.3rem 0.5rem;
  border: 1px solid #ccc;
  border-radius: 3px;
  background: white;
  min-height: 34px;
  position: relative;
  cursor: text;
}

.chip-input-wrap:focus-within {
  border-color: #666;
}

.ticker-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  padding: 0.15rem 0.4rem;
  border-radius: 100px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.chip-include {
  background: #e3f2fd;
  color: #1565c0;
  border: 1px solid #90caf9;
}

.chip-exclude {
  background: #fce4ec;
  color: #c62828;
  border: 1px solid #ef9a9a;
}

.chip-remove {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1;
  padding: 0 0.1rem;
  color: inherit;
  opacity: 0.6;
}

.chip-remove:hover {
  opacity: 1;
}

.chip-text-input {
  border: none;
  outline: none;
  font-size: 0.83rem;
  flex: 1;
  min-width: 80px;
  padding: 0.15rem 0;
  background: transparent;
}

.ticker-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 50;
  background: white;
  border: 1px solid #ccc;
  border-top: none;
  border-radius: 0 0 4px 4px;
  max-height: 220px;
  overflow-y: auto;
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.ticker-dropdown-item {
  padding: 0.4rem 0.6rem;
  font-size: 0.83rem;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ticker-dropdown-item:hover,
.ticker-dropdown-item.highlighted {
  background: #f0f0f0;
}

@media (max-width: 768px) {
  .stock-filter-row {
    grid-template-columns: 1fr;
  }
}

/* Sector + geography columns */
.col-sector, .col-geography {
  color: #666;
  font-size: 0.85rem;
  text-transform: capitalize;
}

.filter-input {
  width: 100%;
  padding: 0.35rem 0.5rem;
  border: 1px solid #ccc;
  border-radius: 3px;
  font-size: 0.83rem;
  background: white;
}

.filter-input:focus {
  outline: none;
  border-color: #666;
}
