/* ── Corporate Brain Demo: Scoped Styles ──────────────────────────────────
   All rules under .cb-demo — same design language as .lg-demo.
─────────────────────────────────────────────────────────────────────────── */

.cb-demo {
  --cbd-green:        #22c55e;
  --cbd-green-tint:   #f0fdf4;
  --cbd-green-border: #bbf7d0;
  --cbd-text:         #111111;
  --cbd-text-sec:     #6b7280;
  --cbd-text-ter:     #9ca3af;
  --cbd-bg:           #fafafa;
  --cbd-bg-white:     #ffffff;
  --cbd-border:       #e5e7eb;
  --cbd-r-sm:         0.375rem;
  --cbd-r-md:         0.5rem;
  --cbd-r-lg:         0.75rem;
  --cbd-r-xl:         1rem;
  --cbd-font:         'Inter', -apple-system, BlinkMacSystemFont, sans-serif;

  font-family: var(--cbd-font);
  font-size: 0.9375rem;
  line-height: 1.6;
  color: var(--cbd-text);
  -webkit-font-smoothing: antialiased;
}

.cb-demo *, .cb-demo *::before, .cb-demo *::after { box-sizing: border-box; }
.cb-demo button { border: none; background: none; font-family: inherit; }
.cb-demo p, .cb-demo ul { margin: 0; padding: 0; list-style: none; }

/* ── App Shell ─────────────────────────────────────────────────────────── */
.cb-demo .app-shell {
  margin: 0;
  max-width: none;
  background: var(--cbd-bg-white);
  border: 1.5px solid #b8bfc9;
  border-radius: var(--cbd-r-xl);
  box-shadow: 0 6px 32px rgba(0,0,0,0.13), 0 2px 8px rgba(0,0,0,0.07);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 460px;
}

/* ── Panel header (shared) ─────────────────────────────────────────────── */
.cb-demo .cb-panel-hdr {
  padding: 12px 16px;
  border-bottom: 1px solid var(--cbd-border);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--cbd-bg-white);
}
.cb-demo .cb-avatar {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, #166534 0%, #22c55e 100%);
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 800; color: #fff;
  flex-shrink: 0; letter-spacing: .03em;
}
.cb-demo .cb-agent-name { font-size: 13px; font-weight: 600; color: var(--cbd-text); line-height: 1.2; }
.cb-demo .cb-agent-desc { font-size: 11px; color: var(--cbd-text-ter); }

/* ── Section label (right panels) ─────────────────────────────────────── */
.cb-demo .cb-section-lbl {
  padding: 11px 14px 9px;
  font-size: 10.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .08em;
  color: var(--cbd-text-ter);
  border-bottom: 1px solid var(--cbd-border);
  flex-shrink: 0;
}

/* ── Split layout ──────────────────────────────────────────────────────── */
.cb-demo .cb-split {
  display: flex; flex: 1; min-height: 0;
}

/* ══ UC1 — FORM + RESPONSE ══════════════════════════════════════════════ */

/* Form panel (left) */
.cb-demo .cb-form-panel {
  flex: 1; display: flex; flex-direction: column;
  border-right: 1px solid var(--cbd-border);
  min-width: 0;
}
.cb-demo .cb-form-body {
  padding: 18px 16px; display: flex; flex-direction: column; gap: 12px; flex: 1;
}
.cb-demo .cb-field { display: flex; flex-direction: column; gap: 4px; }
.cb-demo .cb-field-label {
  font-size: 10.5px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .07em; color: var(--cbd-text-ter);
}
.cb-demo .cb-input {
  height: 34px; padding: 0 11px;
  border: 1px solid var(--cbd-border); border-radius: var(--cbd-r-md);
  font-size: 12.5px; color: var(--cbd-text); background: var(--cbd-bg);
  font-family: var(--cbd-font); pointer-events: none; outline: none;
  transition: border-color .2s;
}
.cb-demo .cb-input::placeholder { color: var(--cbd-text-ter); }
.cb-demo .cb-input.typing       { border-color: var(--cbd-green); background: #fff; }
.cb-demo .cb-input.filled       { border-color: #d1d5db; background: #fff; color: var(--cbd-text); }

.cb-demo .cb-analyse-btn {
  margin-top: 4px; height: 38px; width: 100%;
  background: var(--cbd-green); color: #fff;
  border-radius: var(--cbd-r-md); font-size: 13px; font-weight: 600;
  pointer-events: none; cursor: default;
  opacity: .45; transition: opacity .35s, transform .1s;
}
.cb-demo .cb-analyse-btn.ready   { opacity: 1; }
.cb-demo .cb-analyse-btn.clicking { transform: scale(.97); }

/* Response panel (right) */
.cb-demo .cb-response-panel {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; background: var(--cbd-bg);
}
.cb-demo .cb-response-body {
  flex: 1; padding: 14px; overflow-y: hidden;
  display: flex; flex-direction: column; gap: 10px;
}
.cb-demo .cb-response-empty {
  flex: 1; display: flex; align-items: center; justify-content: center;
  font-size: 12px; color: var(--cbd-text-ter); text-align: center;
  padding: 0 16px; line-height: 1.5;
}

/* Response bubble (right panel) */
.cb-demo .cb-resp-bubble {
  background: #fff; border: 1px solid var(--cbd-border);
  border-left: 3px solid var(--cbd-green);
  border-radius: var(--cbd-r-md);
  padding: 11px 13px;
  font-size: 12px; color: var(--cbd-text); line-height: 1.6;
}
.cb-demo .cb-ref {
  display: inline-flex; align-items: center; justify-content: center;
  width: 15px; height: 15px; border-radius: 50%;
  background: var(--cbd-green); color: #fff;
  font-size: 9px; font-weight: 700; margin: 0 2px; vertical-align: middle;
}
.cb-demo .cb-verified {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 500; color: #15803d;
  background: var(--cbd-green-tint); border: 1px solid var(--cbd-green-border);
  padding: 3px 10px; border-radius: 9999px;
}

/* Source cards (right panel UC1) */
.cb-demo .cb-src-mini {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; padding: 8px 10px;
  background: #fff; border: 1px solid var(--cbd-border);
  border-radius: var(--cbd-r-md);
  opacity: 0; transform: translateY(5px);
  transition: opacity .4s ease, transform .4s ease, background .25s, border-color .25s;
}
.cb-demo .cb-src-mini.visible   { opacity: 1; transform: translateY(0); }
.cb-demo .cb-src-mini.highlight { background: var(--cbd-green-tint); border-color: var(--cbd-green-border); }
.cb-demo .cb-src-mini-name  { font-size: 11.5px; font-weight: 600; color: var(--cbd-text); }
.cb-demo .cb-src-mini-type  { font-size: 10px; color: var(--cbd-text-ter); background: #f3f4f6; padding: 2px 6px; border-radius: 4px; }
.cb-demo .cb-src-mini-pct   { font-size: 10.5px; font-weight: 700; color: var(--cbd-green); white-space: nowrap; }

/* Chat input bar (UC1 follow-up questions) */
.cb-demo .cb-chat-input-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--cbd-border);
  background: var(--cbd-bg-white);
  flex-shrink: 0;
}
.cb-demo .cb-chat-input {
  flex: 1; height: 34px; padding: 0 11px;
  border: 1px solid var(--cbd-border); border-radius: var(--cbd-r-md);
  font-size: 12.5px; font-family: var(--cbd-font); color: var(--cbd-text);
  background: var(--cbd-bg); pointer-events: none; outline: none;
}
.cb-demo .cb-chat-input::placeholder { color: var(--cbd-text-ter); }
.cb-demo .cb-chat-send-btn {
  height: 34px; padding: 0 14px;
  background: var(--cbd-green); color: #fff;
  border-radius: var(--cbd-r-md); font-size: 12px; font-weight: 600;
  pointer-events: none; cursor: default; white-space: nowrap;
}

/* Typing indicator */
.cb-demo .cb-typing {
  display: flex; gap: 4px; align-items: center;
  padding: 9px 13px;
  background: #f3f4f6; border-radius: 4px 12px 12px 12px;
  width: fit-content;
}
.cb-demo .cb-typing span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--cbd-text-ter);
  animation: cb-bounce 1.2s ease-in-out infinite;
}
.cb-demo .cb-typing span:nth-child(2) { animation-delay: .2s; }
.cb-demo .cb-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes cb-bounce {
  0%,60%,100% { transform: translateY(0); opacity: .5; }
  30%         { transform: translateY(-5px); opacity: 1; }
}

/* ══ UC2 — ERP FULL-WIDTH CHAT ══════════════════════════════════════════ */
.cb-demo .cb-fullchat {
  display: flex; flex-direction: column; flex: 1; min-height: 0;
  position: relative; /* cursor anchor */
}
.cb-demo .cb-fc-messages {
  flex: 1; overflow-y: auto; padding: 16px 20px 8px;
  display: flex; flex-direction: column; gap: 12px;
}
.cb-demo .cb-msg {
  display: flex; gap: 8px; max-width: 100%;
}
.cb-demo .cb-msg__bubble {
  padding: 9px 13px; border-radius: 4px 12px 12px 12px;
  font-size: 12.5px; line-height: 1.55;
  background: #f3f4f6; color: var(--cbd-text);
}
.cb-demo .cb-quick-replies {
  display: flex; gap: 8px; flex-wrap: wrap;
  padding: 4px 20px 16px; flex-shrink: 0;
}
.cb-demo .cb-qr-btn {
  padding: 7px 14px; font-size: 12.5px; font-weight: 500;
  border: 1.5px solid var(--cbd-border); border-radius: var(--cbd-r-lg);
  color: var(--cbd-text-sec); background: #fff;
  transition: border-color .25s, color .25s, background .25s, transform .1s;
  pointer-events: none; cursor: default;
}
.cb-demo .cb-qr-btn.active {
  border-color: var(--cbd-green); color: #15803d;
  background: var(--cbd-green-tint); font-weight: 600;
}

/* ── ERP message wrapper ───────────────────────────────────────────────── */
.cb-demo .cb-erp-msg {
  width: 100%;
}

/* ── Top-to-bottom reveal ──────────────────────────────────────────────── */
.cb-demo .cb-reveal {
  clip-path: inset(0 0 100% 0);
  transition: clip-path 1.6s cubic-bezier(0.4, 0, 0.2, 1);
}
.cb-demo .cb-reveal.shown { clip-path: inset(0 0 0% 0); }

/* ── ERP table (shared by Bestellhistorie + Schneider) ─────────────────── */
.cb-demo .cb-erp-wrap {
  background: #f9fafb; border: 1px solid var(--cbd-border);
  border-radius: var(--cbd-r-lg); overflow: hidden;
}
.cb-demo .cb-erp-title {
  padding: 10px 16px; font-size: 12.5px; font-weight: 700;
  color: var(--cbd-text); border-bottom: 1px solid var(--cbd-border);
  background: #fff;
}
.cb-demo .cb-erp-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.cb-demo .cb-erp-table th {
  padding: 7px 14px; font-size: 10.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em; color: var(--cbd-text-ter);
  text-align: left; border-bottom: 1px solid var(--cbd-border); background: #f9fafb;
}
.cb-demo .cb-erp-table tbody tr td {
  padding: 8px 14px; color: var(--cbd-text); border-bottom: 1px solid var(--cbd-border);
  opacity: 0; transition: opacity .35s ease;
}
.cb-demo .cb-erp-table tbody tr.row-visible td  { opacity: 1; }
.cb-demo .cb-erp-table tbody tr.row-summary td  {
  font-weight: 700; background: var(--cbd-green-tint);
  color: #15803d; border-bottom: none; opacity: 1;
}
.cb-demo .cb-overdue {
  font-size: 10.5px; font-weight: 600;
  color: #ef4444; background: #fef2f2;
  padding: 2px 7px; border-radius: 4px;
}
.cb-demo .cb-invoice-footer {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; background: #fff; border-top: 1px solid var(--cbd-border);
  font-size: 12px;
}
.cb-demo .cb-invoice-rec {
  font-size: 11.5px; font-weight: 600; color: #ef4444;
}

/* ── Customer card ─────────────────────────────────────────────────────── */
.cb-demo .cb-customer-card {
  background: #f9fafb; border: 1px solid var(--cbd-border);
  border-radius: var(--cbd-r-lg); overflow: hidden;
}
.cb-demo .cb-cust-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; background: #fff;
  border-bottom: 1px solid var(--cbd-border);
}
.cb-demo .cb-cust-name  { font-size: 14px; font-weight: 700; color: var(--cbd-text); }
.cb-demo .cb-cust-meta  { font-size: 11.5px; color: var(--cbd-text-sec); }
.cb-demo .cb-status-pill {
  font-size: 10.5px; font-weight: 600; color: #15803d;
  background: var(--cbd-green-tint); border: 1px solid var(--cbd-green-border);
  padding: 2px 9px; border-radius: 9999px;
}
.cb-demo .cb-cust-metrics {
  display: grid; grid-template-columns: 1fr 1fr;
  border-bottom: 1px solid var(--cbd-border);
}
.cb-demo .cb-cust-metric {
  padding: 11px 16px;
}
.cb-demo .cb-cust-metric + .cb-cust-metric { border-left: 1px solid var(--cbd-border); }
.cb-demo .cb-metric-lbl { font-size: 10.5px; color: var(--cbd-text-ter); font-weight: 600; text-transform: uppercase; letter-spacing: .07em; margin-bottom: 3px; }
.cb-demo .cb-metric-val { font-size: 16px; font-weight: 700; color: var(--cbd-text); }
.cb-demo .cb-metric-val.warn { color: #d97706; }
.cb-demo .cb-cust-rows { padding: 10px 16px; display: flex; flex-direction: column; gap: 6px; }
.cb-demo .cb-cust-row { display: flex; gap: 8px; font-size: 12px; }
.cb-demo .cb-cust-row-lbl { font-size: 10.5px; font-weight: 600; color: var(--cbd-text-ter); text-transform: uppercase; letter-spacing: .07em; min-width: 96px; margin-top: 1px; }
.cb-demo .cb-erp-badge {
  margin: 0 16px 12px;
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 10.5px; font-weight: 600; color: var(--cbd-text-ter);
  background: #f3f4f6; padding: 3px 10px; border-radius: 9999px;
}

/* ── Cursor ────────────────────────────────────────────────────────────── */
.cb-demo .cb-cursor-ptr {
  position: absolute; pointer-events: none; z-index: 30; opacity: 0;
  transition: top .85s cubic-bezier(.4,0,.2,1),
              left .85s cubic-bezier(.4,0,.2,1),
              opacity .3s ease;
  filter: drop-shadow(0 2px 5px rgba(0,0,0,.35));
}
.cb-demo .cb-cursor-ptr.visible { opacity: 1; }
@keyframes cb-click-anim {
  0%  { transform: scale(1); }
  45% { transform: scale(.78); }
  100%{ transform: scale(1); }
}
.cb-demo .cb-cursor-ptr.clicking { animation: cb-click-anim .2s ease forwards; }

/* ══ UC2 — Chat + Dashboard Split ══════════════════════════════════════ */

/* User message (right-aligned) */
.cb-demo .cb-msg--user { flex-direction: row-reverse; }
.cb-demo .cb-msg--user .cb-msg__bubble {
  background: var(--cbd-green); color: #fff;
  border-radius: 12px 4px 12px 12px;
}

/* Chat input typing highlight */
.cb-demo .cb-chat-input.typing { border-color: var(--cbd-green); background: #fff; }

/* Left chat panel */
.cb-demo .cb-uc2-left {
  width: 38%; flex-shrink: 0;
  display: flex; flex-direction: column;
  border-right: 1px solid var(--cbd-border);
}

/* Right dashboard panel */
.cb-demo .cb-uc2-right {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column;
  background: var(--cbd-bg);
}

/* Dashboard body */
.cb-demo .cb-dash-body {
  flex: 1; overflow: hidden;
  display: flex; flex-direction: column;
}

/* Customer header row */
.cb-demo .cb-dash-cust-hdr {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 8px;
}
.cb-demo .cb-dash-cust-name { font-size: 13.5px; font-weight: 700; color: var(--cbd-text); }
.cb-demo .cb-dash-cust-meta { font-size: 10.5px; color: var(--cbd-text-ter); margin-top: 2px; }

/* KPI grid (2 × 2) */
.cb-demo .cb-dash-kpis {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
}
.cb-demo .cb-dash-kpi {
  background: #fff; border: 1px solid var(--cbd-border);
  border-radius: var(--cbd-r-md); padding: 10px 12px;
  opacity: 0; transform: translateY(5px);
  transition: opacity .4s ease, transform .4s ease;
}
.cb-demo .cb-dash-kpi.visible { opacity: 1; transform: translateY(0); }
.cb-demo .cb-dash-kpi-lbl {
  font-size: 9.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .07em; color: var(--cbd-text-ter); margin-bottom: 4px;
}
.cb-demo .cb-dash-kpi-val {
  font-size: 17px; font-weight: 800; color: var(--cbd-text); line-height: 1.1;
}
.cb-demo .cb-dash-kpi-val.sm   { font-size: 12.5px; font-weight: 700; margin-top: 2px; }
.cb-demo .cb-dash-kpi-val.warn { color: #d97706; }
.cb-demo .cb-dash-kpi-delta { font-size: 10px; color: var(--cbd-text-ter); margin-top: 3px; }
.cb-demo .cb-dash-kpi-delta.green { color: #15803d; font-weight: 600; }
.cb-demo .cb-dash-kpi-delta.warn  { color: #d97706; font-weight: 600; }

/* Section micro-title */
.cb-demo .cb-dash-sec-title {
  font-size: 9.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .08em; color: var(--cbd-text-ter); margin-bottom: -4px;
}

/* Bar chart */
.cb-demo .cb-dash-chart-area {
  display: flex; align-items: flex-end; gap: 5px; height: 68px;
  border-bottom: 1px solid var(--cbd-border); padding: 0 2px;
}
.cb-demo .cb-dash-bar-col {
  flex: 1; min-width: 0;
}
.cb-demo .cb-dash-bar {
  width: 100%; height: 0; border-radius: 3px 3px 0 0;
  background: var(--cbd-green);
  transition: height .9s cubic-bezier(.4,0,.2,1);
}
.cb-demo .cb-dash-bar.hi { background: #166534; }
.cb-demo .cb-dash-chart-labels {
  display: flex; gap: 5px; padding: 4px 2px 0;
}
.cb-demo .cb-dash-chart-labels span {
  flex: 1; font-size: 9.5px; text-align: center; color: var(--cbd-text-ter);
}

/* Orders table (compact) */
.cb-demo .cb-dash-orders {
  border: 1px solid var(--cbd-border); border-radius: var(--cbd-r-md);
  overflow: hidden; background: #fff;
}
.cb-demo .cb-dash-orders table { width: 100%; border-collapse: collapse; font-size: 11.5px; }
.cb-demo .cb-dash-orders thead th {
  padding: 6px 10px; font-size: 9.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em; color: var(--cbd-text-ter);
  text-align: left; border-bottom: 1px solid var(--cbd-border); background: #f9fafb;
}
.cb-demo .cb-dash-orders tbody tr td {
  padding: 7px 10px; color: var(--cbd-text); border-bottom: 1px solid var(--cbd-border);
  opacity: 0; transition: opacity .3s ease;
}
.cb-demo .cb-dash-orders tbody tr:last-child td { border-bottom: none; }
.cb-demo .cb-dash-orders tbody tr.row-visible td { opacity: 1; }
.cb-demo .cb-dash-st-open { font-size: 10px; font-weight: 600; color: #d97706; background: #fffbeb; padding: 2px 6px; border-radius: 4px; }
.cb-demo .cb-dash-st-paid { font-size: 10px; font-weight: 600; color: #15803d; background: var(--cbd-green-tint); padding: 2px 6px; border-radius: 4px; }

/* Recommendation strip */
.cb-demo .cb-dash-rec {
  display: flex; align-items: center; gap: 7px;
  padding: 8px 12px; font-size: 11.5px; font-weight: 600; color: #dc2626;
  background: #fef2f2; border: 1px solid #fecaca; border-radius: var(--cbd-r-md);
}
