/* ==========================================================================
   AFFILIATE PORTAL — Solid Affiliate 3.x, themed to TVB (v4.20.6)
   Loaded ONLY on the Affiliate Portal page (see functions.php enqueue).

   STRATEGY — the plugin renders its portal from an inline <style> block driven
   entirely by its OWN custom properties (--sld-ap-background, --sld-ap-accent-
   color, --sld-ap-border-color, radii, …). We redefine those properties in TVB
   token terms on the portal root. Because a closer ancestor's variable wins by
   the cascade regardless of stylesheet source order, this recolours BOTH the
   registration and the logged-in dashboard views with no !important and no
   dependence on load order. Targeted rules below add the premium touches on the
   plugin's real classes (verified live on an approved-affiliate dashboard).

   Every colour references a TVB :root token — no raw hex. Plugin files are never
   touched (constraint): all work lives in the theme.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1) VARIABLE REMAP — the engine. Redefine the plugin's design tokens as TVB
   tokens on the portal root (ancestor of every portal element in both views).
   Covers the plugin's light defaults AND its .dark-mode variants, so the portal
   is TVB-native whichever mode the plugin is in.
   ------------------------------------------------------------------------ */
.sld-ap-container,
.sld-ap {
  --sld-ap-background:       var(--surface);
  --sld-ap-shading:          var(--surface-2);
  --sld-ap-primary-color:    var(--text);
  --sld-ap-secondary-color:  var(--text-3);
  --sld-ap-accent-color:     var(--cyan);
  --sld-ap-border-color:     rgba(255,255,255,.08);
  --sld-ap-info-color:       var(--cyan);
  --sld-ap-success-color:    var(--ok);
  --sld-ap-error-color:      var(--danger);
  --sld-ap-border-radius-sm: var(--tvb-r-sm);
  --sld-ap-border-radius-md: var(--tvb-r-md);
  --sld-ap-border-radius-lg: var(--tvb-r-lg);
  /* keep TVB tokens even if the plugin's built-in dark mode is ever enabled */
  --sld-ap-dark-background:      var(--surface);
  --sld-ap-dark-shading:         var(--surface-2);
  --sld-ap-dark-primary-color:   var(--text);
  --sld-ap-dark-secondary-color: var(--text-3);
  --sld-ap-dark-accent-color:    var(--cyan);
  --sld-ap-dark-border-color:    rgba(255,255,255,.08);
}

/* portal text baseline (the plugin sets root text to its primary-color; keep
   it legible on dark even where a rule hardcodes it) */
.sld-ap-container,
.sld-ap,
.sld-ap .sld-ap-title,
.sld-ap .sld-ap-heading,
.sld-ap .sld_field-title,
.sld-ap .sld_field-label { color: var(--text); }
.sld-ap .sld_field-description,
.sld-ap p.description,
.sld-ap .sld-ap-description { color: var(--text-3); }

/* --------------------------------------------------------------------------
   2) CARDS / PANELS — belt-and-suspenders in case a rule hardcodes white.
   ------------------------------------------------------------------------ */
.sld-ap .sld-ap-form_box,
.sld-ap-container .sld-ap-info-box,
.sld-ap-container .sld-ap-main,
.sld-ap-container .sld-ap-nav {
  background: var(--surface);
  border-color: rgba(255,255,255,.08);
  box-shadow: none;
}

/* --------------------------------------------------------------------------
   3) INPUTS / SELECTS / TEXTAREAS
   ------------------------------------------------------------------------ */
.sld-ap input:not([type="submit"]):not([type="button"]):not([type="checkbox"]):not([type="radio"]),
.sld-ap select,
.sld-ap textarea {
  background: var(--surface-2);
  border: 1px solid rgba(255,255,255,.10);
  color: var(--text);
  border-radius: var(--tvb-r-sm);
  padding: 11px 13px;
}
.sld-ap input:not([type="submit"]):not([type="button"]):focus,
.sld-ap select:focus,
.sld-ap textarea:focus {
  outline: none;                              /* replaced by the on-brand ring below */
  border-color: var(--cyan-line);
  box-shadow: 0 0 0 3px var(--cyan-soft);
}
.sld-ap ::placeholder { color: var(--text-4); opacity: 1; }

/* autofill: browsers repaint the field white via an inset shadow + their own
   text colour. Override both so autofilled fields stay dark/legible. */
.sld-ap input:-webkit-autofill,
.sld-ap input:-webkit-autofill:hover,
.sld-ap input:-webkit-autofill:focus,
.sld-ap input:-webkit-autofill:active {
  -webkit-text-fill-color: var(--text);
  -webkit-box-shadow: 0 0 0 1000px var(--surface-2) inset;   /* paints the field bg dark */
  caret-color: var(--text);
  transition: background-color 100000s ease 0s;              /* defeats the white autofill flash */
}

/* --------------------------------------------------------------------------
   4) BUTTONS — primary matches the site's SHOP NOW; logout reads as ghost.
   Two-class scope out-specifies the plugin's single-class rules (no !important).
   ------------------------------------------------------------------------ */
.sld-ap input[type="submit"],
.sld-ap button[type="submit"],
.sld-ap .sld-ap-form_submit,
.sld-ap .sld-ap-edit-email_button,
.sld-ap-container .sld-ap-affiliate-link + button {
  background: var(--cyan);
  color: var(--bg);
  border: 1px solid transparent;
  border-radius: var(--tvb-r-pill);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .12em;
  padding: 12px 24px;
  cursor: pointer;
  transition: transform .2s var(--tvb-ease-out), box-shadow .35s var(--tvb-ease-out);
}
.sld-ap input[type="submit"]:hover,
.sld-ap button[type="submit"]:hover,
.sld-ap .sld-ap-form_submit:hover,
.sld-ap .sld-ap-edit-email_button:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 34px -10px var(--cyan-glow), 0 0 0 1px var(--cyan-line);
}
/* ghost / secondary (logout control top-right of the dashboard) */
.sld-ap .sld-ap-login-user_logout {
  color: var(--cyan);
  border: 1px solid var(--cyan-line);
  border-radius: var(--tvb-r-pill);
  background: transparent;
  transition: background .18s var(--tvb-ease-out), color .18s var(--tvb-ease-out);
}
.sld-ap .sld-ap-login-user_logout:hover { background: var(--cyan-soft); color: var(--cyan); }

/* --------------------------------------------------------------------------
   5) STAT TILES — the hero of the dashboard. Premium, legible at a glance.
   ------------------------------------------------------------------------ */
.sld-ap-container .sld-ap-dashboard_item {
  background: var(--surface-2);
  border: 1px solid var(--cyan-line);
  border-radius: var(--tvb-r-md);
  padding: 18px 20px;
}
.sld-ap-container .sld-ap-dashboard_item-value {
  color: var(--text);
  font-size: 1.9rem;
  font-weight: 800;
  line-height: 1.1;
}
.sld-ap-container .sld-ap-dashboard_item-subtitle {
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: .1em;
  font-size: .72rem;
}

/* --------------------------------------------------------------------------
   6) TABLES (referrals / visits / payouts). Header row shaded, subtle
   separators, hover; horizontal scroll on mobile without a wrapper.
   ------------------------------------------------------------------------ */
.sld-ap-container .sld-ap-table {
  display: block;
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-collapse: collapse;
}
.sld-ap-container .sld-ap-table th,
.sld-ap-container .sld-ap-table td {
  white-space: nowrap;                        /* keeps intrinsic width so the block scrolls */
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255,255,255,.06);
  color: var(--text-2);
}
.sld-ap-container .sld-ap-table thead th {
  background: var(--surface-2);
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: .08em;
  font-size: .72rem;
  font-weight: 600;
}
.sld-ap-container .sld-ap-table tbody tr:hover { background: rgba(255,255,255,.03); }

/* --------------------------------------------------------------------------
   7) SIDEBAR NAV (Dashboard / Referrals / Visits / Payouts). Active = cyan,
   with a cyan left-accent to echo the site's nav language. Ancestor prefix
   out-specifies the plugin's `ul.sld-ap-nav_menu > li a.active`.
   ------------------------------------------------------------------------ */
.sld-ap-container ul.sld-ap-nav_menu > li a {
  color: var(--text-3);
  border-radius: var(--tvb-r-sm);
  border-left: 2px solid transparent;
  transition: color .18s var(--tvb-ease-out), background .18s var(--tvb-ease-out);
}
.sld-ap-container ul.sld-ap-nav_menu > li a:hover { color: var(--text); background: rgba(255,255,255,.03); }
.sld-ap-container ul.sld-ap-nav_menu > li a.active {
  color: var(--cyan);
  background: var(--cyan-soft);
  border: 1px solid var(--cyan-line);
  border-left: 2px solid var(--cyan);
}
.sld-ap-container ul.sld-ap-nav_menu > li a.active svg.sld-ap-nav_menu-icon { color: var(--cyan); }

/* --------------------------------------------------------------------------
   8) NOTICES — info = cyan-soft; success / error tinted-translucent on dark.
   Never solid white or default browser colours.
   ------------------------------------------------------------------------ */
.sld-ap .sld-ap-form_notice.info {
  background: var(--cyan-soft);
  border: 1px solid var(--cyan-line);
  color: var(--cyan);
  border-radius: var(--tvb-r-sm);
}
.sld-ap .sld-ap-form_notice.info .sld-ap-form_notice_icon { color: var(--cyan); }
.sld-ap .sld-ap-form_notice.success {
  background: rgba(52,211,153,.12);
  border: 1px solid rgba(52,211,153,.32);
  color: var(--ok);
  border-radius: var(--tvb-r-sm);
}
.sld-ap .sld-ap-form_notice.warning {
  background: rgba(245,158,11,.12);
  border: 1px solid rgba(245,158,11,.32);
  color: var(--text-2);
  border-radius: var(--tvb-r-sm);
}
.sld-ap .sld-ap-form_notice.error {
  background: rgba(239,68,68,.12);
  border: 1px solid rgba(239,68,68,.35);
  color: var(--danger);
  border-radius: var(--tvb-r-sm);
}

/* status + affiliate link + content links read cyan (nav links keep their own
   treatment above; scope to content, not the whole portal) */
.sld-ap .sld-ap-affiliate-status-approved { color: var(--ok); }
.sld-ap .sld-ap-affiliate-link,
.sld-ap-container .sld-ap-main a,
.sld-ap-container .sld-ap-info-box a { color: var(--cyan); }
.sld-ap-container .sld-ap-main a:hover,
.sld-ap-container .sld-ap-info-box a:hover { text-decoration: underline; }

/* chart / store-credit surfaces inherit via the variable remap; keep them dark */
.sld-ap-container .sld_chart-container,
.sld-ap-container .sld_store-credit-card { background: var(--surface-2); border-radius: var(--tvb-r-md); }

/* --------------------------------------------------------------------------
   9) ADMIN HELPER — visible only to admins; de-emphasised. Scoped to portal
   root; overrides the plugin's orange-tinted default.
   ------------------------------------------------------------------------ */
.sld-ap-container .solid-affiliate-affiliate-portal_admin-helper {
  background: var(--surface-2);
  border: 1px solid rgba(255,255,255,.06);
  color: var(--text-3);
  border-radius: var(--tvb-r-md);
}
.sld-ap-container .solid-affiliate-affiliate-portal_admin-helper a { color: var(--text-2); }

/* --------------------------------------------------------------------------
   9b) AFFILIATE LINKS TAB — RETIRED as a tab (owner, 2026-07-15). The tab is now
   removed outright by the AFFILIATE PORTAL TABS block in functions.php, and
   ?tab=urls redirects away, so this block should never paint. Kept as a safety
   net: if that block is ever deleted (its documented kill switch) the pane comes
   back, and the owner's 2026-07-13 ask below still applies to it. Retire both
   together, never alone.

   Original note — assigned link ONLY (owner, 2026-07-13).
   The pane is a flat list of siblings inside .solid-affiliate-affiliate-
   portal_urls: [h2 "Affiliate Links", p(default assigned URL), p(build-your-
   own instructions), p(more instructions), hr, URL Generator section, hr,
   Custom slugs section]. Owner wants affiliates to see ONLY the assigned
   link — no slug talk, no DIY URL building. Keep the h2 + first paragraph;
   hide the rest. Display-only: the plugin's tracking still accepts ?sld=N
   links; custom-slug creation is already OFF in plugin settings and the
   link display format is set to ID Slugs.
   NOTE: sibling-order selectors — re-verify after Solid Affiliate updates. */
.sld-ap-container .solid-affiliate-affiliate-portal_urls > hr,
.sld-ap-container .solid-affiliate-affiliate-portal_urls > hr ~ * { display: none; }
.sld-ap-container .solid-affiliate-affiliate-portal_urls > p.sld-ap-description:nth-of-type(2),
.sld-ap-container .solid-affiliate-affiliate-portal_urls > p.sld-ap-description:nth-of-type(3) { display: none; }

/* --------------------------------------------------------------------------
   9c) TERMS TAB — the affiliate program terms (page 355) rendered inside the
   portal by the AFFILIATE PORTAL TABS block in functions.php. Its markup is generic
   (h2/h3/p/ul), so it is styled here rather than inheriting the portal's form
   rules. Measured column width + generous leading: this is a legal doc people
   actually have to read. Colours are TVB tokens only, same as the rest.
   ------------------------------------------------------------------------ */
.sld-ap-container .tvb-ap-terms {
  padding: clamp(16px, 3vw, 28px);
  max-width: 78ch;
}
.sld-ap-container .tvb-ap-terms_title {
  margin: 0 0 6px;
  font-size: clamp(1.15rem, 2.4vw, 1.5rem);
  font-weight: 800;
  letter-spacing: -.01em;
}
.sld-ap-container .tvb-ap-terms_doc {
  color: var(--text-2);
  font-size: .95rem;
  line-height: 1.75;
}
.sld-ap-container .tvb-ap-terms_doc > *:first-child { margin-top: 0; }
.sld-ap-container .tvb-ap-terms_doc > *:last-child  { margin-bottom: 0; }
.sld-ap-container .tvb-ap-terms_doc h2,
.sld-ap-container .tvb-ap-terms_doc h3,
.sld-ap-container .tvb-ap-terms_doc h4 {
  color: var(--text);
  margin: 1.6em 0 .5em;
  font-weight: 700;
  line-height: 1.3;
}
.sld-ap-container .tvb-ap-terms_doc h2 { font-size: 1.05rem; }
.sld-ap-container .tvb-ap-terms_doc h3 { font-size: .98rem; }
.sld-ap-container .tvb-ap-terms_doc h4 { font-size: .92rem; }
.sld-ap-container .tvb-ap-terms_doc p  { margin: 0 0 1em; }
.sld-ap-container .tvb-ap-terms_doc ul,
.sld-ap-container .tvb-ap-terms_doc ol { margin: 0 0 1em; padding-left: 1.35em; }
.sld-ap-container .tvb-ap-terms_doc li { margin-bottom: .45em; }
.sld-ap-container .tvb-ap-terms_doc strong { color: var(--text); font-weight: 700; }
.sld-ap-container .tvb-ap-terms_doc hr {
  border: 0;
  border-top: 1px solid rgba(255,255,255,.08);
  margin: 1.8em 0;
}
/* long affiliate URLs / emails in the terms must not push the pane sideways */
.sld-ap-container .tvb-ap-terms_doc a { overflow-wrap: anywhere; }
.sld-ap-container .tvb-ap-terms_doc table {
  width: 100%;
  display: block;
  overflow-x: auto;
  border-collapse: collapse;
}
.sld-ap-container .tvb-ap-terms_foot {
  margin: 1.8em 0 0;
  padding-top: 1.1em;
  border-top: 1px solid rgba(255,255,255,.08);
  font-size: .85rem;
}

/* --------------------------------------------------------------------------
   10) RESPONSIVE — no horizontal overflow at 360px; stat tiles/nav stack.
   ------------------------------------------------------------------------ */
/* The plugin lays the portal out as `grid-template-columns: 150px repeat(6, 1fr)`
   with nav pinned to column 1 and main to 2/-1, and never stacks it. At 360px that
   leaves main ~149px wide — every tab, not just ours (measured 2026-07-15 on the
   live portal: stat tiles 109px). Section 10 has claimed "nav stack" since v4.20.6
   without actually doing it; this makes good on it. Header and info already span
   1/-1, so only nav and main need re-placing. */
@media (max-width: 768px) {
  .sld-ap-container .sld-ap-dashboard_flex { gap: 12px; }
  .sld-ap-container .sld-ap-dashboard_item-value { font-size: 1.55rem; }
  .sld-ap-container .sld-ap-grid_container { grid-template-columns: 1fr; }
  .sld-ap-container .sld-ap-nav  { grid-column: 1 / -1; grid-row: 3 / 4; }
  .sld-ap-container .sld-ap-main { grid-column: 1 / -1; grid-row: 4 / 5; }
  /* nav becomes a horizontal strip above the content instead of a tall stack */
  .sld-ap-container ul.sld-ap-nav_menu {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
  }
  .sld-ap-container ul.sld-ap-nav_menu > li { flex: 0 0 auto; }
}
@media (max-width: 480px) {
  .sld-ap .sld-ap-form_box { padding: 18px 16px; }
  .sld-ap-container .sld-ap-dashboard_item { padding: 14px 16px; }
  .sld-ap-container .tvb-ap-terms { padding: 16px 14px; }
  .sld-ap-container .tvb-ap-terms_doc { font-size: .9rem; line-height: 1.7; }
}

/* --------------------------------------------------------------------------
   11) REDUCED MOTION — honour the OS setting. Scoped to the portal; the
   !important is required to beat the plugin's inline transition declarations
   and is deliberate + documented per the constraint.
   ------------------------------------------------------------------------ */
@media (prefers-reduced-motion: reduce) {
  .sld-ap-container *,
  .sld-ap * {
    transition: none !important;   /* portal-scoped; defeats inline transitions */
    animation: none !important;
  }
}
