/* ==========================================================================
   RPA ORCHESTRATOR - SYSTEM DESIGN SYSTEM (GitHub Dark + Supabase + N8N)
   ========================================================================== */

:root {
  /* --- COLOR SYSTEM (GitHub Dark + Supabase Emerald) --- */
  --bg-canvas: #0d1117;           /* Base background (GitHub dark canvas) */
  --bg-surface: #161b22;          /* Secondary background (Sidebars, headers, panels) */
  --bg-card: #21262d;             /* Cards, modals, drawers, input fields */
  --bg-overlay: #1c2128;          /* Popovers & Command palette */
  --bg-active-pill: rgba(62, 207, 142, 0.12);

  /* Borders & Dividers */
  --border-default: #30363d;      /* Crisp GitHub structural borders */
  --border-subtle: #21262d;       /* Subtle inner dividers */
  --border-focus: #3ecf8e;        /* Focus state border (Supabase emerald) */

  /* Brand & Accent Colors */
  --primary: #3ecf8e;             /* Supabase Emerald Green */
  --primary-hover: #2b9a66;
  --primary-glow: rgba(62, 207, 142, 0.25);
  
  --accent-purple: #8957e5;       /* N8N / GitHub Accent Purple (AI & Logic) */
  --accent-purple-glow: rgba(137, 87, 229, 0.25);

  --accent-blue: #58a6ff;         /* GitHub Blue (Actions & Info) */
  --accent-blue-glow: rgba(88, 166, 255, 0.25);

  --accent-amber: #d29922;        /* GitHub Amber (Warnings & Webhooks) */
  --accent-amber-glow: rgba(210, 153, 34, 0.25);

  --accent-red: #f85149;          /* GitHub Red (Errors & Destructive) */
  --accent-red-glow: rgba(248, 81, 73, 0.25);

  /* Typography Colors */
  --text-primary: #f0f6fc;        /* Crisp white text */
  --text-secondary: #c9d1d9;      /* Standard reading text */
  --text-muted: #8b949e;          /* Secondary labels & meta info */
  --text-tertiary: #6e7681;       /* Disabled / micro-text */

  /* Fonts */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', Consolas, monospace;

  /* Layout dimensions */
  --sidebar-width-expanded: 240px;
  --sidebar-width-collapsed: 72px;
  --header-height: 56px;
}

/* --- BASE & RESET --- */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: var(--font-sans);
  scrollbar-width: thin;
  scrollbar-color: #30363d var(--bg-canvas);
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--bg-canvas);
}
::-webkit-scrollbar-thumb {
  background: #30363d;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: #484f58;
}

body {
  background-color: var(--bg-canvas);
  color: var(--text-primary);
  overflow: hidden;
  min-height: 100vh;
  display: flex;
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* --- LOGIN OVERLAY (Supabase Auth Style) --- */
#login-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(13, 17, 23, 0.94);
  z-index: 10000;
  display: flex;
  justify-content: center;
  align-items: center;
  backdrop-filter: blur(12px);
  transition: opacity 0.4s ease;
}

.login-box {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: 12px;
  padding: 36px;
  width: 100%;
  max-width: 400px;
  text-align: left;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.6), 0 0 0 1px var(--border-default);
}

.login-box h2 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.3px;
  margin-bottom: 6px;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.login-box p {
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 20px;
}

.form-group {
  text-align: left;
  margin-bottom: 18px;
}

.form-group label {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 6px;
  font-weight: 600;
}

.input-field {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: 6px;
  padding: 10px 14px;
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.input-field:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.btn-submit {
  width: 100%;
  background: var(--primary);
  color: #0d1117;
  border: none;
  border-radius: 6px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-submit:hover {
  background: var(--primary-hover);
  box-shadow: 0 0 12px var(--primary-glow);
}

.login-error {
  color: var(--accent-red);
  font-size: 12px;
  margin-top: 12px;
  display: none;
  background: rgba(248, 81, 73, 0.1);
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid rgba(248, 81, 73, 0.2);
}

/* --- MAIN DASHBOARD WRAPPER --- */
.dashboard-wrapper {
  display: flex;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  position: relative;
}

/* --- SIDEBAR NAV (Supabase & GitHub Studio Layout) --- */
.left-sidebar {
  width: var(--sidebar-width-expanded);
  background: var(--bg-surface);
  border-right: 1px solid var(--border-default);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 16px 12px;
  z-index: 100;
  transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  user-select: none;
}

.left-sidebar.collapsed {
  width: var(--sidebar-width-collapsed);
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px 16px 4px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 16px;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text-primary);
  overflow: hidden;
  white-space: nowrap;
}

.sidebar-logo-icon {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--primary) 0%, #059669 100%);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 0 12px var(--primary-glow);
}

.sidebar-logo-icon svg {
  width: 18px;
  height: 18px;
  stroke: #0d1117;
  stroke-width: 2.5;
  fill: none;
}

.sidebar-brand-text {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.2px;
}

.sidebar-brand-text span {
  color: var(--primary);
  font-weight: 500;
}

.sidebar-toggle-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  border-radius: 6px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}

.sidebar-toggle-btn:hover {
  background: var(--bg-card);
  color: var(--text-primary);
  border-color: var(--border-default);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.sidebar-nav-section-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-tertiary);
  padding: 12px 8px 4px 8px;
}

.left-sidebar.collapsed .sidebar-nav-section-title {
  display: none;
}

.sidebar-nav-btn {
  width: 100%;
  height: 40px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 10px;
  transition: all 0.15s ease;
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  position: relative;
}

.sidebar-nav-btn svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
  flex-shrink: 0;
}

.sidebar-nav-btn span.label {
  flex: 1;
  text-align: left;
}

.sidebar-nav-btn span.shortcut {
  font-size: 10px;
  font-family: var(--font-mono);
  background: var(--bg-card);
  color: var(--text-tertiary);
  padding: 2px 5px;
  border-radius: 4px;
  border: 1px solid var(--border-default);
}

.left-sidebar.collapsed .sidebar-nav-btn span.label,
.left-sidebar.collapsed .sidebar-nav-btn span.shortcut {
  display: none;
}

.sidebar-nav-btn:hover {
  color: var(--text-primary);
  background: var(--bg-card);
}

.sidebar-nav-btn.active {
  color: var(--primary);
  background: var(--bg-active-pill);
  border-color: rgba(62, 207, 142, 0.25);
  font-weight: 600;
}

.sidebar-nav-btn.active svg {
  stroke: var(--primary);
}

/* Sidebar Tooltip for Collapsed Mode */
.left-sidebar.collapsed .sidebar-nav-btn {
  justify-content: center;
  padding: 0;
}

.sidebar-footer {
  border-top: 1px solid var(--border-subtle);
  padding-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-logout-btn {
  width: 100%;
  height: 38px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--accent-red);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 10px;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s;
}

.sidebar-logout-btn:hover {
  background: rgba(248, 81, 73, 0.1);
  border-color: rgba(248, 81, 73, 0.2);
}

.left-sidebar.collapsed .sidebar-logout-btn span {
  display: none;
}

.left-sidebar.collapsed .sidebar-logout-btn {
  justify-content: center;
}

/* --- MAIN WORK AREA --- */
.main-work-area {
  flex: 1;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  background: var(--bg-canvas);
}

/* --- TOP HEADER BAR (GitHub Style Breadcrumbs + Actions) --- */
.main-header {
  height: var(--header-height);
  border-bottom: 1px solid var(--border-default);
  padding: 0 24px;
  background: var(--bg-surface);
  position: sticky;
  top: 0;
  z-index: 90;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.header-breadcrumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
}

.header-breadcrumbs a {
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.2s;
}

.header-breadcrumbs a:hover {
  color: var(--text-primary);
}

.header-breadcrumbs .sep {
  color: var(--text-tertiary);
}

.header-breadcrumbs .current {
  color: var(--text-primary);
  font-weight: 600;
}

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

/* Command Palette Trigger Button */
.cmd-palette-trigger {
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: 6px;
  padding: 6px 12px;
  color: var(--text-muted);
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 16px;
  cursor: pointer;
  transition: all 0.2s;
  user-select: none;
}

.cmd-palette-trigger:hover {
  border-color: var(--text-muted);
  color: var(--text-primary);
}

.cmd-palette-trigger kbd {
  font-family: var(--font-mono);
  font-size: 10px;
  background: var(--bg-canvas);
  border: 1px solid var(--border-default);
  padding: 1px 5px;
  border-radius: 4px;
  color: var(--text-secondary);
}

.header-right-status {
  display: flex;
  align-items: center;
  gap: 16px;
}

.status-badge-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(62, 207, 142, 0.1);
  border: 1px solid rgba(62, 207, 142, 0.2);
  color: var(--primary);
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}

.status-ping {
  width: 7px;
  height: 7px;
  background-color: var(--primary);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--primary-glow);
  animation: pingPulse 2s infinite;
}

@keyframes pingPulse {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.15); opacity: 1; box-shadow: 0 0 12px var(--primary-glow); }
  100% { transform: scale(0.95); opacity: 0.8; }
}

/* --- WORK CONTAINER --- */
.work-container {
  padding: 24px 32px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  max-width: 1600px;
  margin: 0 auto;
  width: 100%;
}

.tab-view-container {
  display: none;
  flex-direction: column;
  gap: 24px;
}

.tab-view-container.active-view {
  display: flex;
}

/* Fullscreen Mode for FlowBuilder Canvas */
.flowbuilder-fullscreen-mode .main-header {
  display: flex;
}
.flowbuilder-fullscreen-mode .work-container {
  padding: 0;
  max-width: 100%;
  height: calc(100vh - var(--header-height));
}
.flowbuilder-fullscreen-mode #side-flowbuilder {
  height: 100%;
}

/* --- DASHBOARD KPI CARDS (Supabase Studio Style) --- */
.overview-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

@media (max-width: 1200px) {
  .overview-row { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
  .overview-row { grid-template-columns: 1fr; }
}

.kpi-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: 10px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 12px;
  position: relative;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.kpi-card:hover {
  border-color: #484f58;
}

.kpi-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.kpi-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.kpi-icon-box {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
}

.kpi-icon-box svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
}

.kpi-body {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.kpi-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  font-family: var(--font-sans);
  letter-spacing: -0.5px;
}

.kpi-subtext {
  font-size: 12px;
  color: var(--text-muted);
}

.kpi-progress-bar {
  width: 100%;
  height: 6px;
  background: var(--bg-card);
  border-radius: 3px;
  overflow: hidden;
}

.kpi-progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 3px;
  transition: width 0.4s ease;
}

/* --- CHARTS ROW --- */
.charts-grid-row {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
}

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

.section-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: 10px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.section-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-subtle);
}

.section-panel-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* --- LIVE LOG TERMINAL (GitHub Actions Style) --- */
.terminal-container {
  background: var(--bg-canvas);
  border: 1px solid var(--border-default);
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  height: 380px;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.4);
}

.terminal-toolbar {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-default);
  padding: 8px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.terminal-tabs {
  display: flex;
  align-items: center;
  gap: 6px;
}

.terminal-tab-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.15s;
}

.terminal-tab-btn:hover {
  color: var(--text-primary);
  background: var(--bg-card);
}

.terminal-tab-btn.active {
  background: var(--bg-card);
  color: var(--primary);
  border-color: var(--border-default);
}

.terminal-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.terminal-search {
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: 5px;
  padding: 4px 10px;
  color: var(--text-primary);
  font-size: 11px;
  outline: none;
  width: 180px;
}

.terminal-btn-icon {
  background: transparent;
  border: 1px solid var(--border-default);
  color: var(--text-muted);
  border-radius: 5px;
  padding: 4px 8px;
  font-size: 11px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: all 0.2s;
}

.terminal-btn-icon:hover {
  color: var(--text-primary);
  background: var(--bg-card);
}

.terminal-body {
  flex: 1;
  padding: 12px;
  overflow-y: auto;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-secondary);
}

.terminal-line {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 2px 4px;
  border-radius: 3px;
}

.terminal-line:hover {
  background: rgba(255, 255, 255, 0.03);
}

.terminal-time {
  color: var(--text-tertiary);
  flex-shrink: 0;
}

.terminal-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 3px;
  text-transform: uppercase;
  flex-shrink: 0;
}

.terminal-badge.info { background: rgba(88, 166, 255, 0.15); color: var(--accent-blue); }
.terminal-badge.success { background: rgba(62, 207, 142, 0.15); color: var(--primary); }
.terminal-badge.warn { background: rgba(210, 153, 34, 0.15); color: var(--accent-amber); }
.terminal-badge.error { background: rgba(248, 81, 73, 0.15); color: var(--accent-red); }

.terminal-content {
  flex: 1;
  word-break: break-word;
}

/* --- FLOW BUILDER CANVAS (N8N Style Architecture) --- */
.flowbuilder-wrapper {
  display: flex;
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
  background: var(--bg-canvas);
}

.flowbuilder-left-panel {
  width: 280px;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-default);
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  overflow-y: auto;
  flex-shrink: 0;
  z-index: 60;
}

.node-lib-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.node-lib-category-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-tertiary);
  padding: 6px 0 2px 0;
  border-bottom: 1px solid var(--border-subtle);
}

.node-lib-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.node-grid-card {
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: 8px;
  padding: 10px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.18s cubic-bezier(0.4, 0, 0.2, 1);
  user-select: none;
  text-align: center;
}

.node-grid-card:hover {
  background: var(--bg-overlay);
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
}

.node-grid-card[data-category="action"]:hover { border-color: var(--accent-blue); }
.node-grid-card[data-category="logic"]:hover { border-color: var(--accent-purple); }
.node-grid-card[data-category="utility"]:hover { border-color: var(--accent-amber); }

.node-grid-icon {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: var(--bg-canvas);
  border: 1px solid var(--border-default);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
}

.node-grid-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  line-height: 1.2;
}

.node-grid-card:hover .node-grid-label {
  color: var(--text-primary);
}

/* Canvas Area */
.flow-canvas-container {
  flex: 1;
  height: 100%;
  position: relative;
  overflow: hidden;
  /* Radial dot grid background pattern */
  background-image: radial-gradient(circle, #30363d 1px, transparent 1px);
  background-size: 24px 24px;
  background-position: 0 0;
  cursor: grab;
}

.flow-canvas-container:active {
  cursor: grabbing;
}

/* Floating Toolbar */
.canvas-floating-toolbar {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: 8px;
  padding: 6px 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 50;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.canvas-toolbar-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s;
}

.canvas-toolbar-btn:hover {
  background: var(--bg-card);
  color: var(--text-primary);
  border-color: var(--border-default);
}

.canvas-execute-btn {
  background: var(--primary);
  color: #0d1117;
  border: none;
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 0 12px var(--primary-glow);
  transition: all 0.2s;
}

.canvas-execute-btn:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

/* Floating Zoom Controls */
.canvas-zoom-controls {
  position: absolute;
  bottom: 20px;
  left: 20px;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  z-index: 50;
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.zoom-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s;
}

.zoom-btn:hover {
  background: var(--bg-card);
  color: var(--text-primary);
}

.zoom-btn + .zoom-btn {
  border-top: 1px solid var(--border-subtle);
}

/* Canvas Workspace */
.canvas-workspace {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: visible !important;
  transform-origin: 0 0;
}

/* --- SVG CONNECTION LINES & SOCKET PORTS --- */
.flow-svg-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 5;
  overflow: visible !important;
}

svg#flow-svg-canvas {
  overflow: visible !important;
}

.flow-svg-path {
  fill: none;
  stroke: var(--primary);
  stroke-width: 3px;
  stroke-linecap: round;
  transition: stroke 0.2s, stroke-width 0.2s;
  pointer-events: stroke;
  cursor: pointer;
}

.flow-svg-path:hover {
  stroke: var(--primary-hover);
  stroke-width: 4px;
  filter: drop-shadow(0 0 6px var(--primary-glow));
}

.flow-svg-path.path-selected {
  stroke: #38bdf8;
  stroke-width: 4px;
  stroke-dasharray: 6 3;
  animation: dashOffset 1s linear infinite;
  filter: drop-shadow(0 0 8px rgba(56, 189, 248, 0.6));
}

@keyframes dashOffset {
  from { stroke-dashoffset: 18; }
  to { stroke-dashoffset: 0; }
}

.flow-svg-path-interactive {
  fill: none;
  stroke: transparent;
  stroke-width: 16px;
  pointer-events: stroke;
  cursor: pointer;
}

.flow-svg-path-temp {
  fill: none;
  stroke: var(--accent-amber);
  stroke-width: 3px;
  stroke-dasharray: 5 5;
  pointer-events: none;
}

/* Delete link button floating on connection midpoint */
.flow-link-delete-btn {
  position: absolute;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent-red);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
  z-index: 100;
  transform: translate(-50%, -50%);
  box-shadow: 0 2px 8px rgba(0,0,0,0.5);
  transition: transform 0.15s;
}

.flow-link-delete-btn:hover {
  transform: translate(-50%, -50%) scale(1.2);
}

/* --- N8N FLOW NODES STYLING --- */
.flow-node {
  position: absolute;
  width: 240px;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  cursor: move;
  transition: border-color 0.2s, box-shadow 0.2s;
  user-select: none;
  z-index: 10;
  overflow: visible;
}

.flow-node:hover {
  border-color: #484f58;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
}

.flow-node.selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-glow), 0 12px 32px rgba(0, 0, 0, 0.5);
}

.flow-node[data-category="start"] { border-top: 3px solid #3ecf8e; }
.flow-node[data-category="interaction"] { border-top: 3px solid #58a6ff; }
.flow-node[data-category="data"] { border-top: 3px solid #38bdf8; }
.flow-node[data-category="logic"] { border-top: 3px solid #a78bfa; }
.flow-node[data-category="operator"],
.flow-node[data-category="ai"],
.flow-node[data-category="note"] { border-top: 3px solid #f59e0b; }

.node-header {
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-top-left-radius: 8px;
  border-top-right-radius: 8px;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 12px;
}

.node-header-start {
  background: linear-gradient(135deg, rgba(62, 207, 142, 0.2) 0%, rgba(62, 207, 142, 0.04) 100%);
  border-bottom: 1px solid rgba(62, 207, 142, 0.35);
  color: #3ecf8e;
  font-weight: 700;
}

.node-header-interaction {
  background: linear-gradient(135deg, rgba(88, 166, 255, 0.2) 0%, rgba(88, 166, 255, 0.04) 100%);
  border-bottom: 1px solid rgba(88, 166, 255, 0.35);
  color: #58a6ff;
  font-weight: 700;
}

.node-header-data {
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.2) 0%, rgba(56, 189, 248, 0.04) 100%);
  border-bottom: 1px solid rgba(56, 189, 248, 0.35);
  color: #38bdf8;
  font-weight: 700;
}

.node-header-logic {
  background: linear-gradient(135deg, rgba(167, 139, 250, 0.2) 0%, rgba(167, 139, 250, 0.04) 100%);
  border-bottom: 1px solid rgba(167, 139, 250, 0.35);
  color: #a78bfa;
  font-weight: 700;
}

.node-header-operator,
.node-header-ai,
.node-header-note {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.2) 0%, rgba(245, 158, 11, 0.04) 100%);
  border-bottom: 1px solid rgba(245, 158, 11, 0.35);
  color: #f59e0b;
  font-weight: 700;
}

/* Sockets / Sockets de Conexao */
.node-socket {
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--bg-surface);
  border: 2px solid var(--border-default);
  z-index: 20;
  cursor: crosshair;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.node-socket:hover {
  transform: scale(1.35);
  box-shadow: 0 0 10px currentColor;
}

.node-socket.socket-in {
  left: -7px;
  top: 50%;
  transform: translateY(-50%);
  border-color: #38bdf8;
  background: #0284c7;
}

.node-socket.socket-out {
  right: -7px;
  top: 50%;
  transform: translateY(-50%);
  border-color: #3ecf8e;
  background: #10b981;
}

.node-socket.socket-out-true {
  right: -7px;
  top: 35%;
  border-color: #3ecf8e;
  background: #10b981;
}

.node-socket.socket-out-false {
  right: -7px;
  top: 65%;
  border-color: #f43f5e;
  background: #e11d48;
}

.socket-label {
  position: absolute;
  right: 12px;
  font-size: 10px;
  font-weight: 700;
  user-select: none;
  pointer-events: none;
}

.socket-label-true {
  top: calc(35% - 6px);
  color: #3ecf8e;
}

.socket-label-false {
  top: calc(65% - 6px);
  color: #f43f5e;
}

.node-icon-box {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
  flex-shrink: 0;
}

.node-title-group {
  flex: 1;
  overflow: hidden;
}

.node-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.node-subtitle {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.node-body {
  padding: 10px 12px;
  font-size: 11px;
  color: var(--text-muted);
}

/* SVG Connection Port Anchors */
.node-port {
  width: 12px;
  height: 12px;
  background: var(--bg-card);
  border: 2px solid var(--border-default);
  border-radius: 50%;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  transition: all 0.2s;
  cursor: crosshair;
}

.node-port:hover {
  background: var(--primary);
  border-color: var(--text-primary);
  transform: translateY(-50%) scale(1.2);
}

.node-port.input-port { left: -7px; }
.node-port.output-port { right: -7px; }

/* --- SLIDE-OVER NODE INSPECTOR DRAWER --- */
.slide-over-drawer {
  position: absolute;
  top: 0;
  right: -360px;
  width: 360px;
  height: 100%;
  background: var(--bg-surface);
  border-left: 1px solid var(--border-default);
  box-shadow: -12px 0 36px rgba(0, 0, 0, 0.5);
  z-index: 80;
  display: flex;
  flex-direction: column;
  transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.slide-over-drawer.open {
  right: 0;
}

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

.drawer-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.drawer-close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  width: 28px;
  height: 28px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.drawer-close-btn:hover {
  background: var(--bg-card);
  color: var(--text-primary);
}

.drawer-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-subtle);
  padding: 0 20px;
  gap: 16px;
}

.drawer-tab-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  padding: 10px 0;
  cursor: pointer;
  position: relative;
  transition: color 0.2s;
}

.drawer-tab-btn.active {
  color: var(--primary);
}

.drawer-tab-btn.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 2px;
  background: var(--primary);
}

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

/* --- COMMAND PALETTE OVERLAY (GitHub / Supabase Style) --- */
#command-palette-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(13, 17, 23, 0.8);
  backdrop-filter: blur(6px);
  z-index: 100000;
  display: none;
  justify-content: center;
  align-items: flex-start;
  padding-top: 100px;
}

#command-palette-overlay.open,
#command-palette-overlay.active,
.cmd-palette-overlay.open,
.cmd-palette-overlay.active,
.custom-modal.open,
.custom-modal.active {
  display: flex !important;
}

.cmd-palette-box {
  background: var(--bg-overlay);
  border: 1px solid var(--border-default);
  border-radius: 12px;
  width: 100%;
  max-width: 600px;
  overflow: hidden;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.7);
  display: flex;
  flex-direction: column;
  animation: cmdSlideDown 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes cmdSlideDown {
  from { transform: translateY(-20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.cmd-input-wrapper {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-default);
}

.cmd-input-wrapper svg {
  width: 18px;
  height: 18px;
  stroke: var(--text-muted);
  fill: none;
}

.cmd-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 15px;
}

.cmd-results-list {
  max-height: 320px;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.cmd-item {
  padding: 10px 14px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.15s;
}

.cmd-item:hover, .cmd-item.selected {
  background: var(--bg-card);
  color: var(--text-primary);
}

.cmd-item-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.cmd-item-left svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
}

.cmd-item kbd {
  font-family: var(--font-mono);
  font-size: 10px;
  background: var(--bg-canvas);
  border: 1px solid var(--border-default);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--text-tertiary);
}

/* --- TABLES & ASSETS (GitHub Repo Explorer Style) --- */
.data-table-container {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  border: 1px solid var(--border-default);
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg-surface);
}

.data-table-container th {
  background: var(--bg-card);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border-default);
}

.data-table-container td {
  padding: 12px 16px;
  font-size: 13px;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-subtle);
  transition: background 0.15s;
}

.data-table-container tr:last-child td {
  border-bottom: none;
}

.data-table-container tr:hover td {
  background: var(--bg-card);
  color: var(--text-primary);
}

/* Badges */
.badge-status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}

.badge-status.success { background: rgba(62, 207, 142, 0.15); color: var(--primary); }
.badge-status.running { background: rgba(88, 166, 255, 0.15); color: var(--accent-blue); }
.badge-status.failed { background: rgba(248, 81, 73, 0.15); color: var(--accent-red); }

/* --- DRAG & DROP ZONE (Supabase Style) --- */
.dropzone-box {
  border: 2px dashed var(--border-default);
  border-radius: 10px;
  padding: 32px;
  text-align: center;
  background: var(--bg-surface);
  transition: all 0.2s;
  cursor: pointer;
}

.dropzone-box:hover, .dropzone-box.dragover {
  border-color: var(--primary);
  background: rgba(62, 207, 142, 0.04);
}

.dropzone-icon {
  font-size: 32px;
  margin-bottom: 8px;
}

/* --- FLOATING SIMULATION MODAL & BOTÃO MINIMIZADO --- */
.flow-sim-panel {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 440px;
  max-height: 600px;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: 12px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.7);
  z-index: 9999;
  display: none;
  flex-direction: column;
  overflow: hidden;
  backdrop-filter: blur(12px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.flow-sim-panel.sim-active {
  display: flex !important;
}

.flow-sim-header {
  padding: 10px 16px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-default);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.flow-sim-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
}

.flow-sim-body {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  flex: 1;
}

.flow-sim-console {
  background: #090d13;
  color: #3ecf8e;
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 10px;
  border-radius: 6px;
  max-height: 150px;
  min-height: 80px;
  overflow-y: auto;
  border: 1px solid var(--border-subtle);
  line-height: 1.4;
}

.flow-sim-float-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--primary);
  color: #0d1117;
  font-weight: 700;
  font-size: 12px;
  padding: 10px 18px;
  border-radius: 30px;
  box-shadow: 0 8px 24px rgba(62, 207, 142, 0.4);
  z-index: 10000;
  cursor: pointer;
  border: none;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.flow-sim-float-btn:hover {
  transform: translateY(-2px) scale(1.03);
  background: #4ae09e;
  box-shadow: 0 12px 30px rgba(62, 207, 142, 0.6);
}
