/* ============================================================
   Renzo AI Studio — 5 AI-Native Features
   Feature 1: AI Copilot toast
   Feature 2: Story Builder overlay
   Feature 3: Style Memory banner
   Feature 4: What-If Simulator modal
   Feature 5: Anomaly Watchdog interrupt
   ============================================================ */

/* ── Shared tokens ─────────────────────────────────────────── */
:root {
  --rzas-bg: rgba(10, 14, 26, 0.97);
  --rzas-surface: rgba(255, 255, 255, 0.04);
  --rzas-border: rgba(255, 255, 255, 0.08);
  --rzas-primary: #6366f1;
  --rzas-success: #22c55e;
  --rzas-danger: #ef4444;
  --rzas-warn: #f59e0b;
  --rzas-text: #e2e8f0;
  --rzas-muted: #64748b;
  --rzas-radius: 12px;
  --rzas-shadow: 0 20px 60px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.06);
}

[data-theme="light"] {
  --rzas-bg: rgba(248, 250, 252, 0.98);
  --rzas-surface: rgba(0,0,0,0.03);
  --rzas-border: rgba(0,0,0,0.08);
  --rzas-text: #1e293b;
  --rzas-muted: #94a3b8;
  --rzas-shadow: 0 20px 60px rgba(0,0,0,0.15), 0 0 0 1px rgba(0,0,0,0.06);
}

/* ══════════════════════════════════════════════════════════════
   LAUNCHER TOOLBAR (bottom-right of RBI panel)
   ══════════════════════════════════════════════════════════════ */
.rz-ai-launcher {
  position: absolute;
  bottom: 72px; /* above the input area */
  right: 24px;
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--rzas-bg);
  border: 1px solid var(--rzas-border);
  border-radius: 40px;
  padding: 6px 10px;
  z-index: 100;
  box-shadow: var(--rzas-shadow);
}

.rz-launcher-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--rzas-primary);
  padding-right: 4px;
  border-right: 1px solid var(--rzas-border);
  margin-right: 2px;
}

.rz-launcher-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--rzas-muted);
  padding: 4px 8px;
  border-radius: 8px;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.5px;
  transition: color 0.15s, background 0.15s;
}
.rz-launcher-btn .lucide { width: 14px; height: 14px; }
.rz-launcher-btn:hover { color: var(--rzas-primary); background: rgba(99,102,241,0.1); }


/* ══════════════════════════════════════════════════════════════
   FEATURE 1: AI COPILOT TOAST
   ══════════════════════════════════════════════════════════════ */
.rz-copilot-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  z-index: 20000;
  background: var(--rzas-bg);
  border: 1px solid var(--rzas-border);
  border-radius: var(--rzas-radius);
  box-shadow: var(--rzas-shadow);
  width: min(480px, calc(100vw - 32px));
  opacity: 0;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease;
  pointer-events: none;
}
.rz-copilot-toast.rz-cop-visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
  pointer-events: all;
}

.rz-cop-inner {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
}

.rz-cop-icon {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  background: rgba(99,102,241,0.15);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--rzas-primary);
}
.rz-cop-icon .lucide { width: 18px; height: 18px; }

.rz-cop-body { flex: 1; min-width: 0; }
.rz-cop-title { font-size: 13px; font-weight: 600; color: var(--rzas-text); margin-bottom: 3px; }
.rz-cop-reason { font-size: 11px; color: var(--rzas-muted); line-height: 1.4; }

.rz-cop-actions { display: flex; flex-direction: column; gap: 6px; flex-shrink: 0; }

.rz-cop-yes {
  background: var(--rzas-primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
  white-space: nowrap;
}
.rz-cop-yes:hover { opacity: 0.85; }
.rz-cop-no {
  background: transparent;
  color: var(--rzas-muted);
  border: 1px solid var(--rzas-border);
  border-radius: 8px;
  padding: 5px 14px;
  font-size: 11px;
  cursor: pointer;
  transition: color 0.15s;
}
.rz-cop-no:hover { color: var(--rzas-text); }


/* ══════════════════════════════════════════════════════════════
   FEATURE 2: STORY BUILDER OVERLAY
   ══════════════════════════════════════════════════════════════ */
.rzs-overlay {
  position: fixed;
  inset: 0;
  z-index: 15000;
  background: var(--rzas-bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-family: Inter, system-ui, -apple-system, sans-serif;
  color: var(--rzas-text);
  animation: rzs-fadein 0.25s ease;
}

@keyframes rzs-fadein {
  from { opacity: 0; transform: scale(0.98); }
  to { opacity: 1; transform: scale(1); }
}

.rzs-story {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.rzs-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  border-bottom: 1px solid var(--rzas-border);
  flex-shrink: 0;
}
.rzs-header-left { display: flex; align-items: center; gap: 12px; }
.rzs-badge {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--rzas-primary);
}
.rzs-title { font-size: 15px; font-weight: 600; }
.rzs-header-right { display: flex; align-items: center; gap: 8px; }

.rzs-btn {
  border: none;
  border-radius: 8px;
  padding: 7px 14px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: opacity 0.15s;
}
.rzs-btn .lucide { width: 14px; height: 14px; }
.rzs-btn-ghost {
  background: var(--rzas-surface);
  color: var(--rzas-text);
  border: 1px solid var(--rzas-border);
}
.rzs-btn-ghost:hover { opacity: 0.8; }

.rzs-close {
  width: 32px; height: 32px;
  border-radius: 8px;
  border: 1px solid var(--rzas-border);
  background: transparent;
  color: var(--rzas-muted);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: color 0.15s;
}
.rzs-close:hover { color: var(--rzas-text); }
.rzs-close .lucide { width: 16px; height: 16px; }

/* Executive summary */
.rzs-exec-summary {
  padding: 16px 24px;
  border-bottom: 1px solid var(--rzas-border);
  flex-shrink: 0;
  min-height: 64px;
}
.rzs-exec-loading {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--rzas-muted);
}
.rzs-exec-loading span {
  width: 5px; height: 5px;
  background: var(--rzas-primary);
  border-radius: 50%;
  animation: rz-pulse 1.2s ease-in-out infinite;
}
.rzs-exec-loading span:nth-child(2) { animation-delay: 0.2s; }
.rzs-exec-loading span:nth-child(3) { animation-delay: 0.4s; }
@keyframes rz-pulse { 0%,100%{opacity:0.3} 50%{opacity:1} }

.rzs-exec-text {
  font-size: 13px;
  color: var(--rzas-text);
  line-height: 1.6;
  max-width: 700px;
}
.rzs-exec-highlight {
  display: inline-block;
  margin-top: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--rzas-primary);
  background: rgba(99,102,241,0.1);
  border-radius: 6px;
  padding: 3px 10px;
}

/* Panel grid */
.rzs-panel-grid {
  flex: 1;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  padding: 16px 24px 24px;
}
.rzs-panel-grid::-webkit-scrollbar { width: 4px; }
.rzs-panel-grid::-webkit-scrollbar-thumb { background: var(--rzas-border); border-radius: 2px; }

@media (max-width: 700px) { .rzs-panel-grid { grid-template-columns: 1fr; } }

.rzs-panel {
  background: var(--rzas-surface);
  border: 1px solid var(--rzas-border);
  border-radius: var(--rzas-radius);
  overflow: hidden;
  transition: opacity 0.4s ease, transform 0.4s ease;
  opacity: 0.4;
  transform: translateY(8px);
}
.rzs-panel.rzs-panel-ready,
.rzs-panel:has(.rzs-kpi-grid) {
  opacity: 1;
  transform: translateY(0);
}

.rzs-panel-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--rzas-muted);
  border-bottom: 1px solid var(--rzas-border);
}
.rzs-panel-header .lucide { width: 13px; height: 13px; }

.rzs-panel-body { padding: 12px 16px; min-height: 220px; }

.rzs-panel-loading {
  font-size: 11px;
  color: var(--rzas-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  height: 200px;
}

/* KPI grid inside story panel */
.rzs-kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  padding: 4px;
}
.rzs-kpi-card {
  background: rgba(99,102,241,0.07);
  border-radius: 8px;
  padding: 14px;
  text-align: center;
}
.rzs-kpi-val {
  font-size: 22px;
  font-weight: 700;
  color: var(--rzas-text);
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 6px;
}
.rzs-kpi-delta { font-size: 12px; }
.rzs-kpi-label { font-size: 11px; color: var(--rzas-muted); margin-top: 4px; }


/* ══════════════════════════════════════════════════════════════
   FEATURE 3: STYLE MEMORY BANNER
   ══════════════════════════════════════════════════════════════ */
.rz-style-banner {
  position: absolute;
  top: 70px;
  left: 50%;
  transform: translateX(-50%) translateY(-12px);
  z-index: 200;
  background: var(--rzas-bg);
  border: 1px solid rgba(99,102,241,0.3);
  border-radius: 40px;
  padding: 8px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--rzas-text);
  white-space: nowrap;
  box-shadow: 0 8px 32px rgba(0,0,0,0.3), 0 0 0 1px rgba(99,102,241,0.15);
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: none;
}
.rz-style-banner.rz-style-banner-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: all;
}
.rz-style-banner .lucide { width: 14px; height: 14px; color: var(--rzas-primary); }
.rz-style-banner strong { color: var(--rzas-primary); }

.rz-style-yes, .rz-style-no {
  border: none;
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}
.rz-style-yes { background: var(--rzas-primary); color: #fff; }
.rz-style-yes:hover { opacity: 0.85; }
.rz-style-no { background: var(--rzas-surface); color: var(--rzas-muted); border: 1px solid var(--rzas-border); }
.rz-style-no:hover { color: var(--rzas-text); }


/* ══════════════════════════════════════════════════════════════
   FEATURE 4: WHAT-IF SIMULATOR
   ══════════════════════════════════════════════════════════════ */
.rz-whatif-overlay {
  position: fixed;
  inset: 0;
  z-index: 18000;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: rzwi-fadein 0.2s ease;
}
@keyframes rzwi-fadein { from{opacity:0} to{opacity:1} }

.rz-whatif-modal {
  background: var(--rzas-bg);
  border: 1px solid var(--rzas-border);
  border-radius: var(--rzas-radius);
  box-shadow: var(--rzas-shadow);
  width: min(680px, calc(100vw - 32px));
  max-height: calc(100vh - 64px);
  overflow-y: auto;
  font-family: Inter, system-ui, -apple-system, sans-serif;
  color: var(--rzas-text);
}
.rz-whatif-modal::-webkit-scrollbar { width: 4px; }
.rz-whatif-modal::-webkit-scrollbar-thumb { background: var(--rzas-border); border-radius: 2px; }

.rz-whatif-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--rzas-border);
  flex-shrink: 0;
}
.rz-whatif-badge {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 700;
  color: var(--rzas-primary);
  letter-spacing: 0.5px;
}
.rz-whatif-badge .lucide { width: 15px; height: 15px; }
.rz-whatif-close {
  width: 28px; height: 28px;
  border-radius: 7px;
  border: 1px solid var(--rzas-border);
  background: transparent;
  color: var(--rzas-muted);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.rz-whatif-close:hover { color: var(--rzas-text); }
.rz-whatif-close .lucide { width: 14px; height: 14px; }

.rz-whatif-body {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 0;
}
@media (max-width: 600px) { .rz-whatif-body { grid-template-columns: 1fr; } }

.rz-whatif-controls {
  padding: 16px;
  border-right: 1px solid var(--rzas-border);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.rz-wf-field { display: flex; flex-direction: column; gap: 6px; }
.rz-wf-field label {
  font-size: 11px;
  font-weight: 600;
  color: var(--rzas-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.rz-wf-field select,
.rz-wf-field input[type="text"] {
  background: var(--rzas-surface);
  border: 1px solid var(--rzas-border);
  border-radius: 7px;
  color: var(--rzas-text);
  padding: 7px 10px;
  font-size: 12px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}
.rz-wf-field select:focus,
.rz-wf-field input[type="text"]:focus { border-color: var(--rzas-primary); }

.rz-wf-filter-val { position: relative; }
.rz-wf-hidden { display: none !important; }

.rz-wf-autocomplete {
  position: absolute;
  top: calc(100% + 2px);
  left: 0; right: 0;
  background: var(--rzas-bg);
  border: 1px solid var(--rzas-border);
  border-radius: 7px;
  z-index: 10;
  max-height: 140px;
  overflow-y: auto;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}
.rz-wf-ac-item {
  display: flex;
  justify-content: space-between;
  width: 100%;
  padding: 7px 10px;
  background: transparent;
  border: none;
  color: var(--rzas-text);
  font-size: 11px;
  cursor: pointer;
  text-align: left;
  border-bottom: 1px solid var(--rzas-border);
}
.rz-wf-ac-item:last-child { border-bottom: none; }
.rz-wf-ac-item:hover { background: rgba(99,102,241,0.08); }
.rz-wf-ac-item span { color: var(--rzas-muted); }

.rz-wf-field input[type="range"] {
  width: 100%;
  accent-color: var(--rzas-primary);
  padding: 0;
  border: none;
  background: transparent;
}

.rz-wf-run {
  background: var(--rzas-primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  transition: opacity 0.15s;
  margin-top: 4px;
}
.rz-wf-run:hover { opacity: 0.85; }
.rz-wf-run .lucide { width: 14px; height: 14px; }

.rz-whatif-results {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.rz-wf-hint { font-size: 12px; color: var(--rzas-muted); text-align: center; padding: 32px 0; }

.rz-wf-scenario-label {
  font-size: 11px;
  color: var(--rzas-muted);
  padding: 6px 10px;
  background: var(--rzas-surface);
  border-radius: 6px;
}

.rz-wf-delta-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.rz-wf-kpi-card {
  flex: 1;
  min-width: 80px;
  background: var(--rzas-surface);
  border: 1px solid var(--rzas-border);
  border-radius: 8px;
  padding: 10px 12px;
  text-align: center;
}
.rz-wf-after { border-color: rgba(99,102,241,0.3); }
.rz-wf-kpi-label { font-size: 10px; color: var(--rzas-muted); margin-bottom: 4px; text-transform: uppercase; letter-spacing: 0.5px; }
.rz-wf-kpi-val { font-size: 18px; font-weight: 700; }
.rz-wf-arrow { color: var(--rzas-muted); }
.rz-wf-arrow .lucide { width: 16px; height: 16px; }

.rz-wf-delta {
  font-size: 20px;
  font-weight: 800;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.rz-wf-delta-pct { font-size: 11px; font-weight: 500; color: inherit; opacity: 0.75; }

.rz-wf-chart-title { font-size: 11px; font-weight: 600; color: var(--rzas-muted); }
.rz-wf-chart-wrap { height: 180px; }
.rz-wf-affected { font-size: 11px; color: var(--rzas-muted); }


/* ══════════════════════════════════════════════════════════════
   FEATURE 5: ANOMALY WATCHDOG INTERRUPT
   ══════════════════════════════════════════════════════════════ */
.rz-watchdog-interrupt {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 25000;
  width: min(380px, calc(100vw - 32px));
  background: var(--rzas-bg);
  border-radius: var(--rzas-radius);
  box-shadow: var(--rzas-shadow);
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  opacity: 0;
  transform: translateX(40px);
  transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
  font-family: Inter, system-ui, -apple-system, sans-serif;
  color: var(--rzas-text);
}
.rz-watchdog-interrupt.rz-wd-visible {
  opacity: 1;
  transform: translateX(0);
  pointer-events: all;
}

/* Severity borders */
.rz-watchdog-high { border: 1px solid rgba(239,68,68,0.5); border-left: 3px solid var(--rzas-danger); }
.rz-watchdog-medium { border: 1px solid rgba(245,158,11,0.4); border-left: 3px solid var(--rzas-warn); }

.rz-wd-icon {
  flex-shrink: 0;
  width: 36px; height: 36px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
}
.rz-watchdog-high .rz-wd-icon { background: rgba(239,68,68,0.12); color: var(--rzas-danger); }
.rz-watchdog-medium .rz-wd-icon { background: rgba(245,158,11,0.12); color: var(--rzas-warn); }
.rz-wd-icon .lucide { width: 18px; height: 18px; }

.rz-wd-body { flex: 1; min-width: 0; }
.rz-wd-wait {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--rzas-danger);
  margin-bottom: 3px;
}
.rz-watchdog-medium .rz-wd-wait { color: var(--rzas-warn); }

.rz-wd-headline { font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.rz-wd-detail { font-size: 11px; color: var(--rzas-muted); line-height: 1.4; }

.rz-wd-actions { display: flex; flex-direction: column; gap: 6px; flex-shrink: 0; }

.rz-wd-investigate {
  background: var(--rzas-danger);
  color: #fff;
  border: none;
  border-radius: 7px;
  padding: 6px 12px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
  white-space: nowrap;
}
.rz-watchdog-medium .rz-wd-investigate { background: var(--rzas-warn); color: #000; }
.rz-wd-investigate:hover { opacity: 0.85; }

.rz-wd-action {
  font-size: 11px;
  color: #22c55e;
  margin-top: 6px;
  padding: 6px 10px;
  background: rgba(34,197,153,0.06);
  border-radius: 6px;
  border: 1px solid rgba(34,197,153,0.15);
  display: flex;
  align-items: flex-start;
  gap: 6px;
  line-height: 1.4;
  font-weight: 500;
}

.rz-wd-dismiss {
  background: transparent;
  border: 1px solid var(--rzas-border);
  border-radius: 7px;
  color: var(--rzas-muted);
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  align-self: center;
  transition: color 0.15s;
}
.rz-wd-dismiss:hover { color: var(--rzas-text); }
.rz-wd-dismiss .lucide { width: 13px; height: 13px; }
