/* ── Base ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html, body {
    height: 100%;
    margin: 0;
    font-size: 13px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(225deg, #242d3a 0%, #121622 100%);
    color: #e2e8f0;
    -webkit-font-smoothing: antialiased;
}

a { color: #a78bfa; }
a:hover { color: #c4b5fd; }

/* ── Utilities ─────────────────────────────────────────── */
.surface { background: #1e2535; border-radius: 6px; }
.accent { color: #593196; }
.accent-light { color: #a78bfa; }
.text-muted { color: #94a3b8 !important; }

/* ── Studio shell ──────────────────────────────────────── */
.studio-shell { background: transparent; }

.studio-nav {
    background: #0f1520;
    border-bottom: 1px solid #1e2b3c;
    height: 44px;
}
.studio-nav .brand {
    font-weight: 600;
    font-size: 14px;
    color: #e2e8f0;
    text-decoration: none;
    letter-spacing: -.01em;
}
.studio-nav .brand:hover { color: #a78bfa; }
.studio-nav .brand i { color: #593196; }

.studio-main { height: 100%; }

.studio-status {
    height: 28px;
    background: #0d1117;
    border-top: 1px solid #1e2b3c;
    color: #94a3b8;
    font-size: 12px;
}
.studio-status i { color: #593196; font-size: 10px; }

/* ── Sidebar / Tree ────────────────────────────────────── */
.studio-sidebar {
    width: var(--sidebar-width, 260px);
    background: #151d2b;
    border-right: 1px solid #1e2b3c;
    padding-top: 4px;
}
.studio-sidebar.collapsed { width: 32px; overflow-x: hidden; transition: width .15s ease; }

.sidebar-resizer {
    width: 5px;
    flex-shrink: 0;
    cursor: col-resize;
    background: transparent;
    transition: background .12s ease;
}
.sidebar-resizer:hover, .sidebar-resizer.dragging { background: #593196; }
.studio-sidebar.collapsed + .sidebar-resizer { pointer-events: none; }

.sidebar-toggle {
    background: none;
    border: none;
    color: #64748b;
    cursor: pointer;
    padding: 4px 8px;
    line-height: 1;
    align-self: flex-end;
    font-size: 12px;
    border-radius: 4px;
    margin: 0 4px 4px 4px;
}
.sidebar-toggle:hover { color: #a78bfa; background: #1e2b3c; }
.studio-sidebar.collapsed .sidebar-toggle { align-self: center; margin: 0 0 4px 0; }

.tree-container { padding: 0 4px; }

.tree-node { margin: 1px 0; }
.tree-node > summary {
    display: flex;
    align-items: center;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    list-style: none;
    color: #94a3b8;
    position: relative;
    user-select: none;
}
.tree-node > summary:hover { background: #1e2b3c; color: #e2e8f0; }
.tree-selected { background: #252e42 !important; color: #a78bfa !important; }

.tree-delete {
    display: none;
    background: none;
    border: none;
    color: #64748b;
    padding: 0 2px;
    margin-left: auto;
    cursor: pointer;
    line-height: 1;
}
.tree-node > summary:hover .tree-delete { display: inline; }
.tree-delete:hover { color: #f87171; }

.tree-children {
    border-left: 1px solid #1e2b3c;
    margin-left: 16px;
}

/* ── Add node inline ───────────────────────────────────── */
.add-node-row { display: flex; align-items: center; gap: 2px; padding: 2px 4px; }
.add-node-btn {
    background: none;
    border: none;
    color: #64748b;
    font-size: 12px;
    padding: 3px 6px;
    border-radius: 4px;
    cursor: pointer;
    width: 100%;
    text-align: left;
}
.add-node-btn:hover { background: #1e2b3c; color: #94a3b8; }

.add-node-input {
    flex: 1;
    background: #1e2535;
    border: 1px solid #334155;
    color: #e2e8f0;
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 12px;
    outline: none;
}
.add-node-input:focus { border-color: #593196; }
.add-node-save, .add-node-cancel {
    background: none;
    border: none;
    color: #64748b;
    cursor: pointer;
    padding: 2px 4px;
}
.add-node-save:hover { color: #4ade80; }
.add-node-cancel:hover { color: #f87171; }

/* ── Canvas ────────────────────────────────────────────── */
.canvas-header h3 { font-size: 1.25rem; font-weight: 600; }
.canvas-name { cursor: pointer; }
.canvas-name:hover { color: #a78bfa; }
.canvas-name-edit {
    background: none;
    border: none;
    color: #eab308;
    cursor: pointer;
    padding: 0 4px 2px 4px;
    border-radius: 3px;
    line-height: 1;
    font-size: 0.6rem;
    opacity: 0.7;
    align-self: flex-end;
}
.canvas-name-edit:hover { color: #fde047; opacity: 1; background: #1e2b3c; }
.canvas-name-input {
    background: transparent;
    border: 1px solid #334155;
    border-radius: 4px;
    color: #e2e8f0;
    font-size: 1.25rem;
    font-weight: 600;
    padding: 2px 8px;
    outline: none;
    width: auto;
    min-width: 240px;
}
.canvas-name-input:focus { border-color: #593196; }
.canvas-meta { color: #64748b; }
.canvas-type-badge {
    background: #252e42;
    color: #a78bfa;
    font-size: 11px;
    font-weight: 500;
    letter-spacing: .04em;
    border-radius: 4px;
    padding: 2px 7px;
}

.canvas-section { background: #1a2333; border-radius: 8px; padding: 16px; }
.canvas-section-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: #64748b;
}

.prop-table { border-collapse: collapse; font-size: 12px; }
.prop-table th {
    color: #475569;
    font-size: 11px;
    font-weight: 500;
    padding: 4px 8px;
    border-bottom: 1px solid #1e2b3c;
    text-align: left;
}
.prop-table td { padding: 4px 8px; border-bottom: 1px solid #1a2333; vertical-align: middle; }
.prop-key { font-family: Consolas, 'Courier New', monospace; color: #94a3b8; }

.prop-value-input {
    width: 100%;
    background: transparent;
    border: none;
    color: #e2e8f0;
    font-size: 12px;
    padding: 2px 4px;
    border-radius: 3px;
    outline: none;
}
.prop-value-input:focus { background: #252e42; border: 1px solid #334155; }
.prop-delete {
    background: none;
    border: none;
    color: #475569;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}
.prop-delete:hover { color: #f87171; }

.prop-new-key, .prop-new-val {
    background: #1e2535;
    border: 1px solid #334155;
    color: #e2e8f0;
    border-radius: 4px;
    padding: 3px 8px;
    font-size: 12px;
    outline: none;
    width: 140px;
}
.prop-new-key:focus, .prop-new-val:focus { border-color: #593196; }

.prop-json-editor {
    width: 100%;
    background: #0f1520;
    border: 1px solid #334155;
    color: #e2e8f0;
    border-radius: 4px;
    padding: 8px 10px;
    font-family: Consolas, 'SFMono-Regular', monospace;
    font-size: 12px;
    line-height: 1.4;
    outline: none;
    resize: vertical;
}
.prop-json-editor:focus { border-color: #593196; }

/* ── Auth pages ────────────────────────────────────────── */
.auth-shell {
    background: linear-gradient(225deg, #242d3a 0%, #121622 100%);
    min-height: 100vh;
}
.auth-card {
    border: 1px solid #1e2b3c;
}
.auth-card .form-control {
    background: #0f1520;
    border-color: #334155;
    color: #e2e8f0;
}
.auth-card .form-control:focus {
    background: #0f1520;
    border-color: #593196;
    color: #e2e8f0;
    box-shadow: 0 0 0 2px rgba(89,49,150,.25);
}

/* ── Bootstrap overrides ───────────────────────────────── */
.btn-primary {
    background-color: #593196;
    border-color: #593196;
}
.btn-primary:hover { background-color: #6d3db8; border-color: #6d3db8; }
.btn-outline-secondary { border-color: #334155; color: #94a3b8; }
.btn-outline-secondary:hover { background: #1e2b3c; color: #e2e8f0; border-color: #475569; }

/* ── Blazor reconnect modal (custom, owned by us) ──────── */
#components-reconnect-modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.65);
    z-index: 1050;
    align-items: center;
    justify-content: center;
    color: #e2e8f0;
}
#components-reconnect-modal.components-reconnect-show,
#components-reconnect-modal.components-reconnect-failed,
#components-reconnect-modal.components-reconnect-rejected {
    display: flex;
}
#components-reconnect-modal .reconnect-dialog {
    background: #1e2535;
    border: 1px solid #334155;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0,0,0,.5);
    padding: 20px 24px;
    min-width: 280px;
    max-width: 360px;
}
#components-reconnect-modal .reconnect-title {
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 8px;
    color: #e2e8f0;
}
#components-reconnect-modal .reconnect-title i { color: #eab308; margin-right: 6px; }
#components-reconnect-modal .reconnect-text { color: #94a3b8; }
#components-reconnect-modal .reconnect-state-show,
#components-reconnect-modal .reconnect-state-failed,
#components-reconnect-modal .reconnect-state-rejected { display: none; }
#components-reconnect-modal.components-reconnect-show .reconnect-state-show { display: inline; }
#components-reconnect-modal.components-reconnect-failed .reconnect-state-failed { display: inline; }
#components-reconnect-modal.components-reconnect-rejected .reconnect-state-rejected { display: inline; }
#components-reconnect-modal.components-reconnect-show .reconnect-text.reconnect-state-show,
#components-reconnect-modal.components-reconnect-failed .reconnect-text.reconnect-state-failed,
#components-reconnect-modal.components-reconnect-rejected .reconnect-text.reconnect-state-rejected { display: block; }
#components-reconnect-modal .reconnect-title .reconnect-state-show i,
#components-reconnect-modal.components-reconnect-show .reconnect-title i { animation: reconnect-spin 1.2s linear infinite; }
@keyframes reconnect-spin { to { transform: rotate(360deg); } }

/* ── Scrollbar ─────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #2d3748; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #4a5568; }
