/* 
  SQL Designer Premium Glassmorphism Design System 
*/

@import url('https://fonts.googleapis.com/css2?family=Fira+Code:wght@400;500&family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
  /* Softer dark: slightly lifted grounds, desaturated borders, calmer accents */
  --bg-main: #12161f;
  --bg-sidebar: #161b26;
  --bg-card: rgba(26, 31, 43, 0.85);
  --border-color: rgba(148, 163, 184, 0.10);
  --border-hover: rgba(99, 102, 241, 0.30);

  --primary: #6366f1; /* Indigo */
  --primary-glow: rgba(99, 102, 241, 0.18);
  --accent: #34d399; /* Soft emerald */
  --accent-glow: rgba(52, 211, 153, 0.25);

  --line-idle: rgba(148, 163, 184, 0.30); /* neutral resting lines */

  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-dark: #64748b;

  --pk-color: #eab308; /* Muted gold key */
  --fk-color: #60a5fa; /* Soft blue link */
}

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

body {
  font-family: 'Outfit', sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  display: flex;
}

/* Sidebar Styling */
.sidebar {
  width: 420px;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  height: 100vh;
  z-index: 10;
  box-shadow: 10px 0 30px rgba(0, 0, 0, 0.3);
  flex-shrink: 0;
  transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Collapsed: slide out keeping children laid out (no squishing) */
.sidebar.collapsed {
  margin-left: -420px;
}

@media (prefers-reduced-motion: reduce) {
  .sidebar {
    transition: none;
  }
}

/* Small round icon buttons (sidebar chrome) */
.icon-btn {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  width: 28px;
  height: 28px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

.icon-btn:hover {
  color: var(--text-main);
  border-color: var(--primary);
  background-color: rgba(99, 102, 241, 0.12);
}

/* Floating chip to reopen the collapsed sidebar */
.sidebar-open-btn {
  position: absolute;
  top: 24px;
  left: 24px;
  z-index: 9;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--text-muted);
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
  transition: all 0.2s;
}

.sidebar-open-btn:hover {
  color: var(--text-main);
  border-color: var(--primary);
}

.sidebar-open-btn[hidden] {
  display: none;
}

/* Project switcher: its own full-width row above the editor */
.project-select {
  width: 100%;
  padding: 9px 12px;
  font-size: 13px;
}

/* Clickable bar that folds the SQL editor — full width, reads as a control */
.label-toggle {
  width: 100%;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-muted);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.4px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  padding: 10px 14px;
  transition: all 0.2s;
}

.label-toggle:hover {
  color: var(--text-main);
  border-color: var(--border-hover);
  background: rgba(99, 102, 241, 0.10);
}

.fold-chevron {
  display: inline-block;
  font-size: 14px;
  color: var(--accent);
  transition: transform 0.2s;
}

/* Textual affordance: "mostrar"/"ocultar" on the bar's right side */
.fold-hint {
  margin-left: auto;
  font-size: 11px;
  font-weight: 400;
  color: var(--text-dark);
  text-transform: lowercase;
}

.label-toggle:hover .fold-hint {
  color: var(--accent);
}

/* Folded editor: chevron rotates, editor hides, outline takes the space */
.sidebar.editor-folded .fold-chevron {
  transform: rotate(-90deg);
}

.sidebar.editor-folded .editor-wrapper {
  display: none;
}

.sidebar.editor-folded .editor-section {
  /* Content-sized when folded — flex-shrink 0 stops the section from
     being squeezed below its content (children were spilling over) */
  flex-grow: 0;
  flex-shrink: 0;
  min-height: auto;
}

.sidebar.editor-folded .outline-section {
  flex-grow: 1;
  height: auto;
}

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

.logo-section {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  width: 38px;
  height: 38px;
  border-radius: 9px;
  filter: drop-shadow(0 2px 8px var(--primary-glow));
  flex-shrink: 0;
}

.sidebar-header h1 {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.5px;
  background: linear-gradient(to right, #ffffff, #cbd5e1);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.sidebar-header p {
  font-size: 11px;
  color: var(--text-dark);
  margin-top: 2px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.editor-section {
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex-grow: 1;
  min-height: 0; /* allows flex scrolling child */
}

.section-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
}

.sample-select {
  background-color: rgba(15, 23, 42, 0.8);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 6px 12px;
  border-radius: 6px;
  font-family: inherit;
  font-size: 12px;
  outline: none;
  cursor: pointer;
  transition: border-color 0.2s;
}

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

.editor-wrapper {
  position: relative;
  flex-grow: 1;
  min-height: 0;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background-color: rgba(3, 7, 18, 0.6);
  overflow: hidden;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.4);
}

/* Editor com highlight: <pre> colorido por baixo, textarea transparente por cima */
.sql-editor,
.sql-highlight {
  font-family: 'Fira Code', monospace;
  font-size: 13px;
  line-height: 1.6;
  padding: 16px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  tab-size: 4;
}

.sql-editor {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  background: transparent;
  border: none;
  resize: none;
  color: transparent;
  caret-color: #f1f5f9;
  outline: none;
  overflow-y: auto;
}

.sql-editor::selection {
  background: rgba(99, 102, 241, 0.35);
  color: transparent;
}

.sql-editor::placeholder {
  color: var(--text-dark);
  opacity: 1;
}

.sql-highlight {
  position: absolute;
  inset: 0;
  margin: 0;
  overflow: hidden;
  color: #cbd5e1;
  pointer-events: none;
}

/* Visão limpa: leitura sem comentários, rolagem própria */
.sql-clean {
  pointer-events: auto;
  overflow: auto;
  z-index: 2;
  background: rgba(3, 7, 18, 0.6);
}

.sql-clean[hidden] {
  display: none;
}

.stmt-focus {
  display: inline-block;
  width: 100%;
  background: rgba(52, 211, 153, 0.10);
  box-shadow: inset 2px 0 0 var(--accent);
  border-radius: 4px;
}

/* Chip liga/desliga de comentários, flutuando no canto do editor */
.comments-toggle {
  position: absolute;
  top: 8px;
  right: 10px;
  z-index: 3;
  font-family: 'Fira Code', monospace;
  font-size: 11px;
  font-weight: 500;
  padding: 3px 9px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  background: rgba(15, 23, 42, 0.85);
  color: var(--text-dark);
  cursor: pointer;
  transition: all 0.15s;
}

.comments-toggle:hover {
  color: var(--text-main);
  border-color: var(--border-hover);
}

.comments-toggle.on {
  color: var(--accent);
  border-color: rgba(52, 211, 153, 0.5);
  background: rgba(52, 211, 153, 0.10);
  text-decoration: line-through;
}

/* Espelho de medição: mesma métrica do editor, fora da tela */
.sql-mirror {
  position: absolute !important;
  left: -99999px !important;
  top: 0 !important;
  height: auto !important;
  overflow: visible !important;
  visibility: hidden;
  display: block;
}

/* Cores dos tokens (paleta da interface) */
.tok-kw   { color: #818cf8; }
.tok-type { color: #60a5fa; }
.tok-str  { color: #34d399; }
.tok-num  { color: #eab308; }
.tok-com  { color: #64748b; font-style: italic; }
.tok-id   { color: #f1f5f9; }

/* Snippet contextual: só o DDL do objeto selecionado, quando o editor está dobrado */
.sql-snippet {
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: rgba(10, 14, 22, 0.6);
  overflow: hidden;
}

.snippet-title {
  padding: 6px 12px;
  font-family: 'Fira Code', monospace;
  font-size: 11px;
  color: var(--accent);
  border-bottom: 1px solid var(--border-color);
}

.snippet-pre {
  margin: 0;
  max-height: 230px;
  overflow: auto;
  padding: 10px 12px;
  font-family: 'Fira Code', monospace;
  font-size: 12px;
  line-height: 1.55;
  color: #cbd5e1;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

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

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

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.18);
}

.action-buttons {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
  padding: 0 16px 16px 16px;
}

.btn {
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  padding: 8px 2px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s ease;
  user-select: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), #4f46e5);
  color: white;
  box-shadow: 0 2px 10px rgba(99, 102, 241, 0.22);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.32);
}

.btn-primary:active {
  transform: translateY(1px);
}

.btn-secondary {
  background-color: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-main);
}

.btn-secondary:hover {
  background-color: rgba(255, 255, 255, 0.1);
  border-color: var(--text-dark);
}

.outline-section {
  border-top: 1px solid var(--border-color);
  padding: 14px 16px;
  height: 250px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* VSCode-tree-like list: dense rows, quiet type, no boxes */
.outline-list {
  flex-grow: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0;
  padding-right: 4px;
}

.outline-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 3px 10px;
  border-radius: 4px;
  font-size: 12.5px;
  line-height: 1.5;
  cursor: pointer;
  transition: background-color 0.1s;
}

.outline-item:hover {
  background-color: rgba(255, 255, 255, 0.05);
}

.outline-item-name {
  font-weight: 400;
  color: #cbd5e1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.outline-item-count {
  font-size: 10.5px;
  color: var(--text-dark);
  flex-shrink: 0;
}

/* Settings Modal */
.settings-overlay {
  position: fixed;
  inset: 0;
  background: rgba(3, 7, 18, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
}

.settings-overlay[hidden] {
  display: none;
}

.settings-modal {
  width: 380px;
  max-width: calc(100vw - 48px);
  background: var(--bg-sidebar);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.7);
  overflow: hidden;
}

.settings-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  font-weight: 600;
  font-size: 15px;
}

.settings-section {
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.settings-section + .settings-section {
  border-top: 1px solid var(--border-color);
}

.settings-section-title {
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-dark);
  margin-bottom: 4px;
}

/* Language options: flag + name, built dynamically from lang.js */
.settings-lang-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.lang-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-main);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s;
}

.lang-option:hover {
  background-color: rgba(255, 255, 255, 0.05);
}

.lang-option.active {
  border-color: var(--primary);
  background-color: rgba(99, 102, 241, 0.12);
}

.lang-option .lang-flag {
  font-size: 16px;
}

/* Labeled on/off switches */
.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0;
  font-size: 13px;
  color: var(--text-main);
  cursor: pointer;
  user-select: none;
}

.switch-input {
  display: none;
}

.switch-slider {
  position: relative;
  width: 38px;
  height: 20px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.12);
  transition: background 0.2s;
  flex-shrink: 0;
}

.switch-slider::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: all 0.2s;
}

.switch-input:checked + .switch-slider {
  background: var(--primary);
}

.switch-input:checked + .switch-slider::after {
  left: 20px;
  background: #fff;
}

/* Canvas Area */
.canvas-container {
  flex-grow: 1;
  height: 100vh;
  position: relative;
  overflow: hidden;
  background-color: var(--bg-main);
  background-image: 
    radial-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 0),
    radial-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 0);
  background-position: 0 0, 20px 20px;
  background-size: 40px 40px;
  user-select: none;
}

.canvas-viewport {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  transform-origin: 0 0;
  pointer-events: none; /* so panning container events trigger */
}

/* SVG Connection Lines overlay */
.svg-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 5000px;
  height: 5000px;
  transform-origin: 0 0;
  pointer-events: none;
  overflow: visible;
}

.svg-back {
  z-index: 1; /* Behind table cards (standard view) */
}

.svg-front {
  z-index: 3; /* Above table cards (focused/hovered view) */
}

.svg-overlay * {
  pointer-events: auto; /* allow events on lines */
}

.relationship-group {
  cursor: pointer;
}

.rel-main-line {
  stroke: var(--line-idle);
  stroke-width: 1.5px;
  fill: none;
  vector-effect: non-scaling-stroke;
  transition: stroke 0.2s, stroke-width 0.2s;
}

.rel-glow-line {
  stroke: var(--primary);
  stroke-width: 6px;
  fill: none;
  opacity: 0;
  vector-effect: non-scaling-stroke;
  transition: opacity 0.2s, stroke-width 0.2s;
  filter: blur(2px);
}

.relationship-group:hover .rel-main-line,
.relationship-group.active .rel-main-line {
  stroke: var(--accent);
  stroke-width: 2px;
  stroke-dasharray: 5, 5;
  animation: connection-flow 0.9s linear infinite;
}

.relationship-group:hover .rel-glow-line,
.relationship-group.active .rel-glow-line {
  stroke: var(--accent);
  opacity: 0.18;
  stroke-width: 8px;
}

@keyframes connection-flow {
  from {
    stroke-dashoffset: 20;
  }
  to {
    stroke-dashoffset: 0;
  }
}

.pk-marker-dot {
  fill: var(--pk-color);
  filter: drop-shadow(0 0 2px rgba(234, 179, 8, 0.45));
}

.fk-marker-arrow {
  fill: var(--fk-color);
}

/* Cards Container */
.card-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 5000px;
  height: 5000px;
  transform-origin: 0 0;
  pointer-events: none;
  z-index: 2;
}

.card-container * {
  pointer-events: auto; /* permit clicks on child tables */
}

/* Elevated layer for focused/connected cards: sits above svg-front so
   highlighted lines pass under the involved tables instead of over them */
.card-container-top {
  z-index: 4;
}

/* Table Card CSS */
.table-card {
  position: absolute;
  width: 240px;
  background: var(--bg-card);
  backdrop-filter: blur(12px) saturate(140%);
  -webkit-backdrop-filter: blur(12px) saturate(140%);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  box-shadow: 0 6px 20px -10px rgba(0, 0, 0, 0.45);
  color: var(--text-main);
  user-select: none;
  transition:
    box-shadow 0.25s cubic-bezier(0.4, 0, 0.2, 1),
    border-color 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

.table-card:hover {
  border-color: var(--border-hover);
  box-shadow: 0 10px 28px -14px rgba(0, 0, 0, 0.55);
}

.table-card.highlight-connected {
  border-color: transparent;
  box-shadow:
    0 0 0 1px var(--primary),
    0 8px 22px -12px rgba(0, 0, 0, 0.5);
  z-index: 100;
}

.table-header {
  padding: 12px 16px;
  background: rgba(129, 140, 248, 0.08);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: grab;
}

.table-header:active {
  cursor: grabbing;
}

.table-title {
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 0.2px;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 170px;
}

.table-action-btn {
  background: transparent;
  border: none;
  color: var(--text-dark);
  font-size: 16px;
  cursor: pointer;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s;
}

.table-action-btn:hover {
  color: #ef4444;
  background-color: rgba(239, 68, 68, 0.15);
}

.table-columns {
  padding: 6px 0;
}

.column-row {
  padding: 8px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  transition: background-color 0.15s;
  position: relative;
}

.column-row:hover {
  background-color: rgba(255, 255, 255, 0.03);
}

.col-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.col-name {
  color: #e2e8f0;
}

.key-icon {
  font-size: 11px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
}

.not-null-indicator {
  color: #ef4444;
  margin-left: 2px;
  font-weight: bold;
}

.col-type {
  color: var(--text-muted);
  font-size: 11px;
  font-family: 'Fira Code', monospace;
  padding-left: 10px;
}

/* Floating Toolbar */
.floating-toolbar {
  position: absolute;
  bottom: 24px;
  right: 24px;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  padding: 6px;
  border-radius: 10px;
  display: flex;
  gap: 6px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
  z-index: 8;
}

.toolbar-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 16px;
  width: 36px;
  height: 36px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.toolbar-btn:hover {
  color: var(--text-main);
  background-color: rgba(255, 255, 255, 0.08);
}


.toolbar-divider {
  width: 1px;
  background-color: var(--border-color);
  margin: 6px 3px;
}

/* Helper Guide overlay */
.helper-overlay {
  position: absolute;
  top: 24px;
  right: 24px;
  background: rgba(15, 23, 42, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--border-color);
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 12px;
  color: var(--text-muted);
  pointer-events: none;
  z-index: 5;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.helper-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.helper-key {
  background-color: rgba(255, 255, 255, 0.1);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: monospace;
  color: #fff;
}

/* 
  Highlighting & Fading Focus Interactions 
*/
.table-card {
  transition: 
    opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1),
    filter 0.3s cubic-bezier(0.4, 0, 0.2, 1),
    box-shadow 0.25s cubic-bezier(0.4, 0, 0.2, 1),
    border-color 0.25s cubic-bezier(0.4, 0, 0.2, 1),
    transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Focused card: a calm ring, not a glow */
.table-card.highlight-focused {
  border-color: transparent;
  box-shadow:
    0 0 0 1.5px var(--accent),
    0 12px 30px -14px rgba(0, 0, 0, 0.55);
  transform: scale(1.02);
  z-index: 150 !important;
}

/* Directly related cards */
.table-card.highlight-connected {
  border-color: transparent;
  box-shadow:
    0 0 0 1px var(--primary),
    0 8px 22px -12px rgba(0, 0, 0, 0.5);
  z-index: 100 !important;
}

/* Unrelated cards are faded out */
.table-card.is-faded {
  opacity: 0.2;
  filter: saturate(40%);
  box-shadow: none;
}

.table-card.is-faded:hover {
  opacity: 0.45; /* lighter on hover to invite interaction */
  filter: saturate(70%);
}

/*
  Routine nodes: triggers (amber) and procedures/functions (purple)
*/
.routine-card {
  position: absolute;
  min-width: 150px;
  max-width: 220px;
  background: var(--bg-card);
  backdrop-filter: blur(12px) saturate(140%);
  -webkit-backdrop-filter: blur(12px) saturate(140%);
  border: 1px solid rgba(234, 179, 8, 0.28);
  border-radius: 10px;
  padding: 10px 14px;
  box-shadow: 0 6px 18px -10px rgba(0, 0, 0, 0.45);
  cursor: grab;
  user-select: none;
  transition:
    opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1),
    filter 0.3s cubic-bezier(0.4, 0, 0.2, 1),
    box-shadow 0.25s cubic-bezier(0.4, 0, 0.2, 1),
    border-color 0.25s cubic-bezier(0.4, 0, 0.2, 1),
    transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.routine-card:active {
  cursor: grabbing;
}

/* Subtle color nuance per kind: amber-tinted glass for triggers */
.routine-trigger {
  background:
    linear-gradient(180deg, rgba(234, 179, 8, 0.06) 0%, rgba(234, 179, 8, 0.01) 100%),
    var(--bg-card);
}

/* ...and purple-tinted glass for procedures/functions */
.routine-procedure,
.routine-function {
  border-color: rgba(192, 132, 252, 0.28);
  background:
    linear-gradient(180deg, rgba(192, 132, 252, 0.06) 0%, rgba(192, 132, 252, 0.01) 100%),
    var(--bg-card);
}

.routine-kind {
  font-size: 10px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--pk-color);
  margin-bottom: 4px;
  white-space: nowrap;
}

.routine-procedure .routine-kind,
.routine-function .routine-kind {
  color: #c084fc;
}

.routine-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  font-family: 'Fira Code', monospace;
  overflow-wrap: anywhere;
}

.routine-card:hover {
  border-color: rgba(251, 191, 36, 0.7);
  box-shadow: 0 10px 30px -12px rgba(251, 191, 36, 0.3);
}

.routine-procedure:hover,
.routine-function:hover {
  border-color: rgba(192, 132, 252, 0.75);
  box-shadow: 0 10px 30px -12px rgba(192, 132, 252, 0.3);
}

.routine-card.highlight-focused {
  border-color: transparent;
  transform: scale(1.03);
  box-shadow:
    0 0 0 1.5px var(--accent),
    0 10px 26px -14px rgba(0, 0, 0, 0.55);
}

.routine-card.highlight-connected {
  border-color: transparent;
  box-shadow:
    0 0 0 1px var(--pk-color),
    0 8px 20px -12px rgba(0, 0, 0, 0.5);
}

.routine-procedure.highlight-connected,
.routine-function.highlight-connected {
  border-color: transparent;
  box-shadow:
    0 0 0 1px #c084fc,
    0 8px 20px -12px rgba(0, 0, 0, 0.5);
}

.routine-card.is-faded {
  opacity: 0.2;
  filter: saturate(40%);
  box-shadow: none;
}

.routine-card.is-faded:hover {
  opacity: 0.45;
  filter: saturate(70%);
}

/* Routine connection lines: dashed, colored by kind */
.routine-link .rel-main-line {
  stroke: rgba(234, 179, 8, 0.32);
  stroke-dasharray: 4, 5;
}

.routine-link.routine-link-proc .rel-main-line {
  stroke: rgba(192, 132, 252, 0.32);
}

/* Unrelated lines are faded out */
.relationship-group.is-faded .rel-main-line {
  stroke: rgba(255, 255, 255, 0.04);
  opacity: 0.15;
}
.relationship-group.is-faded .rel-glow-line {
  opacity: 0;
}

/* Highlighted active lines */
.relationship-group.highlight-active .rel-main-line {
  stroke: var(--accent);
  stroke-width: 2px;
  stroke-dasharray: 5, 5;
  animation: connection-flow 0.8s linear infinite;
}

.relationship-group.highlight-active .rel-glow-line {
  stroke: var(--accent);
  opacity: 0.22;
  stroke-width: 8px;
}

