/* =============================================================================
   AdamOps Studio — Premium Dark Theme
   ============================================================================= */

:root {
    --bg-primary: #0a0e17;
    --bg-secondary: #111827;
    --bg-card: rgba(17, 24, 39, 0.85);
    --bg-glass: rgba(255, 255, 255, 0.04);
    --bg-glass-hover: rgba(255, 255, 255, 0.08);
    --border: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(255, 255, 255, 0.15);
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent: #6366f1;
    --accent-glow: rgba(99, 102, 241, 0.3);
    --success: #22c55e;
    --success-glow: rgba(34, 197, 94, 0.2);
    --error: #ef4444;
    --error-glow: rgba(239, 68, 68, 0.2);
    --warning: #f59e0b;

    /* Category colors */
    --cat-data: #3b82f6;
    --cat-preprocessing: #8b5cf6;
    --cat-feature: #ec4899;
    --cat-splitting: #f59e0b;
    --cat-models: #22c55e;
    --cat-evaluation: #06b6d4;

    --sidebar-width: 240px;
    --right-panel-width: 300px;
    --topbar-height: 52px;
    --radius: 10px;
    --radius-sm: 6px;
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: 'Inter', -apple-system, system-ui, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

/* =============================================================================
   Top Bar
   ============================================================================= */

#topbar {
    height: var(--topbar-height);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    z-index: 100;
    backdrop-filter: blur(12px);
}

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

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 16px;
}

.logo-icon {
    font-size: 20px;
    filter: drop-shadow(0 0 6px var(--accent-glow));
}

.logo-accent {
    background: linear-gradient(135deg, var(--accent), #a78bfa);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.tb-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-glass);
    color: var(--text-secondary);
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
}

.tb-btn:hover {
    background: var(--bg-glass-hover);
    border-color: var(--border-hover);
    color: var(--text-primary);
}

.tb-btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
    font-weight: 600;
}

.tb-btn-primary:hover {
    background: #5558e6;
    box-shadow: 0 0 20px var(--accent-glow);
}

.tb-divider {
    width: 1px;
    height: 24px;
    background: var(--border);
    margin: 0 4px;
}

#zoom-controls {
    display: flex;
    align-items: center;
    background: var(--bg-glass);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 2px;
}

.zoom-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    width: 28px;
    height: 28px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.zoom-btn:hover {
    background: var(--bg-glass-hover);
    color: var(--text-primary);
}

.zoom-btn-fit {
    font-size: 18px;
    padding-bottom: 2px;
}

#zoom-level {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    min-width: 48px;
    text-align: center;
    user-select: none;
}

.tb-btn-primary.executing {
    animation: pulse-glow 1.5s ease-in-out infinite;
}

@keyframes pulse-glow {

    0%,
    100% {
        box-shadow: 0 0 10px var(--accent-glow);
    }

    50% {
        box-shadow: 0 0 25px var(--accent-glow);
    }
}

.status-idle {
    color: var(--text-muted);
    font-size: 13px;
}

.status-running {
    color: var(--warning);
    font-size: 13px;
    font-weight: 500;
}

.status-success {
    color: var(--success);
    font-size: 13px;
    font-weight: 500;
}

.status-error {
    color: var(--error);
    font-size: 13px;
    font-weight: 500;
}

/* =============================================================================
   Main Layout
   ============================================================================= */

#main {
    display: flex;
    height: calc(100vh - var(--topbar-height));
}

/* =============================================================================
   Left Sidebar — Node Palette
   ============================================================================= */

#sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-header {
    padding: 16px;
    border-bottom: 1px solid var(--border);
}

.sidebar-header h3 {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

#node-search {
    width: 100%;
    padding: 8px 12px;
    background: var(--bg-glass);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 13px;
    font-family: inherit;
    outline: none;
    transition: var(--transition);
}

#node-search:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-glow);
}

#node-search::placeholder {
    color: var(--text-muted);
}

#node-palette {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

#node-palette::-webkit-scrollbar {
    width: 4px;
}

#node-palette::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 2px;
}

.palette-category {
    margin-bottom: 6px;
}

.palette-category-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    padding: 8px 8px 4px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.palette-category-title .cat-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    display: inline-block;
}

.palette-node {
    padding: 8px 12px;
    margin: 2px 0;
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: var(--text-secondary);
    cursor: grab;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 8px;
    user-select: none;
}

.palette-node:hover {
    background: var(--bg-glass-hover);
    color: var(--text-primary);
}

.palette-node:active {
    cursor: grabbing;
}

.palette-node .node-icon {
    font-size: 14px;
    width: 20px;
    text-align: center;
}

/* =============================================================================
   Canvas
   ============================================================================= */

#canvas-container {
    flex: 1;
    position: relative;
    overflow: hidden;
    background:
        radial-gradient(circle at 50% 50%, rgba(99, 102, 241, 0.03) 0%, transparent 70%),
        var(--bg-primary);
    /* Dot grid pattern */
    background-image:
        radial-gradient(circle at 50% 50%, rgba(99, 102, 241, 0.03) 0%, transparent 70%),
        radial-gradient(circle, rgba(255, 255, 255, 0.04) 1px, transparent 1px);
    background-size: 100% 100%, 24px 24px;
}

#canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    transform-origin: 0 0;
    will-change: transform;
}

#connections-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 5;
    transform-origin: 0 0;
    will-change: transform;
}

#connections-svg path {
    fill: none;
    stroke-width: 2;
    pointer-events: stroke;
}

#connections-svg path.connection-line {
    stroke: rgba(99, 102, 241, 0.5);
    transition: stroke 0.2s;
}

#connections-svg path.connection-line:hover {
    stroke: var(--accent);
    stroke-width: 3;
}

#connections-svg path.connection-preview {
    stroke: rgba(99, 102, 241, 0.4);
    stroke-dasharray: 6 4;
}

#canvas-hint {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: var(--text-muted);
    font-size: 15px;
    pointer-events: none;
    z-index: 1;
}

#canvas-hint p {
    opacity: 0.7;
}

/* =============================================================================
   Minimap
   ============================================================================= */

#minimap {
    position: absolute;
    bottom: 20px;
    left: 20px;
    width: 200px;
    height: 150px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    backdrop-filter: blur(10px);
    z-index: 100;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    opacity: 0.8;
    transition: opacity 0.2s;
}

#minimap:hover {
    opacity: 1;
}

#minimap-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

#minimap-viewport {
    position: absolute;
    border: 1px solid var(--accent);
    background: rgba(99, 102, 241, 0.1);
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.4);
    cursor: move;
    z-index: 2;
}

/* =============================================================================
   Canvas Nodes
   ============================================================================= */

.canvas-node {
    position: absolute;
    min-width: 180px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    backdrop-filter: blur(20px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    z-index: 10;
    transition: box-shadow 0.2s, border-color 0.2s;
    cursor: move;
    user-select: none;
}

.canvas-node:hover {
    border-color: var(--border-hover);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
}

.canvas-node.selected {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-glow), 0 8px 30px rgba(0, 0, 0, 0.4);
}

.canvas-node.executing {
    border-color: var(--warning);
    box-shadow: 0 0 15px rgba(245, 158, 11, 0.3);
}

.canvas-node.success {
    border-color: var(--success);
    box-shadow: 0 0 15px var(--success-glow);
}

.canvas-node.error {
    border-color: var(--error);
    box-shadow: 0 0 15px var(--error-glow);
}

.node-header {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    border-radius: var(--radius) var(--radius) 0 0;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
}

.node-header .cat-indicator {
    width: 4px;
    height: 16px;
    border-radius: 2px;
    flex-shrink: 0;
}

.node-header .node-title {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.node-header .node-delete {
    opacity: 0;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 14px;
    transition: var(--transition);
    flex-shrink: 0;
}

.canvas-node:hover .node-delete {
    opacity: 0.6;
}

.node-delete:hover {
    opacity: 1 !important;
    color: var(--error);
}

.node-ports {
    padding: 8px 0;
}

.node-port-row {
    display: flex;
    align-items: center;
    padding: 3px 14px;
    font-size: 11px;
    color: var(--text-secondary);
}

.node-port-row.input-row {
    justify-content: flex-start;
}

.node-port-row.output-row {
    justify-content: flex-end;
}

.port-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 2px solid var(--text-muted);
    background: var(--bg-secondary);
    cursor: pointer;
    transition: var(--transition);
    flex-shrink: 0;
    z-index: 20;
    position: relative;
}

.port-dot:hover {
    border-color: var(--accent);
    background: var(--accent);
    box-shadow: 0 0 8px var(--accent-glow);
    transform: scale(1.3);
}

.port-dot.connected {
    border-color: var(--accent);
    background: var(--accent);
}

.input-row .port-dot {
    margin-right: 8px;
    margin-left: -5px;
}

.output-row .port-dot {
    margin-left: 8px;
    margin-right: -5px;
}

.port-label {
    font-size: 11px;
    color: var(--text-muted);
}

/* Category colors */
.cat-data {
    background: var(--cat-data) !important;
    border-color: var(--cat-data) !important;
}

.cat-preprocessing {
    background: var(--cat-preprocessing) !important;
    border-color: var(--cat-preprocessing) !important;
}

.cat-feature_engineering {
    background: var(--cat-feature) !important;
    border-color: var(--cat-feature) !important;
}

.cat-splitting {
    background: var(--cat-splitting) !important;
    border-color: var(--cat-splitting) !important;
}

.cat-models {
    background: var(--cat-models) !important;
    border-color: var(--cat-models) !important;
}

.cat-evaluation {
    background: var(--cat-evaluation) !important;
    border-color: var(--cat-evaluation) !important;
}

/* =============================================================================
   Right Panel — Properties & Results
   ============================================================================= */

#right-panel {
    width: var(--right-panel-width);
    background: var(--bg-secondary);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.panel-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
}

.panel-tab {
    flex: 1;
    padding: 12px;
    border: none;
    background: none;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
}

.panel-tab:hover {
    color: var(--text-secondary);
}

.panel-tab.active {
    color: var(--text-primary);
    border-bottom: 2px solid var(--accent);
}

.tab-content {
    display: none;
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.tab-content.active {
    display: block;
}

.tab-content::-webkit-scrollbar {
    width: 4px;
}

.tab-content::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 2px;
}

#properties-empty,
#results-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 200px;
    color: var(--text-muted);
    font-size: 13px;
    text-align: center;
}

#properties-form h4 {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 4px;
}

.prop-desc {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.prop-field {
    margin-bottom: 14px;
}

.prop-field label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 5px;
}

.prop-field input,
.prop-field select {
    width: 100%;
    padding: 8px 10px;
    background: var(--bg-glass);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 13px;
    font-family: inherit;
    outline: none;
    transition: var(--transition);
}

.prop-field input:focus,
.prop-field select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-glow);
}

.prop-field select {
    cursor: pointer;
}

.prop-field select option {
    background: var(--bg-secondary);
}

.prop-field .file-input-wrapper {
    display: flex;
    gap: 6px;
}

.prop-field .file-input-wrapper input {
    flex: 1;
}

.prop-field .file-btn {
    padding: 8px 12px;
    background: var(--bg-glass);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 12px;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    font-family: inherit;
}

.prop-field .file-btn:hover {
    background: var(--bg-glass-hover);
    color: var(--text-primary);
}

/* Results */

.results-section {
    margin-bottom: 20px;
}

.results-section h4 {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.metrics-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.metric-card {
    background: var(--bg-glass);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
}

.metric-card .metric-name {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 4px;
}

.metric-card .metric-value {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}

.log-list {
    font-size: 12px;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
    background: rgba(0, 0, 0, 0.3);
    border-radius: var(--radius-sm);
    padding: 12px;
    max-height: 200px;
    overflow-y: auto;
    line-height: 1.8;
}

.log-list .log-line {
    color: var(--text-secondary);
}

.log-list .log-success {
    color: var(--success);
}

.log-list .log-error {
    color: var(--error);
}

.log-list .log-running {
    color: var(--warning);
}

.node-result-card {
    background: var(--bg-glass);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    margin-bottom: 8px;
}

.node-result-card .nrc-title {
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.node-result-card .nrc-detail {
    font-size: 11px;
    color: var(--text-muted);
    line-height: 1.6;
}

/* Status badges */
.badge {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.badge-success {
    background: var(--success-glow);
    color: var(--success);
}

.badge-error {
    background: var(--error-glow);
    color: var(--error);
}

.badge-pending {
    background: rgba(100, 116, 139, 0.2);
    color: var(--text-muted);
}

/* =============================================================================
   Animations
   ============================================================================= */

@keyframes node-appear {
    from {
        opacity: 0;
        transform: scale(0.9);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.canvas-node {
    animation: node-appear 0.2s ease-out;
}

/* =============================================================================
   Scrollbar styling
   ============================================================================= */

::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

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

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

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