/* ---- Dip Finder Tabs ---- */

/* Header that hosts a tab bar drops its bottom padding so the tabs sit
   flush against the header's bottom border, which acts as the tab track. */
header:has(.dip-tab-bar) {
  padding-bottom: 0;
}

.dip-tab-bar {
  display: flex;
  gap: 8px;
  margin-top: 0.75rem;
}

.dip-tab {
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  padding: 12px 24px;
  font-size: 1rem;
  font-weight: 500;
  letter-spacing: 0.2px;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s;
  margin-bottom: -1px;
}

.dip-tab:hover {
  color: var(--text);
}

.dip-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* Fill the remaining height below the header so the inner #main-scroll
   becomes the scroll area instead of the cards overflowing off-screen.
   switchDipTab() toggles display between 'none' and '' (→ this flex). */
.dip-tab-content {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.dip-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 0.75rem 1rem;
  flex-shrink: 0;
}

.dip-fixed-params {
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 500;
}

.btn-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}
.btn-link:hover {
  text-decoration: underline;
}

/* ---- Watch List Page ---- */

.wl-value-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface2);
  color: var(--muted);
  padding: 5px 7px;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.wl-value-toggle:hover,
.wl-value-toggle:focus-visible {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}
.wl-value-toggle-icon {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
}

.wl-list-header {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) var(--wl-value-col, 4.25rem) var(--wl-remove-col, 18px);
  align-items: center;
  column-gap: 8px;
  padding: 8px 12px;
  border-left: 3px solid transparent;
  border-bottom: 1px solid var(--border);
  overflow: visible;
}
.wl-list-header .wl-list-column-label {
  grid-column: 1 / 3;
}
.wl-list-header .wl-value-toggle {
  grid-column: 3;
  justify-self: center;
  width: max-content;
}

.wl-list-column-label {
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
}

.wl-layout {
  flex: 1;
  display: flex;
  overflow: hidden;
}

.wl-sidebar {
  --wl-value-col: 4.25rem;
  --wl-remove-col: 18px;
  width: 300px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

.wl-add-bar {
  display: flex;
  padding: 10px 12px;
  gap: 6px;
  border-bottom: 1px solid var(--border);
}

.wl-add-input {
  flex: 1;
  min-width: 0;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 0.8rem;
  color: var(--text);
  text-transform: uppercase;
  font-family: monospace;
  outline: none;
}
.wl-add-input:focus {
  border-color: var(--accent);
}

.wl-add-btn {
  background:
    linear-gradient(var(--surface), var(--surface)) padding-box,
    var(--accent-gradient) border-box;
  border: 2px solid transparent;
  border-radius: 6px;
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 700;
  padding: 6px 14px;
  height: 32px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
}
.wl-add-btn:hover {
  background:
    linear-gradient(var(--surface2), var(--surface2)) padding-box,
    var(--accent-gradient-hover) border-box;
}

.wl-ticker-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px 0;
}

.wl-autocomplete {
  position: absolute;
  top: 100%;
  left: 0;
  width: 280px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow-md);
  z-index: 200;
  max-height: 260px;
  overflow-y: auto;
  display: none;
}
.wl-ac-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  cursor: pointer;
  transition: background 0.1s;
}
.wl-ac-item:hover,
.wl-ac-item.wl-ac-active {
  background: var(--surface2);
}
.wl-ac-logo {
  width: 20px;
  height: 20px;
  border-radius: 3px;
  object-fit: contain;
  flex-shrink: 0;
}
.wl-ac-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.wl-ac-symbol {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text);
}
.wl-ac-name {
  font-size: 0.68rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.wl-ac-price {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text);
  flex-shrink: 0;
}
.ticker-logo-fallback.wl-ac-logo {
  width: 20px;
  height: 20px;
  font-size: 0.5rem;
}

.wl-section-label {
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  padding: 8px 14px 4px;
  border-top: 1px solid var(--border);
  margin-top: 4px;
}
.wl-section-label:first-child {
  border-top: none;
  margin-top: 0;
}

.wl-item {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) var(--wl-value-col, 4.25rem) var(--wl-remove-col, 18px);
  align-items: center;
  column-gap: 8px;
  padding: 8px 12px;
  cursor: pointer;
  transition: background 0.15s;
  border-left: 3px solid transparent;
}
.wl-item:has(> .wl-compare-swatch) {
  grid-template-columns: 12px 24px minmax(0, 1fr) var(--wl-value-col, 4.25rem) var(--wl-remove-col, 18px);
}
.wl-item:hover {
  background: var(--surface2);
}
.wl-item-active {
  background: var(--accent-soft);
  border-left-color: var(--accent);
}

.wl-item-logo {
  width: 24px;
  height: 24px;
  border-radius: 4px;
  object-fit: contain;
}

.wl-item-ticker {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wl-item-value {
  color: var(--text);
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  white-space: nowrap;
  justify-self: stretch;
  text-align: right;
}

.wl-item-value-spacer {
  width: var(--wl-remove-col, 18px);
}

.holdings-current-value {
  font-size: 1rem;
  font-weight: 400;
}

.holdings-table td:first-child strong {
  font-size: 0.95rem;
  font-weight: 500;
}

#trades-table .trade-ticker {
  white-space: nowrap;
}

#trades-table .trade-ticker .ticker-logo,
#trades-table .trade-ticker .ticker-logo-fallback {
  width: 24px;
  height: 24px;
  margin-right: 8px;
  vertical-align: middle;
}

#trades-table .trade-ticker strong {
  font-size: 0.95rem;
  font-weight: 500;
  vertical-align: middle;
}

#trades-table td,
.holdings-table td {
  font-size: 1rem;
  font-weight: 400;
}

#trades-table .trade-pnl--unrealized,
#trades-table .trade-pnl--realized {
  font-weight: 400;
}

.wl-item-remove {
  background: none;
  border: none;
  color: var(--red);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0;
  flex: 0 0 18px;
  width: 18px;
  opacity: 0;
  transition: opacity 0.15s;
  line-height: 1;
}
.wl-item:hover .wl-item-remove {
  opacity: 0.6;
}
.wl-item-remove:hover {
  opacity: 1 !important;
}

.wl-empty {
  padding: 2rem 1rem;
  text-align: center;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.6;
}

/* Detail panel */
.wl-detail {
  flex: 1;
  overflow-y: auto;
  padding: 24px 28px;
  background: var(--surface);
}

.wl-detail-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 12px;
}
.wl-detail-placeholder p {
  color: var(--muted);
  font-size: 0.85rem;
}

.wl-detail-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.wl-detail-logo {
  width: 36px;
  height: 36px;
  border-radius: 6px;
  object-fit: contain;
}

.wl-detail-ticker {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text);
}

.wl-detail-name {
  font-size: 0.85rem;
  color: var(--muted);
}

/* ---- Watch List Tabs + Compare view ---- */

.wl-tab-content {
  flex: 1;
  min-height: 0;
}

.wl-compare-hint {
  padding: 12px 14px;
  font-size: 0.72rem;
  color: var(--muted);
  line-height: 1.5;
  border-bottom: 1px solid var(--border);
}

.wl-item-selected {
  background: var(--accent-soft);
}

.wl-compare-swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  border: 1.5px solid var(--border);
  flex-shrink: 0;
  display: inline-block;
}

.wl-compare {
  flex: 1;
  overflow-y: auto;
  padding: 24px 28px;
  background: var(--surface);
}

.wl-compare-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 12px;
}
.wl-compare-placeholder p {
  color: var(--muted);
  font-size: 0.85rem;
}

.wl-compare-chart-wrap {
  min-height: 200px;
  margin-bottom: 1.5rem;
}

.wl-compare-table-wrap {
  overflow-x: auto;
}

.wl-compare-table {
  width: auto;
  border-collapse: collapse;
  font-size: 0.88rem;
}
.wl-compare-table th,
.wl-compare-table td {
  padding: 8px 18px;
  text-align: right;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}
.wl-compare-table thead th {
  font-weight: 700;
  color: var(--text);
  border-bottom: 2px solid var(--border);
}
.wl-compare-metric-col {
  text-align: left !important;
  color: var(--muted);
  font-weight: 600;
  position: sticky;
  left: 0;
  background: var(--surface);
}
.wl-compare-table thead .wl-compare-metric-col {
  color: var(--muted);
}
.wl-compare-th {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  justify-content: flex-end;
}
.wl-compare-table tbody tr:hover td,
.wl-compare-table tbody tr:hover .wl-compare-metric-col {
  background: var(--surface2);
}

#wl-chart-container {
  min-height: 200px;
  position: relative;
}

/* Horizontal scroller for the watch-list dip chart. #wl-chart-inner gets an
   explicit min-width (from dip-finder.js, sized to the ticker count) so bars
   keep a legible slot; when it exceeds the viewport this scrolls sideways with
   momentum instead of compressing the bars into an unreadable smear. */
#wl-chart-scroll {
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
}
#wl-chart-inner {
  height: 380px;
  min-width: 100%;
}
#wl-chart-inner canvas {
  height: 100% !important;
}

.chart-loader-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(var(--bg-rgb, 248, 249, 251), 0.6);
  backdrop-filter: blur(2px);
  z-index: 10;
  border-radius: 8px;
}

[data-theme="dark"] .chart-loader-overlay {
  background: rgba(15, 25, 34, 0.6);
}

.chart-loader-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: chart-spin 0.7s linear infinite;
}

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

/* ---- Danger button ---- */
.btn-danger {
  background: var(--red);
  color: #fff;
  border: 1px solid var(--red);
}
.btn-danger:hover {
  filter: brightness(0.92);
}
.btn-danger:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Account / data card on the Trades page is prose, not a dip-finder card —
   reset the base .card grid so the heading + paragraph stack full-width. */
#account-card {
  display: block;
}
