/* ================================================================
   ML STUDIO — Side Panel
   Painel lateral direito tipo wizard para pipeline de Machine Learning.
   Padrao Inspector: slide-in da direita, resize handle, theme-aware.
   ================================================================ */

/* --- Container principal --- */
.nn-side-panel {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 380px;
    min-width: 300px;
    max-width: 600px;
    background: var(--neutral-0);
    border-left: 1px solid var(--neutral-200);
    z-index: 15;
    display: none;
    flex-direction: column;
    overflow: hidden;
    box-shadow: -4px 0 16px rgba(0, 0, 0, 0.08);
    pointer-events: auto;
}

.nn-side-panel.visible {
    display: flex;
}

.viz-settings-active .nn-side-panel {
    bottom: 80px;
    transition: transform 0.3s ease, bottom 0.2s ease;
}

[data-theme="dark"] .nn-side-panel {
    background: rgba(26, 29, 35, 0.94);
    backdrop-filter: blur(8px);
    border-left-color: var(--neutral-700);
    box-shadow: -4px 0 16px rgba(0, 0, 0, 0.3);
}

/* --- Resize Handle (borda esquerda) --- */
.nn-panel-resize-handle {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    cursor: ew-resize;
    z-index: 2;
    background: transparent;
    transition: background 0.15s;
}

.nn-panel-resize-handle:hover,
.nn-panel-resize-handle:active {
    background: var(--accent-primary);
}

/* --- Header --- */
.nn-panel-header {
    padding: 10px 14px;
    border-bottom: 1px solid var(--neutral-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-shrink: 0;
}

[data-theme="dark"] .nn-panel-header {
    border-bottom-color: var(--neutral-700);
}

.nn-panel-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--window-text);
}

.nn-panel-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--neutral-400);
    padding: 6px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    min-width: 28px;
    min-height: 28px;
    justify-content: center;
}

.nn-panel-close:hover {
    background: var(--overlay-light);
    color: var(--window-text);
}

.nn-panel-close > * {
    pointer-events: none;
}

/* --- Wizard Steps Navigation --- */
.nn-wizard-steps {
    display: flex;
    padding: 0 14px;
    border-bottom: 1px solid var(--neutral-200);
    flex-shrink: 0;
    overflow-x: auto;
}

[data-theme="dark"] .nn-wizard-steps {
    border-bottom-color: var(--neutral-700);
}

.nn-wizard-step {
    flex: 1;
    padding: 8px 4px;
    text-align: center;
    font-size: 11px;
    font-weight: 500;
    color: var(--neutral-400);
    border-bottom: 2px solid transparent;
    cursor: pointer;
    white-space: nowrap;
    transition: color 0.15s, border-color 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.nn-wizard-step:hover {
    color: var(--window-text);
    background: var(--overlay-subtle);
}

.nn-wizard-step.active {
    color: var(--primary-text);
    border-bottom-color: var(--accent-primary);
    font-weight: 600;
}

.nn-wizard-step.completed {
    color: var(--accent-green);
}

.nn-wizard-step-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    font-size: 10px;
    font-weight: 700;
    background: var(--neutral-200);
    color: var(--neutral-500);
}

.nn-wizard-step.active .nn-wizard-step-num {
    background: var(--accent-primary);
    color: #fff;
}

.nn-wizard-step.completed .nn-wizard-step-num {
    background: var(--accent-green);
    color: #fff;
}

/* --- Step Body (scrollable area) --- */
.nn-panel-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 14px;
}

/* --- Step Footer (navigation buttons) --- */
.nn-panel-footer {
    padding: 10px 14px;
    border-top: 1px solid var(--neutral-200);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

[data-theme="dark"] .nn-panel-footer {
    border-top-color: var(--neutral-700);
}

/* --- Step 1: Data Overview --- */
.nn-data-summary {
    margin-bottom: 16px;
}

.nn-data-summary h5 {
    font-size: 12px;
    font-weight: 600;
    color: var(--window-text);
    margin: 0 0 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.nn-data-tree {
    font-size: 12px;
    color: var(--window-muted);
    line-height: 1.8;
    padding-left: 4px;
}

.nn-data-tree .nn-data-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.nn-data-tree .nn-data-count {
    font-weight: 600;
    color: var(--primary-text);
}

.nn-param-list {
    margin-top: 12px;
}

.nn-param-list h5 {
    font-size: 12px;
    font-weight: 600;
    color: var(--window-text);
    margin: 0 0 6px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.nn-param-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    margin: 2px;
    font-size: 11px;
    background: var(--neutral-100);
    border-radius: 10px;
    color: var(--window-text);
}

[data-theme="dark"] .nn-param-badge {
    background: var(--neutral-200);
}

.nn-param-badge .nn-param-count {
    font-size: 10px;
    color: var(--neutral-400);
}

/* --- Step 1: Preview Table --- */
.nn-preview-section {
    margin-top: 16px;
}

.nn-preview-section h5 {
    font-size: 12px;
    font-weight: 600;
    color: var(--window-text);
    margin: 0 0 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.nn-preview-table {
    width: 100%;
    font-size: 11px;
    border-collapse: collapse;
    font-family: monospace;
}

.nn-preview-table th {
    padding: 4px 6px;
    text-align: left;
    font-weight: 600;
    color: var(--neutral-500);
    border-bottom: 1px solid var(--neutral-200);
    font-size: 10px;
    text-transform: uppercase;
}

.nn-preview-table td {
    padding: 3px 6px;
    color: var(--window-text);
    border-bottom: 1px solid var(--neutral-100);
}

.nn-preview-table tr:hover td {
    background: var(--overlay-subtle);
}

.nn-preview-empty {
    text-align: center;
    padding: 20px;
    font-size: 12px;
    color: var(--neutral-400);
}

/* --- Step 2: Network Config (compact builder) --- */
.nn-network-select {
    margin-bottom: 12px;
}

.nn-network-select select {
    width: 100%;
    padding: 6px 10px;
    font-size: 12px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--neutral-300);
    background: var(--neutral-0);
    color: var(--window-text);
}

.nn-compact-topology {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 12px;
}

.nn-compact-topology input {
    width: 50px;
    padding: 4px 6px;
    font-size: 12px;
    text-align: center;
    border-radius: var(--radius-md);
    border: 1px solid var(--neutral-300);
    background: var(--neutral-0);
    color: var(--window-text);
}

.nn-compact-topology .nn-topo-arrow {
    color: var(--neutral-400);
    font-size: 14px;
}

.nn-compact-builder {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.nn-compact-catalog {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 8px;
    background: var(--neutral-50);
    border-radius: var(--radius-lg);
    max-height: 120px;
    overflow-y: auto;
}

.nn-compact-dropzone {
    min-height: 40px;
    padding: 8px;
    border: 2px dashed var(--neutral-300);
    border-radius: var(--radius-lg);
    transition: border-color 0.15s, background-color 0.15s;
}

.nn-compact-dropzone.drag-over {
    border-color: var(--accent-primary);
    background: var(--overlay-subtle);
}

.nn-compact-dropzone-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--neutral-400);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.nn-compact-mapped {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.nn-compact-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    font-size: 11px;
    border-radius: 10px;
    cursor: grab;
    white-space: nowrap;
    font-family: monospace;
}

.nn-compact-pill .nn-pill-remove {
    cursor: pointer;
    opacity: 0.5;
    font-size: 10px;
}

.nn-compact-pill .nn-pill-remove:hover {
    opacity: 1;
}

/* Calculator variable type badge (M=metric, R=rule/ratio) */
.nn-calc-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    border-radius: 3px;
    font-size: var(--text-xs, 10px);
    font-weight: 700;
    background: rgba(22, 160, 133, 0.25);
    color: #16a085;
    margin-right: 2px;
    flex-shrink: 0;
    font-family: system-ui, sans-serif;
}

/* --- Step 3: Training --- */
.nn-train-status {
    text-align: center;
    padding: 20px 0;
}

.nn-train-status h5 {
    font-size: 14px;
    font-weight: 600;
    color: var(--window-text);
    margin: 0 0 8px;
}

.nn-train-progress {
    width: 100%;
    height: 8px;
    background: var(--neutral-100);
    border-radius: var(--radius-md);
    overflow: hidden;
    margin: 12px 0;
}

.nn-train-progress-fill {
    height: 100%;
    background: var(--accent-primary);
    border-radius: var(--radius-md);
    transition: width 0.1s linear;
}

.nn-train-metrics {
    display: flex;
    gap: 16px;
    justify-content: center;
    margin-top: 12px;
}

.nn-train-metric {
    text-align: center;
}

.nn-train-metric-value {
    font-size: 20px;
    font-weight: 700;
    font-family: monospace;
    color: var(--primary-text);
}

.nn-train-metric-label {
    font-size: 11px;
    color: var(--neutral-400);
    margin-top: 2px;
}

.nn-train-samples {
    font-size: 12px;
    color: var(--window-muted);
    margin-top: 8px;
}

/* --- Network Diagram (Canvas) --- */
.nn-network-diagram {
    display: block;
    width: 100%;
    height: 180px;
    margin: 10px 0;
    background: var(--neutral-50);
    border-radius: var(--radius-xl);
    border: 1px solid var(--neutral-200);
}

[data-theme="dark"] .nn-network-diagram {
    background: rgba(0, 0, 0, 0.2);
    border-color: var(--neutral-700);
}

/* --- Step 4: What-If (inherits from nn-whatif.css, vertical layout) --- */
.nn-panel-body .nn-whatif-panel {
    flex-direction: column;
    gap: 16px;
    min-height: 0;
}

.nn-panel-body .nn-whatif-inputs,
.nn-panel-body .nn-whatif-outputs {
    flex: none;
}

.nn-panel-body .nn-whatif-footer {
    flex-direction: column;
    gap: 8px;
    align-items: stretch;
}

.nn-panel-body .nn-whatif-plume-connect {
    flex-direction: column;
    gap: 4px;
}

.nn-panel-body .nn-whatif-plume-connect select {
    width: 100%;
}
