/* ============================================================================
   seo.css — Marketlens SEO & Performance modules
   ----------------------------------------------------------------------------
   Builds ON bi.css + research.css (bi-card, bi-empty-state, bi-stat-card,
   kw-table, priority-badge, bi-btn, FacetDropdown) + Huddle tokens.
   Adds seo-* : 4-up stat row, delta tag, trend chart, GSC connection screens,
   audit issue cards, bulk-meta editable table, internal-linking, reports.
   Single global CSS, vanilla-JS friendly.
   ========================================================================== */

/* shared section shell (reuses bi-page/bi-header/bi-title from bi.css) */
.seo-intro { font-size: var(--text-sm); color: var(--text-secondary); margin: 0 0 18px; line-height: var(--leading-md); max-width: 80ch; }
.seo-intro b { color: var(--text-primary); font-weight: var(--weight-medium); }

/* 4-up stat row (vs default 3-up) */
.seo-stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 18px; }
@media (max-width: 900px) { .seo-stat-row { grid-template-columns: repeat(2, 1fr); } }
.seo-stat { background: var(--bg-card); border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); box-shadow: var(--shadow-xs); padding: 16px; display: flex; flex-direction: column; gap: 7px; }
.seo-stat__top { display: flex; align-items: center; gap: 8px; }
.seo-stat__icon { width: 30px; height: 30px; border-radius: var(--radius-md); background: var(--primary-tint); color: var(--primary); display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.seo-stat__icon svg { width: 16px; height: 16px; }
.seo-stat__label { font-size: var(--text-sm); color: var(--text-muted); font-weight: var(--weight-medium); }
.seo-stat__value { font-size: var(--text-2xl); font-weight: var(--weight-bold); letter-spacing: var(--tracking-tight); color: var(--text-primary); line-height: 1.1; font-variant-numeric: tabular-nums; }
.seo-stat__foot { display: flex; align-items: center; gap: 8px; }
.seo-stat__loading { color: var(--text-disabled); }

/* delta tag (reusable) */
.seo-delta { display: inline-flex; align-items: center; gap: 3px; font-size: var(--text-xs); font-weight: var(--weight-semibold); padding: 1px 7px; border-radius: var(--radius-pill); font-variant-numeric: tabular-nums; }
.seo-delta svg { width: 12px; height: 12px; }
.seo-delta--up { background: var(--success-surface); color: var(--success); }
.seo-delta--down { background: var(--danger-surface); color: var(--danger); }
.seo-delta--flat { background: var(--gray-100); color: var(--text-muted); }
.seo-delta__note { font-size: 11px; color: var(--text-muted); font-weight: var(--weight-regular); }

/* quick-action cards (dashboard) */
.seo-quick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.seo-quick { display: flex; gap: 14px; align-items: flex-start; cursor: pointer; }
.seo-quick__icon { width: 40px; height: 40px; border-radius: var(--radius-md); background: var(--primary-tint); color: var(--primary); display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.seo-quick__icon svg { width: 20px; height: 20px; }
.seo-quick__name { font-size: var(--text-md); font-weight: var(--weight-semibold); color: var(--text-primary); display: flex; align-items: center; gap: 6px; }
.seo-quick__desc { font-size: var(--text-xs); color: var(--text-muted); margin-top: 3px; line-height: 1.5; }
.seo-quick__open { font-size: var(--text-xs); font-weight: var(--weight-semibold); color: var(--text-link); display: inline-flex; align-items: center; gap: 3px; margin-top: 8px; }
.seo-quick__open svg { width: 13px; height: 13px; }
/* quick-action card: equal-height flex with Open button pinned to bottom */
.seo-quick-card { display: flex; flex-direction: column; gap: 16px; cursor: pointer; }
.seo-quick-card .seo-quick { flex: 1; }
.seo-quick__btn { align-self: flex-start; }

/* range selector (reuses kw-seg from research.css visually; alias) */
.seo-range { display: inline-flex; gap: 2px; background: var(--bg-subtle); border: 1px solid var(--border-subtle); border-radius: var(--radius-md); padding: 3px; }
.seo-range button { border: none; background: none; padding: 5px 11px; border-radius: 6px; font-size: var(--text-xs); font-weight: var(--weight-semibold); color: var(--text-muted); cursor: pointer; font-family: var(--font-sans); }
.seo-range button.on { background: var(--bg-card); color: var(--primary); box-shadow: var(--shadow-xs); }
/* larger segmented control to match adjacent bi-btn height (36px) */
.kw-seg--lg { padding: 0; }
.kw-seg--lg button { height: 34px; padding: 0 14px; font-size: var(--text-sm); }

/* freshness stamp line */
.seo-stamp { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: var(--text-xs); color: var(--text-muted); margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border-subtle); }
.seo-stamp a { color: var(--text-link); cursor: pointer; }
.seo-stamp__dot { width: 3px; height: 3px; border-radius: 50%; background: var(--text-disabled); }

/* connection / setup screens */
.seo-connect { max-width: 560px; margin: 24px auto; }
.seo-connect-card { background: var(--bg-card); border: 1px solid var(--border-subtle); border-radius: var(--radius-xl); box-shadow: var(--shadow-xs); padding: 36px 32px; text-align: center; }
.seo-connect-card__icon { width: 60px; height: 60px; border-radius: var(--radius-xl); background: var(--primary-tint); color: var(--primary); display: inline-flex; align-items: center; justify-content: center; margin-bottom: 18px; }
.seo-connect-card__icon svg { width: 28px; height: 28px; }
.seo-connect-card__title { font-size: var(--text-xl); font-weight: var(--weight-semibold); color: var(--text-primary); }
.seo-connect-card__desc { font-size: var(--text-sm); color: var(--text-muted); margin: 8px 0 0; line-height: var(--leading-md); }
.seo-connect-card__actions { display: flex; gap: 10px; justify-content: center; margin-top: 22px; flex-wrap: wrap; }
.seo-connect-tip { font-size: var(--text-xs); color: var(--text-disabled); margin-top: 18px; line-height: 1.6; }
.seo-google-btn { background: #fff; color: #1f2328; border: 1px solid var(--border-default); box-shadow: var(--shadow-xs); }
.seo-google-btn:hover { background: #f7f8fa; color: #1f2328; }
.seo-google-btn .seo-g { width: 16px; height: 16px; }
.seo-setup-steps { text-align: left; display: flex; flex-direction: column; gap: 14px; margin: 18px 0; }
.seo-setup-step { display: flex; gap: 12px; }
.seo-setup-step__n { width: 22px; height: 22px; border-radius: 50%; background: var(--primary-tint); color: var(--indigo-700); font-size: 11px; font-weight: var(--weight-bold); display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; }
[data-theme="dark"] .seo-setup-step__n { color: var(--indigo-300); }
.seo-setup-step__t { font-size: var(--text-sm); color: var(--text-secondary); line-height: 1.5; }
.seo-code { font-family: var(--font-mono); font-size: 12px; background: var(--gray-900); color: #D7DCEC; padding: 2px 7px; border-radius: var(--radius-xs); word-break: break-all; }

/* property picker */
.seo-prop-list { display: flex; flex-direction: column; gap: 8px; }
.seo-prop { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--border-subtle); border-radius: var(--radius-md); background: var(--bg-card); }
.seo-prop__icon { width: 32px; height: 32px; border-radius: var(--radius-md); background: var(--bg-subtle); color: var(--text-secondary); display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.seo-prop__meta { flex: 1; min-width: 0; }
.seo-prop__url { font-size: var(--text-sm); font-weight: var(--weight-medium); color: var(--text-primary); font-family: var(--font-mono); }
.seo-prop__type { font-size: 11px; color: var(--text-muted); }

/* trend chart */
.seo-chart-card { background: var(--bg-card); border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); box-shadow: var(--shadow-xs); padding: 18px 20px; margin-bottom: 18px; }
.seo-chart-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.seo-chart-legend { display: flex; gap: 16px; align-items: center; }
.seo-chart-legend button { display: inline-flex; align-items: center; gap: 6px; font-size: var(--text-xs); font-weight: var(--weight-medium); color: var(--text-muted); background: none; border: none; cursor: pointer; font-family: var(--font-sans); }
.seo-chart-legend button.on { color: var(--text-primary); }
.seo-chart-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.seo-chart { width: 100%; height: 200px; display: block; overflow: visible; }
.seo-chart .grid { stroke: var(--border-subtle); stroke-width: 1; }
.seo-chart .axis { fill: var(--text-disabled); font-size: 10px; font-family: var(--font-sans); }
.seo-chart .line-c { fill: none; stroke: var(--primary); stroke-width: 2; }
.seo-chart .line-i { fill: none; stroke: var(--blue-400); stroke-width: 2; stroke-dasharray: 4 3; }
.seo-chart .area-c { fill: var(--primary-tint); opacity: .6; }
.seo-chart .dot { fill: var(--bg-card); stroke: var(--primary); stroke-width: 2; }
.seo-chart-hover { fill: var(--text-primary); opacity: .08; }
.seo-chart-tip { position: absolute; pointer-events: none; background: var(--gray-900); color: #fff; font-size: 11px; padding: 7px 10px; border-radius: var(--radius-md); box-shadow: var(--shadow-md); white-space: nowrap; transform: translate(-50%, -100%); z-index: 5; }
.seo-chart-tip b { font-weight: var(--weight-semibold); }
.seo-chart-wrap { position: relative; }

/* opportunity cards */
.seo-opp { display: flex; flex-direction: column; gap: 8px; }
.seo-opp__head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.seo-opp__type { font-size: var(--text-sm); font-weight: var(--weight-semibold); color: var(--text-primary); }
.seo-opp__metric { font-size: var(--text-xs); color: var(--text-secondary); font-variant-numeric: tabular-nums; background: var(--bg-subtle); border: 1px solid var(--border-subtle); border-radius: var(--radius-sm); padding: 3px 8px; display: inline-flex; align-items: center; gap: 5px; }
.seo-opp__desc { font-size: var(--text-xs); color: var(--text-muted); line-height: 1.5; }

/* sitemap cards */
.seo-sitemap { display: flex; align-items: center; gap: 12px; }
.seo-sitemap__icon { width: 32px; height: 32px; border-radius: var(--radius-md); background: var(--bg-subtle); color: var(--text-secondary); display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.seo-sitemap__path { font-size: var(--text-sm); font-weight: var(--weight-medium); color: var(--text-primary); font-family: var(--font-mono); }
.seo-sitemap__meta { font-size: 11px; color: var(--text-muted); }

/* audit issue cards (expandable) */
.seo-issue { cursor: pointer; }
.seo-issue__head { display: flex; align-items: center; gap: 12px; }
.seo-issue__sev { flex: 0 0 auto; }
.seo-issue__label { font-size: var(--text-sm); font-weight: var(--weight-semibold); color: var(--text-primary); flex: 1; }
.seo-issue__count { font-size: 11px; font-weight: var(--weight-semibold); background: var(--gray-100); color: var(--text-muted); padding: 1px 9px; border-radius: var(--radius-pill); }
.seo-issue__chev { color: var(--text-muted); transition: transform .12s; }
.seo-issue__chev.open { transform: rotate(90deg); }
.seo-issue__items { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border-subtle); display: flex; flex-direction: column; gap: 8px; }
.seo-issue__item { display: flex; align-items: center; gap: 8px; font-size: var(--text-sm); color: var(--text-secondary); }
.seo-issue__item a { color: var(--text-link); font-size: 11px; display: inline-flex; align-items: center; gap: 3px; margin-left: auto; }
.seo-issue__more { font-size: var(--text-xs); color: var(--text-muted); font-style: italic; }
.priority-badge.priority-error { background: var(--danger-surface); color: var(--danger); }
.priority-badge.priority-warning { background: var(--warning-surface); color: var(--warning); }
.priority-badge.priority-notice { background: var(--gray-100); color: var(--text-muted); }

/* bulk meta editable table */
.bm-table td { vertical-align: top; padding-top: 12px; padding-bottom: 12px; }
.bm-post { min-width: 180px; }
.bm-post__title { font-size: var(--text-sm); font-weight: var(--weight-medium); color: var(--text-primary); display: flex; align-items: center; gap: 6px; }
.bm-post__sub { font-size: 11px; color: var(--text-muted); display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.bm-post__view { display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 9px; border: 1px solid var(--border-default); border-radius: var(--radius-md); background: var(--bg-card); color: var(--text-secondary); font-size: 11px; font-weight: var(--weight-semibold); cursor: pointer; text-decoration: none; transition: background-color .12s, border-color .12s, color .12s; }
.bm-post__view:hover { background: var(--bg-hover); border-color: var(--border-strong); color: var(--text-primary); }
.bm-post__view svg { width: 12px; height: 12px; }
.bm-field { width: 100%; border: 1px solid var(--border-default); background: var(--bg-card); border-radius: var(--radius-sm); padding: 7px 9px; font-family: var(--font-sans); font-size: var(--text-sm); color: var(--text-primary); resize: vertical; line-height: 1.45; }
.bm-field:focus { outline: none; border-color: var(--border-focus); box-shadow: var(--focus-ring); }
.seo-counter { font-size: 11px; font-variant-numeric: tabular-nums; color: var(--text-muted); margin-top: 4px; display: block; }
.seo-counter.over { color: var(--danger); font-weight: var(--weight-semibold); }
.bm-row-dirty td { background: var(--warning-surface); }
.bm-row-dirty .bm-field { border-color: var(--warning); }

/* internal linking */
.seo-orphan { display: flex; flex-direction: column; gap: 10px; }
.seo-orphan__head { display: flex; align-items: flex-start; gap: 12px; }
.seo-orphan__main { flex: 1; min-width: 0; }
.seo-orphan__title { font-size: var(--text-sm); font-weight: var(--weight-semibold); color: var(--text-primary); display: block; }
.seo-orphan__sub { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.seo-sugg-panel { margin-top: 4px; padding-top: 12px; border-top: 1px solid var(--border-subtle); display: flex; flex-direction: column; gap: 8px; }
.seo-sugg { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--border-subtle); border-radius: var(--radius-md); background: var(--bg-subtle); }
.seo-sugg__anchor { font-size: var(--text-xs); color: var(--text-link); background: var(--primary-tint); padding: 2px 8px; border-radius: var(--radius-sm); white-space: nowrap; }
.seo-sugg__arrow { color: var(--text-disabled); flex: 0 0 auto; }
.seo-sugg__target { font-size: var(--text-sm); color: var(--text-primary); font-weight: var(--weight-medium); flex: 1; min-width: 0; }
.seo-sugg__reason { font-size: 11px; color: var(--text-muted); }

/* reports */
.rep-sec-title { font-size: var(--text-xs); font-weight: var(--weight-semibold); text-transform: uppercase; letter-spacing: var(--tracking-wide); color: var(--text-disabled); margin: 22px 0 12px; display: flex; align-items: center; gap: 8px; }
.rep-sec-title svg { width: 14px; height: 14px; color: var(--text-muted); }
.csite-badge { display: inline-flex; align-items: center; gap: 6px; font-size: var(--text-xs); font-weight: var(--weight-medium); padding: 4px 11px; border-radius: var(--radius-pill); background: var(--bg-subtle); border: 1px solid var(--border-subtle); color: var(--text-secondary); }
.csite-badge b { color: var(--text-primary); font-weight: var(--weight-bold); font-variant-numeric: tabular-nums; }
.csite-badge__dot { width: 7px; height: 7px; border-radius: 50%; }
.rep-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.rep-note { font-size: var(--text-xs); color: var(--text-muted); margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--border-subtle); line-height: 1.6; }
.rep-note a { color: var(--text-link); }

/* AI vs free affordance hint */
.seo-free-tag { font-size: 10px; font-weight: var(--weight-semibold); text-transform: uppercase; letter-spacing: .04em; color: var(--success); background: var(--success-surface); border: 1px solid var(--success-border); padding: 1px 7px; border-radius: var(--radius-pill); }
.seo-ai-tag { font-size: 10px; font-weight: var(--weight-semibold); text-transform: uppercase; letter-spacing: .04em; color: var(--indigo-700); background: var(--primary-tint); border: 1px solid var(--indigo-100); padding: 1px 7px; border-radius: var(--radius-pill); }
[data-theme="dark"] .seo-ai-tag { color: var(--indigo-300); border-color: var(--primary-tint-2); }