/* =============================================
   Knowledge Tree - Tree Visualization Styles
   ============================================= */

/* Tree Nodes */
.tree-node {
    cursor: pointer;
}

.tree-node:hover .node-circle {
    filter: brightness(1.15);
}

.tree-node.selected .node-circle {
    stroke: white;
    stroke-width: 2.5;
    filter: drop-shadow(0 0 6px rgba(99, 102, 241, 0.4));
}

.tree-node.selected .node-label {
    font-weight: 600;
    fill: white;
}

/* Node Circle */
.node-circle {
    stroke: rgba(255, 255, 255, 0.15);
    stroke-width: 1.5;
}

.node-circle-root {
    stroke-width: 2;
    stroke: rgba(255, 255, 255, 0.25);
}

/* Node Label */
.node-label {
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 11px;
    font-weight: 500;
    fill: #cbd5e1;
    pointer-events: none;
}

.node-label-root {
    font-size: 13px;
    font-weight: 600;
    fill: #e2e8f0;
}

/* Node Icon */
.node-icon {
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    font-size: 7px;
    fill: white;
    pointer-events: none;
}

/* Links */
.tree-link {
    fill: none;
    stroke: rgba(99, 102, 241, 0.2);
    stroke-width: 1.5;
}

.tree-link.animate {
    stroke-dasharray: 8 12;
    stroke-linecap: round;
    animation: flowPulse 1.5s linear infinite;
}

.tree-link:hover {
    stroke: rgba(99, 102, 241, 0.4);
}

/* Electricity Flow Animation */
.tree-link-flow {
    fill: none;
    stroke: url(#flowGradient);
    stroke-width: 1.5;
    stroke-linecap: round;
    opacity: 0.5;
}

@keyframes flowPulse {
    0% {
        stroke-dashoffset: 40;
    }
    100% {
        stroke-dashoffset: 0;
    }
}

.tree-link-flow.animate {
    stroke-dasharray: 6 14;
    animation: flowPulse 1.2s linear infinite;
}

/* Expand/Collapse Toggle */
.node-toggle {
    cursor: pointer;
    transform-box: fill-box;
    transform-origin: center;
}

.node-toggle:hover .node-toggle-circle {
    stroke: rgba(99, 102, 241, 0.6);
}

.node-toggle-circle {
    fill: var(--bg-secondary, #1a1a2e);
    stroke: rgba(148, 163, 184, 0.3);
    stroke-width: 1.5;
    transition: stroke 0.2s ease, stroke-width 0.2s ease, fill 0.2s ease;
}

.node-toggle-icon {
    fill: #94a3b8;
    font-size: 8px;
    pointer-events: none;
    dominant-baseline: middle;
    text-anchor: middle;
    transform-box: fill-box;
    transform-origin: center;
}

.node-toggle.collapsed .node-toggle-icon {
    transform: none;
}

.tree-node:hover .node-circle {
    filter: brightness(1.2);
    transform: scale(1.1);
}

.tree-node .node-circle {
    transition: all 0.2s ease;
}

.tree-node.selected .node-circle {
    stroke-width: 3;
    stroke: white;
    filter: drop-shadow(0 0 8px rgba(99, 102, 241, 0.5));
}

.tree-node.selected .node-label {
    font-weight: 600;
    fill: white;
}

/* Node Circle */
.node-circle {
    stroke: rgba(255, 255, 255, 0.2);
    stroke-width: 2;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.node-circle-root {
    stroke-width: 3;
    stroke: rgba(255, 255, 255, 0.3);
}

/* Node Label */
.node-label {
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    fill: #e2e8f0;
    pointer-events: none;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.node-label-root {
    font-size: 14px;
    font-weight: 600;
}

/* Node Icon */
.node-icon {
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    font-size: 7px;
    fill: white;
    pointer-events: none;
}

/* Links */
.tree-link {
    fill: none;
    stroke: rgba(99, 102, 241, 0.25);
    stroke-width: 2;
    transition: all 0.2s ease;
}

.tree-link.animate {
    stroke-dasharray: 8 12;
    stroke-linecap: round;
    animation: flowPulse 1.5s linear infinite;
}

.tree-link:hover {
    stroke: rgba(99, 102, 241, 0.5);
    stroke-width: 2.5;
}

/* Electricity Flow Animation */
.tree-link-flow {
    fill: none;
    stroke: url(#flowGradient);
    stroke-width: 2;
    stroke-linecap: round;
    opacity: 0.6;
}

@keyframes flowPulse {
    0% {
        stroke-dashoffset: 40;
    }
    100% {
        stroke-dashoffset: 0;
    }
}

.tree-link-flow.animate {
    stroke-dasharray: 8 12;
    animation: flowPulse 1.5s linear infinite;
}

/* Link Path Styles */
.link-path {
    fill: none;
    stroke: rgba(99, 102, 241, 0.2);
    stroke-width: 2;
    stroke-linecap: round;
}

.link-path-animated {
    stroke-dasharray: 5, 5;
    animation: dashFlow 1s linear infinite;
}

@keyframes dashFlow {
    to {
        stroke-dashoffset: -10;
    }
}

/* Expand/Collapse Toggle */
.node-toggle {
    cursor: pointer;
    transform-box: fill-box;
    transform-origin: center;
}

.node-toggle:hover {
    filter: drop-shadow(0 0 6px rgba(99, 102, 241, 0.25));
}

.node-toggle-circle {
    fill: var(--bg-secondary, #1a1a2e);
    stroke: rgba(99, 102, 241, 0.4);
    stroke-width: 2;
    transition: stroke 0.2s ease, stroke-width 0.2s ease, fill 0.2s ease;
}

.node-toggle-icon {
    fill: #94a3b8;
    font-size: 10px;
    pointer-events: none;
    dominant-baseline: middle;
    text-anchor: middle;
    transform-box: fill-box;
    transform-origin: center;
}

.node-toggle.collapsed .node-toggle-icon {
    transform: none;
}

/* Node Tooltip */
.node-tooltip {
    position: absolute;
    background: rgba(26, 26, 46, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(148, 163, 184, 0.1);
    border-radius: 8px;
    padding: 12px 16px;
    max-width: 300px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    z-index: 100;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.node-tooltip.visible {
    opacity: 1;
}

.node-tooltip-title {
    font-size: 14px;
    font-weight: 600;
    color: #e2e8f0;
    margin-bottom: 4px;
}

.node-tooltip-preview {
    font-size: 12px;
    color: #94a3b8;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.node-tooltip-meta {
    display: flex;
    gap: 12px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(148, 163, 184, 0.1);
}

.node-tooltip-meta span {
    font-size: 11px;
    color: #64748b;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Tree Background Pattern */
.tree-background {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 0;
}

.tree-grid {
    stroke: rgba(148, 163, 184, 0.03);
    stroke-width: 1;
}

/* Minimap */
.tree-minimap {
    position: absolute;
    bottom: 1rem;
    left: 1rem;
    width: 200px;
    height: 150px;
    background: rgba(26, 26, 46, 0.8);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(148, 163, 184, 0.1);
    border-radius: 8px;
    overflow: hidden;
    z-index: 50;
}

@media (max-width: 768px) {
    .tree-minimap {
        display: none;
    }
}

.minimap-viewport {
    position: absolute;
    border: 2px solid rgba(99, 102, 241, 0.5);
    background: rgba(99, 102, 241, 0.1);
    pointer-events: none;
}

/* Drag Indicators */
.tree-node.dragging {
    opacity: 0.5;
}

.tree-node.drag-over .node-circle {
    stroke: #10b981;
    stroke-width: 3;
    filter: drop-shadow(0 0 8px rgba(16, 185, 129, 0.5));
}

/* Selection Box */
.selection-box {
    position: absolute;
    border: 2px dashed rgba(99, 102, 241, 0.5);
    background: rgba(99, 102, 241, 0.1);
    pointer-events: none;
    z-index: 50;
}

/* Connection Animation */
.connection-particle {
    fill: var(--accent-primary, #6366f1);
    opacity: 0.6;
}

/* Tree Loading State */
.tree-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    z-index: 10;
}

.tree-loading-text {
    font-size: 0.9rem;
    color: var(--text-muted, #64748b);
}

/* Tree Zoom Info */
.tree-zoom-info {
    position: absolute;
    bottom: 1rem;
    right: 1rem;
    padding: 0.5rem 0.75rem;
    background: rgba(26, 26, 46, 0.8);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(148, 163, 184, 0.1);
    border-radius: 6px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    color: var(--text-muted, #64748b);
    z-index: 50;
}

@media (max-width: 768px) {
    .tree-zoom-info {
        display: none;
    }
}

/* Node Count Badge */
.node-count-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    background: var(--accent-primary, #6366f1);
    border-radius: 9px;
    font-size: 10px;
    font-weight: 600;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Pulse Animation for New Nodes */
@keyframes nodePulse {
    0% {
        transform: scale(0);
        opacity: 0;
    }
    50% {
        transform: scale(1.2);
        opacity: 1;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.tree-node.new-node {
    animation: nodePulse 0.5s ease;
}

/* Connection Flow Animation */
@keyframes flowAnimation {
    0% {
        stroke-dashoffset: 20;
    }
    100% {
        stroke-dashoffset: 0;
    }
}

.link-flow {
    stroke-dasharray: 10, 10;
    animation: flowAnimation 1s linear infinite;
}
