/*
 * This is a manifest file that'll be compiled into application.css.
 *
 * With Propshaft, assets are served efficiently without preprocessing steps. You can still include
 * application-wide styles in this file, but keep in mind that CSS precedence will follow the standard
 * cascading order, meaning styles declared later in the document or manifest will override earlier ones,
 * depending on specificity.
 *
 * Consider organizing styles into separate files for maintainability.
 */

/* UI-SPEC tokens (Phase 1) */
:root {
  --color-bg: #FFFFFF;
  --color-surface: #F3F4F6;
  --color-accent: #2563EB;
  --color-destructive: #DC2626;
  --color-positive: #16A34A;

  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;
  --space-3xl: 64px;
}

body {
  background: var(--color-bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

.page-container {
  padding: var(--space-xl) var(--space-lg);
}

.login-page {
  display: flex;
  justify-content: center;
  padding-top: var(--space-3xl);
}

.login-card {
  background: var(--color-surface);
  padding: var(--space-lg);
  border-radius: 8px;
  width: 100%;
  max-width: 360px;
}

.login-card h1 {
  font-size: 24px;
  font-weight: 600;
  line-height: 1.2;
  margin: 0 0 var(--space-xl);
}

.flash-alert {
  color: var(--color-destructive);
  margin-bottom: var(--space-md);
}

.flash-notice {
  color: var(--color-accent);
  margin-bottom: var(--space-md);
}

.reconnect-banner,
.reconnect-flow {
  background: var(--color-surface);
  border: 1px solid var(--color-destructive);
  border-radius: 4px;
  padding: var(--space-lg);
  margin-bottom: var(--space-xl);
}

.reconnect-banner summary,
.reconnect-flow h2 {
  font-size: 24px;
  font-weight: 600;
  line-height: 1.2;
  color: var(--color-destructive);
  margin: 0 0 var(--space-sm);
  cursor: pointer;
}

.reconnect-banner p,
.reconnect-flow p {
  margin: 0 0 var(--space-md);
}

/* Unverified-account banner (Phase 7, D-04) — mirrors .reconnect-banner's
   shape exactly, accent- (not destructive-) colored: this is an actionable
   pending state, not an error. Reopens on every page load (server-rendered
   from Current.user.verified_at fresh each time), same non-permanently-
   dismissible idiom as .reconnect-banner. */
.verification-banner {
  background: var(--color-surface);
  border: 1px solid var(--color-accent);
  border-radius: 4px;
  padding: var(--space-lg);
  margin-bottom: var(--space-xl);
}

.verification-banner summary {
  font-size: 24px;
  font-weight: 600;
  line-height: 1.2;
  color: var(--color-accent);
  margin: 0 0 var(--space-sm);
  cursor: pointer;
}

.verification-banner p {
  margin: 0 0 var(--space-md);
}

.page-nav-link {
  display: inline-block;
  margin-bottom: var(--space-lg);
  color: var(--color-accent);
  text-decoration: none;
}

/* Connections page — populated account list (UI-SPEC "populated" row) */
.account-list {
  /* 🧪 backstop: scrolls within the section instead of paginating/clipping
     when Fidelity returns an unusually large number of sub-accounts. */
  max-height: 320px;
  overflow-y: auto;
}

.account-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  background: var(--color-surface);
  border-radius: 4px;
  padding: var(--space-sm) var(--space-md);
  margin-bottom: var(--space-md);
}

.account-name,
.account-mask {
  /* 🧪 backstop: long institution/account names truncate with an ellipsis
     rather than wrapping. */
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-name {
  flex: 1;
  min-width: 0;
}

/* Holdings dashboard — populated holdings list (Phase 2, mirrors
   .account-list/.account-row's overflow/truncation pattern) */
.holding-list {
  /* 🧪 backstop: scrolls within the section instead of paginating/clipping
     for accounts with an unusually large number of positions. */
  max-height: 320px;
  overflow-y: auto;
  margin-bottom: var(--space-lg);
}

.holding-row {
  display: grid;
  grid-template-columns: minmax(120px, 2fr) 90px 110px 110px 150px;
  column-gap: var(--space-md);
  align-items: center;
  background: var(--color-surface);
  border-radius: 4px;
  padding: var(--space-sm) var(--space-md);
  margin-bottom: var(--space-md);
}

.holding-header {
  background: none;
  font-size: 14px;
  font-weight: 400;
  line-height: 1.5;
  margin-bottom: var(--space-sm);
}

.security-name {
  /* 🧪 backstop: long security/fund names truncate with an ellipsis; the
     full name is available via a title hover attribute in the view. */
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.holding-quantity,
.holding-value,
.holding-cost-basis,
.holding-gain {
  text-align: right;
}

.gain-positive { color: var(--color-positive); }
.gain-negative { color: var(--color-destructive); }

.view-toggle {
  display: flex;
  flex-wrap: wrap;
  row-gap: var(--space-sm);
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.view-toggle a {
  color: inherit;
  text-decoration: none;
}

.view-toggle a.active { color: var(--color-accent); font-weight: 600; }

/* PIPE-06 filter/sort bar on /jobs — mirrors .view-toggle's exact
   flex-row + active-accent pattern (UI-SPEC Component Notes). */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  row-gap: var(--space-sm);
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.filter-bar a.active { color: var(--color-accent); font-weight: 600; }

/* Grouped-by-account sections (D-13) — each account's .holding-list below
   already scrolls independently (🧪 backstop, reuses .account-list's
   max-height + overflow-y pattern), this just spaces sections apart. */
.account-group {
  margin-bottom: var(--space-lg);
}

.account-group h2 {
  font-size: 14px;
  font-weight: 400;
  line-height: 1.5;
  margin: 0 0 var(--space-sm);
}

.last-synced {
  font-size: 14px;
  margin: 0 0 var(--space-md);
}

/* Display role (32px/600) — new this phase, reserved for the net worth
   total figure above the trend chart (D-14). */
.net-worth-total {
  font-size: 32px;
  font-weight: 600;
  line-height: 1.2;
  margin-bottom: var(--space-sm);
}

.net-worth-chart {
  /* 🧪 backstop: fixed min-height reserves layout space so Chart.js's
     client-side render doesn't cause a layout shift on page load. */
  min-height: 240px;
  margin-bottom: var(--space-xl);
}

.form-field {
  margin-bottom: var(--space-md);
}

.form-field label {
  display: block;
  font-size: 14px;
  margin-bottom: var(--space-xs);
}

.form-field input {
  width: 100%;
  padding: var(--space-sm);
  box-sizing: border-box;
}

.btn-primary {
  background: var(--color-accent);
  color: #FFFFFF;
  border: none;
  border-radius: 4px;
  min-height: 44px;
  padding: 0 var(--space-lg);
  font-size: 16px;
  cursor: pointer;
}

.btn-primary:focus {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.btn-primary:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

/* Watchlist section (D-10/D-11) — first real use of the --space-2xl token,
   separating the watchlist from the holdings/sync section above it. */
.watchlist-section {
  margin-top: var(--space-2xl);
}

.watchlist-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-md);
}

.watchlist-card {
  background: var(--color-surface);
  border-radius: 4px;
  padding: var(--space-lg);
}

/* New 16px/600/1.5 size+weight combination (UI-SPEC Typography) — one step
   down from the 24px Heading role since this repeats once per card. */
.watchlist-ticker {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.5;
}

.watchlist-empty {
  margin-top: var(--space-md);
}

/* Reuses .gain-positive/.gain-negative (defined above under the holdings
   table) — no new color values. inline-flex + gap gives the currency
   figure and glyph/percent a consistent gap, matching .holding-gain's
   grid-item spacing without requiring watchlist-card to itself be a grid. */
.watchlist-quote {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
}

/* Remove-ticker control (WATCH-02) — no fill, color-only per UI-SPEC's
   accent-scarcity rule, but still hits the 44px minimum touch target via
   padding (not visual size) like every other interactive control this
   phase introduces. */
.link-destructive {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: var(--space-sm) 0;
  color: var(--color-destructive);
  text-decoration: none;
}

/* Notes/thesis expandable editor (WATCH-03, D-12) — native <details>/
   <summary>, no new JS controller, mirrors .reconnect-banner's idiom. */
.watchlist-notes {
  margin-top: var(--space-sm);
}

.watchlist-notes summary {
  display: flex;
  align-items: center;
  min-height: 44px;
  color: var(--color-accent);
  cursor: pointer;
}

.watchlist-notes textarea {
  width: 100%;
  min-height: 80px;
  padding: var(--space-sm);
  box-sizing: border-box;
  font-family: inherit;
  font-size: 16px;
}

/* Price alert set/clear editor (WATCH-06) — mirrors .watchlist-notes'
   <details>/<summary> idiom exactly, no new JS controller. */
.watchlist-alert {
  margin-top: var(--space-sm);
}

.watchlist-alert summary {
  display: flex;
  align-items: center;
  min-height: 44px;
  color: var(--color-accent);
  cursor: pointer;
}

.watchlist-alert input[type="number"] {
  width: 100%;
  padding: var(--space-sm);
  box-sizing: border-box;
  font-family: inherit;
  font-size: 16px;
}

/* Small "Triggered" pill next to .watchlist-ticker, once an alert has fired. */
.watchlist-alert-badge {
  display: inline-block;
  margin-left: var(--space-xs);
  padding: 2px var(--space-xs);
  border-radius: 4px;
  background: var(--color-accent);
  color: var(--color-surface);
  font-size: 12px;
  font-weight: 600;
}

/* Low-emphasis per-card action (accent-scarcity, UI-SPEC Color section) —
   no fill, underlined text, 44px touch target via padding not size. */
.btn-text {
  background: none;
  border: none;
  color: inherit;
  text-decoration: underline;
  min-height: 44px;
  padding: var(--space-sm) 0;
  font-size: 16px;
  cursor: pointer;
}

.btn-text:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

/* News headline section (WATCH-05, D-09) — 14px/400/1.5 Label role per
   UI-SPEC. Headline links are an explicit accent-scarcity exemption
   (alongside the one page-level "Add to Watchlist" CTA). */
.news-list {
  list-style: none;
  margin: var(--space-sm) 0 0;
  padding: 0;
}

.news-item {
  font-size: 14px;
  font-weight: 400;
  line-height: 1.5;
}

.news-item a {
  color: var(--color-accent);
}

.news-unavailable,
.news-empty {
  margin: var(--space-sm) 0 0;
  font-size: 14px;
  font-weight: 400;
  line-height: 1.5;
}

/* Market Health page — index stat tiles (MKT-01, D-05) */
.market-stat-row {
  display: flex;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
}

.market-stat-ticker {
  font-size: 14px;
  font-weight: 400;
  line-height: 1.5;
  display: block;
}

/* Same 16px/600/1.5 "bold body" combination as .watchlist-ticker — color
   codes only the change figure via .gain-positive/.gain-negative, never the
   ticker text. */
.market-stat-quote {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.5;
}

.market-index-chart {
  /* 🧪 backstop: identical values to .net-worth-chart — fixed min-height
     reserves layout space so Chart.js's client-side render doesn't cause a
     layout shift on page load. */
  min-height: 240px;
  margin-bottom: var(--space-xl);
}

/* Zero/sparse-history captions in place of the chart (RESEARCH.md
   Pitfall 2). Label role — inherits body text color, no muted/tertiary
   token exists yet in this app. */
.market-chart-note {
  font-size: 14px;
  font-weight: 400;
  line-height: 1.5;
  margin-top: var(--space-xs);
}

/* Sector Performance & Exposure section (MKT-02/MKT-03, D-09) — mirrors
   .watchlist-section's first use of the 2xl token. */
.sector-section {
  margin-top: var(--space-2xl);
}

/* Deliberately NO max-height/overflow-y (unlike .holding-list/.account-list)
   — cardinality is fixed at exactly 12 rows, never unbounded (UI-SPEC
   overflow row). */
.sector-list {
  margin-top: var(--space-md);
}

.sector-row {
  display: grid;
  grid-template-columns: minmax(140px, 1.5fr) 160px 90px 110px 130px;
  column-gap: var(--space-md);
  align-items: center;
  background: var(--color-surface);
  border-radius: 4px;
  padding: var(--space-sm) var(--space-md);
  margin-bottom: var(--space-md);
}

.sector-name {
  /* Reuses .security-name's truncate-with-ellipsis pattern — sector names
     are short/fixed GICS labels, so this is a backstop, not the expected
     case. */
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sector-sparkline {
  /* 🧪 backstop: fixed min-height reserves layout space so Chart.js's
     client-side render doesn't cause a layout shift on page load. */
  min-height: 48px;
}

.sector-change,
.sector-exposure-percent,
.sector-exposure-value {
  text-align: right;
}

.exposure-empty {
  margin-top: var(--space-md);
}

/* Market News section (MKT-04, D-13) — mirrors .sector-section/
   .watchlist-section's same 2xl-token spacing pattern. .news-list/
   .news-item/.news-empty/.news-unavailable reused verbatim from Phase 3 —
   no new declarations for those four classes. */
.market-news-section {
  margin-top: var(--space-2xl);
}

/* Ticker detail page (Phase 8, D-07) — current price/day-change above the
   chart, "Your Position" and "Recent News" sections below it. */
.security-price {
  font-size: 32px;
  font-weight: 600;
  line-height: 1.2;
  margin: 0 0 var(--space-xs);
}

.security-day-change {
  font-size: 16px;
  margin: 0 0 var(--space-lg);
}

.security-price-chart {
  /* 🧪 backstop: identical values to .net-worth-chart/.market-index-chart —
     fixed min-height reserves layout space so Chart.js's client-side render
     doesn't cause a layout shift on page load. */
  min-height: 240px;
  margin-bottom: var(--space-xl);
}

.security-position {
  background: var(--color-surface);
  border-radius: 4px;
  padding: var(--space-lg);
  margin-top: var(--space-2xl);
}

.security-news-section {
  margin-top: var(--space-2xl);
}

/* Persistent top nav tab bar (D-10/D-11, Phase 10) — copies .view-toggle's
   exact flex-row + active-accent pattern verbatim. Exactly two links,
   never a third. */
.tab-bar {
  display: flex;
  flex-wrap: wrap;
  row-gap: var(--space-sm);
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.tab-bar a {
  color: inherit;
  text-decoration: none;
}

.tab-bar a.active { color: var(--color-accent); font-weight: 600; }

/* Jobs source/level badge pills (PIPE-07, D-04) — Label-Semibold (14px/600),
   text color inherited (NOT accent) per UI-SPEC's accent-scarcity rule. */
.source-badge,
.level-badge {
  display: inline-block;
  background: var(--color-surface);
  padding: var(--space-xs);
  border-radius: 4px;
  font-size: 14px;
  font-weight: 600;
}

/* Jobs watchlist card long-value truncation (company/title/location) —
   copies .security-name's exact truncate-with-ellipsis declarations. */
.opening-field-truncate {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Jobs pipeline Kanban board (D-07/D-08, Plan 10-02) */
.pipeline-board {
  display: flex;
  gap: var(--space-md);
  overflow-x: auto;
}

.pipeline-column {
  background: var(--color-surface);
  border-radius: 4px;
  padding: var(--space-md);
  min-width: 260px;
  flex: 1;
}

.pipeline-column h3 {
  font-size: 14px;
  font-weight: 400;
  line-height: 1.5;
  margin: 0 0 var(--space-sm);
}

.pipeline-column-cards {
  /* 🧪 backstop: reuses .holding-list's max-height/overflow-y pattern for
     columns with an unusually large number of cards. */
  max-height: 320px;
  overflow-y: auto;
  /* G-10-1 fix: without a min-height, a childless column collapses to 0px
     box-model height and SortableJS has no droppable surface to register a
     drop into — roughly one card's worth of vertical space keeps every
     column droppable even when empty. */
  min-height: 88px;
}

/* G-10-1 fix: placeholder shown inside any active-status column with zero
   openings, so an empty column still has real visible content. */
.pipeline-column-empty {
  color: inherit;
  font-size: 13px;
  margin: 0;
  padding: var(--space-sm) 0;
}

.pipeline-card {
  background: var(--color-bg);
  border-radius: 4px;
  padding: var(--space-md);
  margin-bottom: var(--space-sm);
}

/* D-07 drag handle — inherited text color (not accent-reserved), the glyph
   alone conveys nothing to assistive tech so it always carries the
   aria-label set in the view. */
.pipeline-card-handle {
  display: inline-block;
  margin-right: var(--space-sm);
  color: inherit;
  cursor: grab;
}

.pipeline-empty {
  margin-top: var(--space-md);
}

/* Collapsed-by-default disclosure (D-09) — inverted from .reconnect-banner/
   .verification-banner, which default open. Destructive-colored heading
   since this is an outcome worth flagging, mirroring .reconnect-banner
   summary's idiom, not an accent-reserved action. */
.rejected-withdrawn {
  margin-top: var(--space-xl);
}

.rejected-withdrawn summary {
  display: flex;
  align-items: center;
  min-height: 44px;
  color: var(--color-destructive);
  cursor: pointer;
}

/* D-08 non-drag "Move to" fallback — plain select + submit, built and
   verified before any drag-drop code exists. */
.move-to-form {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-top: var(--space-sm);
}
