/* ============================================================
   Screener page — form panel
   ============================================================ */

/* ── Panel shell ─────────────────────────────────────────── */
.screener-filters {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 0.875rem;
  overflow: hidden;
  margin-bottom: 1.25rem;
}

/* ── Top bar: Load Screener ──────────────────────────────── */
.screener-top {
  display: flex;
  align-items: center;
  padding: 0.625rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
  background: rgba(6, 182, 212, 0.03);
}

.screener-load-select {
  max-width: 260px;
  font-size: 0.85rem;
  padding: 0.4rem 2.25rem 0.4rem 0.65rem;
  color: var(--text-secondary);
}

/* ── Body ────────────────────────────────────────────────── */
.screener-body {
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* ── Shared field block ──────────────────────────────────── */
.screener-field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

/* ── Ticker row (full width) ─────────────────────────────── */
.screener-field--ticker {
  padding: 1.1rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
}

/* ── Three-column row ────────────────────────────────────── */
.screener-row-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-bottom: 1px solid var(--border-color);
}

.screener-row-3 .screener-field {
  padding: 1.1rem 1.25rem;
}

.screener-row-3 .screener-field + .screener-field {
  border-left: 1px solid var(--border-color);
}

/* ── Footer row: Spread Width + Actions ──────────────────── */
.screener-footer {
  display: flex;
  align-items: flex-end;
  gap: 0.75rem;
  padding: 0.875rem 1.25rem;
}

.screener-spread {
  /* constrain the spread-width select so it doesn't stretch */
  flex: 0 0 auto;
  min-width: 130px;
}

.screener-actions {
  display: flex;
  gap: 0.5rem;
  margin-left: auto;
  align-items: flex-end;
}

/* ── Field labels ────────────────────────────────────────── */
.screener-label {
  display: block;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 0.1rem;
}

/* ── Inputs & selects ────────────────────────────────────── */
.form-input,
.form-select {
  width: 100%;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 0.9rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-input:focus,
.form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.15);
  outline: none;
}

.form-select {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background-image: url('data:image/svg+xml;utf8,<svg fill="%2364748b" height="20" viewBox="0 0 24 24" width="20" xmlns="http://www.w3.org/2000/svg"><path d="M7 10l5 5 5-5z"/></svg>');
  background-repeat: no-repeat;
  background-position: right 0.6rem center;
  background-size: 1.1rem;
  padding-right: 2.25rem;
}

.form-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.screener-hint {
  display: block;
  margin-top: 0.2rem;
}

/* ── Radio groups — pill segmented controls ──────────────── */
.radio-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.4rem;
}

.radio-group label {
  display: inline-flex;
  align-items: center;
  gap: 0;
  cursor: pointer;
  font-size: 0.8rem;
  color: var(--text-secondary);
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 999px;
  padding: 0.3rem 0.7rem;
  user-select: none;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
  white-space: nowrap;
}

.radio-group input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.radio-group label:has(input[type="radio"]:checked) {
  color: var(--primary);
  border-color: var(--primary);
  background: rgba(6, 182, 212, 0.1);
  font-weight: 600;
}

.radio-group label:has(input[type="radio"]:focus-visible) {
  outline: 2px solid rgba(6, 182, 212, 0.4);
  outline-offset: 2px;
}

/* ── Buttons ─────────────────────────────────────────────── */
.screener-search-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 1.4rem;
  font-size: 0.9rem;
  font-weight: 700;
  white-space: nowrap;
}

.screener-save-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.875rem;
  white-space: nowrap;
}

/* ── Strike inputs ───────────────────────────────────────── */
.strike-inputs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}

.strike-input-group {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.strike-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 0.03em;
}

/* ── Filter tags ─────────────────────────────────────────── */
.filter-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.filter-tag {
  background: rgba(6, 182, 212, 0.1);
  color: var(--primary);
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  border: 1px solid rgba(6, 182, 212, 0.2);
}

.filter-tag-remove {
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: rgba(6, 182, 212, 0.2);
  flex-shrink: 0;
}

/* ── Results header ──────────────────────────────────────── */
.results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.timestamp {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.results-count {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.sort-options {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.sort-select {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  padding: 0.45rem 2rem 0.45rem 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 0.875rem;
  background-image: url('data:image/svg+xml;utf8,<svg fill="%2394a3b8" height="20" viewBox="0 0 24 24" width="20" xmlns="http://www.w3.org/2000/svg"><path d="M7 10l5 5 5-5z"/></svg>');
  background-repeat: no-repeat;
  background-position: right 0.5rem center;
  background-size: 1.1rem;
}

.sort-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.15);
  outline: none;
}

.sort-direction-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0.4rem;
  display: flex;
  align-items: center;
  transition: color 0.15s;
}

.sort-direction-btn:hover { color: var(--primary); }
.sort-direction-btn.asc svg { transform: rotate(180deg); }

/* ── Card grid ───────────────────────────────────────────── */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 1.5rem;
}

/* ── Loading / empty states ──────────────────────────────── */
.loading {
  text-align: center;
  padding: 3rem 0;
  color: var(--text-secondary);
}

.spinner {
  border: 3px solid rgba(255, 255, 255, 0.15);
  border-top-color: var(--primary);
  border-radius: 50%;
  width: 36px;
  height: 36px;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 1rem;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.no-results {
  text-align: center;
  padding: 3rem 0;
  color: var(--text-secondary);
}

.no-results svg { color: var(--primary); margin-bottom: 1rem; }
.no-results h3 { font-size: 1.4rem; margin-bottom: 0.5rem; }

/* ── Toggle switch (Save modal) ──────────────────────────── */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  cursor: pointer;
}

.toggle-switch input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
  position: absolute;
  inset: 0;
  background: #475569;
  border-radius: 24px;
  transition: 0.25s;
}

.toggle-slider:before {
  content: "";
  position: absolute;
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: 0.25s;
}

.toggle-switch input:checked + .toggle-slider { background: var(--primary); }
.toggle-switch input:checked + .toggle-slider:before { transform: translateX(20px); }
.toggle-switch input:focus + .toggle-slider { box-shadow: 0 0 0 2px rgba(6, 182, 212, 0.35); }
.toggle-switch input:disabled + .toggle-slider { opacity: 0.45; cursor: not-allowed; }

/* ── Ticker pro-tip (guest upsell) ──────────────────────── */
.ticker-pro-tip {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
  margin-top: 0.5rem;
  padding: 0.6rem 0.75rem;
  border-radius: 0.5rem;
  background: rgba(6, 182, 212, 0.06);
  border: 1px solid rgba(6, 182, 212, 0.18);
  font-size: 0.79rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.ticker-pro-tip-icon { flex-shrink: 0; font-size: 0.9rem; margin-top: 1px; }
.ticker-pro-tip strong { color: var(--text-primary); }

.ticker-pro-tip-link {
  display: inline-block;
  margin-top: 0.25rem;
  color: var(--primary);
  font-weight: 600;
  text-decoration: none;
}

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

/* ============================================================
   Responsive
   ============================================================ */

/* Medium: keep 3-col but tighten */
@media (max-width: 1100px) {
  .card-grid {
    grid-template-columns: repeat(auto-fit, minmax(308px, 420px));
    justify-content: center;
    gap: 1rem;
  }
}

/* Tablet: collapse 3-col to 2 */
@media (max-width: 860px) {
  .screener-row-3 {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Delta field wraps to full width on its own row */
  .screener-row-3 .screener-field:last-child {
    grid-column: 1 / -1;
    border-left: none;
    border-top: 1px solid var(--border-color);
  }
}

/* Mobile: full single column */
@media (max-width: 640px) {
  .screener-row-3 {
    grid-template-columns: 1fr;
  }

  .screener-row-3 .screener-field + .screener-field {
    border-left: none;
    border-top: 1px solid var(--border-color);
  }

  .screener-row-3 .screener-field:last-child {
    grid-column: auto;
    border-top: 1px solid var(--border-color);
  }

  .screener-footer {
    flex-direction: column;
    align-items: stretch;
    gap: 0.875rem;
  }

  .screener-spread {
    min-width: 0;
    width: 100%;
  }

  .screener-actions {
    margin-left: 0;
    flex-direction: column-reverse;
    gap: 0.5rem;
  }

  .screener-search-btn,
  .screener-save-btn {
    width: 100%;
    justify-content: center;
    padding: 0.75rem 1rem;
  }

  .screener-search-btn {
    font-size: 1rem;
  }

  .form-input,
  .form-select {
    font-size: 1rem; /* prevent iOS zoom on focus */
    padding: 0.65rem 0.75rem;
  }

  .strike-inputs {
    grid-template-columns: 1fr;
  }

  .card-grid {
    grid-template-columns: 1fr;
    justify-content: center;
    gap: 0.75rem;
  }

  .results-header {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 480px) {
  .screener-field--ticker,
  .screener-row-3 .screener-field {
    padding: 0.875rem 1rem;
  }

  .screener-footer {
    padding: 0.875rem 1rem;
  }
}
