/*
  EcosystemDiagram CSS Module
  ============================
  Ported from ecosystem-diagram.html (standalone artifact).
  Component catalog mirrors json-render primitives used by the
  Runwell chatbot widgets across the four product brands.

  Brand rules:
    Runwell tangerine (#FF6B35) = Office, Virtual Assistant, Channels
    Tenant emerald (brand.tenantPrimary) = Knowledge, Website
    Tenant accent (brand.tenantAccent) = Outbound flow arrows
*/

/* ==========================================================================
   Design tokens (CSS custom properties)
   ========================================================================== */
.ecosystem {
  /* Runwell tokens */
  --rw-primary: #ff6b35;
  --rw-primary-hover: #e55a28;
  --rw-primary-glow: rgba(255, 107, 53, 0.12);
  --rw-primary-edge: rgba(255, 107, 53, 0.32);
  --rw-bg: #faf9f8;
  --rw-surface: #ffffff;
  --rw-text: #0b0a09;
  --rw-text-2: #44403c;
  --rw-muted: #78716c;
  --rw-muted-2: #a8a29e;
  --rw-border: #e7e5e4;
  --rw-border-soft: #f2f0ee;
  --rw-border-strong: #d6d3d1;

  /* Tenant tokens (overridden via inline style from brand prop) */
  --vd-emerald: #2e8a60;
  --vd-emerald-hover: #267350;
  --vd-emerald-soft: rgba(46, 138, 96, 0.1);
  --vd-emerald-edge: rgba(46, 138, 96, 0.32);
  --vd-gold: #cdaf58;
  --vd-gold-soft: rgba(205, 175, 88, 0.14);
  --vd-gold-edge: rgba(205, 175, 88, 0.4);
  --vd-cream: #faf8f5;
  --vd-deep: #12211a;

  /* Neutrals */
  --n-50: #fafaf9;
  --n-100: #f5f5f4;
  --n-200: #e7e5e4;
  --n-300: #d6d3d1;
  --n-400: #a8a29e;
  --n-500: #78716c;
  --n-600: #57534e;
  --n-700: #44403c;
  --n-800: #292524;
  --n-900: #1c1917;

  /* Semantic */
  --success: #059669;
  --success-bg: rgba(5, 150, 105, 0.1);

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(28, 25, 23, 0.05);
  --shadow-sm: 0 1px 3px rgba(28, 25, 23, 0.08), 0 1px 2px rgba(28, 25, 23, 0.04);
  --shadow-md: 0 4px 12px rgba(28, 25, 23, 0.08), 0 2px 4px rgba(28, 25, 23, 0.04);
  --shadow-lg: 0 20px 50px rgba(28, 25, 23, 0.09), 0 8px 16px rgba(28, 25, 23, 0.05);
  --shadow-rw: 0 0 0 1px var(--rw-primary-edge), 0 20px 50px rgba(255, 107, 53, 0.12);
  --shadow-vd: 0 0 0 1px var(--vd-emerald-edge), 0 20px 50px rgba(46, 138, 96, 0.1);

  /* Radii */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 20px;
  --r-full: 999px;

  position: relative;
  max-width: 1400px;
  margin: 0 auto;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    sans-serif;
  color: var(--rw-text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ==========================================================================
   SVG overlay for connection lines
   ========================================================================== */
.ecosystemSvg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 5;
  overflow: visible;
}

/* ==========================================================================
   Ecosystem grid (card layout)
   ========================================================================== */
.ecosystemGrid {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1fr;
  gap: 140px;
  padding-left: 120px;
  padding-right: 120px;
}

/* ==========================================================================
   jr-card (Card primitive)
   ========================================================================== */
.jrCard {
  background: var(--rw-surface);
  border: 1px solid var(--rw-border);
  border-radius: var(--r-xl);
  padding: 22px 26px;
  box-shadow: var(--shadow-sm);
  position: relative;
  transition: box-shadow 0.2s, transform 0.2s, border-color 0.2s;
}

.jrCardRunwellFocus {
  border-color: var(--rw-primary-edge);
  box-shadow: var(--shadow-rw);
}
.jrCardRunwellFocus::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: var(--r-xl);
  background: radial-gradient(
    circle at 80% 0%,
    var(--rw-primary-glow) 0%,
    transparent 55%
  );
  pointer-events: none;
}

.jrCardRunwellTint {
  background: linear-gradient(180deg, #fffaf5 0%, #ffffff 40%);
  border-color: var(--rw-primary-edge);
}
.jrCardRunwellTint::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: var(--r-xl);
  background: radial-gradient(
      circle at 0% 0%,
      var(--rw-primary-glow) 0%,
      transparent 50%
    ),
    radial-gradient(
      circle at 100% 0%,
      var(--rw-primary-glow) 0%,
      transparent 50%
    );
  pointer-events: none;
}

.jrCardVirtue {
  background: var(--vd-cream);
  border-color: var(--vd-emerald-edge);
  box-shadow: var(--shadow-vd);
}
.jrCardVirtue::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: var(--r-xl);
  background: radial-gradient(
      circle at 20% 0%,
      var(--vd-emerald-soft) 0%,
      transparent 50%
    ),
    radial-gradient(
      circle at 100% 100%,
      var(--vd-gold-soft) 0%,
      transparent 55%
    );
  pointer-events: none;
}

.jrCardOffice {
  padding: 24px 28px 26px;
}

.jrCardHeader {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  position: relative;
}

.jrCardTitleBlock {
  display: flex;
  align-items: center;
  gap: 14px;
}

.jrCardIcon {
  width: 44px;
  height: 44px;
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: var(--rw-primary-glow);
  color: var(--rw-primary);
}
.jrCardVirtue .jrCardIcon {
  background: var(--vd-emerald-soft);
  color: var(--vd-emerald);
}
.jrCardIcon svg {
  width: 22px;
  height: 22px;
}

.jrCardTitle {
  font-size: 18px;
  font-weight: 700;
  color: var(--rw-text);
  letter-spacing: -0.3px;
  margin-bottom: 2px;
}
.jrCardVirtue .jrCardTitle {
  color: var(--vd-deep);
}

.jrCardSublabel {
  font-size: 13px;
  color: var(--rw-muted);
  font-weight: 500;
}
.jrCardVirtue .jrCardSublabel {
  color: var(--vd-emerald-hover);
}

.jrCardDescription {
  margin-top: 10px;
  font-size: 13px;
  color: var(--rw-text-2);
  line-height: 1.5;
  position: relative;
}
.jrCardVirtue .jrCardDescription {
  color: var(--vd-deep);
}

.jrCardBody {
  margin-top: 14px;
  position: relative;
}
.jrCardHeader + .jrCardBody {
  margin-top: 16px;
}

/* ==========================================================================
   Stack + Grid primitives
   ========================================================================== */
.jrStack {
  display: flex;
  flex-direction: column;
}
.jrStackRow {
  flex-direction: row;
  align-items: center;
}
.jrStackGapXs {
  gap: 6px;
}
.jrStackGapSm {
  gap: 10px;
}
.jrStackGapMd {
  gap: 14px;
}
.jrStackGapLg {
  gap: 20px;
}
.jrStackGapXl {
  gap: 28px;
}
.jrStackBetween {
  justify-content: space-between;
}

.jrGrid {
  display: grid;
}
.jrGridCols2 {
  grid-template-columns: 1fr 1fr;
}
.jrGridCols3 {
  grid-template-columns: 1fr 1fr 1fr;
}
.jrGridSplit {
  grid-template-columns: 1.25fr 1fr;
}
.jrGridGapSm {
  gap: 12px;
}
.jrGridGapMd {
  gap: 18px;
}
.jrGridGapLg {
  gap: 80px;
}

/* ==========================================================================
   Text + Badge + StatusIndicator primitives
   ========================================================================== */
.jrText {
  color: var(--rw-text-2);
  font-size: 13.5px;
  line-height: 1.6;
}
.jrTextMuted {
  color: var(--rw-muted);
}
.jrTextSmall {
  font-size: 12px;
}

.jrBadge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: var(--n-100);
  border: 1px solid var(--rw-border);
  border-radius: var(--r-full);
  font-size: 11px;
  font-weight: 600;
  color: var(--rw-text-2);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  white-space: nowrap;
}
.jrBadgeRunwell {
  background: var(--rw-primary-glow);
  border-color: var(--rw-primary-edge);
  color: var(--rw-primary);
}
.jrBadgeVirtue {
  background: var(--vd-emerald-soft);
  border-color: var(--vd-emerald-edge);
  color: var(--vd-emerald);
}
.jrBadgeGold {
  background: var(--vd-gold-soft);
  border-color: var(--vd-gold-edge);
  color: #8a6a02;
}
.jrBadgeSuccess {
  background: var(--success-bg);
  border-color: rgba(5, 150, 105, 0.25);
  color: var(--success);
}

.jrStatus {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 500;
  color: var(--rw-muted);
}
.jrStatusDot {
  position: relative;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  flex-shrink: 0;
}
.jrStatusDot::after {
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  background: var(--success);
  opacity: 0.3;
  animation: ping 1.8s cubic-bezier(0, 0, 0.2, 1) infinite;
}
@keyframes ping {
  0% {
    transform: scale(1);
    opacity: 0.3;
  }
  75%,
  100% {
    transform: scale(2);
    opacity: 0;
  }
}

/* ==========================================================================
   Metric primitive
   ========================================================================== */
.jrMetric {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.jrMetricLabel {
  font-size: 11px;
  font-weight: 600;
  color: var(--rw-muted);
  text-transform: uppercase;
  letter-spacing: 0.9px;
}
.jrMetricValue {
  display: flex;
  align-items: baseline;
  gap: 5px;
  font-size: 22px;
  font-weight: 700;
  color: var(--rw-text);
  letter-spacing: -0.4px;
  line-height: 1;
}
.jrMetricUnit {
  font-size: 12px;
  font-weight: 500;
  color: var(--rw-muted);
  letter-spacing: 0;
}
.jrMetricVirtue .jrMetricValue {
  color: var(--vd-deep);
}

/* ==========================================================================
   List primitive (capability list)
   ========================================================================== */
.jrList {
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.jrListItem {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 13px;
  color: var(--rw-text-2);
}
.jrListBullet {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--rw-primary-glow);
  color: var(--rw-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 1px;
}
.jrListBullet svg {
  width: 9px;
  height: 9px;
}
.jrCardVirtue .jrListBullet {
  background: var(--vd-emerald-soft);
  color: var(--vd-emerald);
}
.jrCardVirtue .jrListItem {
  color: var(--vd-deep);
}

/* ==========================================================================
   SectionHeader primitive (used inside Office)
   ========================================================================== */
.jrSectionHeader {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.jrSectionHeaderLabel {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--rw-muted);
  text-transform: uppercase;
  letter-spacing: 1.4px;
}
.jrSectionHeaderLine {
  flex: 1;
  height: 1px;
  background: var(--rw-border);
}

/* ==========================================================================
   ChannelTile composite
   ========================================================================== */
.jrChannel {
  background: var(--vd-cream);
  border: 1px solid var(--vd-emerald-edge);
  border-radius: var(--r-lg);
  padding: 16px 18px;
  transition: border-color 0.2s, transform 0.2s, box-shadow 0.2s;
  position: relative;
}
.jrChannel:hover {
  border-color: var(--vd-emerald);
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(46, 138, 96, 0.12);
}

.jrChannelHead {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}
.jrChannelIcon {
  width: 36px;
  height: 36px;
  border-radius: var(--r-md);
  background: var(--vd-emerald-soft);
  color: var(--vd-emerald);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.jrChannelIcon svg {
  width: 20px;
  height: 20px;
}

.jrChannelTitle {
  font-size: 14px;
  font-weight: 700;
  color: var(--vd-deep);
  letter-spacing: -0.2px;
}
.jrChannelSub {
  font-size: 11px;
  color: var(--vd-emerald-hover);
  margin-top: 1px;
  font-weight: 500;
}

.jrChannelFooter {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 9px;
  border-top: 1px solid rgba(46, 138, 96, 0.18);
}

.jrDirection {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 600;
  color: var(--vd-emerald-hover);
  text-transform: uppercase;
  letter-spacing: 0.8px;
}
.jrDirection svg {
  width: 12px;
  height: 12px;
}

/* ==========================================================================
   SourceCard composite (content sources)
   ========================================================================== */
.jrSource {
  background: var(--vd-cream);
  border: 1px solid var(--vd-emerald-edge);
  border-radius: var(--r-lg);
  padding: 16px 18px;
  transition: all 0.2s;
  position: relative;
}
.jrSource:hover {
  border-color: var(--vd-emerald);
  transform: translateY(-1px);
  box-shadow: 0 8px 24px rgba(46, 138, 96, 0.1);
}

.jrSourceHead {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}
.jrSourceIcon {
  width: 32px;
  height: 32px;
  border-radius: var(--r-md);
  background: var(--vd-emerald-soft);
  color: var(--vd-emerald);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.jrSourceIcon svg {
  width: 16px;
  height: 16px;
}

.jrSourceTitle {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--vd-deep);
  letter-spacing: -0.1px;
}
.jrSourceSub {
  font-size: 11px;
  color: var(--vd-emerald-hover);
  margin-top: 1px;
  font-weight: 500;
}

.jrSourceMeta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 11px;
  color: var(--vd-emerald-hover);
  font-weight: 500;
  padding-top: 8px;
  border-top: 1px solid rgba(46, 138, 96, 0.15);
}
.jrSourceMetaDot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--vd-emerald);
}

/* ==========================================================================
   FeatureChip composite (Office built-in features)
   ========================================================================== */
.jrFeature {
  background: var(--rw-surface);
  border: 1px solid var(--rw-border);
  border-radius: var(--r-md);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: border-color 0.2s, transform 0.2s;
}
.jrFeature:hover {
  border-color: var(--rw-border-strong);
  transform: translateY(-1px);
}

.jrFeatureIcon {
  width: 34px;
  height: 34px;
  border-radius: var(--r-sm);
  background: var(--n-100);
  color: var(--rw-text);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.jrFeatureIcon svg {
  width: 16px;
  height: 16px;
}

.jrFeatureBody {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.jrFeatureLabel {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--rw-text);
  letter-spacing: -0.1px;
}
.jrFeatureMeta {
  font-size: 10.5px;
  color: var(--rw-muted);
  font-weight: 500;
}

/* ==========================================================================
   ModuleCard composite (Office paid modules)
   ========================================================================== */
.jrModule {
  background: linear-gradient(160deg, var(--rw-surface) 0%, #fff7f2 100%);
  border: 1.5px solid var(--rw-primary-edge);
  border-radius: var(--r-lg);
  padding: 22px 24px 20px;
  position: relative;
  transition: all 0.2s;
  overflow: hidden;
}
.jrModule:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--rw-primary);
  transform: translateY(-2px);
}
.jrModule::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 140px;
  height: 140px;
  background: radial-gradient(
    circle at top right,
    var(--rw-primary-glow) 0%,
    transparent 60%
  );
  pointer-events: none;
}

.jrModuleHead {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
  position: relative;
}

.jrModuleTitleRow {
  display: flex;
  align-items: center;
  gap: 11px;
}
.jrModuleIcon {
  width: 38px;
  height: 38px;
  border-radius: var(--r-md);
  background: var(--rw-primary);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 6px 16px rgba(255, 107, 53, 0.3);
}
.jrModuleIcon svg {
  width: 20px;
  height: 20px;
}

.jrModuleTitle {
  font-size: 16px;
  font-weight: 700;
  color: var(--rw-text);
  letter-spacing: -0.2px;
}
.jrModuleSub {
  font-size: 11.5px;
  color: var(--rw-muted);
  font-weight: 500;
  margin-top: 1px;
}

.jrModuleBody {
  font-size: 12.5px;
  color: var(--rw-text-2);
  line-height: 1.55;
  margin-bottom: 14px;
  position: relative;
}

.jrModuleFooter {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--rw-border-soft);
  position: relative;
}

.jrModuleOutput {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11px;
  color: var(--rw-muted);
  font-weight: 500;
}
.jrModuleOutput svg {
  width: 12px;
  height: 12px;
  color: var(--rw-primary);
}

/* ==========================================================================
   VA capability box
   ========================================================================== */
.vaCapabilities {
  background: var(--rw-bg);
  border-radius: var(--r-md);
  padding: 16px 18px;
  border: 1px solid var(--rw-border-soft);
}

/* ==========================================================================
   SVG connection styles (edge paths)
   ========================================================================== */
.edge {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.edgeInbound {
  stroke: var(--rw-primary);
  stroke-width: 3.4;
}
.edgeKnowledge {
  stroke: var(--vd-emerald);
  stroke-width: 3.2;
  stroke-dasharray: 7 5;
}
.edgeSync {
  stroke: var(--rw-primary);
  stroke-width: 3.8;
}
.edgeOutbound {
  stroke: var(--vd-gold);
  stroke-width: 3.6;
}

/* ==========================================================================
   Animations
   ========================================================================== */
@keyframes pulse {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.4;
    transform: scale(0.82);
  }
}

/* ==========================================================================
   Mobile responsive
   ========================================================================== */
@media (max-width: 1024px) {
  .ecosystemGrid {
    padding-left: 40px;
    padding-right: 40px;
  }
}

@media (max-width: 768px) {
  .ecosystem {
    font-size: 13px;
  }
  .ecosystemGrid {
    padding-left: 0;
    padding-right: 0;
    gap: 20px;
  }
  .ecosystemSvg {
    display: none; /* edges are too complex for mobile */
  }
  .jrGridSplit {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  .jrGridCols3 {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .jrGridCols2 {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .jrCard {
    padding: 16px 18px;
  }
  .jrCardTitle {
    font-size: 16px;
  }
  .jrModule {
    padding: 16px 18px 14px;
  }
  .jrMetricValue {
    font-size: 18px;
  }
}
