/* ──────────────────────────────────────────────────────────────
   GWS Stock Insight — public/preview view (v2 spec renderer).
   Loaded for both the public detail panel and the builder Preview
   mode. Models the PDF brand template: dark teal section titles,
   IBM Plex typography, generous spacing, charts inline.
   ────────────────────────────────────────────────────────────── */

.gws-pubview {
    background: #fff;
    color: #1e293b;
    font-family: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    padding: 0 4px;
}

/* ── Hero header (single source of truth for ticker + name) ── */
.gws-pubview-header {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 18px;
    padding: 6px 0 18px;
    margin-bottom: 4px;
    border-bottom: 1px solid #e2e8f0;
}
.gws-pubview-title { flex: 1; min-width: 0; }
.gws-pubview-title h1 {
    margin: 0 0 6px;
    font-size: 1.65rem;
    font-weight: 600;
    color: #0f172a;
    letter-spacing: -0.01em;
    line-height: 1.2;
}
.gws-pubview-subtitle {
    font-size: 0.88rem;
    color: #64748b;
}
/* Secondary identity line — ISIN · Sector · Currency · Exchange.
   Smaller, more muted than the primary subtitle so it reads as
   "reference info" not "headline info". */
.gws-pubview-meta {
    font-size: 0.78rem;
    color: #94a3b8;
    margin-top: 4px;
    letter-spacing: 0.1px;
}
.gws-pubview-meta .meta-label {
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: #cbd5e1;
    margin-right: 2px;
}
.gws-pubview-ticker {
    font-weight: 700;
    color: #2C3E50;
    letter-spacing: 0.3px;
}
.gws-pubview-sep { color: #cbd5e1; }
.gws-pubview-logo {
    flex-shrink: 0;
    order: -1;  /* logo before title in DOM, but render side-by-side */
}
.gws-pubview-logo img {
    max-width: 64px;
    max-height: 64px;
    object-fit: contain;
    border-radius: 6px;
}
.gws-pubview-hero-actions {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 6px;
}
.gws-pubview-hero-report {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #fff;
    border: 1px solid #e2e8f0;
    color: #475569;
    padding: 6px 12px;
    border-radius: 5px;
    font-size: 0.78rem;
    font-weight: 500;
    text-decoration: none;
    line-height: 1;
}
.gws-pubview-hero-report:hover { background: #f8fafc; border-color: #cbd5e1; }
.gws-pubview-hero-close {
    background: #fff;
    border: 1px solid #e2e8f0;
    color: #94a3b8;
    width: 32px;
    height: 32px;
    border-radius: 5px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    line-height: 1;
}
.gws-pubview-hero-close:hover { background: #f8fafc; color: #0f172a; border-color: #cbd5e1; }

/* ── Tab nav: rounded pill buttons, no scroll ── */
.gws-pubview-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 16px 0 22px;
}
.gws-pubview-tab {
    background: #f1f5f9;
    border: 1px solid transparent;
    padding: 9px 18px;
    font-size: 0.85rem;
    font-weight: 600;
    color: #475569;
    cursor: pointer;
    border-radius: 6px;
    transition: background 0.12s, color 0.12s;
}
.gws-pubview-tab:hover { background: #e2e8f0; color: #0f172a; }
.gws-pubview-tab.active {
    background: #2C3E50;
    color: #fff;
}
.gws-pubview-tab-pane { display: none; }
.gws-pubview-tab-pane.active { display: block; }

/* ── Section label (replaces heavy teal banner) ──
   Tiny uppercase tracker with a hairline rule extending to the right.
   Used on every section header in the editorial-redesigned layout.
   The heavy teal banner is kept only on the balance-sheet table head. */
.gws-pubview-section {
    margin-bottom: 36px;
}
.gws-pubview-section-title {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0 0 16px;
    padding: 0;
    background: transparent;
    color: #94a3b8;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
}
.gws-pubview-section-title::after {
    content: '';
    flex: 1;
    height: 1px;
    background: #e2e8f0;
}

/* ── Header strip (legacy — only renders if a layout still has it.
   New default layout drops header-strip because the panel head
   already shows ticker + name) ── */
.gws-pubview-headerstrip {
    margin-bottom: 28px;
    padding-bottom: 18px;
    border-bottom: 1px solid #e2e8f0;
}
.gws-pubview-headerstrip-name {
    margin: 0 0 6px;
    font-size: 1.8rem;
    font-weight: 600;
    line-height: 1.15;
    color: #0f172a;
    letter-spacing: -0.01em;
}
.gws-pubview-headerstrip-sub {
    font-size: 0.82rem;
    color: #64748b;
    letter-spacing: 0.2px;
}
.gws-pubview-headerstrip-sep {
    color: #cbd5e1;
    margin: 0 2px;
}

/* ── Fact strip (5–6 key numbers) ── */
.gws-pubview-factstrip {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 0;
    margin-bottom: 36px;
    padding: 4px 0 0;
}
.gws-pubview-factstrip-cell {
    padding: 0 16px;
    border-left: 1px solid #f1f5f9;
}
.gws-pubview-factstrip-cell:first-child {
    border-left: none;
    padding-left: 0;
}
.gws-pubview-factstrip-label {
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.7px;
    color: #94a3b8;
    margin-bottom: 6px;
}
.gws-pubview-factstrip-value {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 1.4rem;
    font-weight: 600;
    color: #0f172a;
    line-height: 1.1;
    font-feature-settings: 'tnum';
}
.gws-pubview-factstrip-value.is-pos { color: #059669; }
.gws-pubview-factstrip-value.is-neg { color: #dc2626; }

/* ── Ratings (compact horizontal badges, tier-tinted) ── */
.gws-pubview-ratings-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}
.gws-pubview-rating-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px 6px 10px;
    border-radius: 4px;
    font-size: 0.78rem;
    background: #f1f5f9;
    color: #475569;
}
.gws-pubview-rating-badge .agency {
    font-size: 0.66rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #94a3b8;
    font-weight: 600;
}
.gws-pubview-rating-badge .grade {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 700;
    color: #0f172a;
    font-size: 0.88rem;
}
.gws-pubview-rating-badge .outlook {
    font-size: 0.7rem;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    padding-left: 8px;
    border-left: 1px solid #e2e8f0;
}
/* Tier tint (subtle background by grade quality) */
.gws-pubview-rating-badge.tier-aaa { background: #ecfdf5; }
.gws-pubview-rating-badge.tier-aaa .grade { color: #047857; }
.gws-pubview-rating-badge.tier-aa  { background: #f0fdf4; }
.gws-pubview-rating-badge.tier-aa  .grade { color: #15803d; }
.gws-pubview-rating-badge.tier-a   { background: #f7fee7; }
.gws-pubview-rating-badge.tier-a   .grade { color: #4d7c0f; }
.gws-pubview-rating-badge.tier-bbb { background: #fefce8; }
.gws-pubview-rating-badge.tier-bbb .grade { color: #854d0e; }
.gws-pubview-rating-badge.tier-bb  { background: #fef3c7; }
.gws-pubview-rating-badge.tier-bb  .grade { color: #92400e; }
.gws-pubview-rating-badge.tier-b   { background: #fee2e2; }
.gws-pubview-rating-badge.tier-b   .grade { color: #b91c1c; }

/* ── Stat grid (technical info, in 3-col layout, no empty rows) ── */
.gws-pubview-stat-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 18px 28px;
}
@media (max-width: 700px) {
    .gws-pubview-stat-grid { grid-template-columns: repeat(2, 1fr); }
}
.gws-pubview-stat-item {
    padding-bottom: 14px;
    border-bottom: 1px solid #f1f5f9;
}
.gws-pubview-stat-label {
    font-size: 0.75rem;
    color: #64748b;
    margin-bottom: 4px;
}
.gws-pubview-stat-value {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 1.05rem;
    font-weight: 600;
    color: #0f172a;
}
.gws-pubview-stat-value.is-pos { color: #059669; }
.gws-pubview-stat-value.is-neg { color: #dc2626; }

/* ── Valuation rows ── */
.gws-pubview-val-rows {
    display: flex;
    flex-direction: column;
}
.gws-pubview-val-row {
    display: grid;
    grid-template-columns: 90px 90px 30px 1fr 110px;
    align-items: baseline;
    gap: 14px;
    padding: 12px 0;
    border-bottom: 1px solid #f1f5f9;
}
.gws-pubview-val-row:last-child { border-bottom: none; }
.gws-pubview-val-label {
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: #475569;
}
.gws-pubview-val-stock {
    font-size: 1rem;
    font-weight: 600;
    font-family: 'IBM Plex Mono', monospace;
    color: #1e293b;
    text-align: right;
}
.gws-pubview-val-stock.is-better { color: #059669; }
.gws-pubview-val-stock.is-worse  { color: #dc2626; }
.gws-pubview-val-vs {
    font-size: 0.7rem;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    text-align: center;
}
.gws-pubview-val-ind {
    font-size: 1rem;
    color: #64748b;
    font-family: 'IBM Plex Mono', monospace;
}
.gws-pubview-val-ind-suffix {
    font-family: 'IBM Plex Sans', sans-serif;
    font-size: 0.72rem;
    color: #94a3b8;
    margin-left: 4px;
}
.gws-pubview-val-diff {
    font-size: 0.85rem;
    font-weight: 600;
    text-align: right;
    color: #94a3b8;
}
.gws-pubview-val-diff.is-better { color: #059669; }
.gws-pubview-val-diff.is-worse  { color: #dc2626; }

/* ── Tables (used by anagraphic, technical-info, etc.) ── */
.gws-pubview-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.86rem;
}
.gws-pubview-table th,
.gws-pubview-table td {
    padding: 9px 14px;
    border-bottom: 1px solid #f1f5f9;
    text-align: left;
}
.gws-pubview-table th {
    color: #64748b;
    font-weight: 500;
    width: 220px;
    font-size: 0.82rem;
}
.gws-pubview-table td {
    color: #1e293b;
    font-weight: 500;
}

.gws-pubview-customtable th,
.gws-pubview-customtable td {
    border: 1px solid #e2e8f0;
}
.gws-pubview-customtable th {
    width: auto;
    background: #f8fafc;
}

/* ── Narratives — full container width, generous reading ── */
.gws-pubview-narrative {
    font-size: 1.02rem;
    line-height: 1.75;
    color: #334155;
}
.gws-pubview-narrative p {
    margin: 0 0 1rem;
}
.gws-pubview-narrative p:last-child {
    margin-bottom: 0;
}

/* ── Charts ── */
.gws-pubview-chart-wrap {
    background: #fff;
    /* Height comes from inline style (sec.height_px; default 240px).
       Always 100% width. Chart.js instances use maintainAspectRatio:false
       so they fill this exact box — no more ~half-page-tall line charts
       in the PDF. */
    position: relative;
}
.gws-pubview-chart-wrap canvas {
    max-height: 100% !important;
}
.gws-pubview-rev-row {
    /* Flex so inline widths on .gws-pubview-rev-col actually apply. Each
       column gets its own width_pct from the builder. */
    display: flex;
    flex-wrap: wrap;
    gap: 18px;
    align-items: flex-start;
}
.gws-pubview-rev-col {
    box-sizing: border-box;
    min-width: 0;
    flex-grow: 0;
    flex-shrink: 0;
}

/* Valuation row when industry data is missing: keep the 5-column grid so
   the stock value column stays aligned with the rows that do have industry
   data. The vs/ind/diff cells are rendered as empty <div>s by the JS so
   the column slots are preserved. Removed the prior .is-standalone
   override which collapsed the grid and visually misaligned that row. */
.gws-pubview-rev-col h6 {
    margin: 0 0 6px;
    font-size: 0.82rem;
    color: #475569;
    font-weight: 600;
    text-align: center;
}

/* ── Balance Sheet ── */
.gws-pubview-fin-wrap {
    overflow-x: auto;
}
.gws-pubview-fin {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.78rem;
    font-family: 'IBM Plex Mono', monospace;
}
.gws-pubview-fin th,
.gws-pubview-fin td {
    padding: 5px 10px;
    border-bottom: 1px solid #f1f5f9;
    text-align: right;
}
.gws-pubview-fin thead th {
    background: #2C3E50;
    color: #fff;
    text-align: center;
    font-weight: 600;
    padding: 7px 10px;
}
.gws-pubview-fin thead th:first-child {
    text-align: left;
}
.gws-pubview-fin-section td {
    background: #f1f5f9;
    color: #2C3E50;
    text-align: left;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.72rem;
    letter-spacing: 0.4px;
    padding: 6px 10px;
}
.gws-pubview-fin-label {
    text-align: left !important;
    font-weight: 500;
}
.gws-pubview-fin-growth td {
    color: #64748b;
    font-style: italic;
    font-size: 0.72rem;
    padding-top: 1px;
    padding-bottom: 5px;
}
.gws-pubview-fin-growth .pos { color: #059669; }
.gws-pubview-fin-growth .neg { color: #dc2626; }

/* ── Image figures ──
   Width comes from inline style (set by the renderer per the spec's
   width_pct), so we don't put any width rules here. */
.gws-pubview-image {
    margin: 0 auto;
    box-sizing: border-box;
    text-align: center;
}
.gws-pubview-image img {
    width: 100%;
    height: auto;
    border-radius: 4px;
    display: block;
}
.gws-pubview-image figcaption {
    font-size: 0.78rem;
    color: #64748b;
    margin-top: 6px;
}
.gws-pubview-image-source {
    font-style: italic;
}

/* ── Metrics grid ── */
.gws-pubview-metric-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 10px;
}
.gws-pubview-metric {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    padding: 10px;
    text-align: center;
}
.gws-pubview-metric-label {
    font-size: 0.72rem;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-bottom: 4px;
}
.gws-pubview-metric-value {
    font-size: 1rem;
    font-weight: 600;
    color: #1e293b;
}

/* ── Attached images (rendered inside a section's body) ─────
   When the power user uploads/drops an image from a section's toolbar,
   it's stored in that section's `images` array and rendered here in the
   public + Preview view. Visually grouped with a top divider so it
   reads as part of the section, not a separate block. */
.gws-pubview-attached-images {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid #f1f5f9;
}
.gws-pubview-attached-image {
    margin: 0;
    box-sizing: border-box;
    text-align: center;
}
.gws-pubview-attached-image img {
    width: 100%;
    height: auto;
    border-radius: 4px;
    display: block;
}
.gws-pubview-attached-image figcaption {
    font-size: 0.78rem;
    color: #64748b;
    margin-top: 6px;
    text-align: left;
}
/* Title — short bold heading ABOVE the image. Added 2026-04 alongside
   the caption that goes below. Both are optional per image. */
.gws-pubview-attached-image-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 6px;
    line-height: 1.3;
}

/* Mobile: collapse to one-image-per-row in browser viewport. The PDF
   renderer uses A4 dimensions, not the browser viewport, so this rule
   does not affect downloaded PDFs. */
@media (max-width: 700px) {
    .gws-pubview-attached-image,
    .gws-pubview-image {
        width: 100% !important;
    }
}

/* Phone (≤480px): the hero header's [logo | title | actions] row no
   longer fits — the Download/Close buttons get pushed past the right
   edge. Wrap the actions onto a second line (right-aligned) and tighten
   the tab pills so several fit per row instead of overflowing. */
@media (max-width: 480px) {
    .gws-pubview-header {
        flex-wrap: wrap;
        gap: 10px 14px;
        padding-bottom: 14px;
    }
    .gws-pubview-title h1 { font-size: 1.3rem; }
    .gws-pubview-subtitle { font-size: 0.82rem; }
    .gws-pubview-meta { font-size: 0.72rem; }
    .gws-pubview-logo img { max-width: 48px; max-height: 48px; }
    .gws-pubview-hero-actions {
        flex-basis: 100%;
        justify-content: flex-end;
        gap: 6px;
    }
    .gws-pubview-hero-report {
        padding: 6px 10px;
        font-size: 0.72rem;
    }
    .gws-pubview-hero-close {
        width: 30px;
        height: 30px;
    }
    .gws-pubview-tabs {
        gap: 4px;
        margin: 12px 0 18px;
    }
    .gws-pubview-tab {
        padding: 7px 11px;
        font-size: 0.76rem;
    }
}

/* ── Empty state ── */
.gws-pubview-empty {
    color: #94a3b8;
    font-style: italic;
    text-align: center;
    padding: 18px;
    font-size: 0.85rem;
}
