/* Feature Engineering demo styles */

:root {
    --feature-size: 80px;
}

/* Remove padding for Lasso tab panel */
.infotab-panel[data-tab-title="Lasso"] {
    padding-top: 0 !important;
    padding-bottom: 0 !important;
}

/* Demo area layout */
.demo-area {
    display: flex !important;
    flex-direction: column !important;
    gap: 20px !important;
}

/* Top section: chart + sidebar */
.top-section {
    display: flex !important;
    flex-direction: row !important;
    gap: 20px;
    align-items: stretch;
}

/* Plot container - takes ~72% of width with fixed height */
.plot-container {
    flex: 0 0 calc(72% - 15px);
    display: flex;
    justify-content: flex-start;
    align-items: flex-start;
    height: 480px;
}

#prediction-plot {
    width: 100% !important;
    max-width: 100% !important;
    height: 480px !important;
}

/* Metrics sidebar - takes ~28% of width */
.metrics-sidebar {
    flex: 0 0 28%;
    min-width: 280px;
    height: 480px;
}

/* Metrics panel - styled like controls panel */
.metrics-panel {
    background: #f5f7fa;
    padding: 25px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    border: 1px solid #dee2e6;
    height: 100%;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
}

.metrics-panel h3 {
    margin-top: 0 !important;
    margin-bottom: 20px !important;
    font-size: 16px;
    color: #2c3e50;
}

/* Metric boxes - styled like .metriclabel but keep MetricLabel colors */
.metrics-sidebar .metriclabel {
    padding: 0 15px 15px 15px;
    border-radius: 0;
    text-align: center;
    font-size: 16px;
    font-weight: 500;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    word-break: break-all;
    overflow-wrap: break-word;
    line-height: 1.2;
    position: relative;
    margin: 10px 0;
    height: 60px;
    box-sizing: border-box;
    padding-top: 10px;
    /* background, color, border, border-left are set by MetricLabel for each metric's color */
}

/* Feature panel */
.feature-panel {
    padding-top: 0;
    padding-bottom: 10px;
}

.feature-panel h3 {
    position: relative;
    min-height: 24px;
}

/* Feature engineering grid */
.feature-engineering-grid {
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* Header row with feature icons */
.feature-header-row {
    display: flex;
    gap: 15px;
    margin-bottom: 8px;
}

/* Empty corner cell */
.transform-label-cell {
    width: 45px;
    flex-shrink: 0;
}

/* Feature icon box */
.feature-icon-box {
    width: var(--feature-size);
    height: var(--feature-size);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    color: white;
    font-weight: 600;
    flex-shrink: 0;
    box-sizing: border-box;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
    border: 3px solid transparent;
}

.feature-icon-box:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.feature-icon-box.active {
    border-color: rgba(255, 255, 255, 0.8);
}

.feature-icon-box.semi-active {
    border-color: rgba(255, 255, 255, 0.4);
    border-style: dashed;
}

.feature-icon-box .icon {
    font-size: 38px;
    line-height: 1;
}

.feature-icon-box .label {
    font-size: 11px;
    margin-top: 4px;
    text-align: center;
}

/* Transformation row */
.transformation-row {
    display: flex;
    gap: 15px;
    margin-bottom: 4px;
}

/* Row toggle for enabling/disabling all features for a transformation */
.transform-row-toggle {
    width: 45px;
    height: 29px;
    border: 2px solid #ddd;
    background: white;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    color: #666;
    transition: all 0.2s ease;
    user-select: none;
    flex-shrink: 0;
    box-sizing: border-box;
}

.transform-row-toggle:hover {
    border-color: #999;
    background: #f5f5f5;
}

.transform-row-toggle.active {
    border-color: #4a89c4;
    background: #e3f2fd;
    color: #1976d2;
}

.transform-row-toggle.semi-active {
    border-color: #4a89c4;
    background: linear-gradient(90deg, #e3f2fd 50%, white 50%);
    color: #1976d2;
}

.transform-toggle {
    width: var(--feature-size);
    min-width: var(--feature-size);
    max-width: var(--feature-size);
    height: 29px;
    border: 2px solid #ddd;
    background: white;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    color: #666;
    transition: all 0.2s ease;
    user-select: none;
    flex-shrink: 0;
    box-sizing: border-box;
}

.transform-toggle:hover {
    border-color: #999;
    background: #f5f5f5;
}

.transform-toggle.active {
    border-color: #4a89c4;
    background: #e3f2fd;
    color: #1976d2;
}

.transform-toggle.disabled {
    opacity: 0.3;
    cursor: not-allowed;
    pointer-events: none;
}

/* Feature colors - icon boxes */
.feature-latitude { background: linear-gradient(135deg, #5a9fd4, #4a89c4); }
.feature-longitude { background: linear-gradient(135deg, #66c98e, #56b97e); }
.feature-bathrooms { background: linear-gradient(135deg, #e88b7b, #d87b6b); }
.feature-bedrooms { background: linear-gradient(135deg, #a87ab8, #9a6aa8); }
.feature-floor-area { background: linear-gradient(135deg, #d89456, #c88446); }
.feature-living-rooms { background: linear-gradient(135deg, #5ab9d4, #4aa9c4); }
.feature-distance-tube { background: linear-gradient(135deg, #d87ab8, #c86aa8); }
.feature-distance-bus { background: linear-gradient(135deg, #8899aa, #7889a0); }
.feature-bus-stops { background: linear-gradient(135deg, #7ac98e, #6ab97e); }

/* Responsive adjustments */
@media (max-width: 1200px) {
    .feature-header-row {
        gap: 10px;
    }

    .transformation-row {
        gap: 10px;
    }

    .feature-icon-box {
        width: var(--feature-size);
        height: var(--feature-size);
    }

    .transform-toggle {
        width: var(--feature-size);
        height: 27px;
        font-size: 12px;
    }
}

@media (max-width: 900px) {
    .top-section {
        flex-direction: column;
    }

    .plot-container {
        flex: 1 1 100%;
        width: 100%;
    }

    .metrics-sidebar {
        flex: 1 1 100%;
        max-width: 100%;
        width: 100%;
        flex-direction: row;
        flex-wrap: wrap;
    }
}

/* Dataset toggle (Train/Test) */
.dataset-toggle {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}


/* Model controls row: buttons + loss curve */
.model-controls-row {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
    width: 100%;
}

/* Model control buttons panel */
.model-controls-panel {
    flex: 0 0 auto;
    border: 2px solid #ddd;
    border-radius: 0;
    background: white;
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Loss curve canvas */
#loss-curve-canvas {
    flex: 1 0 auto;
    border: 2px solid #ddd;
    border-radius: 0;
    background: white;
    padding: 0;
    box-sizing: border-box;
    min-width: 0;
    overflow: hidden;
    height: 115px;
    max-height: 115px;
    display: block;
}

.model-btn {
    display: block;
    width: 100%;
    padding: 12px 20px;
    background: #3498db;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.model-btn:hover {
    background: #2980b9;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}

.model-btn:active {
    background: #21618c;
    transform: translateY(0);
}

.model-btn:disabled {
    cursor: not-allowed;
    pointer-events: none;
}

/* Train button - green */
#train-model-btn {
    background: #27ae60;
}

#train-model-btn:hover {
    background: #229954;
}

#train-model-btn:active {
    background: #1e8449;
}

/* Reset button - orange */
#reset-features-btn {
    background: #e67e22;
}

#reset-features-btn:hover {
    background: #ca6f1e;
}

#reset-features-btn:active {
    background: #af601a;
}

/* Training badge - green */
.training-badge {
    position: absolute;
    left: 175px;
    top: -2px;
    padding: 6px 14px;
    background: #10b981;
    color: white;
    font-size: 12px;
    font-weight: 600;
    border-radius: 999px;
    animation: pulse 2s ease-in-out infinite;
    white-space: nowrap;
}

/* Retrain badge - orange */
.retrain-badge {
    position: absolute;
    left: 175px;
    top: -2px;
    padding: 6px 14px;
    background: #f59e0b;
    color: white;
    font-size: 12px;
    font-weight: 600;
    border-radius: 999px;
    animation: pulse 2s ease-in-out infinite;
    white-space: nowrap;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

/* Lambda controls for Lasso mode */
.lambda-controls {
    margin-top: -4px;
    margin-bottom: -4px;

}

.lambda-label {
    font-size: 11px;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 6px;
    text-align: center;
}

.lambda-buttons {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 5px;
}

.lambda-btn {
    padding: 6px 10px;
    background: white;
    color: #6b7280;
    border: 2px solid #dee2e6;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
}

.lambda-btn:hover {
    border-color: #9ca3af;
    background: #f3f4f6;
}

.lambda-btn.active {
    border-color: #8b5cf6;
    background: #f5f3ff;
    color: #7c3aed;
}

.lambda-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* Coefficient visualization boxes for Lasso mode */
.coefficient-box {
    width: var(--feature-size);
    min-width: var(--feature-size);
    max-width: var(--feature-size);
    height: 29px;
    border: 2px solid transparent;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    flex-shrink: 0;
    box-sizing: border-box;
    transition: all 0.2s ease;
}

.coefficient-box.positive {
    /* Green for positive coefficients */
    border-color: #16a34a;
}

.coefficient-box.negative {
    /* Red for negative coefficients */
    border-color: #dc2626;
}

.coefficient-box.zero {
    /* Grey for near-zero coefficients */
    background: #f3f4f6;
    border-color: #d1d5db;
    color: #9ca3af;
}
