/* ==========================================================================
   НЕЙРОРАЗВЕДКА STUDIO 2.0 — WORKSPACE STYLES
   ========================================================================== */
:root {
    --bg-app: #090c12;
    --bg-panel: #111622;
    --bg-elevated: #182032;
    --bg-card: #1e273d;
    --border: #253047;
    --border-strong: #374666;
    --text-main: #f1f5f9;
    --text-sec: #94a3b8;
    --text-muted: #64748b;
    --accent: #6366f1;
    --accent-hover: #818cf8;
    --accent-soft: rgba(99, 102, 241, 0.16);
    --cyan: #06b6d4;
    --danger: #ef4444;
    --topbar-h: 52px;
    --left-w: 280px;
    --right-w: 300px;
}

body.theme-light {
    --bg-app: #e2e8f0;
    --bg-panel: #ffffff;
    --bg-elevated: #f8fafc;
    --bg-card: #f1f5f9;
    --border: #cbd5e1;
    --border-strong: #94a3b8;
    --text-main: #0f172a;
    --text-sec: #475569;
    --text-muted: #64748b;
    --accent: #4f46e5;
    --accent-hover: #4338ca;
    --accent-soft: rgba(79, 70, 229, 0.12);
}

* {
    box-sizing: border-box;
    scrollbar-width: thin;
    scrollbar-color: var(--border-strong) var(--bg-app);
}
*::-webkit-scrollbar { width: 6px; height: 6px; }
*::-webkit-scrollbar-track { background: var(--bg-app); }
*::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; }
*::-webkit-scrollbar-thumb:hover { background: var(--accent); }

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    overflow: hidden;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-app);
    color: var(--text-main);
    font-size: 13px;
}

/* Topbar */
.nr-topbar {
    height: var(--topbar-h);
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 14px;
    gap: 8px;
}

.nr-topbar-left, .nr-topbar-right {
    display: flex;
    align-items: center;
    gap: 6px;
}

.nr-logo {
    display: flex;
    align-items: center;
    gap: 7px;
    font-weight: 800;
    font-size: 13.5px;
    letter-spacing: 0.03em;
    margin-right: 4px;
    white-space: nowrap;
}

.nr-logo-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 10px var(--accent);
}

.nr-badge {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 5px;
    background: var(--accent-soft);
    border: 1px solid rgba(99, 102, 241, 0.45);
    color: #a5b4fc;
}
body.theme-light .nr-badge { color: var(--accent); }

.nr-page-switcher {
    display: flex;
    align-items: center;
    gap: 4px;
    background: var(--bg-app);
    border: 1px solid var(--border);
    padding: 2px 4px;
    border-radius: 7px;
}

.nr-page-switcher select {
    background: transparent;
    border: none;
    color: var(--text-main);
    font-size: 12px;
    font-weight: 600;
    padding: 3px 6px;
    outline: none;
    cursor: pointer;
    max-width: 145px;
}
.nr-page-switcher select option {
    background: var(--bg-panel);
    color: var(--text-main);
}

.nr-viewport-bar {
    display: flex;
    background: var(--bg-app);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 3px;
    gap: 2px;
}

.nr-vp-btn {
    background: transparent;
    border: none;
    color: var(--text-sec);
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
}
.nr-vp-btn:hover { color: var(--text-main); }
.nr-vp-btn.active { background: var(--accent); color: #fff; }

.nr-btn {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 6px 10px;
    border-radius: 7px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    white-space: nowrap;
    transition: 0.15s;
}
.nr-btn:hover { border-color: var(--border-strong); background: var(--bg-card); }
.nr-btn-icon { padding: 3px 7px; border: none; background: var(--bg-elevated); }
.nr-btn-primary { background: linear-gradient(135deg, #6366f1, #4f46e5); border-color: transparent; color: #fff; }
.nr-btn-primary:hover { filter: brightness(1.08); background: linear-gradient(135deg, #6366f1, #4f46e5); }
.nr-btn-ai { background: linear-gradient(135deg, #7c3aed, #06b6d4); border-color: transparent; color: #fff; font-weight: 600; }
.nr-btn-ai:hover { filter: brightness(1.08); background: linear-gradient(135deg, #7c3aed, #06b6d4); }
.nr-btn-danger { background: rgba(239, 68, 68, 0.15); border-color: rgba(239, 68, 68, 0.4); color: #fca5a5; }
.nr-btn-danger:hover { background: var(--danger); color: #fff; }
.nr-w-full { width: 100%; }

@media (max-width: 1260px) {
    .nr-logo span:nth-child(2), .nr-badge { display: none; }
}

/* Workspace */
.nr-workspace {
    display: flex;
    height: calc(100vh - var(--topbar-h));
    width: 100%;
}

.nr-sidebar-left {
    width: var(--left-w);
    background: var(--bg-panel);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.nr-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    background: var(--bg-elevated);
}

.nr-tab {
    flex: 1;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-sec);
    padding: 10px 4px;
    font-size: 11.5px;
    font-weight: 600;
    cursor: pointer;
}
.nr-tab.active {
    color: var(--text-main);
    border-bottom-color: var(--accent);
    background: var(--bg-panel);
}

.nr-tab-pane {
    display: none;
    flex-direction: column;
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}
.nr-tab-pane.active { display: flex; }

.nr-search-box input {
    width: 100%;
    padding: 8px 10px;
    border-radius: 7px;
    border: 1px solid var(--border);
    background: var(--bg-app);
    color: var(--text-main);
    font-size: 12px;
    margin-bottom: 8px;
    outline: none;
}
.nr-search-box input:focus { border-color: var(--accent); }

.nr-cat-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 10px;
}
.nr-cat-pill {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    color: var(--text-sec);
    font-size: 10.5px;
    padding: 3px 8px;
    border-radius: 999px;
    cursor: pointer;
}
.nr-cat-pill.active, .nr-cat-pill:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.nr-block-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 11px 12px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: 0.16s;
}
.nr-block-card:hover {
    border-color: var(--accent);
    background: var(--bg-card);
    transform: translateY(-1px);
}

.nr-block-tag {
    display: inline-block;
    font-size: 9.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #a5b4fc;
    background: var(--accent-soft);
    padding: 2px 7px;
    border-radius: 4px;
    margin-bottom: 5px;
}
body.theme-light .nr-block-tag { color: var(--accent); }

.nr-block-title { font-weight: 600; font-size: 12.5px; margin-bottom: 3px; }
.nr-block-desc { font-size: 11px; color: var(--text-sec); line-height: 1.4; }

.nr-pane-hint { font-size: 11.5px; color: var(--text-sec); margin-bottom: 10px; line-height: 1.45; }
.nr-pane-hint code { background: var(--bg-elevated); padding: 1px 5px; border-radius: 4px; color: #38bdf8; }

.nr-layer-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 10px;
    margin-bottom: 6px;
    font-size: 12px;
    gap: 6px;
}

.nr-layer-actions { display: flex; gap: 3px; flex-shrink: 0; }
.nr-layer-btn {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-main);
    border-radius: 5px;
    padding: 2px 6px;
    cursor: pointer;
    font-size: 11px;
}
.nr-layer-btn:hover { border-color: var(--accent); }

.nr-project-actions { display: flex; flex-direction: column; gap: 8px; }
.nr-divider { border: none; border-top: 1px solid var(--border); margin: 8px 0; }

/* Center Canvas */
.nr-canvas-area {
    flex: 1;
    background: var(--bg-app);
    display: flex;
    justify-content: center;
    align-items: stretch;
    overflow: hidden;
    position: relative;
}

.nr-canvas-stage {
    width: 100%;
    height: 100%;
    transition: width 0.25s ease;
    background: #07090e;
}
.nr-canvas-stage[data-viewport="tablet"] { width: 768px; border-left: 1px solid var(--border-strong); border-right: 1px solid var(--border-strong); }
.nr-canvas-stage[data-viewport="mobile"] { width: 390px; border-left: 1px solid var(--border-strong); border-right: 1px solid var(--border-strong); }

#studio-canvas { width: 100%; height: 100%; border: none; display: block; }

/* Right Inspector */
.nr-sidebar-right {
    width: var(--right-w);
    background: var(--bg-panel);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.nr-inspector-header {
    padding: 12px 14px;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
    font-weight: 700;
    font-size: 12.5px;
}

.nr-inspector-body { padding: 14px; overflow-y: auto; flex: 1; }

.nr-empty-state {
    color: var(--text-sec);
    font-size: 12px;
    line-height: 1.55;
    background: var(--bg-elevated);
    border: 1px dashed var(--border-strong);
    border-radius: 10px;
    padding: 16px;
    text-align: center;
}

.nr-prop-group {
    margin-bottom: 13px;
    padding-bottom: 13px;
    border-bottom: 1px solid var(--border);
}
.nr-prop-group label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-sec);
    margin-bottom: 5px;
}
.nr-prop-group input[type="text"],
.nr-prop-group input[type="number"],
.nr-prop-group select,
.nr-prop-group textarea {
    width: 100%;
    background: var(--bg-app);
    border: 1px solid var(--border);
    color: var(--text-main);
    border-radius: 6px;
    padding: 7px 9px;
    font-size: 12px;
    outline: none;
}
.nr-prop-group input[type="color"] {
    width: 100%;
    height: 32px;
    border: 1px solid var(--border);
    background: var(--bg-app);
    border-radius: 6px;
    cursor: pointer;
}
.nr-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

/* Modals */
.nr-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(5, 8, 15, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    z-index: 5000;
}
.nr-modal-backdrop[hidden] { display: none; }

.nr-modal {
    background: var(--bg-panel);
    border: 1px solid var(--border-strong);
    border-radius: 14px;
    width: 100%;
    max-width: 660px;
    max-height: calc(100vh - 32px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.75);
}
.nr-modal-lg { max-width: 840px; }

.nr-modal-header {
    padding: 14px 18px;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.nr-modal-header h3 { margin: 0; font-size: 14.5px; }
.nr-modal-close {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-main);
    width: 28px;
    height: 28px;
    border-radius: 6px;
    font-size: 16px;
    cursor: pointer;
}

.nr-modal-body {
    padding: 18px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.nr-modal-footer {
    padding: 12px 18px;
    background: var(--bg-elevated);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.nr-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 640px) { .nr-grid-2 { grid-template-columns: 1fr; } }

.nr-field label {
    display: block;
    font-size: 11.5px;
    font-weight: 600;
    color: var(--text-sec);
    margin-bottom: 5px;
}
.nr-field input, .nr-field select, .nr-field textarea {
    width: 100%;
    background: var(--bg-app);
    border: 1px solid var(--border);
    color: var(--text-main);
    border-radius: 7px;
    padding: 8px 10px;
    font-size: 12.5px;
    font-family: inherit;
    outline: none;
}

.nr-code-area { font-family: 'JetBrains Mono', monospace !important; font-size: 12px !important; line-height: 1.5; }
.nr-ai-status { padding: 10px 12px; border-radius: 8px; background: var(--accent-soft); border: 1px solid var(--accent); color: var(--text-main); font-size: 12px; }

.nr-toast {
    position: fixed;
    bottom: 20px;
    right: 24px;
    background: var(--bg-elevated);
    border: 1px solid var(--accent);
    color: var(--text-main);
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 12.5px;
    font-weight: 500;
    z-index: 9000;
    opacity: 0;
    transform: translateY(10px);
    pointer-events: none;
    transition: 0.22s ease;
}
.nr-toast.show { opacity: 1; transform: translateY(0); }
