/* CSS Variables - Dark Cyberpunk Theme */
:root {
  --bg-primary: #0a0a14;
  --bg-secondary: #12121f;
  --bg-tertiary: #1a1a2e;
  --bg-card: #16162a;

  --accent-primary: #00ff9d;
  --accent-secondary: #6495ed;
  --accent-warning: #ffa500;
  --accent-error: #ff4757;

  --text-primary: #ffffff;
  --text-secondary: #a0a0b0;
  --text-muted: #606070;

  --border-color: #2a2a4a;
  --border-glow: rgba(0, 255, 157, 0.3);

  --shadow-glow: 0 0 20px rgba(0, 255, 157, 0.2);
  --shadow-soft: 0 4px 20px rgba(0, 0, 0, 0.3);

  --font-mono: 'SF Mono', 'Monaco', 'Inconsolata', 'Fira Code', monospace;
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

  --transition-fast: 0.15s ease;
  --transition-normal: 0.3s ease;

  --header-height: 60px;
  --taskbar-height: 50px;
  --chat-width: 380px;
}

/* Reset */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* Base */
html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
}

/* App Container */
.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* Header */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: var(--header-height);
  padding: 0 24px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
}

.logo {
  font-family: var(--font-mono);
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--text-primary);
}

.logo-accent {
  color: var(--accent-primary);
  text-shadow: 0 0 10px var(--accent-primary);
}

.stats {
  display: flex;
  gap: 24px;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.stat-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.stat-value {
  font-family: var(--font-mono);
  font-size: 18px;
  color: var(--accent-primary);
}

.connection-status {
  flex-direction: row;
  gap: 8px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-error);
  transition: background var(--transition-normal);
}

.connection-status.connected .status-dot {
  background: var(--accent-primary);
  box-shadow: 0 0 10px var(--accent-primary);
}

.connection-status.connected .stat-label {
  color: var(--accent-primary);
}

/* Main Content */
.main-content {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* Canvas Container */
.canvas-container {
  flex: 1;
  position: relative;
  background: var(--bg-primary);
  overflow: hidden;
}

#network-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.canvas-overlay {
  position: absolute;
  pointer-events: none;
}

/* Node Tooltip */
#node-tooltip {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 12px 16px;
  min-width: 180px;
  box-shadow: var(--shadow-soft);
}

.tooltip-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.tooltip-desc {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.tooltip-status {
  font-size: 11px;
  font-family: var(--font-mono);
  padding: 4px 8px;
  border-radius: 4px;
  display: inline-block;
}

.tooltip-status.idle {
  background: rgba(100, 149, 237, 0.2);
  color: var(--accent-secondary);
}

.tooltip-status.busy {
  background: rgba(255, 165, 0, 0.2);
  color: var(--accent-warning);
}

.tooltip-status.active {
  background: rgba(0, 255, 157, 0.2);
  color: var(--accent-primary);
}

/* Chat Panel */
.chat-panel {
  width: var(--chat-width);
  display: flex;
  flex-direction: column;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border-color);
}

.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  gap: 12px;
}

.chat-header h2 {
  font-size: 16px;
  font-weight: 600;
  white-space: nowrap;
}

.chat-selectors {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.agent-select,
.model-select {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 6px 10px;
  color: var(--text-primary);
  font-size: 12px;
  cursor: pointer;
  outline: none;
  transition: border-color var(--transition-fast);
  max-width: 140px;
}

.agent-select:hover,
.agent-select:focus,
.model-select:hover,
.model-select:focus {
  border-color: var(--accent-primary);
}

.agent-select option,
.model-select option {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.model-select optgroup {
  background: var(--bg-secondary);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 11px;
}

/* Chat Messages */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.message {
  max-width: 90%;
  animation: slideIn 0.3s ease-out;
}

.message.user {
  align-self: flex-end;
}

.message.assistant,
.message.system {
  align-self: flex-start;
}

.message-content {
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.5;
}

.message.user .message-content {
  background: var(--accent-primary);
  color: var(--bg-primary);
  border-bottom-right-radius: 4px;
}

.message.assistant .message-content {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border-bottom-left-radius: 4px;
}

.message.system .message-content {
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
  padding: 8px;
}

.message-agent {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 4px;
  font-family: var(--font-mono);
}

/* Chat Input */
.chat-input-container {
  display: flex;
  gap: 8px;
  padding: 16px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-tertiary);
}

.chat-input {
  flex: 1;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 10px 14px;
  color: var(--text-primary);
  font-size: 14px;
  font-family: var(--font-sans);
  resize: none;
  outline: none;
  min-height: 40px;
  max-height: 120px;
  transition: border-color var(--transition-fast);
}

.chat-input:focus {
  border-color: var(--accent-primary);
}

.chat-input::placeholder {
  color: var(--text-muted);
}

.chat-send {
  width: 40px;
  height: 40px;
  background: var(--accent-primary);
  border: none;
  border-radius: 8px;
  color: var(--bg-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.chat-send:hover {
  background: #00e68a;
  transform: scale(1.05);
}

.chat-send:active {
  transform: scale(0.95);
}

.chat-send:disabled {
  background: var(--text-muted);
  cursor: not-allowed;
  transform: none;
}

/* Task Bar */
.task-bar {
  height: var(--taskbar-height);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
}

.task-bar-label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  white-space: nowrap;
}

.task-list {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  flex: 1;
}

.no-tasks {
  color: var(--text-muted);
  font-size: 13px;
}

.task-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--bg-tertiary);
  border-radius: 6px;
  font-size: 13px;
  white-space: nowrap;
  animation: slideIn 0.3s ease-out;
}

.task-item .task-agent {
  color: var(--accent-secondary);
  font-family: var(--font-mono);
  font-size: 11px;
}

.task-item .task-text {
  color: var(--text-secondary);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.task-item .task-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid var(--accent-primary);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Typing Indicator */
.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 10px 14px;
}

.typing-indicator span {
  width: 8px;
  height: 8px;
  background: var(--text-muted);
  border-radius: 50%;
  animation: bounce 1.4s infinite ease-in-out both;
}

.typing-indicator span:nth-child(1) { animation-delay: -0.32s; }
.typing-indicator span:nth-child(2) { animation-delay: -0.16s; }
.typing-indicator span:nth-child(3) { animation-delay: 0; }

/* Waiting Status (Marvin waiting for agent) */
.waiting-status {
  padding: 8px 0;
}

.waiting-indicator {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: rgba(100, 149, 237, 0.1);
  border: 1px solid rgba(100, 149, 237, 0.3);
  border-radius: 8px;
}

.waiting-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid rgba(100, 149, 237, 0.3);
  border-top-color: var(--accent-secondary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.waiting-text {
  flex: 1;
  font-size: 13px;
  color: var(--text-secondary);
}

.waiting-text strong {
  color: var(--accent-secondary);
}

.waiting-message {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Responsive */
@media (max-width: 900px) {
  .chat-panel {
    position: fixed;
    right: -100%;
    top: var(--header-height);
    bottom: var(--taskbar-height);
    width: 100%;
    max-width: 400px;
    transition: right var(--transition-normal);
    z-index: 100;
  }

  .chat-panel.open {
    right: 0;
  }
}
