/**
 * VariationTree Component Styles
 * Light water theme design for the deep study page
 */

.variation-tree-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: transparent;
    border-radius: 12px;
    overflow: hidden;
}

/* Toolbar Styles */
.variation-tree-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: #f8fafc;
    border-bottom: 1px solid #dce3eb;
    position: sticky;
    top: 0;
    z-index: 10;
    gap: 16px;
    flex-wrap: wrap;
}

/* Color Picker Styles - Dropdown under Colors button */
.toolbar-color-picker {
    display: none; /* Hidden by default */
    position: absolute;
    top: 100%;
    left: 0;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: rgba(255,255,255,0.95);
    border-radius: 8px;
    border: 1px solid #a0aec0;
    /* backdrop-filter removed for light theme */
    z-index: 1000;
    margin-top: 4px;
    box-shadow: 0 4px 12px rgba(26, 35, 50, 0.06);
}

/* Make the Colors button container relative for positioning */
.colors-button-container {
    position: relative;
    display: inline-block;
}

.color-options {
    display: flex;
    gap: 4px;
}

.color-btn {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    transition: all 0.2s ease;
}

.color-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 2px 8px rgba(26, 35, 50, 0.06);
}

.color-btn.active {
    border-color: #4a5568;
    box-shadow: 0 2px 8px rgba(26,35,50,0.06);
}

/* Trace mode current line highlighting */
.current-line-highlight {
    stroke: #c9a84c !important;
    stroke-width: 3px !important;
    filter: none !important;
    animation: currentLinePulse 2s ease-in-out infinite;
}

@keyframes currentLinePulse {
    0%, 100% {
        stroke-opacity: 1;
        filter: none;
    }
    50% {
        stroke-opacity: 0.7;
        filter: none;
    }
}

.toolbar-section {
    display: flex;
    align-items: center;
    gap: 8px;
}

.toolbar-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: rgba(91, 155, 213, 0.04);
    border: 1px solid #dce3eb;
    border-radius: 6px;
    color: #4a5568;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    /* backdrop-filter removed for light theme */
}

.toolbar-btn:hover {
    background: rgba(91, 155, 213, 0.06);
    border-color: #a0aec0;
    color: #1a2332;
    transform: translateY(-1px);
}

.toolbar-btn.active {
    background: rgba(91, 155, 213, 0.2);
    border-color: rgba(91, 155, 213, 0.4);
    color: rgba(91, 155, 213, 0.9);
    box-shadow: 0 2px 8px rgba(26,35,50,0.06);
}

.toolbar-btn svg {
    transition: transform 0.3s ease;
}

.toolbar-btn:hover svg {
    transform: scale(1.1);
}

.toolbar-label {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #4a5568;
    font-size: 0.8rem;
    font-weight: 500;
}

.toolbar-slider {
    width: 80px;
    height: 4px;
    background: rgba(91, 155, 213, 0.06);
    border-radius: 2px;
    outline: none;
    -webkit-appearance: none;
    cursor: pointer;
}

.toolbar-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    background: rgba(91, 155, 213, 0.8);
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(26, 35, 50, 0.06);
}

.toolbar-slider::-webkit-slider-thumb:hover {
    background: rgba(91, 155, 213, 1);
    transform: scale(1.2);
    box-shadow: 0 2px 8px rgba(26,35,50,0.06);
}

/* Content Area */
.variation-tree-content {
    flex: 1;
    position: relative;
    overflow: hidden;
}

.variation-tree-svg-container {
    width: 100%;
    height: 100%;
    overflow: auto;
    background: transparent;
    position: relative;
    contain: strict;
    isolation: isolate;
}

.variation-tree-svg-container svg {
    display: block;
    cursor: grab;
    overflow: visible;
    pointer-events: auto;
}

/* Prevent hover effects from causing layout shifts */
.variation-tree-svg-container .node {
    contain: layout;
}

.variation-tree-svg-container .node:hover {
    contain: layout;
}

/* Ensure mini-board hover doesn't affect scrollbars */
.mini-board-hover {
    position: fixed !important;
    z-index: 10000;
    pointer-events: none;
    contain: layout style paint;
}

/* Selected path highlighting */
.node.selected-path .node-bg {
    stroke: #c9a84c !important;
    stroke-width: 3px !important;
    filter: none;
}

.link.selected-path {
    stroke: #c9a84c !important;
    stroke-width: 4px !important;
    filter: none;
}

/* Toolbar button active states */
.toolbar-btn.active {
    background: rgba(91, 155, 213, 0.3) !important;
    border-color: rgba(91, 155, 213, 0.5) !important;
    color: rgba(91, 155, 213, 1) !important;
}

.variation-tree-svg-container svg:active {
    cursor: grabbing;
}

/* Tree Nodes */
.node {
    cursor: pointer;
    transition: all 0.3s ease;
}

.node:hover .node-bg {
    fill: rgba(91, 155, 213, 0.06);
    stroke: rgba(91, 155, 213, 0.4);
    stroke-width: 2;
    filter: none;
}

.node.selected .node-bg {
    fill: rgba(91, 155, 213, 0.2);
    stroke: rgba(91, 155, 213, 0.6);
    stroke-width: 2;
    filter: none;
}

.node-bg {
    transition: all 0.3s ease;
}

.node-move {
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(26, 35, 50, 0.1);
}

.node-eval {
    font-family: 'Courier New', monospace;
    font-weight: 500;
    text-shadow: 0 1px 2px rgba(26, 35, 50, 0.1);
}

.node-stats {
    font-family: 'Inter', sans-serif;
    font-weight: 400;
    text-shadow: 0 1px 2px rgba(26, 35, 50, 0.1);
}

.node-badges text {
    filter: drop-shadow(0 1px 2px rgba(26, 35, 50, 0.1));
}

.expand-indicator {
    transition: all 0.3s ease;
}

.expand-indicator:hover {
    fill: #a0aec0;
    stroke: rgba(91, 155, 213, 0.25);
    transform: scale(1.1);
}

.expand-text {
    font-family: 'Inter', sans-serif;
    font-weight: bold;
    text-shadow: 0 1px 2px rgba(26, 35, 50, 0.1);
}

/* Tree Links */
.link {
    transition: all 0.3s ease;
    opacity: 0.7;
}

.link:hover {
    opacity: 1;
    filter: none !important;
}

/* Loading States */
.node.loading .node-bg {
    fill: rgba(201, 168, 76, 0.1);
    stroke: rgba(201, 168, 76, 0.3);
    animation: pulse 2s infinite;
}

.node.loading .expand-indicator {
    fill: rgba(201, 168, 76, 0.2);
    stroke: rgba(201, 168, 76, 0.4);
    animation: spin 1s linear infinite;
}

/* Error States */
.node.error .node-bg {
    fill: rgba(217, 83, 79, 0.1);
    stroke: rgba(217, 83, 79, 0.3);
}

.node.error .node-move {
    fill: rgba(217, 83, 79, 0.8);
}

/* Terminal Nodes */
.node.terminal .node-bg {
    fill: rgba(156, 163, 175, 0.1);
    stroke: rgba(156, 163, 175, 0.3);
}

.node.terminal .expand-indicator {
    display: none;
}

/* Hover Board */
.variation-tree-hover-board {
    position: fixed;
    z-index: 1000;
    pointer-events: none;
    background: #ffffff;
    border: 1px solid #dce3eb;
    border-radius: 8px;
    padding: 12px;
    max-width: 200px;
    box-shadow: 0 2px 12px rgba(26, 35, 50, 0.08);
}

.hover-board-content {
    color: #1a2332;
    font-size: 0.8rem;
}

.hover-fen {
    font-family: 'Courier New', monospace;
    font-size: 0.7rem;
    color: #7a8a9e;
    margin-bottom: 4px;
    word-break: break-all;
}

.hover-move {
    font-weight: 600;
    color: rgba(91, 155, 213, 0.9);
}

/* Animations */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* PV Spine Highlighting */
.node.pv-spine .node-bg {
    stroke: rgba(201, 168, 76, 0.6);
    stroke-width: 3;
    filter: none;
}

.link.pv-spine {
    stroke: rgba(201, 168, 76, 0.8) !important;
    stroke-width: 4 !important;
    filter: none !important;
}

/* Quality-based styling */
.node.quality-best .node-bg {
    stroke: rgba(92, 184, 92, 0.5);
}

.node.quality-excellent .node-bg {
    stroke: rgba(91, 155, 213, 0.5);
}

.node.quality-good .node-bg {
    stroke: rgba(91, 155, 213, 0.4);
}

.node.quality-playable .node-bg {
    stroke: rgba(91, 155, 213, 0.15);
}

.node.quality-inaccuracy .node-bg {
    stroke: rgba(201, 168, 76, 0.4);
}

.node.quality-mistake .node-bg {
    stroke: rgba(217, 83, 79, 0.4);
}

.node.quality-blunder .node-bg {
    stroke: rgba(217, 83, 79, 0.5);
}

/* Responsive Design */
@media (max-width: 768px) {
    .variation-tree-toolbar {
        flex-direction: column;
        gap: 8px;
        padding: 8px 12px;
    }
    
    .toolbar-section {
        width: 100%;
        justify-content: center;
    }
    
    .toolbar-btn {
        font-size: 0.75rem;
        padding: 4px 8px;
    }
    
    .toolbar-slider {
        width: 60px;
    }
}

/* Scrollbar Styling */
.variation-tree-svg-container::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.variation-tree-svg-container::-webkit-scrollbar-track {
    background: #f0f4f8;
    border-radius: 4px;
}

.variation-tree-svg-container::-webkit-scrollbar-thumb {
    background: #cdd6e0;
    border-radius: 4px;
    transition: all 0.3s ease;
}

.variation-tree-svg-container::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}

.variation-tree-svg-container::-webkit-scrollbar-corner {
    background: transparent;
}
