[v-cloak] { display: none; }

/* ===== CSS Variables for Theming ===== */
:root {
    /* Dark theme (default) */
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --bg-card: #1e293b;
    --bg-hover: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #64748b;
    --border-color: #334155;
    --border-light: #475569;
    --shadow-color: rgba(0, 0, 0, 0.3);
    --grid-dot-color: #334155;
    --scrollbar-thumb: #475569;
    --scrollbar-track: transparent;
    --node-ghost-bg: rgba(30, 41, 59, 0.6);
    --node-ghost-bg-hover: rgba(30, 41, 59, 0.9);
    --tab-active-bg: #1e293b;
    --tab-inactive-bg: #0f172a;
    --input-bg: #1e293b;
    --modal-overlay: rgba(0, 0, 0, 0.4);
}

/* Light theme */
html.light {
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-tertiary: #e2e8f0;
    --bg-card: #ffffff;
    --bg-hover: #f1f5f9;
    --text-primary: #1e293b;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --border-color: #e2e8f0;
    --border-light: #cbd5e1;
    --shadow-color: rgba(0, 0, 0, 0.1);
    --grid-dot-color: #cbd5e1;
    --scrollbar-thumb: #cbd5e1;
    --scrollbar-track: #f1f5f9;
    --node-ghost-bg: rgba(255, 255, 255, 0.8);
    --node-ghost-bg-hover: rgba(255, 255, 255, 0.95);
    --tab-active-bg: #ffffff;
    --tab-inactive-bg: #f1f5f9;
    --input-bg: #ffffff;
    --modal-overlay: rgba(0, 0, 0, 0.2);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--bg-primary);
    transition: background-color 0.3s ease;
}

/* Canvas grid background */
.canvas-container {
    background-color: var(--bg-primary);
    background-image:
        radial-gradient(circle, var(--grid-dot-color) 1px, transparent 1px);
    background-size: 24px 24px;
    width: 100%;
    height: 100%;
    overflow: hidden;
    position: relative;
    cursor: grab;
    transition: background-color 0.3s ease, background-image 0.3s ease;
}
.canvas-container:active { cursor: grabbing; }

/* Flow node card */
.flow-node {
    position: absolute;
    width: 280px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 10px 15px -3px var(--shadow-color), 0 4px 6px -2px var(--shadow-color);
    z-index: 10;
    user-select: none;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

/* Hover state */
.flow-node:hover {
    box-shadow: 0 0 0 2px #3b82f6;
    transform: translateY(-1px);
}

/* Ghost node style */
.flow-node.ghost-node {
    background: var(--node-ghost-bg);
    border: 1px dashed var(--border-light);
    backdrop-filter: blur(4px);
    color: var(--text-muted);
    cursor: alias;
}
.flow-node.ghost-node .node-header {
    background: transparent;
    border-bottom: 1px dashed var(--border-color);
    color: var(--text-secondary);
}
.flow-node.ghost-node:hover {
    border-color: #60a5fa;
    background: var(--node-ghost-bg-hover);
}

/* Node variants: library/global faq/intent */
.flow-node.library-node { border-color: #f59e0b; }
.flow-node.library-node .node-header { background: linear-gradient(to right, rgba(245, 158, 11, 0.1), transparent); }

.flow-node.global_faq_node { border-color: #10b981; }
.flow-node.global_faq_node .node-header { background: linear-gradient(to right, rgba(16, 185, 129, 0.1), transparent); }

.flow-node.intent_node { border-color: #8b5cf6; }
.flow-node.intent_node .node-header { background: linear-gradient(to right, rgba(139, 92, 246, 0.1), transparent); }

/* Connection layer */
.connections-layer { position: absolute; top: 0; left: 0; pointer-events: none; z-index: 1; }
path { fill: none; stroke: var(--border-light); stroke-width: 2px; transition: stroke 0.3s; }
path.route { stroke-opacity: 0.8; }
path.ghost { stroke-dasharray: 6,4; opacity: 0.5; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--scrollbar-track); }
::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-light); }

/* Tabs */
.tab-item {
    position: relative;
    transition: all 0.2s;
}
.tab-active {
    background: var(--tab-active-bg);
    color: var(--text-primary);
    border-top: 2px solid #3b82f6;
}
.tab-inactive {
    background: var(--tab-inactive-bg);
    color: var(--text-muted);
    border-right: 1px solid var(--border-color);
}
.tab-inactive:hover {
    background: var(--bg-hover);
    color: var(--text-secondary);
}

/* Module group */
.module-group {
    position: absolute;
    border: 2px dashed;
    border-radius: 16px;
    z-index: 2;
    pointer-events: none;
    transition: all 0.3s ease;
}
.module-group.is-collapsed { border-style: solid; box-shadow: 0 4px 6px -1px var(--shadow-color); }

.module-group-header {
    pointer-events: auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: #ffffff;
    font-size: 13px;
    font-weight: 600;
    padding: 6px 12px;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.2);
    cursor: pointer;
    backdrop-filter: blur(4px);
    transition: transform 0.1s;
}
.module-group-header:active { transform: scale(0.98); }

.module-group-title { max-width: 220px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-shadow: 0 1px 2px rgba(0,0,0,0.5); }
.module-group-toggle { font-weight: 700; opacity: 0.8; }
.module-dot { width: 8px; height: 8px; border-radius: 9999px; flex: 0 0 8px; box-shadow: 0 0 0 1px rgba(0,0,0,0.2); }

/* Form focus states */
input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 1px #3b82f6;
}

/* ===== Light Theme Adjustments ===== */
html.light .module-group-header {
    color: #1e293b;
    text-shadow: none;
}
html.light .module-group-title {
    text-shadow: none;
}

/* ===== Light Theme Utility Classes ===== */
html.light .text-slate-300 { color: #475569 !important; }
html.light .text-slate-400 { color: #64748b !important; }
html.light .text-slate-500 { color: #94a3b8 !important; }
html.light .text-slate-600 { color: #64748b !important; }
html.light .text-slate-200 { color: #334155 !important; }
html.light .text-slate-100 { color: #1e293b !important; }

html.light .bg-slate-900 { background-color: #ffffff !important; }
html.light .bg-slate-800 { background-color: #f1f5f9 !important; }
html.light .bg-slate-800\/50 { background-color: rgba(241, 245, 249, 0.5) !important; }
html.light .bg-slate-800\/30 { background-color: rgba(241, 245, 249, 0.3) !important; }
html.light .bg-slate-700 { background-color: #e2e8f0 !important; }
html.light .bg-slate-700\/30 { background-color: rgba(226, 230, 240, 0.3) !important; }

html.light .border-slate-700 { border-color: #e2e8f0 !important; }
html.light .border-slate-800 { border-color: #f1f5f9 !important; }
html.light .border-slate-600 { border-color: #cbd5e1 !important; }

html.light .hover\:bg-slate-800:hover { background-color: #e2e8f0 !important; }
html.light .hover\:bg-slate-700:hover { background-color: #cbd5e1 !important; }
html.light .hover\:border-slate-700:hover { border-color: #cbd5e1 !important; }
html.light .hover\:border-slate-600:hover { border-color: #94a3b8 !important; }

html.light .shadow-inner { box-shadow: inset 0 2px 4px 0 rgba(0, 0, 0, 0.06) !important; }

/* Light theme input/textarea styles */
html.light input,
html.light textarea {
    background-color: #ffffff;
    color: #1e293b;
    border-color: #cbd5e1;
}
html.light input::placeholder,
html.light textarea::placeholder {
    color: #94a3b8;
}

/* Light theme modal overlays */
html.light .backdrop-blur-sm {
    backdrop-filter: blur(4px);
}

/* Light theme empty state */
html.light .empty-state-icon {
    opacity: 0.3;
}
