/* ==========================================================================
   RobinGPT — Analyze Result Premium UI Layer (v2)
   ==========================================================================
   Scope: EVERYTHING here targets #investigateView and its existing
   descendants only (same IDs/classes js/app.js already wires up — no
   markup, no class names, no data-row-key attributes were changed to
   make this work). Nothing in this file touches backend, APIs, AI
   logic, routing, swap, bridge, wallet, or discover. It loads after
   css/style.css and css/swap-bridge.css and overrides/extends the
   report's presentation layer only.

   DIRECTION
   A single research report, not a dashboard of cards. Density over
   decoration: tight type scale, a real column grid, quiet borders
   instead of glow, hairline dividers used the way a terminal uses
   them — to separate rows of real numbers, not to pad space. Color is
   reserved for meaning (risk/positive/warning/critical) — never for
   flourish. The one deliberate signature is the score rail described
   in §4: a fixed-width vertical strip that keeps risk visible while
   scrolling, instead of one gauge that disappears after the fold.
   ========================================================================== */

/* --------------------------------------------------------------------
   0. Page shell
   -------------------------------------------------------------------- */
.investigate-view {
  max-width: 1180px;
  padding: 24px 24px 80px;
}

@media (min-width: 1040px) {
  /* Two-column research layout: primary column (identity, stats,
     summary, all analysis cards) + a slim sticky rail carrying the
     score. This is the signature layout move — the score stays in
     view as you read the report instead of being one card among many
     that scrolls away after the first screen. */
  .report-body {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 260px;
    grid-template-areas:
      "header  rail"
      "stats   rail"
      "main    rail";
    column-gap: 20px;
    align-items: start;
  }
  .report-header { grid-area: header; }
  .report-grid { grid-area: stats; }
  #scoreAndSummaryCards { grid-area: rail; position: sticky; top: 16px; display: flex; flex-direction: column; gap: 14px; }

  /* Everything else in reading order stacks in the main column. Using
     the natural DOM order (header/social/grid already placed by area,
     everything after report-grid falls into an implicit row) keeps
     this purely CSS — no JS/markup reordering required.
     Updated for the Analyze UX refinement's reorganized report order
     (Risk -> AI Verdict -> Launchpad -> Market -> Holder/Wallet/Security
     -> Creator -> Advanced): #aiReportBlock (AI Verdict), #launchpadCards,
     and #marketOverviewCards are new top-level sections and need this
     rule the same way every other direct child of .report-body's main
     column does — without it they fall to CSS Grid's implicit placement
     at this breakpoint, which can overlap the sticky score rail instead
     of staying in the main column. #dataAnalysisCards was removed (its
     one child, executiveSummaryCard, moved into #primaryAnalysisCards —
     see index.html). #tokenChartCard/#recentTransactionsCard were
     removed from this list on purpose: they're no longer direct children
     of .report-body — they're nested inside #marketOverviewCards /
     #advancedAnalysisCards respectively, so their parent's grid-column
     rule already positions them; listing a non-direct-child here would
     be a no-op, not a duplicate safeguard. */
  .report-social-row,
  .powered-by-tag,
  .show-more-stats-btn,
  #aiReportBlock,
  #launchpadCards,
  #marketOverviewCards,
  .token-source-row,
  .quick-actions,
  .quick-questions,
  #primaryAnalysisCards,
  #creatorIntelCard,
  .show-advanced-btn,
  #advancedAnalysisCards {
    grid-column: 1;
  }
}

/* --------------------------------------------------------------------
   1. Progress checklist (pre-skeleton loading state)
   -------------------------------------------------------------------- */
.investigate-progress {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 380px;
  margin: 16px auto 32px;
  padding: 16px 18px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  opacity: 1;
  max-height: 220px;
  overflow: hidden;
  transition: opacity 0.35s var(--ease), max-height 0.4s var(--ease), margin 0.35s var(--ease), padding 0.35s var(--ease), border-color 0.35s var(--ease);
}
/* Priority 2: same collapse-on-completion behavior as style.css's base
   rule — kept in sync here since this file's box styling (border/
   background/padding) loads after and wins the cascade. */
.investigate-progress.is-done {
  opacity: 0;
  max-height: 0;
  margin: 0 auto;
  padding: 0 18px;
  border-color: transparent;
  pointer-events: none;
}
.progress-step {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12.5px;
  font-family: var(--font-mono);
  color: var(--text-tertiary);
  transition: color 0.2s var(--ease);
}
.progress-step-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1.5px solid var(--border-strong);
  font-size: 10px;
  color: transparent;
  flex-shrink: 0;
  transition: all 0.2s var(--ease);
}
.progress-step.active { color: var(--text-primary); }
.progress-step.active .progress-step-icon {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-dim);
  animation: rg-step-pulse 1.1s ease-in-out infinite;
}
.progress-step.done { color: var(--text-secondary); }
.progress-step.done .progress-step-icon {
  border-color: var(--primary);
  background: var(--primary);
  color: var(--bg);
}
@keyframes rg-step-pulse {
  0%, 100% { box-shadow: 0 0 0 3px var(--primary-dim); }
  50% { box-shadow: 0 0 0 5px transparent; }
}

/* --------------------------------------------------------------------
   2. Token header — identity block
   -------------------------------------------------------------------- */
.report-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  margin-bottom: 14px;
}
.report-token-id { display: flex; align-items: center; gap: 14px; min-width: 0; }
.report-token-avatar {
  width: 46px;
  height: 46px;
  border-radius: 11px;
  font-size: 17px;
  box-shadow: 0 0 0 1px var(--border-strong);
  flex-shrink: 0;
}
.report-token-id-text { min-width: 0; }
.report-token-name {
  font-size: 18px;
  line-height: 1.25;
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}
.report-token-addr {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  cursor: default;
  transition: color 0.15s var(--ease);
}
.report-token-addr:hover { color: var(--text-secondary); }

.report-header-badges {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  flex-shrink: 0;
  padding-top: 2px;
}
.report-chain-pill {
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.launchpad-header-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.01em;
  background: var(--primary-dim);
  color: var(--primary-2);
  border: 1px solid rgba(0, 200, 5, 0.25);
  white-space: nowrap;
}
.launchpad-header-badge::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--primary-2);
}

.verified-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px;
  height: 15px;
  color: var(--primary-2);
  flex-shrink: 0;
}

.powered-by-tag {
  margin: 0 0 14px;
  opacity: 0.6;
  font-size: 11px;
}

.report-social-row { margin: 0 0 16px; display: flex; flex-wrap: wrap; gap: 8px; }
.social-btn {
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 12.5px;
  border: 1px solid var(--border);
  background: var(--surface);
  transition: border-color 0.15s var(--ease), background 0.15s var(--ease);
}
.social-btn:hover {
  border-color: var(--border-strong);
  background: var(--surface-hover);
}

/* --------------------------------------------------------------------
   3. Stat grid — dense, scannable, address-bar for the token
   -------------------------------------------------------------------- */
.report-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
  gap: 1px;
  margin-bottom: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--border);
  overflow: hidden;
}
.report-stat {
  background: var(--surface);
  border: none;
  border-radius: 0;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: background 0.15s var(--ease);
}
.report-stat:hover {
  background: var(--surface-hover);
  transform: none;
  box-shadow: none;
}
.report-stat-label {
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
}
.report-stat-value {
  font-family: var(--font-mono);
  font-size: 14.5px;
  font-weight: 600;
  margin-top: 0;
  overflow-wrap: anywhere;
}
.report-stat--secondary { background: var(--surface); }
.report-stat[data-field="volume"] .report-stat-value,
.report-stat[data-field="liquidity"] .report-stat-value,
.report-stat[data-field="marketCap"] .report-stat-value {
  color: var(--text-primary);
}

/* --------------------------------------------------------------------
   4. Score rail — RobinGPT Score + Summary. Sticky on desktop (see
      §0), stacked normally on mobile. Score card is compact and
      number-led; the arc is a confirming glance, not the headline.
   -------------------------------------------------------------------- */
#scoreAndSummaryCards { margin-bottom: 16px; }

#riskScoreCard {
  padding: 18px;
  border-radius: 12px;
  text-align: center;
}
#riskScoreCard .report-card-head {
  justify-content: center;
  font-size: 11.5px;
  margin-bottom: 10px;
}
.score-gauge { margin: 2px 0 4px; }
.score-value { font-size: 27px; }
.score-label {
  font-size: 12.5px;
  font-weight: 600;
  margin-top: 4px;
}
#riskRecommendationText {
  font-size: 12.5px !important;
  line-height: 1.6;
  color: var(--text-secondary);
  text-align: left;
  margin-top: 12px !important;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.score-reasons {
  text-align: left;
  margin-top: 10px;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.live-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 6px var(--primary-glow);
  animation: rg-pulse 2.4s ease-in-out infinite;
}
@keyframes rg-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* RobinGPT Summary — reads as an insight panel: Overview line implicit
   in the card head, then a scannable strengths/warnings list. Icon
   bullets keep it compact rather than long paragraph copy. */
#aiSummaryCard {
  padding: 16px 18px;
  border-radius: 12px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
}
#aiSummaryCard .report-card-head { font-size: 11.5px; margin-bottom: 10px; }
.ai-summary-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.ai-summary-list li {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--bg-elev-1);
  font-size: 12.5px;
  line-height: 1.5;
}
.ai-summary-list li.positive { background: var(--primary-dim); }
.ai-summary-list li.warning { background: var(--warning-dim); }
.ai-summary-list li.critical { background: var(--danger-dim); }
.ai-summary-icon {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  font-size: 10px;
  font-weight: 700;
  margin-top: 1px;
}
.ai-summary-list li.positive .ai-summary-icon { background: var(--primary); color: #06210a; }
.ai-summary-list li.warning .ai-summary-icon { background: var(--warning); color: #2a1d00; }
.ai-summary-list li.critical .ai-summary-icon { background: var(--danger); color: #2a0a0a; }

/* --------------------------------------------------------------------
   4.5. AI Verdict — the pre-existing "Generate AI Report" feature
   (button + Overview/Strengths/Risks/Recommendation/Confidence cards,
   #aiReportBlock in index.html) moved from the bottom of the report up
   to right after the score, matching its new weight in the report's
   reading order (Analyze UX refinement). The button/card styling itself
   is untouched (css/style.css's .generate-ai-btn/.ai-report-cta-note/
   .ai-report-error — still real, working, on-demand AI generation, not
   duplicated or rebuilt here) — this only fits its spacing to sit
   naturally under the score card instead of as an isolated block at
   the page's end.
   -------------------------------------------------------------------- */
#aiReportBlock { margin: 4px 0 4px; }
#aiReportBlock .generate-ai-btn { margin-bottom: 4px; }

/* --------------------------------------------------------------------
   5. Analysis cards — the consistent card system every section below
      the fold uses. One border weight, one radius, one head style,
      one row rhythm. No card gets special-case padding or type sizes
      anymore; visual weight comes from position/order, not from a
      card styling itself louder than its neighbors.
   -------------------------------------------------------------------- */
.report-cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 16px; }
.report-card {
  padding: 16px 18px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  transition: border-color 0.15s var(--ease);
}
.report-card:hover { border-color: var(--border-strong); box-shadow: none; transform: none; }
.report-card--wide { grid-column: 1 / -1; }
.report-card--compact { padding: 14px 16px; }
.report-card-head {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-tertiary);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.report-card--compact .report-card-head { margin-bottom: 8px; }

/* Executive Summary reads as prose inside the same card system — no
   special gradient treatment, it earns attention by being first in
   reading order, not by looking different from its neighbors. */
#executiveSummaryCard .summary-text { font-size: 13.5px; line-height: 1.7; }

/* Data rows — the backbone of every analysis card */
.data-row { padding: 8px 0; border-bottom: 1px solid var(--border); }
.data-row:last-of-type { border-bottom: none; padding-bottom: 0; }
.data-row-label { font-size: 12.5px; color: var(--text-secondary); }
.data-row-value { font-size: 12.5px; font-weight: 600; }
.report-card--compact .data-row { padding: 6px 0; font-size: 12.5px; }

/* Holder bars — thinner, quieter track */
.holder-metric { padding: 9px 0 10px; border-bottom: 1px solid var(--border); }
.holder-metric:last-child { border-bottom: none; }
.holder-metric .data-row { border-bottom: none; padding: 0 0 6px; }
.holder-bar-track {
  height: 5px;
  border-radius: 3px;
  background: var(--bg-elev-1);
  overflow: hidden;
}
.holder-bar-fill {
  height: 100%;
  border-radius: 3px;
  background: var(--primary-2);
  transition: width 0.5s var(--ease);
}
.holder-bar-fill.level-moderate { background: var(--warning); }
.holder-bar-fill.level-high { background: var(--danger); }

.metric-tip {
  font-size: 11.5px;
  color: var(--text-tertiary);
  line-height: 1.5;
  margin: 10px 0 0;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

/* Security / Wallet Risk flag lists */
.risk-flags { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.risk-flags li {
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--bg-elev-1);
  font-size: 12.5px;
  line-height: 1.5;
}
.risk-flags li.critical { background: var(--danger-dim); }
.risk-flags li.warning { background: var(--warning-dim); }
.risk-flags li.positive { background: var(--primary-dim); }

.risk-pill {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 4px 10px;
  border-radius: 999px;
}

/* Chart placeholder — honest, not decorative */
#tokenChartCard { margin-bottom: 12px; }
.chart-placeholder {
  padding: 32px 16px;
  text-align: center;
  font-size: 12.5px;
  color: var(--text-tertiary);
  border: 1px dashed var(--border-strong);
  border-radius: 10px;
}

#recentTransactionsCard { margin-bottom: 12px; }
.recent-tx-list { list-style: none; margin: 0; padding: 0; }

/* --------------------------------------------------------------------
   6. Quick actions & quick questions
   -------------------------------------------------------------------- */
.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 14px 0;
  border-top: 1px solid var(--border);
  margin-top: 4px;
}
.quick-action-btn {
  padding: 9px 15px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 12.5px;
  border: 1px solid var(--border);
  background: transparent;
  transition: border-color 0.15s var(--ease), background 0.15s var(--ease), transform 0.15s var(--ease);
}
.quick-action-btn:hover {
  border-color: var(--border-strong);
  background: var(--surface-hover);
  transform: translateY(-1px);
}
.quick-action-btn--utility { background: var(--surface); margin-left: 0; opacity: 1; }
.quick-action-btn.copied {
  background: var(--primary-dim);
  border-color: rgba(0, 200, 5, 0.35);
  color: var(--primary-2);
}
.trade-btn.quick-action-btn {
  background: var(--primary-dim);
  border-color: rgba(0, 200, 5, 0.3);
  color: var(--primary-2);
}

.quick-questions {
  margin-top: 4px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.quick-questions-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-tertiary);
  margin-bottom: 9px;
}
.quick-questions-pills { display: flex; flex-wrap: wrap; gap: 7px; }
.quick-question-pill {
  padding: 7px 13px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s var(--ease), color 0.15s var(--ease);
}
.quick-question-pill:hover {
  border-color: rgba(0, 200, 5, 0.35);
  color: var(--primary-2);
}

/* --------------------------------------------------------------------
   7. Show more / Show advanced toggles
   -------------------------------------------------------------------- */
.show-advanced-btn, .show-more-stats-btn {
  border-radius: 8px;
  font-size: 12.5px;
  padding: 10px;
  border: 1px solid var(--border);
  background: transparent;
  transition: background 0.15s var(--ease), border-color 0.15s var(--ease);
}
.show-advanced-btn:hover, .show-more-stats-btn:hover {
  background: var(--surface);
  border-color: var(--border-strong);
}

/* --------------------------------------------------------------------
   8. Loading skeleton
   -------------------------------------------------------------------- */
.skeleton-text {
  border-radius: 5px;
  min-width: 48px;
  display: inline-block;
}
.report-stat-value.skeleton-text { height: 15px; min-width: 56px; }
.report-token-name.skeleton-text,
.report-chain-pill.skeleton-text { min-width: 90px; }

/* --------------------------------------------------------------------
   9. Error state — calm, centered, one recovery action
   -------------------------------------------------------------------- */
.report-error {
  padding: 56px 22px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  max-width: 440px;
  margin: 36px auto;
  text-align: center;
}
.report-error::before {
  content: "!";
  display: block;
  width: 44px;
  height: 44px;
  margin: 0 auto 16px;
  border-radius: 12px;
  background: var(--danger-dim);
  color: var(--danger);
  font-size: 19px;
  font-weight: 700;
  line-height: 44px;
}
.report-error-title { font-size: 17px; margin-bottom: 6px; }
.report-error-text { font-size: 13px; margin-bottom: 22px; }
.report-error .ghost-btn.accent {
  padding: 10px 20px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 13px;
}

/* --------------------------------------------------------------------
   10. Empty state — before any address has been submitted
   -------------------------------------------------------------------- */
@supports selector(:has(*)) {
  #reportRoot:has(#reportBody.hidden):has(#reportError.hidden)::after {
    content: "Paste a contract address above to generate an on-chain analysis report.";
    display: block;
    text-align: center;
    color: var(--text-tertiary);
    font-size: 13px;
    padding: 64px 24px;
    border: 1px dashed var(--border-strong);
    border-radius: 12px;
    margin: 16px 0;
  }
}

/* --------------------------------------------------------------------
   11. Mobile — thumb-friendly, single column, no horizontal scroll
   -------------------------------------------------------------------- */
@media (max-width: 1039px) {
  #scoreAndSummaryCards { position: static; }
}

@media (max-width: 768px) {
  .investigate-view { padding: 16px 14px 64px; }

  .report-header {
    padding: 14px;
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  .report-header-badges { padding-top: 0; }
  .report-token-avatar { width: 42px; height: 42px; border-radius: 10px; }
  .report-token-name { font-size: 16.5px; }

  .report-grid { grid-template-columns: repeat(2, 1fr); }
  .report-stat { padding: 11px 12px; }
  .report-stat-value { font-size: 13.5px; }

  .report-cards { grid-template-columns: 1fr; gap: 10px; }
  .report-card { padding: 14px 16px; }

  #riskScoreCard { padding: 16px; }
  .score-value { font-size: 24px; }

  /* Quick actions become a thumb-friendly two-column grid instead of
     a wrapped inline row — every button gets a consistent, tappable
     hit area at this width. */
  .quick-actions {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
  .quick-action-btn {
    justify-content: center;
    padding: 12px 10px;
    font-size: 12.5px;
  }
  .quick-action-btn--utility { margin-left: 0; }

  .report-error { padding: 44px 18px; margin: 20px auto; }
}

@media (max-width: 420px) {
  .report-grid { grid-template-columns: repeat(2, 1fr); }
  .quick-actions { grid-template-columns: 1fr 1fr; }
  .report-token-id { gap: 11px; }
}

/* --------------------------------------------------------------------
   12. Motion — respect the existing reduced-motion rule
   -------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .progress-step.active .progress-step-icon,
  .live-dot { animation: none; }
}
