/*
 * 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);
}

.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;
  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; }

/* 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;
}

/* 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;
}
