/* =============================================================================
   FLOWORK OS — DUAL-CANVAS LIFECYCLE STAGE: CANVAS_DUAL_MODE.CSS
   Architecture: Sovereign Solo Studio vs. Swarm Tactical War Room
   Zero-Zombie, Zero Idle Overhead, Multi-OS High-Contrast Glassmorphism
   Co-authored-by: Flowork OS <agent@floworkos.com>
   ============================================================================= */

/* ── VIEWPORT STAGE INTEGRATION ── */
.view-panel-canvas {
  display: none;
  flex: 1;
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
  box-sizing: border-box;
}

.view-panel-canvas.active {
  display: flex !important;
  flex-direction: column;
}

.canvas-dynamic-root {
  display: flex;
  flex: 1;
  width: 100%;
  height: 100%;
  overflow: hidden;
  position: relative;
}

/* Common Canvas Mode Container Shell */
.canvas-mode-container {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  padding: 16px 20px;
  gap: 14px;
  box-sizing: border-box;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 229, 255, 0.25) transparent;
}

/* =============================================================================
   1. SOVEREIGN SOLO STUDIO (MR. FLOW CORE)
   Theme: Obsidian Black, Electric Cyan (#00e5ff), Emerald (#10b981)
   Focus: Single-Agent High-Fidelity Execution, Zero Background Overhead
   ============================================================================= */
.solo-studio-container {
  background: radial-gradient(circle at 15% 15%, rgba(0, 229, 255, 0.04) 0%, transparent 60%),
              radial-gradient(circle at 85% 85%, rgba(16, 185, 129, 0.03) 0%, transparent 50%),
              rgba(3, 7, 18, 0.85);
}

/* Solo Header Banner */
.solo-header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(6, 11, 20, 0.92);
  border: 1px solid rgba(0, 229, 255, 0.22);
  border-radius: 12px;
  padding: 12px 18px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(0, 229, 255, 0.15);
}

.solo-header-identity {
  display: flex;
  align-items: center;
  gap: 12px;
}

.solo-avatar-crest {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(0, 229, 255, 0.25), rgba(16, 185, 129, 0.2));
  border: 1.5px solid rgba(0, 229, 255, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  box-shadow: 0 0 12px rgba(0, 229, 255, 0.2);
}

.solo-title-wrap {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.solo-title-main {
  font-size: 14px;
  font-weight: 700;
  color: #f8fafc;
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.solo-badge-tag {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 6px;
  background: rgba(0, 229, 255, 0.12);
  color: #00e5ff;
  border: 1px solid rgba(0, 229, 255, 0.3);
  letter-spacing: 0.05em;
}

.solo-subtitle {
  font-size: 11px;
  color: #94a3b8;
  display: flex;
  align-items: center;
  gap: 6px;
}

.solo-header-telemetry {
  display: flex;
  align-items: center;
  gap: 8px;
}

.solo-pill {
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 20px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #cbd5e1;
}

.solo-pill-accent {
  background: rgba(16, 185, 129, 0.12);
  border-color: rgba(16, 185, 129, 0.35);
  color: #34d399;
}

/* Solo Main Body Split Grid */
.solo-body-grid {
  display: grid;
  grid-template-columns: 1.55fr 1fr;
  gap: 14px;
  flex: 1;
  min-height: 0;
}

@media (max-width: 1024px) {
  .solo-body-grid {
    grid-template-columns: 1fr;
  }
}

.solo-card {
  background: rgba(6, 11, 20, 0.88);
  border: 1px solid rgba(0, 229, 255, 0.14);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.solo-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: rgba(0, 229, 255, 0.04);
  border-bottom: 1px solid rgba(0, 229, 255, 0.12);
}

.solo-card-title {
  font-size: 12px;
  font-weight: 700;
  color: #e2e8f0;
  display: flex;
  align-items: center;
  gap: 6px;
}

.solo-tab-strip {
  display: flex;
  gap: 4px;
}

.solo-subtab-btn {
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid transparent;
  background: transparent;
  color: #94a3b8;
  cursor: pointer;
  transition: all 0.18s ease;
}

.solo-subtab-btn:hover {
  color: #f1f5f9;
  background: rgba(255, 255, 255, 0.05);
}

.solo-subtab-btn.active {
  background: rgba(0, 229, 255, 0.14);
  border-color: rgba(0, 229, 255, 0.35);
  color: #00e5ff;
}

.solo-card-body {
  padding: 14px;
  flex: 1;
  overflow-y: auto;
  font-size: 12px;
  color: #cbd5e1;
  line-height: 1.5;
}

/* Solo Radar HUD Items */
.solo-radar-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.05);
  margin-bottom: 8px;
}

.solo-radar-label {
  font-size: 11px;
  color: #94a3b8;
  display: flex;
  align-items: center;
  gap: 6px;
}

.solo-radar-val {
  font-size: 11px;
  font-weight: 600;
  color: #f1f5f9;
}

.solo-doctrine-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 10px;
}

.solo-doctrine-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  padding: 6px 10px;
  border-radius: 6px;
  background: rgba(16, 185, 129, 0.06);
  border: 1px solid rgba(16, 185, 129, 0.2);
  color: #a7f3d0;
}

/* Code & Artifact Preview inside Solo Studio */
.solo-artifact-box {
  background: #040810;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 10px;
  font-family: var(--font-mono, monospace);
  font-size: 11px;
  color: #e2e8f0;
  max-height: 380px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

.solo-artifact-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.solo-btn-action {
  background: rgba(0, 229, 255, 0.12);
  border: 1px solid rgba(0, 229, 255, 0.3);
  color: #00e5ff;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.solo-btn-action:hover {
  background: rgba(0, 229, 255, 0.25);
  box-shadow: 0 0 8px rgba(0, 229, 255, 0.3);
}

/* =============================================================================
   2. SWARM TACTICAL WAR ROOM (MULTI-AGENT SQUAD)
   Theme: Obsidian Slate, Neon Violet (#a855f7), Electric Cyan (#38bdf8), Amber (#f59e0b)
   Focus: DAG Mesh Visualization, Live Blackboard, Stage Gates & Multi-Lane Channels
   ============================================================================= */
.group-warroom-container {
  background: radial-gradient(circle at 10% 20%, rgba(168, 85, 247, 0.06) 0%, transparent 60%),
              radial-gradient(circle at 90% 70%, rgba(56, 189, 248, 0.05) 0%, transparent 55%),
              radial-gradient(circle at 50% 50%, rgba(245, 158, 11, 0.03) 0%, transparent 70%),
              rgba(3, 7, 18, 0.88);
}

/* War Room Header Banner */
.warroom-header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(12, 10, 26, 0.94);
  border: 1px solid rgba(168, 85, 247, 0.3);
  border-radius: 12px;
  padding: 12px 18px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(168, 85, 247, 0.2);
}

.warroom-identity {
  display: flex;
  align-items: center;
  gap: 12px;
}

.warroom-avatar-crest {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(168, 85, 247, 0.35), rgba(56, 189, 248, 0.25));
  border: 1.5px solid rgba(168, 85, 247, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 19px;
  box-shadow: 0 0 14px rgba(168, 85, 247, 0.3);
}

.warroom-title-wrap {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.warroom-title-main {
  font-size: 14px;
  font-weight: 700;
  color: #faf5ff;
  display: flex;
  align-items: center;
  gap: 8px;
}

.warroom-badge-tag {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 6px;
  background: rgba(168, 85, 247, 0.15);
  color: #c084fc;
  border: 1px solid rgba(168, 85, 247, 0.35);
  letter-spacing: 0.05em;
}

.warroom-subtitle {
  font-size: 11px;
  color: #94a3b8;
  display: flex;
  align-items: center;
  gap: 8px;
}

.warroom-roster-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 10px;
  background: rgba(255, 255, 255, 0.06);
  color: #cbd5e1;
}

.warroom-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.warroom-pill-phase {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.35);
  color: #fbbf24;
}

/* Center Stage: Interactive Dynamic SVG DAG Mesh */
.warroom-dag-stage {
  background: rgba(8, 7, 18, 0.94);
  border: 1px solid rgba(168, 85, 247, 0.2);
  border-radius: 12px;
  position: relative;
  min-height: 280px;
  height: 340px;
  overflow: hidden;
  box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
}

.warroom-dag-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 14px;
  background: rgba(168, 85, 247, 0.06);
  border-bottom: 1px solid rgba(168, 85, 247, 0.14);
}

.warroom-dag-title {
  font-size: 11px;
  font-weight: 700;
  color: #d8b4fe;
  display: flex;
  align-items: center;
  gap: 6px;
}

.warroom-dag-canvas-wrap {
  flex: 1;
  position: relative;
  width: 100%;
  height: 100%;
}

.swarm-dag-svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* SVG DAG Node Styling */
.dag-node-group {
  cursor: pointer;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.dag-node-group:hover {
  filter: drop-shadow(0 0 10px rgba(168, 85, 247, 0.7));
}

.dag-node-rect {
  fill: rgba(18, 15, 36, 0.95);
  stroke: rgba(168, 85, 247, 0.4);
  stroke-width: 1.5;
  rx: 8;
  ry: 8;
  transition: all 0.2s ease;
}

.dag-node-group.active .dag-node-rect {
  stroke: #38bdf8;
  fill: rgba(14, 165, 233, 0.2);
  stroke-width: 2;
}

.dag-node-group.leader .dag-node-rect {
  stroke: #fbbf24;
  fill: rgba(245, 158, 11, 0.15);
}

.dag-node-label {
  fill: #f1f5f9;
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  text-anchor: middle;
}

.dag-node-sublabel {
  fill: #94a3b8;
  font-family: inherit;
  font-size: 9px;
  text-anchor: middle;
}

.dag-link-path {
  fill: none;
  stroke: rgba(168, 85, 247, 0.35);
  stroke-width: 1.5;
  stroke-dasharray: 4 3;
}

.dag-link-active {
  stroke: #38bdf8;
  stroke-width: 2;
  stroke-dasharray: none;
  filter: drop-shadow(0 0 4px rgba(56, 189, 248, 0.5));
}

/* Bottom Split: Blackboard & Multi-Lane Stream */
.warroom-bottom-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  flex: 1;
  min-height: 0;
}

@media (max-width: 900px) {
  .warroom-bottom-grid {
    grid-template-columns: 1fr;
  }
}

.warroom-card {
  background: rgba(10, 9, 22, 0.88);
  border: 1px solid rgba(168, 85, 247, 0.18);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.warroom-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: rgba(168, 85, 247, 0.05);
  border-bottom: 1px solid rgba(168, 85, 247, 0.12);
}

.warroom-card-title {
  font-size: 12px;
  font-weight: 700;
  color: #faf5ff;
  display: flex;
  align-items: center;
  gap: 6px;
}

.warroom-card-body {
  padding: 12px 14px;
  flex: 1;
  overflow-y: auto;
  font-size: 12px;
  color: #cbd5e1;
}

/* Blackboard Item Boxes */
.blackboard-section-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  color: #c084fc;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
  margin-top: 8px;
}

.blackboard-section-title:first-child {
  margin-top: 0;
}

.blackboard-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  margin-bottom: 6px;
}

.blackboard-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-top: 5px;
  background: #38bdf8;
  box-shadow: 0 0 6px #38bdf8;
}

.blackboard-text {
  font-size: 11px;
  color: #e2e8f0;
  flex: 1;
  line-height: 1.4;
}

/* Inter-Agent Channel Feed */
.swarm-feed-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.05);
  margin-bottom: 6px;
}

.swarm-feed-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 10.5px;
}

.swarm-feed-sender {
  font-weight: 700;
  color: #c084fc;
}

.swarm-feed-time {
  color: #64748b;
  font-size: 9.5px;
}

.swarm-feed-msg {
  font-size: 11px;
  color: #cbd5e1;
  line-height: 1.4;
}

/* Chat Header Shortcut Button to Switch to Canvas Stage */
.chat-btn-canvas-toggle {
  background: rgba(0, 229, 255, 0.1);
  border: 1px solid rgba(0, 229, 255, 0.25);
  color: #00e5ff;
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 10.5px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.18s ease;
}

.chat-btn-canvas-toggle:hover {
  background: rgba(0, 229, 255, 0.2);
  border-color: rgba(0, 229, 255, 0.45);
  box-shadow: 0 0 8px rgba(0, 229, 255, 0.25);
}

.chat-btn-canvas-toggle.group-mode {
  background: rgba(168, 85, 247, 0.15);
  border-color: rgba(168, 85, 247, 0.35);
  color: #c084fc;
}

.chat-btn-canvas-toggle.group-mode:hover {
  background: rgba(168, 85, 247, 0.25);
  border-color: rgba(168, 85, 247, 0.5);
  box-shadow: 0 0 10px rgba(168, 85, 247, 0.3);
}

/* =============================================================================
   3. APP MODE: DOCKED HUMAN-AI CO-CREATION STAGE
   Strictly scoped to when an application / plugin tab is active.
   Zero leakage to Solo Studio, Zero leakage to App Store or Installed Apps.
   ============================================================================= */
.canvas-layout.app-mode {
  display: flex !important;
  flex-direction: row !important;
  width: 100% !important;
  flex: 1 1 0% !important;
  min-height: 0 !important;
  height: calc(100% - 54px) !important;
  max-height: calc(100% - 54px) !important;
  overflow: hidden !important;
  position: relative !important;
  box-sizing: border-box !important;
}

.canvas-layout.app-mode .workbench-main {
  flex: 1 1 0% !important;
  min-width: 320px !important;
  height: 100% !important;
  position: relative !important;
  display: flex !important;
  flex-direction: column !important;
  overflow: hidden !important;
}

.canvas-layout.app-mode .viewport-stage {
  flex: 1 !important;
  width: 100% !important;
  height: 100% !important;
  position: relative !important;
  overflow: hidden !important;
}

.canvas-layout.app-mode .view-panel-plugin {
  width: 100% !important;
  height: 100% !important;
  position: relative !important;
  display: block !important;
  overflow: hidden !important;
}

.canvas-layout.app-mode .view-panel-plugin iframe {
  width: 100% !important;
  height: 100% !important;
  border: none !important;
  display: block !important;
}

/* Side Chat Panel in App Mode */
.canvas-layout.app-mode .rightbar-chat {
  width: var(--rightbar-width, 360px) !important;
  min-width: var(--rightbar-min-width, 280px) !important;
  max-width: var(--rightbar-max-width, 950px) !important;
  height: 100% !important;
  flex-shrink: 0 !important;
  position: relative !important;
  top: auto !important;
  bottom: auto !important;
  left: auto !important;
  right: auto !important;
  display: flex !important;
  flex-direction: column !important;
  background: rgba(8, 14, 28, 0.94) !important;
  border: 1px solid rgba(0, 229, 255, 0.22) !important;
  border-radius: 14px !important;
  box-shadow: -4px 0 20px rgba(0, 0, 0, 0.45) !important;
  z-index: 25 !important;
  opacity: 1 !important;
  pointer-events: auto !important;
  transform: none !important;
  overflow: hidden !important;
  box-sizing: border-box !important;
}

/* Chat Header in App Mode */
.canvas-layout.app-mode .rightbar-chat-header {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  padding: 10px 14px !important;
  border-radius: 14px 14px 0 0 !important;
  background: rgba(14, 165, 233, 0.10) !important;
  border-bottom: 1px solid rgba(0, 242, 254, 0.22) !important;
  box-sizing: border-box !important;
  width: 100% !important;
}

.canvas-layout.app-mode .rightbar-chat-header .chat-header-actions,
.canvas-layout.app-mode .rightbar-chat-header .chat-window-controls {
  display: flex !important;
  align-items: center !important;
  gap: 6px !important;
}

/* Chat Messages in App Mode */
.canvas-layout.app-mode .rightbar-chat-messages {
  flex: 1 1 0% !important;
  min-height: 0 !important;
  overflow-y: auto !important;
  padding: 14px 16px !important;
  display: flex !important;
  flex-direction: column !important;
  background: transparent !important;
  box-sizing: border-box !important;
  width: 100% !important;
}

/* Chat Footer & Input in App Mode */
.canvas-layout.app-mode .rightbar-chat-footer {
  display: flex !important;
  flex-direction: column !important;
  position: relative !important;
  z-index: 20 !important;
  padding: 10px 14px !important;
  border-top: 1px solid rgba(0, 229, 255, 0.15) !important;
  background: rgba(6, 11, 20, 0.92) !important;
  border-radius: 0 0 14px 14px !important;
  width: 100% !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
  overflow: hidden !important;
  flex-shrink: 0 !important;
  margin-top: auto !important;
}

.canvas-layout.app-mode .chat-input-box {
  display: flex !important;
  flex-direction: column !important;
  position: relative !important;
  width: 100% !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
}

.canvas-layout.app-mode .fl-loop-sys-bar {
  width: 100% !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
  flex-wrap: wrap !important;
  border-radius: 12px !important;
  padding: 4px 8px !important;
  gap: 4px !important;
}

/* Interactive Splitter Resizer in App Mode */
.canvas-layout.app-mode .resizer-right {
  display: flex !important;
  width: 14px !important;
  min-width: 14px !important;
  max-width: 14px !important;
  height: 100% !important;
  flex-shrink: 0 !important;
  cursor: col-resize !important;
  opacity: 1 !important;
  pointer-events: auto !important;
  z-index: 30 !important;
  position: relative !important;
}

/* When Chat Docked to LEFT in App Mode */
.canvas-layout.app-mode.chat-dock-left .rightbar-chat {
  order: 1 !important;
  box-shadow: 6px 0 24px rgba(0, 0, 0, 0.45) !important;
}

.canvas-layout.app-mode.chat-dock-left .resizer-right {
  order: 2 !important;
}

.canvas-layout.app-mode.chat-dock-left .workbench-main {
  order: 3 !important;
}

/* When Chat Docked to RIGHT in App Mode (Default) */
.canvas-layout.app-mode:not(.chat-dock-left) .workbench-main {
  order: 1 !important;
}

.canvas-layout.app-mode:not(.chat-dock-left) .resizer-right {
  order: 2 !important;
}

.canvas-layout.app-mode:not(.chat-dock-left) .rightbar-chat {
  order: 3 !important;
}

