/* gp-client.css — the GP client view, shared by BOTH surfaces (CP5b):
 *   • the internal marketer portal (/marketer, loaded before marketer.css)
 *   • the GP Client Portal (portal.mafar.tech, on the Nginx whitelist)
 *
 * Rules moved verbatim from marketer.css: status notes, the campaign →
 * ad set → ad tree, creative cards + modal, the six-preset range picker,
 * the two KPI groups, the KPI/chart grids and the table chrome the shared
 * modules (js/gp-client-overview.js, js/gp-ads-tree.js, js/creative-cards.js,
 * js/gp-range.js) render. Class names keep their historical mkt-gp-* / mkt-*
 * prefix — they predate the split and are used by MP/MG drill-downs too;
 * renaming is legacy cleanup, not part of this pass.
 *
 * Tokens: canonical style.css tokens plus the handful of marketer-portal
 * variables these rules always used, declared here with the SAME values so
 * the portal (which never loads marketer.css) resolves them. marketer.css
 * redeclares them identically — no cascade change on the internal side. */

:root {
  --mkt-lead: #f59e0b;
  --mkt-sales: #22c55e;
  --mkt-surface-stripe: #f8fafc;
  --mkt-table-row-hover: #f1f5f9;
  --mkt-tab-text: #5a6b82;
  --mkt-sub-row-bg: #fafbfc;
  --border-accent: rgba(26, 43, 74, 0.35);
}

[data-theme="dark"] {
  --mkt-lead: #fbbf24;
  --mkt-sales: #4ade80;
  --mkt-surface-stripe: rgba(255,255,255,0.04);
  --mkt-table-row-hover: rgba(255,255,255,0.04);
  --mkt-tab-text: #8b949e;
  --mkt-sub-row-bg: #1a1f26;
  --border-accent: rgba(230, 237, 243, 0.30);
}

/* ─── Layout helpers ─── */
/* Spacing modifier — explicit card separation where parent container
   provides no gap (MKT-018 service breakdown, MKT-027 funnel summary). */
.section-card--mkt-spaced { margin-bottom: 20px; }


.mkt-kpi-grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}


/* Two side-by-side chart cards (GP portfolio Spend / Leads row) */
.mkt-chart-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}


/* ─── Component: Table ─── */
.mkt-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

/* Cell metrics/chrome come from canonical .data-table — the (0,1,1)
   th/td blocks and the (0,2,1) hover that used to sit here were
   shadowed dead (2.7b sweep). Zebra tint below stays: portal-local
   and live (canonical has no zebra). */
.mkt-table tr:nth-child(even) td {
  background: var(--mkt-surface-stripe);
}


/* Change 1: table scroll wrappers — retired 2026-09-03; every table now
   sits in the canonical .data-table-wrap container (style.css). */


/* ═══ GP dashboard (Phase 2B) ═══════════════════════════════════════════ */

/* Muted status notes (no sheet connected / ad data unavailable / partial trend) */
.mkt-gp-note {
  font-size: 11px;
  color: var(--color-slate-400);
  line-height: 1.5;
}

.mkt-gp-note-cell {
  font-size: 12px;
  color: var(--color-slate-400);
}

/* ── Ads performance tab: campaign table ── */
.mkt-gp-ads__camp-row {
  cursor: pointer;
}

.mkt-gp-ads__camp-row [data-arrow] {
  color: var(--color-slate-400);
}

.mkt-gp-ads__camp-name {
  font-weight: 500;
  color: var(--color-text-primary);
}

.mkt-gp-ads__objective {
  font-size: 10px;
  color: var(--color-slate-400);
  text-transform: uppercase;
  letter-spacing: 0.02em;
  margin-top: 2px;
}

.mkt-gp-ads__creatives-row > td {
  background: var(--color-surface-row-expanded, var(--color-surface-2));
}

.mkt-gp-ads__creatives-row .mkt-gp-note {
  padding: 10px 14px;
}

/* ── Creative cards (flattened campaign → creative, no ad set layer) ── */
.mkt-gp-ads__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  padding: 12px 14px;
}

.mkt-gp-ads__card {
  border: 0.5px solid var(--color-border);
  border-radius: 6px;
  overflow: hidden;
  background: var(--color-surface);
  display: flex;
  flex-direction: column;
}

.mkt-gp-ads__thumb-wrap {
  position: relative;
  width: 100%;
  background: var(--color-surface-row-expanded, var(--color-surface-2));
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mkt-gp-ads__thumb-wrap--empty {
  aspect-ratio: 1 / 1;
}

.mkt-gp-ads__thumb-wrap--empty::after {
  content: '🖼';
  font-size: 24px;
  opacity: 0.3;
}

/* Reference-format pass (18 Aug 2026): the FULL poster shows in the card —
   natural aspect ratio, contained, never cropped. The old 16:9 cover crop
   cut square/4:5 clinic posters. Height-capped so a story-format creative
   can't stretch the whole grid row. */
.mkt-gp-ads__thumb {
  width: 100%;
  height: auto;
  max-height: 340px;
  object-fit: contain;
  display: block;
}

.mkt-gp-ads__thumb--broken {
  display: none;
}

/* Play-icon overlay for video creatives — badge only, no playback */
.mkt-gp-ads__video-badge {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  pointer-events: none;
}

.mkt-gp-ads__card-body {
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.mkt-gp-ads__ad-name {
  font-size: 12px;
  font-weight: 500;
  color: var(--color-text-primary);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* .mkt-gp-ads__metrics deleted 18 Aug 2026 (reference-format pass):
   inline card metrics replaced by the stacked .mkt-gp-ads__stats. */

@media (max-width: 600px) {
  .mkt-gp-ads__grid {
    grid-template-columns: 1fr 1fr;
  }
}

.mkt-gp-ads__camp-row--static {
  cursor: default;
}

/* ─── G8: GP date-range picker ───
   Segmented control reusing the seg-toggle pattern (the GP/MP/MG toggle)
   rather than a new component. Promotion candidate: .range-picker. */
.range-nav {
  display: flex;
  align-items: center;
}

/* The [hidden] attribute must beat the components' explicit display values
   (.mkt-month-nav is display:flex) — GP shows the range picker, MP/MG the
   month stepper, never both. */
.mkt-month-nav[hidden],
.range-nav[hidden] { display: none; }

.range-picker {
  flex-wrap: wrap;
}

.range-picker__caret {
  font-size: 9px;
  margin-left: 2px;
}

.range-picker__drop {
  position: absolute;
  background: var(--color-surface);
  border: 1px solid var(--color-border-cal);
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
  z-index: 1000;
  padding: 6px;
  font-size: 13px;
  animation: mktCalPopIn 150ms ease forwards;
}

.range-picker__drop-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border: none;
  background: none;
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
  color: var(--color-on-surface);
  cursor: pointer;
}

.range-picker__drop-item:hover { background: var(--color-hover-soft); }
.range-picker__drop-item.--selected {
  background: var(--seg-active-bg, var(--color-primary));
  color: var(--color-on-primary);
}

.range-picker__drop-sep {
  height: 1px;
  background: var(--color-divider);
  margin: 4px 2px;
}

/* The hidden attribute must beat the explicit display values below — the
   date fields show only after "Pick dates…", which then hides itself. */
.range-picker__dates[hidden],
.range-picker__drop-item[hidden] { display: none; }

.range-picker__dates {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px 10px 10px;
}

.range-picker__date-label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  font-weight: 500;
  color: var(--color-on-surface-var);
}

/* Resolved-range subtitle under the page title — "All" never overclaims */
.mkt-gp-range-sub {
  font-size: 13px;
  color: var(--mkt-tab-text);
  margin-top: 2px;
}

/* ─── G8: KPI groups ───
   Two labelled framings of the same client (all campaigns vs lead-gen
   only). Labels are sentence case, never ALL CAPS. The lead-gen group
   carries --border-accent — border ONLY, no fill (reference fills
   rejected). Promotion candidates: .kpi-group, .kpi-group__label. */
.kpi-group {
  margin-bottom: 20px;
}

.kpi-group__label {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-on-surface-var);
  margin-bottom: 8px;
}

.kpi-group--accent {
  border: 0.5px solid var(--border-accent);
  border-radius: var(--radius-md);
  padding: 12px;
}

.mkt-kpi-grid-5 {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 14px;
}

/* ─── G8: GP drill-down tree (campaign → ad set → ad) ───
   Reference-format pass (18 Aug 2026): ad sets are real table rows so their
   Spend/Leads/CPL/Impressions align under the campaign columns, on a muted
   stripe like the reference dashboard. */
.mkt-gp-ads__adset-row {
  cursor: pointer;
  background: var(--mkt-sub-row-bg);
}

.mkt-gp-ads__adset-row:hover { background: var(--mkt-table-row-hover); }

.mkt-gp-ads__adset-name-cell {
  padding-left: 28px !important;
  font-weight: 500;
}

.mkt-gp-ads__adset-name-cell [data-arrow] {
  color: var(--mkt-tab-text);
  margin-right: 4px;
}

/* Stacked labelled metrics on creative cards (reference format) */
.mkt-gp-ads__stats {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.mkt-gp-ads__stat {
  display: flex;
  flex-direction: column;
}

.mkt-gp-ads__stat-label {
  font-size: 10px;
  color: var(--mkt-tab-text);
}

.mkt-gp-ads__stat-value {
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--color-on-surface);
}

/* Ad-tier status dot (effective_status) */
.mkt-gp-status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
  background: var(--color-slate-400, #94a3b8);
  flex-shrink: 0;
}
.mkt-gp-status-dot--active { background: var(--mkt-sales); }
.mkt-gp-status-dot--paused { background: var(--mkt-lead); }
.mkt-gp-status-dot--off    { opacity: 0.5; }

.mkt-gp-ads__card--clickable { cursor: pointer; }
.mkt-gp-ads__card--clickable:hover { background: var(--mkt-table-row-hover); }
.mkt-gp-ads__card--clickable:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

/* ─── Active/paused pass — dimming + paused fold (shared MktCreative) ───
   Paused things stay data (they may hold real spend in range) — dimmed,
   never hidden outright; the fold and the campaign filter do the hiding,
   and both are explicit user actions. */
.mkt-gp-ads__card--paused { opacity: 0.6; }
.mkt-gp-ads__card--paused:hover { opacity: 1; }

.mkt-gp-ads__card--tail { display: none; }
.mkt-creative-grid-wrap--tail-shown .mkt-gp-ads__card--tail { display: flex; }

.mkt-gp-ads__fold-btn {
  display: block;
  width: 100%;
  padding: 8px;
  font-size: 12px;
  color: var(--color-slate-400);
  border-top: 0.5px solid var(--color-border);
  border-radius: 0;
  text-align: center;
}
.mkt-gp-ads__fold-btn:hover {
  color: var(--color-text-primary);
  background: var(--color-surface-row-expanded, var(--color-surface-2));
}

/* Paused campaign rows (GP tree + MP table) */
.mkt-gp-ads__camp-row--paused > td,
.mkt-ads-campaign-row--paused > td { opacity: 0.6; }
.mkt-gp-ads__camp-row--paused:hover > td,
.mkt-ads-campaign-row--paused:hover > td { opacity: 1; }

/* ─── G8: creative modal ─── */
.mkt-gp-creative {
  position: fixed;
  inset: 0;
  background: var(--color-modal-scrim);
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.mkt-gp-creative__card {
  position: relative;
  background: var(--color-surface);
  border-radius: 14px;
  box-shadow: var(--shadow-cloud);
  width: min(460px, 100%);
  max-height: 90vh;
  overflow-y: auto;
}

.mkt-gp-creative__close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background: var(--color-surface);
  color: var(--color-on-surface);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  z-index: 1;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.18);
}

.mkt-gp-creative__imgwrap {
  position: relative;
  background: var(--color-surface-low);
  border-radius: 14px 14px 0 0;
  overflow: hidden;
}

.mkt-gp-creative__img {
  display: block;
  width: 100%;
  max-height: 55vh;
  object-fit: contain;
}

/* ─── Video playback (GP + MP/MG creative modal) ───
   The media area swaps between poster and player in place, so both sit in
   the same rounded top slot. */
.mkt-gp-creative__video {
  display: block;
  width: 100%;
  max-height: 55vh;
  /* Letterboxing shows through on non-16:9 creatives — black reads as
     "video frame", not as a missing surface. */
  background: #000;
  border-radius: 14px 14px 0 0;
}

/* "Preparing video…" while the signed source resolves — sits under the play
   badge so the poster never looks inert. */
.mkt-gp-creative__video-status {
  position: absolute;
  left: 50%;
  top: calc(50% + 30px);
  transform: translateX(-50%);
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--color-modal-scrim);
  color: #fff;
  font-size: 11px;
  white-space: nowrap;
}

/* Fallbacks when Meta gives no direct source */
.mkt-gp-creative__video-link {
  display: block;
  padding: 10px 16px;
  border-bottom: 0.5px solid var(--color-border);
  color: var(--color-primary-text, var(--color-on-surface));
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}

.mkt-gp-creative__video-link:hover { background: var(--color-hover-soft); }

.mkt-gp-creative__video-note {
  padding: 10px 16px;
  border-bottom: 0.5px solid var(--color-border);
}

.mkt-gp-creative__body {
  padding: 14px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.mkt-gp-creative__name {
  display: flex;
  align-items: center;
  font-weight: 600;
  font-size: 14px;
}

.mkt-gp-creative__metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--color-slate-500);
}

.mkt-gp-creative__copy {
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
  color: var(--color-on-surface);
}

.mkt-gp-creative__linkcard {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border: 0.5px solid var(--color-border);
  border-radius: 10px;
  background: var(--mkt-surface-stripe);
}

.mkt-gp-creative__headline {
  font-size: 13px;
  font-weight: 600;
}

.mkt-gp-creative__domain {
  font-size: 11px;
  color: var(--mkt-tab-text);
  text-transform: uppercase;
}

.mkt-gp-creative__cta {
  flex-shrink: 0;
  padding: 6px 12px;
  border-radius: 8px;
  background: var(--color-surface-low);
  font-size: 12px;
  font-weight: 600;
  text-transform: capitalize;
  white-space: nowrap;
}

/* ─── G9: funnel shell ─── */
.mkt-gp-funnel {
  padding: 4px 0;
}

/* ─── G8/G9 responsive ─── */
@media (max-width: 900px) {
  .mkt-kpi-grid-5 { grid-template-columns: repeat(2, 1fr); gap: 10px; }
}

@media (max-width: 768px) {
  .range-nav { width: 100%; }
  .range-picker { width: 100%; }
  .range-picker .seg-toggle__btn { flex: 1; min-height: 44px; padding: 8px 6px; font-size: 12px; }
}


/* Portal-width responsive rules for the grids (marketer.css carries its own
   copy inside its mobile section; the portal has no marketer.css). */
@media (max-width: 768px) {
  .mkt-kpi-grid-4 { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .mkt-chart-grid-2 { grid-template-columns: 1fr; }
}
