/* ═══════════════════════════════════════════════════════════════════════
   REFERRAL (P6 distribution flywheel) — consumer web + desktop only.
   Hidden on mobile viewports per product scope (<900px + body.is-mobile).
   Hidden for enterprise members via body.is-enterprise.
   ═══════════════════════════════════════════════════════════════════════ */

/* Wrapper is position:relative so the ⓘ info popover can anchor to it
   without being clipped by the banner's overflow:hidden. */
.session-refer-banner-wrap {
  position: relative;
  margin: 0 0 12px;
}
.session-refer-banner { margin: 0; }

/* Refer label — warmer orange accent vs. the amber feedback label */
.session-refer-banner .sfb-banner-label {
  background: rgba(217, 119, 87, 0.14);
  color: #d97757;
  border: 1px solid rgba(217, 119, 87, 0.28);
}
[data-theme='dark'] .session-refer-banner .sfb-banner-label {
  background: rgba(217, 119, 87, 0.18);
  color: #e68d6d;
}

/* Right side: progress bar + Share button */
.sfb-refer-right {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-left: auto;
}
.sfb-refer-progress {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  min-width: 170px;
}
.sfb-refer-bar {
  width: 160px;
  height: 6px;
  background: rgba(0, 0, 0, 0.08);
  border-radius: 999px;
  overflow: hidden;
}
[data-theme='dark'] .sfb-refer-bar { background: rgba(255, 255, 255, 0.08); }
.sfb-refer-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #d97757 0%, #e68d6d 100%);
  border-radius: 999px;
  transition: width 0.35s ease;
}
.sfb-refer-progress-text {
  font-size: 10.5px;
  color: #6e6e80;
  white-space: nowrap;
}
[data-theme='dark'] .sfb-refer-progress-text { color: #9898a8; }

.sfb-refer-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-card, #fff);
  border: 1px solid rgba(217, 119, 87, 0.35);
  color: #d97757;
  padding: 6px 14px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  transition: background 0.15s, border-color 0.15s;
}
[data-theme='dark'] .sfb-refer-btn {
  background: transparent;
  border-color: rgba(217, 119, 87, 0.4);
  color: #e68d6d;
}
.sfb-refer-btn:hover {
  background: rgba(217, 119, 87, 0.08);
  border-color: #d97757;
}
.sfb-refer-btn svg { width: 14px; height: 14px; }

/* ⓘ info button */
.session-refer-banner .sfb-info-btn,
.wispherflow-share-popover .sfb-info-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px;
  margin-left: 4px;
  color: #9898a8;
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
  transition: color 0.15s;
}
.session-refer-banner .sfb-info-btn:hover,
.wispherflow-share-popover .sfb-info-btn:hover { color: #d97757; }
.session-refer-banner .sfb-info-btn svg,
.wispherflow-share-popover .sfb-info-btn svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
}

/* Info popover — hover-triggered, animates in/out like Google's ⓘ tooltips.
   Uses visibility+opacity+transform instead of display:none so CSS transitions work. */
.sfb-info-popover {
  position: absolute;
  top: calc(100% + 8px);
  left: 170px;
  width: 300px;
  background: var(--bg-card, #fff);
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 10px;
  padding: 14px 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
  font-family: 'DM Sans', sans-serif;
  z-index: 9999;
  /* hidden state */
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-6px) scale(0.97);
  transform-origin: top center;
  transition:
    opacity 0.13s ease-in,
    transform 0.13s ease-in,
    visibility 0s linear 0.13s;
}
[data-theme='dark'] .sfb-info-popover {
  background: #12121a;
  border-color: rgba(255, 255, 255, 0.08);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.55);
}
.sfb-info-popover.visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0) scale(1);
  transition:
    opacity 0.16s ease-out,
    transform 0.16s ease-out,
    visibility 0s linear 0s;
}
.sfb-info-popover h5 {
  margin: 0 0 8px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 600;
  color: #2a2a2a;
}
[data-theme='dark'] .sfb-info-popover h5 { color: #f0ede8; }
.sfb-info-popover h5 svg {
  width: 14px;
  height: 14px;
  stroke: #d97757;
  fill: none;
  stroke-width: 1.8;
}
.sfb-info-popover p {
  margin: 0 0 8px;
  font-size: 11.5px;
  line-height: 1.5;
  color: #6e6e80;
}
[data-theme='dark'] .sfb-info-popover p { color: #9898a8; }
.sfb-info-popover p strong { color: #2a2a2a; font-weight: 600; }
[data-theme='dark'] .sfb-info-popover p strong { color: #f0ede8; }
.sfb-info-popover ol {
  margin: 0 0 8px;
  padding-left: 18px;
  font-size: 11.5px;
  line-height: 1.6;
  color: #6e6e80;
}
[data-theme='dark'] .sfb-info-popover ol { color: #9898a8; }
.sfb-info-popover ol li { margin-bottom: 4px; }
.sfb-info-popover .foot-note {
  font-size: 10.5px;
  color: #9898a8;
  font-style: italic;
  margin: 6px 0 0;
}

/* Shared share popover */
.wispherflow-share-popover {
  width: 340px;
  background: var(--bg-card, #fff);
  border: 1px solid rgba(217, 119, 87, 0.25);
  border-radius: 10px;
  padding: 16px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
  font-family: 'DM Sans', sans-serif;
  /* Force own GPU compositing layer so position:fixed renders correctly in
     Electron transparent+content-protected windows (WDA_EXCLUDEFROMCAPTURE
     on Windows / NSWindowSharingNone on macOS can suppress fixed elements
     that share a compositor tile with the window backdrop). */
  will-change: transform;
  isolation: isolate;
}
[data-theme='dark'] .wispherflow-share-popover {
  background: #12121a;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
}
.wispherflow-share-popover h4 {
  margin: 0 0 4px;
  font-size: 13.5px;
  font-weight: 600;
  color: #2a2a2a;
  display: flex;
  align-items: center;
  gap: 6px;
}
[data-theme='dark'] .wispherflow-share-popover h4 { color: #f0ede8; }
.wispherflow-share-popover .subtitle {
  font-size: 11.5px;
  color: #6e6e80;
  margin: 0 0 14px;
  line-height: 1.5;
}
[data-theme='dark'] .wispherflow-share-popover .subtitle { color: #9898a8; }
.wispherflow-share-popover .linkbox {
  display: flex;
  align-items: center;
  background: rgba(0, 0, 0, 0.04);
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 6px;
  padding: 4px 4px 4px 12px;
  margin-bottom: 10px;
}
[data-theme='dark'] .wispherflow-share-popover .linkbox {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.08);
}
.wispherflow-share-popover .linkbox-text {
  flex: 1;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11.5px;
  color: #2a2a2a;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
[data-theme='dark'] .wispherflow-share-popover .linkbox-text { color: #f0ede8; }
.wispherflow-share-popover .linkbox-text span { color: #d97757; font-weight: 600; }
.wispherflow-share-popover .copy-btn {
  background: #d97757;
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 5px 10px;
  font-size: 10.5px;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-family: 'DM Sans', sans-serif;
}
.wispherflow-share-popover .channels {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  margin-bottom: 12px;
}
.wispherflow-share-popover .channel {
  background: transparent;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 6px;
  padding: 8px 4px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s;
}
[data-theme='dark'] .wispherflow-share-popover .channel {
  border-color: rgba(255, 255, 255, 0.08);
}
.wispherflow-share-popover .channel:hover { border-color: #d97757; }
.wispherflow-share-popover .channel svg {
  width: 16px;
  height: 16px;
  fill: #6e6e80;
  margin-bottom: 3px;
}
[data-theme='dark'] .wispherflow-share-popover .channel svg { fill: #9898a8; }
.wispherflow-share-popover .channel:hover svg { fill: #d97757; }
.wispherflow-share-popover .channel-name {
  font-size: 10px;
  color: #6e6e80;
  display: block;
}
[data-theme='dark'] .wispherflow-share-popover .channel-name { color: #9898a8; }
.wispherflow-share-popover .progress-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0 0;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  font-size: 11px;
  color: #6e6e80;
}
[data-theme='dark'] .wispherflow-share-popover .progress-row {
  border-top-color: rgba(255, 255, 255, 0.08);
  color: #9898a8;
}
.wispherflow-share-popover .progress-row strong { color: #d97757; font-weight: 700; }
.wispherflow-share-popover .how-link {
  font-size: 10.5px;
  color: #d97757;
  text-decoration: none;
  margin-top: 6px;
  display: inline-block;
  cursor: pointer;
  font-weight: 600;
}
.wispherflow-share-popover .how-link:hover { text-decoration: underline; }

/* Close × button (plain icon, no background fill) */
.sfb-close-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px;
  margin-left: 4px;
  color: #9898a8;
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
  transition: color 0.15s;
}
.sfb-close-btn:hover { color: #d97757; }
.sfb-close-btn svg { width: 15px; height: 15px; }

/* Row-level share icon (appears on completed session rows).
 * Solid filled rounded square — terra fill, white icon — matches the
 * "round square" visual language of the live-session End/primary buttons.
 * box-sizing + explicit 28×28 + flex-basis crush any vertical-rectangle
 * stretching from the parent flex container or 1px border math. */
.session-row-share-btn {
  /* Desktop: 28×28 to match the rest of the row's .table-icon-btn
   * siblings exactly. The previous size + filled background + box-shadow
   * combo made it visually heavier (read as "bigger") than its
   * outline-only neighbours. Now: same 28×28 dimensions, no shadow,
   * smaller icon for parity with sibling weight. */
  box-sizing: border-box !important;
  width: 28px !important;
  height: 28px !important;
  min-width: 28px !important;
  max-width: 28px !important;
  min-height: 28px !important;
  max-height: 28px !important;
  flex: 0 0 28px !important;
  aspect-ratio: 1 / 1 !important;
  padding: 0 !important;
  margin: 0 !important;
  line-height: 1 !important;
  background: #d97757;
  border: 1px solid #d97757;
  color: #ffffff;
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  box-shadow: none;
  transition:
    background 0.15s ease,
    border-color 0.15s ease;
  -webkit-appearance: none;
  appearance: none;
  font-size: 0;
}
.session-row-share-btn:hover {
  background: #c46849;
  border-color: #c46849;
}
.session-row-share-btn svg {
  width: 13px;
  height: 13px;
  pointer-events: none;
}

/* On mobile + tablet the data-table actions render as 44x44 touch targets
 * (see components.css ~line 13778). The share icon must match that size
 * exactly so it sits flush in the row alongside duplicate / download /
 * delete — otherwise it reads as a separate, smaller affordance. */
@media (max-width: 1024px) {
  .session-row-share-btn {
    width: 44px !important;
    height: 44px !important;
    min-width: 44px !important;
    max-width: 44px !important;
    min-height: 44px !important;
    max-height: 44px !important;
    flex: 0 0 44px !important;
    border-radius: 12px !important;
  }
  .session-row-share-btn svg {
    width: 18px !important;
    height: 18px !important;
  }
}

/* Row share button hover preview card — small, pointer-events:none so
   it never intercepts the click that still opens the full share panel. */
.row-share-hover-card {
  position: fixed;
  z-index: 10002;
  width: 214px;
  background: var(--bg-card, #fff);
  border: 1px solid rgba(217, 119, 87, 0.28);
  border-radius: 9px;
  padding: 10px 12px 9px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.14);
  font-family: 'DM Sans', sans-serif;
  pointer-events: none;
  /* hidden state */
  opacity: 0;
  visibility: hidden;
  transform: translateY(5px) scale(0.97);
  transform-origin: bottom center;
  transition:
    opacity 0.13s ease-in,
    transform 0.13s ease-in,
    visibility 0s linear 0.13s;
}
[data-theme='dark'] .row-share-hover-card {
  background: #12121a;
  border-color: rgba(217, 119, 87, 0.3);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.5);
}
.row-share-hover-card.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
  transition:
    opacity 0.16s ease-out,
    transform 0.16s ease-out,
    visibility 0s linear 0s;
}
.rshc-head {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}
.rshc-head svg {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
  stroke: #d97757;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.rshc-head span {
  font-size: 12px;
  font-weight: 600;
  color: #2a2a2a;
}
[data-theme='dark'] .rshc-head span { color: #f0ede8; }
.rshc-sub {
  font-size: 11px;
  color: #6e6e80;
  line-height: 1.45;
  margin: 0 0 7px;
}
[data-theme='dark'] .rshc-sub { color: #9898a8; }
.rshc-progress {
  display: flex;
  align-items: center;
  gap: 6px;
}
.rshc-bar {
  flex: 1;
  height: 4px;
  background: rgba(0, 0, 0, 0.08);
  border-radius: 999px;
  overflow: hidden;
}
[data-theme='dark'] .rshc-bar { background: rgba(255, 255, 255, 0.08); }
.rshc-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #d97757 0%, #e68d6d 100%);
  border-radius: 999px;
  transition: width 0.3s ease;
}
.rshc-prog-text {
  font-size: 10px;
  color: #9898a8;
  white-space: nowrap;
}
.rshc-hint {
  display: block;
  margin-top: 7px;
  font-size: 10px;
  color: #d97757;
  font-weight: 600;
  letter-spacing: 0.01em;
}

/* Minimal toast for Instagram copy-link flow */
.wispherflow-mini-toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  background: #2a2a2a;
  color: #fff;
  padding: 10px 16px;
  border-radius: 8px;
  font: 500 12.5px/1.4 'DM Sans', sans-serif;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  z-index: 10001;
  max-width: 340px;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.wispherflow-mini-toast.visible { opacity: 1; }

/* Mobile scope:
 *   - The full-width referral banner stays hidden (eats too much real
 *     estate at the top of the sessions page on phones).
 *   - The inline per-row share button + its popover ARE shown so users
 *     can share completed-session entries directly from the History
 *     table on mobile, matching desktop. */
@media (max-width: 900px) {
  .session-refer-banner-wrap {
    display: none !important;
  }
}
body.is-mobile .session-refer-banner-wrap {
  display: none !important;
}
body.is-enterprise .session-refer-banner-wrap,
body.is-enterprise .session-row-share-btn {
  display: none !important;
}
