/* ==========================================================================
   FlowForge — Authentic n8n 1.x Visual Workflow & AI Agent Studio Stylesheet
   ========================================================================== */

:root {
  --bg-app: #111115;
  --bg-canvas: #16161c;
  --bg-panel: #1c1c24;
  --bg-panel-elevated: #24242f;
  --bg-input: #14141a;
  --border-subtle: #2c2c3a;
  --border-focus: #ff6d5a;
  --text-primary: #f4f4f6;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  --n8n-orange: #ff6d5a;
  --n8n-orange-hover: #ff8272;
  --n8n-green: #10b981;
  --n8n-purple: #a855f7;
  --n8n-cyan: #38bdf8;
  --n8n-amber: #f59e0b;
  --n8n-red: #ef4444;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow-node: 0 10px 25px -5px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.07);
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', Consolas, monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
}

body, html {
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background: var(--bg-app);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
}

input, textarea, select, pre, code {
  user-select: text;
  font-family: inherit;
}

/* ==========================================
   LAYOUT SHELL
   ========================================== */
.app-shell {
  display: flex;
  width: 100vw;
  height: 100vh;
}

/* Left Icon Sidebar (n8n Main Navigation) */
.left-rail {
  width: 58px;
  background: #131318;
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 0;
  z-index: 40;
  justify-content: space-between;
}

.brand-logo {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, #ff6d5a 0%, #ff3e6c 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 15px;
  color: #fff;
  box-shadow: 0 4px 14px rgba(255, 109, 90, 0.4);
  cursor: pointer;
  margin-bottom: 14px;
}

.rail-nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  align-items: center;
}

.rail-btn {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
}

.rail-btn:hover {
  background: var(--bg-panel-elevated);
  color: var(--text-primary);
}

.rail-btn.active {
  background: rgba(255, 109, 90, 0.15);
  color: var(--n8n-orange);
  border-color: rgba(255, 109, 90, 0.35);
}

/* Node Palette Drawer */
.node-drawer {
  width: 300px;
  background: var(--bg-panel);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  z-index: 35;
  transition: width 0.2s ease, opacity 0.2s ease;
}

.node-drawer.collapsed {
  width: 0;
  overflow: hidden;
  border-right: none;
}

.drawer-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.drawer-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
  font-size: 14px;
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.search-box input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  padding: 8px 10px 8px 32px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  outline: none;
}

.search-box input:focus {
  border-color: var(--n8n-orange);
}

.search-box .search-icon {
  position: absolute;
  left: 10px;
  color: var(--text-muted);
  font-size: 13px;
}

.category-tabs {
  display: flex;
  gap: 5px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.cat-pill {
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
}

.cat-pill.active {
  background: var(--n8n-orange);
  border-color: var(--n8n-orange);
  color: #fff;
}

.node-catalog-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.catalog-group-title {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: 700;
  margin: 8px 0 4px 2px;
}

.catalog-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 11px;
  background: var(--bg-panel-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  cursor: grab;
  transition: all 0.15s ease;
}

.catalog-item:hover {
  border-color: var(--n8n-orange);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.catalog-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
  color: #fff;
}

.catalog-meta {
  flex: 1;
  min-width: 0;
}

.catalog-name {
  font-weight: 600;
  font-size: 12.5px;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.catalog-sub {
  font-size: 11px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ==========================================
   MAIN WORKSPACE & TOP HEADER
   ========================================== */
.main-workspace {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  min-width: 0;
}

.top-bar {
  min-height: 52px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  gap: 10px;
  z-index: 30;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
}

.top-bar::-webkit-scrollbar {
  height: 3px;
}
.top-bar::-webkit-scrollbar-thumb {
  background: var(--border-subtle);
}

.workflow-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.workflow-name-input {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-primary);
  font-size: 13.5px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  width: 220px;
  max-width: 260px;
  transition: all 0.2s ease;
}

.workflow-name-input:hover, .workflow-name-input:focus {
  background: var(--bg-input);
  border-color: var(--border-subtle);
  outline: none;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  background: rgba(16, 185, 129, 0.12);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
  white-space: nowrap;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 8px #10b981;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
  flex-shrink: 1;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 11.5px;
  font-weight: 600;
  border: 1px solid var(--border-subtle);
  background: var(--bg-panel-elevated);
  color: var(--text-primary);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.btn:hover {
  background: #2e2e3d;
  border-color: #3e3e52;
}

.btn-primary {
  background: var(--n8n-orange);
  border-color: var(--n8n-orange);
  color: #fff;
  box-shadow: 0 4px 14px rgba(255, 109, 90, 0.35);
}

.btn-primary:hover {
  background: var(--n8n-orange-hover);
  border-color: var(--n8n-orange-hover);
}

.btn-ai {
  background: linear-gradient(135deg, #9333ea 0%, #6366f1 100%);
  border-color: #a855f7;
  color: #fff;
}

.btn-ai:hover {
  filter: brightness(1.1);
}

/* ==========================================
   INFINITE DOT-GRID CANVAS & NODES
   ========================================== */
.canvas-viewport {
  flex: 1;
  position: relative;
  overflow: hidden;
  background-color: var(--bg-canvas);
  background-image: radial-gradient(rgba(255, 255, 255, 0.13) 1px, transparent 1px);
  background-size: 22px 22px;
  cursor: grab;
}

.canvas-viewport:active {
  cursor: grabbing;
}

.canvas-transform-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 4000px;
  height: 3000px;
  transform-origin: 0 0;
  pointer-events: none;
}

.edges-svg {
  position: absolute;
  top: 0;
  left: 0;
  width: 4000px;
  height: 3000px;
  overflow: visible;
  pointer-events: stroke;
  z-index: 5;
}

.nodes-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 4000px;
  height: 3000px;
  pointer-events: none;
  z-index: 10;
}

/* n8n Node Card */
.n8n-node {
  position: absolute;
  width: 220px;
  background: #21212b;
  border: 2px solid #343446;
  border-radius: 14px;
  box-shadow: var(--shadow-node);
  pointer-events: all;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.n8n-node.trigger-node {
  border-top-left-radius: 32px;
  border-bottom-left-radius: 32px;
}

.n8n-node.agent-node {
  width: 265px;
  background: linear-gradient(180deg, #271f36 0%, #1f1d2b 100%);
  border-color: rgba(168, 85, 247, 0.55);
}

.n8n-node.sub-node {
  width: 168px;
  border-radius: 24px;
  background: #1b2230;
  border-style: dashed;
}

.n8n-node:hover {
  border-color: #6b7280;
}

.n8n-node.selected {
  border-color: var(--n8n-orange) !important;
  box-shadow: 0 0 0 3px rgba(255, 109, 90, 0.25), var(--shadow-node);
}

.n8n-node.running {
  border-color: var(--n8n-amber) !important;
  box-shadow: 0 0 22px rgba(245, 158, 11, 0.55);
}

.n8n-node.success {
  border-color: var(--n8n-green);
}

.n8n-node.error {
  border-color: var(--n8n-red);
}

/* Quick Actions Bar on Node Hover & Selection */
.node-quick-bar {
  position: absolute;
  top: -34px;
  right: 0px;
  background: #181820;
  border: 1px solid var(--n8n-orange);
  border-radius: 8px;
  display: none;
  align-items: center;
  gap: 4px;
  padding: 3px 6px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.65);
  z-index: 50;
}

/* Invisible hover bridge so moving cursor from node to quick-bar never loses hover */
.node-quick-bar::after {
  content: '';
  position: absolute;
  left: -10px;
  right: -10px;
  bottom: -14px;
  height: 16px;
}

.n8n-node:hover .node-quick-bar,
.n8n-node.selected .node-quick-bar {
  display: flex;
}

.quick-icon-btn {
  height: 24px;
  padding: 0 6px;
  border: none;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
  border-radius: 5px;
  cursor: pointer;
  font-size: 11.5px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  transition: background 0.12s ease, transform 0.12s ease;
}

.quick-icon-btn:hover {
  background: var(--n8n-orange);
  color: #fff;
  transform: scale(1.06);
}

/* Node Inner Body */
.node-body {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
}

.node-icon-box {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 18px;
  flex-shrink: 0;
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.25);
}

.node-info {
  flex: 1;
  min-width: 0;
}

.node-title {
  font-weight: 600;
  font-size: 13px;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

/* Execution Status Badge on Node */
.node-exec-badge {
  position: absolute;
  bottom: -11px;
  right: 12px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  background: #13131a;
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: 4px;
  z-index: 20;
}

.node-exec-badge.success {
  color: #34d399;
  border-color: rgba(16, 185, 129, 0.45);
  background: rgba(6, 78, 59, 0.85);
}

.node-exec-badge.pinned {
  color: #f59e0b;
  border-color: rgba(245, 158, 11, 0.5);
  background: rgba(69, 26, 3, 0.9);
}

/* Connection Handles (Ports) */
.port-handle {
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #9ca3af;
  border: 2.5px solid #181820;
  cursor: crosshair;
  z-index: 22;
  transition: transform 0.12s ease, background 0.12s ease;
}

.port-handle:hover {
  transform: scale(1.35);
  background: var(--n8n-orange);
}

.port-in {
  left: -8px;
  top: 50%;
  transform: translateY(-50%);
}

.port-out {
  right: -8px;
  top: 50%;
  transform: translateY(-50%);
}

.port-out-true {
  right: -8px;
  top: 32%;
  background: #10b981;
}

.port-out-false {
  right: -8px;
  top: 70%;
  background: #ef4444;
}

.port-label {
  position: absolute;
  right: 10px;
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  pointer-events: none;
}

/* AI Agent Bottom Sub-Node Ports (Chat Model *, Memory, Tool) */
.agent-subports-bar {
  display: flex;
  justify-content: space-around;
  padding: 6px 10px 9px;
  border-top: 1px dashed rgba(168, 85, 247, 0.35);
  background: rgba(17, 17, 23, 0.45);
  border-bottom-left-radius: 12px;
  border-bottom-right-radius: 12px;
}

.agent-subport-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  font-size: 9.5px;
  color: #d8b4fe;
  font-weight: 600;
}

.subport-diamond {
  width: 12px;
  height: 12px;
  transform: rotate(45deg);
  border: 2px solid #181820;
  cursor: crosshair;
  margin-top: 4px;
  margin-bottom: -14px;
  transition: transform 0.15s ease;
}

.subport-diamond:hover {
  transform: rotate(45deg) scale(1.35);
}

.subnode-top-port {
  position: absolute;
  top: -7px;
  left: 50%;
  transform: translateX(-50%) rotate(45deg);
  width: 12px;
  height: 12px;
  background: #38bdf8;
  border: 2px solid #181820;
  cursor: crosshair;
}

/* SVG Edges */
.edge-path {
  fill: none;
  stroke: #525266;
  stroke-width: 2.4px;
  transition: stroke 0.2s ease;
  cursor: pointer;
}

.edge-path:hover {
  stroke: var(--n8n-orange);
  stroke-width: 3.2px;
}

.edge-path.sub-edge {
  stroke-dasharray: 6 5;
  stroke: #a855f7;
  stroke-width: 2px;
}

.edge-path.active-flow {
  stroke: #10b981;
  stroke-width: 3px;
  stroke-dasharray: 8 6;
  animation: flowDash 0.55s linear infinite;
}

@keyframes flowDash {
  to {
    stroke-dashoffset: -28;
  }
}

/* ==========================================
   FLOATING CANVAS CONTROLS & TEST BAR
   ========================================== */
.canvas-floating-bar {
  position: absolute;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  background: rgba(24, 24, 32, 0.92);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.6);
  z-index: 28;
}

.canvas-zoom-controls {
  position: absolute;
  bottom: 22px;
  left: 18px;
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(24, 24, 32, 0.9);
  border: 1px solid var(--border-subtle);
  padding: 4px;
  border-radius: 8px;
  z-index: 28;
}

/* ==========================================
   BOTTOM DRAWER (EXECUTION LOGS & LIVE AI CHAT)
   ========================================== */
.bottom-drawer {
  height: 270px;
  background: var(--bg-panel);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  z-index: 32;
  transition: height 0.2s ease;
}

.bottom-drawer.collapsed {
  height: 38px;
}

.drawer-tabs-bar {
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: #16161e;
  border-bottom: 1px solid var(--border-subtle);
}

.drawer-tabs-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.drawer-tab {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  padding: 8px 4px;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
}

.drawer-tab.active {
  color: var(--n8n-orange);
  border-bottom-color: var(--n8n-orange);
}

.drawer-content-area {
  flex: 1;
  display: flex;
  overflow: hidden;
}

.logs-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
  font-family: var(--font-mono);
  font-size: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.log-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 6px 10px;
  border-radius: 6px;
  background: var(--bg-input);
  border-left: 3px solid var(--n8n-green);
}

.log-row.agent-step {
  border-left-color: var(--n8n-purple);
}

/* Interactive Chat Panel inside Bottom Drawer */
.chat-studio-container {
  display: flex;
  width: 100%;
  height: 100%;
}

.chat-messages-pane {
  flex: 1;
  padding: 12px 18px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chat-bubble {
  max-width: 78%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 12.5px;
  line-height: 1.5;
  white-space: pre-wrap;
}

.chat-bubble.user {
  align-self: flex-end;
  background: var(--n8n-orange);
  color: #fff;
}

.chat-bubble.assistant {
  align-self: flex-start;
  background: var(--bg-panel-elevated);
  border: 1px solid rgba(168, 85, 247, 0.4);
  color: var(--text-primary);
}

.chat-input-bar {
  width: 380px;
  border-left: 1px solid var(--border-subtle);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #15151d;
}

.chat-input-bar textarea {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  color: #fff;
  padding: 10px;
  font-size: 12.5px;
  resize: none;
  outline: none;
}

.chat-input-bar textarea:focus {
  border-color: var(--n8n-purple);
}

/* ==========================================
   N8N 3-COLUMN NODE INSPECTOR MODAL (INPUT | PARAMETERS | OUTPUT)
   ========================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(9, 9, 13, 0.78);
  backdrop-filter: blur(5px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal-backdrop.open {
  display: flex;
}

.n8n-inspector-modal {
  width: 92vw;
  max-width: 1360px;
  height: 84vh;
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.75);
}

.inspector-header {
  height: 56px;
  padding: 0 20px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #181820;
}

.inspector-3col {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1.25fr 1fr;
  overflow: hidden;
}

.inspector-col {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border-subtle);
  overflow: hidden;
}

.inspector-col:last-child {
  border-right: none;
}

.col-header {
  height: 40px;
  padding: 0 14px;
  background: #15151c;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}

.col-body {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
}

.form-group {
  margin-bottom: 14px;
}

.form-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  outline: none;
}

.form-control:focus {
  border-color: var(--n8n-orange);
}

textarea.form-control {
  font-family: var(--font-mono);
  min-height: 120px;
  line-height: 1.45;
}

.json-viewer {
  background: #121217;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 12px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: #a7f3d0;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 100%;
  overflow-y: auto;
}

.expr-chip {
  display: inline-block;
  padding: 3px 8px;
  margin: 2px;
  background: rgba(255, 109, 90, 0.14);
  border: 1px solid rgba(255, 109, 90, 0.35);
  color: #ff988a;
  border-radius: 5px;
  font-family: var(--font-mono);
  font-size: 11px;
  cursor: pointer;
}

.expr-chip:hover {
  background: var(--n8n-orange);
  color: #fff;
}

/* ==========================================================================
   RESPONSIVE DESIGN & MOBILE / TABLET / LAPTOP ADAPTATION
   ========================================================================== */

/* 1. Standard Laptops & Medium Screens (<= 1400px) */
@media (max-width: 1400px) {
  .workflow-name-input {
    width: 170px;
    font-size: 12.5px;
  }
  .btn {
    padding: 5px 8px;
    font-size: 11px;
    gap: 4px;
  }
  .node-drawer {
    width: 260px;
  }
  .bottom-drawer {
    height: 230px;
  }
}

/* 2. Small Laptops & Tablets Landscape (<= 1100px) */
@media (max-width: 1100px) {
  .node-drawer {
    position: absolute;
    left: 58px;
    top: 0;
    bottom: 0;
    z-index: 50;
    box-shadow: 10px 0 30px rgba(0, 0, 0, 0.7);
  }
  .node-drawer.collapsed {
    left: -320px;
  }
  .workflow-name-input {
    width: 140px;
  }
  .top-actions {
    overflow-x: auto;
    padding-bottom: 2px;
  }
  .btn span:not(:first-child) {
    display: inline;
  }
  .inspector-3col {
    grid-template-columns: 1fr;
    height: auto;
    overflow-y: auto;
  }
  .inspector-col {
    border-right: none;
    border-bottom: 1px solid var(--border-subtle);
    min-height: 220px;
  }
  #dashKpiRow {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

/* 3. Tablets & Phablets (<= 900px) */
@media (max-width: 900px) {
  .app-shell {
    flex-direction: column;
  }
  .left-rail {
    width: 100vw;
    height: 48px;
    flex-direction: row;
    padding: 0 12px;
    border-right: none;
    border-bottom: 1px solid var(--border-subtle);
  }
  .left-rail .brand-logo {
    margin-bottom: 0;
    margin-right: 8px;
    width: 32px;
    height: 32px;
  }
  .rail-nav {
    flex-direction: row;
    gap: 4px;
    width: auto;
  }
  .rail-btn {
    width: 34px;
    height: 34px;
  }
  .node-drawer {
    left: 0;
    top: 48px;
    width: 100vw;
    max-width: 320px;
  }
  .top-bar {
    padding: 0 8px;
    gap: 6px;
  }
  .workflow-title-group {
    display: none;
  }
  .n8n-inspector-modal {
    width: 96vw !important;
    max-height: 92vh !important;
    border-radius: 12px !important;
  }
  #dashKpiRow {
    grid-template-columns: 1fr !important;
  }
  #softixDashboardScreen div[style*="grid-template-columns: 1.2fr 1fr"],
  #softixDashboardScreen div[style*="grid-template-columns:1.2fr 1fr"] {
    grid-template-columns: 1fr !important;
  }
  .canvas-floating-bar {
    bottom: 48px;
    transform: translateX(-50%) scale(0.9);
  }
}

/* 4. Mobile Phones (<= 600px) */
@media (max-width: 600px) {
  .top-actions .btn {
    padding: 4px 7px;
    font-size: 10.5px;
  }
  .canvas-zoom-controls {
    bottom: 50px;
    left: 8px;
    transform: scale(0.85);
    transform-origin: bottom left;
  }
  .bottom-drawer {
    height: 190px;
  }
  .drawer-tabs-left {
    gap: 8px;
  }
  .drawer-tab {
    font-size: 11px;
    padding: 6px 2px;
  }
  #softixLoginOverlay > div {
    width: 94vw !important;
    padding: 22px 18px !important;
  }
}

