/* ============================================================
   DIA v4 — product command centre
   Business context · live conversation · operational timeline
   ============================================================ */

.stage {
  --accent-a: #155EEF;
  --accent-b: #06B6D4;
  position: relative;
  border-radius: var(--r-2xl);
  background: var(--dark-surface);
  border: 1px solid var(--dark-border);
  overflow: hidden;
  isolation: isolate;
}

/* ambient light that changes per business */
.stage::before {
  content: "";
  position: absolute;
  inset: -30% -10% auto -10%;
  height: 70%;
  z-index: 0;
  background:
    radial-gradient(46% 60% at 22% 0%, color-mix(in srgb, var(--accent-a) 42%, transparent), transparent 70%),
    radial-gradient(40% 55% at 78% 8%, color-mix(in srgb, var(--accent-b) 34%, transparent), transparent 70%);
  opacity: 0.5;
  filter: blur(38px);
  transition: background 900ms var(--ease), opacity 900ms var(--ease);
  pointer-events: none;
}
@supports not (background: color-mix(in srgb, red 50%, transparent)) {
  .stage::before { background: radial-gradient(46% 60% at 30% 0%, rgba(6, 182, 212,0.4), transparent 70%); }
}

.stage > * { position: relative; z-index: 1; }

/* ---------------- top bar ---------------- */
.stage__bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s3) var(--s4);
  padding: var(--s4) var(--s5);
  border-bottom: 1px solid var(--dark-border);
  background: rgba(11, 19, 32, 0.55);
  backdrop-filter: blur(12px);
}
.stage__bar .tabs { background: rgba(255,255,255,0.06); }
.stage__controls { display: flex; align-items: center; gap: var(--s2); margin-left: auto; }
.stage__btn {
  width: 44px; height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(255,255,255,0.08);
  color: #fff;
  cursor: pointer;
  transition: background var(--t-fast), transform var(--t-fast);
}
.stage__btn:hover { background: rgba(255,255,255,0.16); }
.stage__btn:active { transform: scale(0.94); }
.stage__btn svg { width: 15px; height: 15px; }
.stage__btn--text { width: auto; min-width: 44px; padding-inline: 0.7rem; border-radius: var(--r-pill); font-size: var(--fs-xs); font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------------- three areas ---------------- */
.stage__grid {
  display: grid;
  grid-template-columns: minmax(0, 0.82fr) minmax(0, 1.28fr) minmax(0, 0.9fr);
  min-height: 460px;
}
.stage__col { padding: var(--s5); }
.stage__col + .stage__col { border-left: 1px solid var(--dark-border); }
.stage__col--center { padding: 0; display: flex; flex-direction: column; }

.stage h3.stage__title {
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-on-dark-soft);
  margin-bottom: var(--s4);
}

/* ---------------- business context ---------------- */
.bizcard__name { font-size: 1.15rem; font-weight: 600; color: #fff; letter-spacing: -0.02em; }
.bizcard__type { font-size: var(--fs-sm); color: var(--text-on-dark-soft); }
.bizcard__status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-top: 10px;
  padding: 4px 10px;
  border-radius: var(--r-pill);
  background: rgba(22, 163, 106, 0.16);
  color: #46D39A;
  font-size: var(--fs-xs);
  font-weight: 500;
}
.bizcard__status::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  animation: livedot 2.4s ease-in-out infinite;
}
@keyframes livedot { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

.syslist { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.sysline {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0;
  font-size: var(--fs-sm);
  color: var(--text-on-dark-soft);
}
.sysline__dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #38D6EA;
  box-shadow: 0 0 0 0 rgba(56, 214, 234, 0.5);
  animation: syspulse 3.2s ease-out infinite;
  flex: none;
}
.sysline:nth-child(2) .sysline__dot { animation-delay: 0.5s; }
.sysline:nth-child(3) .sysline__dot { animation-delay: 1s; }
@keyframes syspulse {
  0% { box-shadow: 0 0 0 0 rgba(56, 214, 234, 0.45); }
  70% { box-shadow: 0 0 0 7px rgba(56, 214, 234, 0); }
  100% { box-shadow: 0 0 0 0 rgba(56, 214, 234, 0); }
}

.request-box {
  margin: var(--s5) 0;
  padding: var(--s4);
  border-radius: var(--r-md);
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--dark-border);
  font-size: var(--fs-sm);
  color: #fff;
}
.request-box span { display: block; font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-on-dark-soft); margin-bottom: 5px; }

.rules { list-style: none; margin: 0; padding: 0; display: grid; gap: 7px; }
.rule {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  margin: 0;
  padding: 7px 9px;
  border-radius: 10px;
  font-size: var(--fs-xs);
  color: var(--text-on-dark-soft);
  border: 1px solid transparent;
  transition: background var(--t-base), color var(--t-base), border-color var(--t-base);
}
.rule__mark {
  flex: none;
  width: 6px; height: 6px;
  margin-top: 6px;
  border-radius: 2px;
  background: var(--text-muted);
  transition: background var(--t-base), transform var(--t-base);
}
.rule.is-active {
  background: rgba(56, 214, 234, 0.12);
  border-color: rgba(56, 214, 234, 0.3);
  color: #fff;
}
.rule.is-active .rule__mark { background: #38D6EA; transform: scale(1.4); }

/* ---------------- conversation column ---------------- */
.convo-head {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: var(--s4) var(--s5);
  border-bottom: 1px solid var(--dark-border);
  font-size: var(--fs-sm);
}
.convo-head__icon {
  width: 34px; height: 34px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: rgba(255,255,255,0.08);
  color: #fff;
  flex: none;
}
.convo-head__icon svg { width: 16px; height: 16px; }
.convo-head__meta { min-width: 0; }
.convo-head__meta b { display: block; color: #fff; font-weight: 500; }
.convo-head__right { margin-left: auto; display: flex; align-items: center; gap: var(--s3); }
.calltimer { font-variant-numeric: tabular-nums; font-size: var(--fs-sm); color: var(--text-on-dark-soft); }

/* channel-specific header icon colour */
.convo-head[data-channel="whatsapp"] .convo-head__icon { color: #46D39A; }
.convo-head[data-channel="instagram"] .convo-head__icon { color: #CFFAFE; }
.convo-head[data-channel="website"] .convo-head__icon { color: #38D6EA; }

/* waveform */
.wave { display: flex; align-items: center; gap: 3px; height: 22px; }
.wave i {
  width: 3px;
  height: 5px;
  border-radius: 2px;
  background: #38D6EA;
  opacity: 0.5;
  transform-origin: center;
}
.wave[data-mode="active"] i { animation: waveb 900ms ease-in-out infinite; opacity: 1; }
.wave[data-mode="ring"] i { animation: waveb 1600ms ease-in-out infinite; opacity: 0.8; }
.wave i:nth-child(1) { animation-delay: 0ms; }
.wave i:nth-child(2) { animation-delay: 90ms; }
.wave i:nth-child(3) { animation-delay: 180ms; }
.wave i:nth-child(4) { animation-delay: 270ms; }
.wave i:nth-child(5) { animation-delay: 360ms; }
.wave i:nth-child(6) { animation-delay: 450ms; }
.wave i:nth-child(7) { animation-delay: 540ms; }
@keyframes waveb { 0%, 100% { height: 5px; } 50% { height: 20px; } }
@media (prefers-reduced-motion: reduce) { .wave i { animation: none !important; height: 10px; } }

.stage .convo { flex: 1; max-height: 380px; }

/* view toggle + handover */
.stage__foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s3);
  padding: var(--s4) var(--s5);
  border-top: 1px solid var(--dark-border);
}
.viewtoggle { display: inline-flex; padding: 3px; gap: 2px; border-radius: var(--r-pill); background: rgba(255,255,255,0.07); }
.viewtoggle button {
  min-height: 44px;
  padding: 0.4rem 1rem;
  border-radius: var(--r-pill);
  color: var(--text-on-dark-soft);
  font-size: var(--fs-xs);
  font-weight: 500;
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast);
}
.viewtoggle button[aria-pressed="true"] { background: rgba(255,255,255,0.16); color: #fff; }
.handover-btn {
  margin-left: auto;
  min-height: 44px;
  padding: 0.4rem 0.95rem;
  border-radius: var(--r-pill);
  border: 1px solid rgba(255,255,255,0.2);
  color: #fff;
  font-size: var(--fs-xs);
  font-weight: 500;
  cursor: pointer;
  transition: background var(--t-fast), border-color var(--t-fast);
}
.handover-btn:hover:not([disabled]) { background: rgba(255,255,255,0.1); border-color: rgba(255,255,255,0.35); }
.handover-btn[disabled] { opacity: 0.45; cursor: default; }
.handover-note {
  width: 100%;
  padding: 0.55rem 0.75rem;
  border-radius: 10px;
  /* human attention uses the orange accent, never gold */
  background: rgba(249, 115, 22, 0.14);
  border: 1px solid rgba(249, 115, 22, 0.32);
  color: #FDBA74;
  font-size: var(--fs-xs);
  animation: msg-in 300ms var(--ease-out) both;
}

/* ---------------- business view record ---------------- */
.rec {
  padding: var(--s5);
  animation: panel-in var(--t-slow) both;
}
.rec__head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); margin-bottom: var(--s4); }
.rec__head b { color: #fff; font-size: var(--fs-body); }
.rec__row {
  display: flex;
  justify-content: space-between;
  gap: var(--s4);
  padding: 0.5rem 0;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  font-size: var(--fs-sm);
  color: var(--text-on-dark-soft);
}
.rec__row span:last-child { color: #fff; text-align: right; font-weight: 500; }
.rec__note {
  margin-top: var(--s4);
  padding: var(--s3) var(--s4);
  border-radius: 10px;
  background: rgba(56, 214, 234, 0.12);
  color: #BBD9F5;
  font-size: var(--fs-xs);
}

/* ---------------- action timeline ---------------- */
.timeline { position: relative; }
.timeline .results li { padding: 0.55rem 0; }
.timeline .results li::after {
  content: "";
  position: absolute;
  left: 9px;
  width: 1px;
  height: 14px;
  margin-top: 30px;
  background: rgba(255,255,255,0.12);
}
.timeline .results { position: relative; }
.timeline .results li { position: relative; }
.timeline .results li:last-child::after { display: none; }

.stage-result {
  margin-top: var(--s5);
  padding: var(--s4);
  border-radius: var(--r-md);
  background: rgba(22, 163, 106, 0.12);
  border: 1px solid rgba(22, 163, 106, 0.28);
  display: grid;
  gap: 3px;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity var(--t-slow), transform var(--t-slow);
}
.stage-result.is-in { opacity: 1; transform: none; }
.stage-result b { color: #7BE3B4; font-size: var(--fs-sm); }
.stage-result span { color: var(--text-on-dark-soft); font-size: var(--fs-xs); }

/* ---------------- responsive ---------------- */
@media (max-width: 1080px) {
  .stage__grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); }
  .stage__col--right { grid-column: 1 / -1; border-left: 0; border-top: 1px solid var(--dark-border); }
}
/* Tablet keeps context + conversation side by side; phones stack. */
@media (max-width: 720px) {
  .stage__grid { grid-template-columns: minmax(0, 1fr); }
  .stage__col + .stage__col { border-left: 0; border-top: 1px solid var(--dark-border); }
  .stage .convo { max-height: 320px; }
  .stage__bar { gap: var(--s2); }
  .stage__controls { margin-left: 0; width: 100%; }
  .handover-btn { margin-left: 0; }
}
