/* Cortalyst theme tokens. Light is the default (bare :root); dark - the
   original look, lifted from the static signal report retired in Phase 7 -
   is opted into via [data-theme="dark"] on <html>, toggled in _Layout.cshtml
   and persisted to localStorage. Every color used anywhere in this file
   comes from one of these two token sets - never a literal that only reads
   correctly on one background. */

:root {
  --bg: #f4f6fb;
  --card-bg: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --muted-2: #94a3b8;
  --body-text: #334155;
  --link: #2563eb;
  --link-hover: #1d4ed8;
  --accent-a: #2563eb;
  --accent-b: #22d3ee;
  --buy-bg: #dcfce7;
  --buy-text: #15803d;
  --sell-bg: #fee2e2;
  --sell-text: #b91c1c;
  --neutral-bg: #eef2f7;
  --neutral-text: #475569;
  --watch-bg: #fef3c7;
  --watch-text: #92400e;
  --info-bg: #dbeafe;
  --info-text: #1d4ed8;
  --panel-bg: rgba(15, 23, 42, .035);
  --panel-border: rgba(15, 23, 42, .09);
  --card-shadow: 0 18px 40px rgba(15, 23, 42, .08);
  --row-stripe: rgba(15, 23, 42, .025);
  --google-btn-bg: #ffffff;
  --google-btn-border: #dadce0;
  --google-btn-text: #3c4043;
  --google-btn-hover-bg: #f8f9fa;
}

:root[data-theme="dark"] {
  --bg: #020617;
  --card-bg: #0f172a;
  --border: #1e293b;
  --text: #ffffff;
  --muted: #94a3b8;
  --muted-2: #64748b;
  --body-text: #cbd5e1;
  --link: #22d3ee;
  --link-hover: #7dd3fc;
  --accent-a: #2563eb;
  --accent-b: #22d3ee;
  --buy-bg: rgba(34, 197, 94, .14);
  --buy-text: #86efac;
  --sell-bg: rgba(239, 68, 68, .14);
  --sell-text: #fca5a5;
  --neutral-bg: rgba(148, 163, 184, .14);
  --neutral-text: #cbd5e1;
  --watch-bg: rgba(234, 179, 8, .16);
  --watch-text: #fde68a;
  --info-bg: rgba(37, 99, 235, .16);
  --info-text: #93c5fd;
  --panel-bg: rgba(2, 6, 23, .35);
  --panel-border: rgba(30, 41, 59, .75);
  --card-shadow: 0 18px 50px rgba(15, 23, 42, .35);
  --row-stripe: rgba(255, 255, 255, .02);
  --google-btn-bg: #131314;
  --google-btn-border: #5f6368;
  --google-btn-text: #e8eaed;
  --google-btn-hover-bg: #1e1f20;
}

html, body {
  background: var(--bg);
  color: var(--text);
}

/* The cookie banner is a sticky flex item pinned to the viewport bottom, so
   it always covers that strip regardless of scroll position. Native
   scroll-into-view (keyboard focus, anchor jumps, and Selenium's
   pre-click scroll alike) doesn't know that and will stop scrolling as
   soon as a target element is nominally within the viewport bounds, even
   if the banner still visually covers it. scroll-padding-bottom tells the
   browser to always leave this much room at the bottom when scrolling a
   target into view. Sized generously for the banner's two-line wrap on
   narrow viewports, not just its single-line height. */
html {
  scroll-padding-bottom: 110px;
}

body {
  margin: 0;
  font-family: Inter, Arial, sans-serif;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

a {
  color: var(--link);
}

a:hover {
  color: var(--link-hover);
}

.page {
  /* width: 100% (not just max-width) matters here: .page is a flex item of
     body's column flex context with no explicit width, and any descendant
     using CSS Grid auto-fit/minmax (see .grid below) can't resolve its own
     column count without a *definite* ancestor width - stretch alone isn't
     enough, so without this the whole chain collapses to the grid's
     minimum track size instead of expanding to fill the viewport. */
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 24px;
}

/* Only the main content wrapper needs breathing room before the footer -
   .page alone (navbar, footer) shouldn't carry it too. */
main.page {
  padding-bottom: 70px;
  /* Fills the remaining height in the flex-column body, so the footer (and
     the cookie banner below it) sit at the bottom on short pages instead of
     riding up under the content. */
  flex: 1 0 auto;
}

/* Navbar - deliberately full-width with its own left/right anchoring
   (brand at the true left edge, auth controls at the true right edge)
   instead of sharing .page's centered, width-capped column: that column
   is right for body copy, but on a navbar it left the whole nav cluster
   floating with uneven gaps on wide screens instead of hugging the edges. */
.navbar {
  background: var(--card-bg) !important;
  border-bottom: 1px solid var(--border) !important;
  box-shadow: none !important;
}

.navbar-inner {
  width: 100%;
  justify-content: space-between;
  padding: 0 24px;
  gap: 12px;
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 900;
  color: var(--text) !important;
  letter-spacing: -0.5px;
}

.navbar-brand img {
  border-radius: 8px;
}

.navbar .nav-link {
  color: var(--muted) !important;
}

.navbar .nav-link:hover {
  color: var(--text) !important;
}

.navbar-toggler {
  border-color: var(--border) !important;
}

/* Bootstrap's default toggler icon is dark - correct as-is on the light
   navbar, but needs inverting to read against the dark theme's navbar. */
:root[data-theme="dark"] .navbar-toggler-icon {
  filter: invert(1) grayscale(100%) brightness(2);
}

/* Theme toggle - the icon reflects the current mode (sun while light, moon
   while dark); clicking flips both the mode and the icon. */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}

.theme-toggle:hover {
  background: var(--border);
  color: var(--text);
}

.theme-toggle svg {
  width: 18px;
  height: 18px;
}

.theme-toggle .icon-moon {
  display: none;
}

:root[data-theme="dark"] .theme-toggle .icon-sun {
  display: none;
}

:root[data-theme="dark"] .theme-toggle .icon-moon {
  display: block;
}

/* Signed-in greeting + settings cog, next to the theme toggle in the header */
.greeting {
  color: var(--muted);
  cursor: default;
}

.settings-cog {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border);
  color: var(--muted);
  transition: background .15s ease, color .15s ease;
}

.settings-cog:hover {
  background: var(--border);
  color: var(--text);
}

.settings-cog svg {
  width: 18px;
  height: 18px;
}

/* Hero */
.hero {
  background: linear-gradient(135deg, rgba(37, 99, 235, .28), rgba(34, 211, 238, .12));
  border: 1px solid var(--border);
  border-radius: 28px;
  padding: 30px;
  margin: 36px 0 34px;
}

.hero h1 {
  margin: 0;
  font-size: 42px;
  font-weight: 900;
  letter-spacing: -1.2px;
}

.hero p {
  color: var(--body-text);
  font-size: 17px;
  line-height: 1.6;
  max-width: 780px;
}

/* Dashboard / Settings tabs (Bootstrap nav-tabs, retokened for both themes) */
.cortalyst-tabs {
  margin-top: 28px;
  border-bottom: 1px solid var(--border);
  gap: 4px;
}

.cortalyst-tabs .nav-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  border: 1px solid transparent;
  border-top-left-radius: 8px;
  border-top-right-radius: 8px;
  font-weight: 600;
  padding: 10px 18px;
}

.tab-lock-icon {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
  color: var(--muted-2);
}

.cortalyst-tabs .nav-link:hover {
  color: var(--text);
  border-color: var(--border) var(--border) transparent;
}

.cortalyst-tabs .nav-link.active {
  color: var(--text);
  background: var(--card-bg);
  border-color: var(--border) var(--border) var(--card-bg);
}

.cortalyst-tab-content {
  padding-top: 28px;
}

/* Settings (Account / My Watchlist / My Industries left-nav shell) */
.settings-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 32px;
  align-items: start;
}

.settings-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 24px;
}

.settings-nav-link {
  padding: 10px 14px;
  border-radius: 10px;
  color: var(--body-text);
  font-weight: 600;
  text-decoration: none;
}

.settings-nav-link:hover {
  background: var(--panel-bg);
  color: var(--text);
}

.settings-nav-link.active {
  background: var(--card-bg);
  border: 1px solid var(--border);
  color: var(--accent-a);
}

.settings-nav-upgrade-hint {
  padding: 10px 14px;
  color: var(--accent-a);
  font-weight: 600;
  font-size: 13px;
}

.settings-content {
  min-width: 0;
}

@media (max-width: 760px) {
  .settings-layout {
    grid-template-columns: 1fr;
  }

  .settings-nav {
    position: static;
    flex-direction: row;
    flex-wrap: wrap;
  }
}

/* Lightweight list rows (Settings' list-management pages) */
.list-rows {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.list-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.list-row .symbol {
  min-width: 70px;
  font-weight: 800;
}

.list-row .subtle {
  flex: 1;
}

.list-row .btn {
  margin-left: auto;
}

/* Settings field blocks: read-only view by default, pencil icon reveals
   the edit form in place. */
.field-block .field-edit {
  display: none;
}

.field-block.editing .field-view {
  display: none;
}

.field-block.editing .field-edit {
  display: block;
}

.field-view-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.field-rows {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.field-label {
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
}

.field-value {
  font-size: 16px;
  color: var(--text);
  margin-top: 2px;
}

.edit-icon-btn {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}

.edit-icon-btn:hover {
  background: var(--border);
  color: var(--text);
}

.edit-icon-btn svg {
  width: 16px;
  height: 16px;
}

/* Homepage demo video */
.video-frame {
  position: relative;
  border-radius: 20px;
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--card-shadow);
  background: #000;
  line-height: 0;
}

.video-frame video {
  display: block;
  width: 100%;
  height: auto;
}

.video-play-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: rgba(0, 0, 0, .15);
  cursor: pointer;
  transition: background .15s ease;
}

.video-play-overlay:hover {
  background: rgba(0, 0, 0, .3);
}

.video-play-overlay svg {
  width: 72px;
  height: 72px;
  color: #fff;
  filter: drop-shadow(0 2px 10px rgba(0, 0, 0, .5));
}

/* Cookie notice banner */
/* A real flex item at the end of the (flex-column) body, not a fixed
   overlay - reserves its own space so it can never cover other content,
   including on pages short enough to fit without scrolling. position:
   sticky still keeps it pinned to the viewport bottom while scrolling on
   longer pages. */
.cookie-banner {
  position: sticky;
  bottom: 0;
  z-index: 1050;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 14px 24px;
  background: var(--card-bg);
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 16px rgba(15, 23, 42, .08);
}

.cookie-banner p {
  margin: 0;
  max-width: 720px;
  font-size: 14px;
  color: var(--body-text);
  text-align: center;
}

/* Sections */
.section {
  margin-top: 42px;
}

.section-title {
  font-size: 26px;
  font-weight: 900;
  margin: 0 0 18px;
}

h1, h2, h3, h4, h5, .h1, .h2, .h3, .h4, .h5 {
  color: var(--text) !important;
}

h1 {
  font-weight: 900;
  letter-spacing: -0.5px;
}

.text-muted {
  color: var(--muted) !important;
}

/* Card grid - the main building block for signal/candidate listings */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 18px;
}

/* Login/Register: a fixed-width, centered column instead of .grid's
   auto-fit listing layout, which was never meant for a 1-2 item form -
   on a wide viewport it left the form pinned to a minimum-size column
   instead of behaving like a login card. */
.auth-grid {
  display: grid;
  grid-template-columns: minmax(0, 420px);
  justify-content: center;
  gap: 18px;
}

.card, .cortalyst-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 22px;
  box-shadow: var(--card-shadow);
  /* Baseline for any text inside a card that doesn't set its own color -
     Bootstrap's .card component sets a muted default (--bs-card-color)
     that doesn't track our own theme tokens, so it goes stale when the
     theme is toggled unless we override it explicitly here. */
  color: var(--text);
}

.card-top {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.symbol {
  font-size: 22px;
  font-weight: 900;
  color: var(--text) !important;
}

.subtle {
  color: var(--muted);
  font-size: 14px;
}

.text-block {
  color: var(--body-text);
  line-height: 1.55;
  font-size: 14px;
  margin-top: 12px;
}

/* Mobile-only accordion for dashboard signal cards: collapsed by default
   with a one-line reasoning/evidence preview so there's a reason to tap,
   not just a bare chevron. Desktop (above the breakpoint) always shows
   .card-detail in full and never renders the summary row's flex layout. */
.card-mobile-summary {
  display: none;
}

@media (max-width: 700px) {
  .card-mobile-summary {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    margin-top: 4px;
    padding: 0;
    border: none;
    background: none;
    font: inherit;
    text-align: left;
    cursor: pointer;
  }

  .card-mobile-summary .preview-text {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--muted);
    font-size: 14px;
  }

  .card-mobile-summary .chevron {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    color: var(--muted);
    transition: transform .15s ease;
  }

  .card.expanded .card-mobile-summary .chevron {
    transform: rotate(180deg);
  }

  .card-detail {
    display: none;
  }

  .card.expanded .card-detail {
    display: block;
  }
}

.text-block strong {
  color: var(--text);
}

/* Badges - remaps Bootstrap's bg-* utility badges to the report's
   buy/sell/neutral/watch palette so existing markup doesn't need to change
   class-by-class. */
.badge {
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.badge.bg-success { background: var(--buy-bg) !important; color: var(--buy-text) !important; }
.badge.bg-danger { background: var(--sell-bg) !important; color: var(--sell-text) !important; }
.badge.bg-secondary { background: var(--neutral-bg) !important; color: var(--neutral-text) !important; }
.badge.bg-warning { background: var(--watch-bg) !important; color: var(--watch-text) !important; }
.badge.bg-info { background: var(--info-bg) !important; color: var(--info-text) !important; }
.badge.bg-primary { background: var(--accent-a) !important; color: #fff !important; }

.tech-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

/* Confidence bar */
.confidence {
  margin: 16px 0;
}

.bar {
  height: 9px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 8px;
}

.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-a), var(--accent-b));
}

/* Historical performance rows */
.history {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.history-title {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.history-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.history-item {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 9px 10px;
}

.history-label {
  color: var(--muted);
  font-size: 11px;
  margin-bottom: 5px;
}

.history-signal {
  font-size: 12px;
  font-weight: 900;
}

.history-return {
  margin-top: 5px;
  font-size: 13px;
  font-weight: 900;
}

@media (max-width: 520px) {
  .history-row {
    grid-template-columns: 1fr;
  }
}

.positive { color: var(--buy-text); }
.negative { color: var(--sell-text); }
.flat { color: var(--neutral-text); }

/* Earnings cards */
.earnings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}

.earnings-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 20px;
}

.earnings-metrics {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-top: 16px;
}

.metric {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 12px;
}

.metric-label {
  color: var(--muted);
  font-size: 12px;
}

.metric-value {
  margin-top: 4px;
  font-size: 17px;
  font-weight: 900;
}

/* Forms and inputs */
.form-control, .form-select {
  background: var(--bg) !important;
  border: 1px solid var(--border) !important;
  color: var(--text) !important;
}

/* No !important here on purpose: Bootstrap's floating-label placeholder
   rule (.form-floating > .form-control::placeholder, higher specificity)
   needs to keep winning inside form-floating fields - it hides the native
   placeholder so it doesn't overlap the floating label. This rule still
   applies to plain (non-floating) inputs like the watchlist search box. */
.form-control::placeholder {
  color: var(--muted-2);
}

.form-control:focus, .form-select:focus {
  border-color: var(--accent-a) !important;
  box-shadow: 0 0 0 0.2rem rgba(37, 99, 235, .25) !important;
}

.form-label, .form-check-label {
  color: var(--muted);
}

.form-check-input {
  background-color: var(--bg);
  border-color: var(--border);
}

.form-check-input:checked {
  background-color: var(--accent-a);
  border-color: var(--accent-a);
}

/* Buttons */
.btn-primary {
  background: var(--accent-a);
  border: none;
  font-weight: 700;
}

.btn-primary:hover, .btn-primary:focus {
  filter: brightness(1.1);
}

.btn-secondary {
  background: var(--card-bg);
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-secondary:hover {
  background: var(--border);
  color: var(--text);
}

.btn-outline-danger {
  color: var(--sell-text);
  border-color: rgba(239, 68, 68, .4);
}

.btn-outline-danger:hover {
  background: var(--sell-bg);
  color: var(--sell-text);
  border-color: rgba(239, 68, 68, .6);
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 0.2rem rgba(37, 99, 235, .3);
}

/* Google sign-in button, kept close to Google's official branding
   guidelines rather than the site's usual button styles - straying far
   from their spec undercuts the recognizability it's meant to provide. */
.google-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  padding: 10px 16px;
  border-radius: 6px;
  border: 1px solid var(--google-btn-border);
  background: var(--google-btn-bg);
  color: var(--google-btn-text);
  font-weight: 600;
  font-size: 15px;
  font-family: Inter, Arial, sans-serif;
  cursor: pointer;
  transition: background .15s ease, box-shadow .15s ease;
}

.google-btn:hover, .google-btn:focus {
  background: var(--google-btn-hover-bg);
  color: var(--google-btn-text);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .15);
}

.google-btn-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* Tables (kept for a handful of data-dense pages) */
.table {
  color: var(--text);
  border-color: var(--border);
}

.table > :not(caption) > * > * {
  background: var(--card-bg);
  color: var(--text);
  border-bottom-color: var(--border);
  box-shadow: none;
}

.table-striped > tbody > tr:nth-of-type(odd) > * {
  background: var(--row-stripe);
  color: var(--text);
}

.table thead th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
  border-bottom: 1px solid var(--border);
}

/* Lists (symbol search results) */
.list-group-item {
  background: var(--card-bg);
  border-color: var(--border);
  color: var(--text);
}

.list-group-item-action:hover, .list-group-item-action:focus {
  background: var(--border);
  color: var(--text);
}

/* Alerts */
.alert-warning {
  background: var(--watch-bg);
  border: 1px solid rgba(234, 179, 8, .35);
  color: var(--watch-text);
}

/* Footer */
.site-footer {
  margin-top: 48px;
  color: var(--muted-2);
  font-size: 13px;
  border-top: 1px solid var(--border);
  padding: 24px 0;
}

.site-footer a {
  color: var(--muted-2);
}
