/* ============================================================
   System Design Whiteboard — Cyan Dark Theme
   ============================================================ */

:root {
  --primary: #06B6D4;
  --primary-dim: rgba(6, 182, 212, 0.12);
  --secondary: #22D3EE;
  --accent: #F59E0B;
  --bg: #0A0F14;
  --bg-card: #111827;
  --bg-surface: #1E293B;
  --bg-input: #0F172A;
  --border: rgba(6, 182, 212, 0.12);
  --border-hover: rgba(6, 182, 212, 0.3);
  --text: #E2E8F0;
  --text-dim: #94A3B8;
  --text-muted: #64748B;
  --radius: 12px;
  --radius-sm: 8px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --mono: 'JetBrains Mono', 'Fira Code', monospace;
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body { font-family: var(--font); background: var(--bg); color: var(--text); overflow: hidden; }

.app { display: flex; flex-direction: column; height: 100vh; }

/* Toolbar */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: rgba(17, 24, 39, 0.95);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  z-index: 100;
  gap: 12px;
  flex-wrap: wrap;
}

.toolbar-left { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.logo { font-size: 1.3rem; }
.title {
  font-size: 1rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  white-space: nowrap;
}

.toolbar-center { display: flex; align-items: center; overflow-x: auto; flex: 1; min-width: 0; }

.toolbar-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; flex-wrap: wrap; }

/* Palette */
.component-palette { display: flex; gap: 4px; }

.palette-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  cursor: grab;
  transition: all var(--transition);
  font-family: var(--font);
  white-space: nowrap;
}

.palette-item:hover { border-color: var(--primary); background: var(--primary-dim); }
.palette-item:active { cursor: grabbing; transform: scale(0.95); }
.palette-icon { font-size: 1rem; }
.palette-label { font-size: 0.6rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; }

/* Toolbar buttons */
.toolbar-btn, .toolbar-select {
  padding: 6px 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: var(--font);
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.toolbar-btn:hover { border-color: var(--primary); }
.toolbar-btn.small { padding: 4px 8px; font-size: 0.9rem; }
.toolbar-btn.danger { background: rgba(239, 68, 68, 0.12); border-color: rgba(239, 68, 68, 0.3); color: #EF4444; }
.toolbar-btn.danger:hover { background: rgba(239, 68, 68, 0.25); }
.toolbar-select:focus { border-color: var(--primary); outline: none; }

.zoom-controls { display: flex; align-items: center; gap: 4px; }
.zoom-level { font-size: 0.75rem; color: var(--text-muted); font-family: var(--mono); min-width: 40px; text-align: center; }

/* Canvas */
.canvas-container {
  flex: 1;
  position: relative;
  overflow: hidden;
  cursor: default;
  background:
    linear-gradient(rgba(6, 182, 212, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(6, 182, 212, 0.03) 1px, transparent 1px);
  background-size: 40px 40px;
}

.canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 4000px;
  height: 4000px;
  transform-origin: 0 0;
}

.connections-svg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

.connections-svg line, .connections-svg path {
  pointer-events: auto;
  cursor: pointer;
}

.nodes-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
}

/* Node */
.node {
  position: absolute;
  min-width: 100px;
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  cursor: grab;
  user-select: none;
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  z-index: 5;
}

.node:hover { border-color: var(--border-hover); }
.node.selected { border-color: var(--primary); box-shadow: 0 0 15px rgba(6, 182, 212, 0.25); z-index: 10; }
.node.dragging { cursor: grabbing; opacity: 0.85; z-index: 20; }

.node-icon { font-size: 1.6rem; }
.node-label { font-size: 0.78rem; font-weight: 600; color: var(--text); text-align: center; }
.node-sublabel { font-size: 0.65rem; color: var(--text-muted); text-align: center; }
.node-type-text {
  background: transparent;
  border: 1px dashed var(--border);
  padding: 8px 12px;
  min-width: 120px;
}
.node-type-text .node-label { font-size: 0.85rem; font-weight: 400; color: var(--text-dim); }

/* Arrow Label */
.arrow-label {
  position: absolute;
  font-size: 0.65rem;
  font-family: var(--mono);
  color: var(--accent);
  background: rgba(10, 15, 20, 0.85);
  padding: 2px 6px;
  border-radius: 4px;
  white-space: nowrap;
  pointer-events: none;
  z-index: 3;
}

/* Properties Panel */
.props-panel {
  position: fixed;
  right: 0;
  top: 0;
  bottom: 0;
  width: 280px;
  background: rgba(17, 24, 39, 0.97);
  backdrop-filter: blur(20px);
  border-left: 1px solid var(--border);
  z-index: 200;
  display: flex;
  flex-direction: column;
  animation: slideIn 0.2s ease;
}

@keyframes slideIn { from { transform: translateX(100%); } to { transform: translateX(0); } }

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

.props-title { font-size: 0.9rem; font-weight: 600; }

.props-close {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.3rem;
  cursor: pointer;
}

.props-body { padding: 16px; display: flex; flex-direction: column; gap: 12px; overflow-y: auto; flex: 1; }

.props-field { display: flex; flex-direction: column; gap: 4px; }
.props-label { font-size: 0.72rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; }
.props-subtitle { font-size: 0.78rem; font-weight: 600; color: var(--text-dim); }

.props-input {
  padding: 7px 10px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: var(--font);
  font-size: 0.82rem;
  outline: none;
}

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

.props-color-input {
  width: 100%;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  background: none;
  padding: 2px;
}

.props-divider { border: none; border-top: 1px solid var(--border); margin: 4px 0; }

/* Responsive */
@media (max-width: 768px) {
  .toolbar { padding: 6px 10px; }
  .palette-label { display: none; }
  .toolbar-center { order: 3; width: 100%; }
  .props-panel { width: 100%; }
}
