/**
 * KNN Classification Visualizer Styles
 *
 * Visualization-specific styles only. Common styles are in visualizations.css.
 * Colors for classes 0-2 use shared --viz-class-* variables.
 */

/* ============================================
   KNN-Specific CSS Custom Properties
   ============================================ */
:root {
    /* Reuse shared class colors */
    --knn-class-0: var(--viz-class-0);
    --knn-class-1: var(--viz-class-1);
    --knn-class-2: var(--viz-class-2);

    /* Query point - reuse shared */
    --knn-query-bg: var(--viz-query-bg);
    --knn-query-border: var(--viz-query-border);

    /* Neighbor visualization */
    --knn-neighbor-line: rgba(0, 0, 0, 0.5);
    --knn-neighbor-line-width: 2px;

    /* Decision boundary */
    --knn-boundary-opacity: 0.2;

    /* Vote bars - use shared bg */
    --knn-vote-bar-bg: #e9ecef;
}

[data-theme="gruvbox-dark"] {
    /* Neighbor lines - lighter for dark bg */
    --knn-neighbor-line: rgba(235, 219, 178, 0.6);

    /* Vote bars */
    --knn-vote-bar-bg: #3c3836;
}

/* ============================================
   Canvas Styling
   ============================================ */
#knn-canvas,
#boundary-canvas {
    border: none;
    border-radius: 0;
    display: block;
}

#boundary-canvas {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
    pointer-events: none;
}

#knn-canvas {
    position: relative;
    z-index: 2;
    cursor: crosshair;
}

/* ============================================
   Vote Breakdown
   ============================================ */
.vote-breakdown {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--viz-border);
}

.vote-header {
    font-weight: 600;
    margin-bottom: 8px;
    font-size: 12px;
    color: var(--viz-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.vote-bars {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.vote-bar {
    display: flex;
    align-items: center;
    gap: 8px;
}

.vote-bar-label {
    min-width: 55px;
    font-size: 12px;
    font-weight: 500;
}

.vote-bar-container {
    flex: 1;
    height: 18px;
    background: var(--knn-vote-bar-bg);
    border-radius: 3px;
    overflow: hidden;
}

.vote-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 6px;
    min-width: 0;
}

.vote-bar-fill.class-0 { background-color: var(--knn-class-0); }
.vote-bar-fill.class-1 { background-color: var(--knn-class-1); }
.vote-bar-fill.class-2 { background-color: var(--knn-class-2); }

.vote-bar-value {
    font-size: 10px;
    font-weight: 600;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

/* ============================================
   Neighbors List
   ============================================ */
.neighbors-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-weight: 600;
}

.neighbors-list {
    max-height: 220px;
    overflow-y: auto;
}

.neighbor-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 10px;
    margin: 3px 0;
    border-radius: 4px;
    font-family: var(--viz-mono-font);
    font-size: 11px;
    cursor: pointer;
    transition: background-color 0.15s ease;
    border-left: 3px solid transparent;
}

.neighbor-item:hover {
    background-color: var(--viz-hover-bg);
}

.neighbor-item.class-0 { border-left-color: var(--knn-class-0); }
.neighbor-item.class-1 { border-left-color: var(--knn-class-1); }
.neighbor-item.class-2 { border-left-color: var(--knn-class-2); }

.neighbor-rank {
    font-weight: 700;
    min-width: 24px;
}

.neighbor-class {
    padding: 2px 6px;
    border-radius: 3px;
    font-weight: 600;
    font-size: 10px;
    color: #fff;
}

.neighbor-class.class-0 { background-color: var(--knn-class-0); }
.neighbor-class.class-1 { background-color: var(--knn-class-1); }
.neighbor-class.class-2 { background-color: var(--knn-class-2); }

.neighbor-distance {
    color: var(--viz-text-muted);
    min-width: 60px;
    text-align: right;
}

.neighbor-coords {
    color: var(--viz-text-muted);
    font-size: 10px;
}

/* ============================================
   Legend Neighbor Line
   ============================================ */
.legend-line.neighbor-line {
    background-color: var(--knn-neighbor-line);
    height: 2px;
    width: 20px;
    display: inline-block;
    vertical-align: middle;
}

/* ============================================
   Vote indicator dots in legend
   ============================================ */
.vote-indicator {
    display: inline-flex;
    gap: 2px;
    margin-left: 6px;
    vertical-align: middle;
}

.vote-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: currentColor;
    opacity: 0.8;
}

/* ============================================
   Click Overlay
   ============================================ */
.click-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.3);
    z-index: 5;
    border-radius: 4px;
    pointer-events: none;
}

.click-overlay span {
    color: #fff;
    font-size: 16px;
    font-weight: 500;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

.click-overlay.hidden {
    display: none;
}

/* ============================================
   Combined Controls Panel - Two Column Layout
   ============================================ */
.knn-controls-panel {
    display: flex;
    gap: 20px;
}

/* Left column: Algorithm options */
.knn-options-col {
    flex: 1;
}

.knn-options-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.knn-option-group {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.knn-options-col .option-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.knn-options-col .option-row > label:first-child {
    min-width: 55px;
    font-size: 12px;
}

.knn-options-col .option-row select {
    width: auto;
    min-width: 90px;
    font-size: 12px;
}

.knn-options-col .k-stepper {
    display: flex;
    align-items: center;
    gap: 2px;
}

.knn-options-col .k-stepper .btn {
    padding: 2px 8px;
    font-size: 14px;
    line-height: 1;
}

.knn-options-col .k-input {
    width: 32px;
    text-align: center;
    font-size: 12px;
    font-weight: 600;
    border: 1px solid var(--viz-border);
    border-radius: 3px;
    padding: 2px 4px;
    background: var(--viz-bg);
    color: var(--viz-text);
}

.knn-options-col .checkbox-label {
    font-size: 12px;
    margin-right: 10px;
}

/* Right column: Playback */
.knn-playback-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    border-left: 1px solid var(--viz-border);
    padding-left: 20px;
}

.knn-playback-col .btn-toolbar {
    display: flex;
    gap: 4px;
}

.knn-playback-col .btn-toolbar .btn {
    padding: 4px 8px;
}

.knn-playback-col .speed-control {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: var(--viz-text-muted);
    width: 100%;
}

.knn-playback-col .speed-control input[type="range"] {
    flex: 1;
}

/* ============================================
   Responsive Adjustments
   ============================================ */
@media (max-width: 992px) {
    .knn-controls-panel {
        flex-direction: column;
    }

    .knn-playback-col {
        border-left: none;
        border-top: 1px solid var(--viz-border);
        padding-left: 0;
        padding-top: 15px;
    }
}
