/**
 * Knowledge Graph Visualization Styles
 */

/* Container */
.knowledge-graph-container {
    position: relative;
    width: 100%;
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

/* SVG */
.knowledge-graph-svg {
    cursor: grab;
    background: transparent;
}

.knowledge-graph-svg:active {
    cursor: grabbing;
}

/* Nodes */
.kg-node {
    cursor: pointer;
    transition: transform 0.2s ease;
}

.kg-node:hover {
    transform: scale(1.1);
}

.kg-node circle {
    transition: all 0.3s ease;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

.kg-node:hover circle {
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
}

.kg-node-icon {
    pointer-events: none;
    user-select: none;
}

.kg-node-label {
    pointer-events: none;
    user-select: none;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.8);
}

/* Links */
.kg-link {
    transition: stroke-opacity 0.3s ease;
}

/* Tooltip */
.kg-tooltip {
    position: absolute;
    padding: 0;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    pointer-events: none;
    z-index: 1000;
    min-width: 180px;
    overflow: hidden;
    transition: opacity 0.2s ease;
}

.kg-tooltip-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
}

.kg-tooltip-type {
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    color: white;
}

.kg-tooltip-header strong {
    font-size: 13px;
    color: #1e293b;
}

.kg-tooltip-body {
    padding: 10px 12px;
}

.kg-tooltip-body div {
    font-size: 12px;
    color: #64748b;
    margin-bottom: 4px;
}

.kg-tooltip-body div:last-child {
    margin-bottom: 0;
}

/* Legend */
.kg-legend {
    position: absolute;
    top: 12px;
    left: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    z-index: 100;
}

.kg-legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.kg-legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.kg-legend-label {
    font-size: 12px;
    font-weight: 500;
    color: #374151;
}

/* Stats */
.kg-stats {
    position: absolute;
    top: 12px;
    right: 12px;
    display: flex;
    gap: 16px;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    z-index: 100;
    font-size: 13px;
    color: #64748b;
}

.kg-stats strong {
    color: #1e293b;
}

/* Controls */
.kg-controls {
    position: absolute;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 8px;
    padding: 8px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    z-index: 100;
}

.kg-controls button {
    padding: 6px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    background: white;
    color: #374151;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.kg-controls button:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
}

.kg-controls button.active {
    background: #3b82f6;
    border-color: #3b82f6;
    color: white;
}

/* Search */
.kg-search {
    position: absolute;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    z-index: 100;
}

.kg-search input {
    width: 200px;
    padding: 6px 10px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s ease;
}

.kg-search input:focus {
    border-color: #3b82f6;
}

.kg-search input::placeholder {
    color: #94a3b8;
}

/* Detail Panel */
.kg-detail-panel {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 280px;
    max-height: 400px;
    overflow-y: auto;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    z-index: 200;
    display: none;
}

.kg-detail-panel.visible {
    display: block;
}

.kg-detail-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    border-bottom: 1px solid #e2e8f0;
}

.kg-detail-header h3 {
    margin: 0;
    font-size: 16px;
    color: #1e293b;
}

.kg-detail-close {
    background: none;
    border: none;
    font-size: 20px;
    color: #94a3b8;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.kg-detail-close:hover {
    color: #64748b;
}

.kg-detail-body {
    padding: 16px;
}

.kg-detail-section {
    margin-bottom: 16px;
}

.kg-detail-section:last-child {
    margin-bottom: 0;
}

.kg-detail-section h4 {
    margin: 0 0 8px 0;
    font-size: 12px;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.kg-detail-connections {
    list-style: none;
    padding: 0;
    margin: 0;
}

.kg-detail-connections li {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
    border-bottom: 1px solid #f1f5f9;
    font-size: 13px;
    color: #374151;
}

.kg-detail-connections li:last-child {
    border-bottom: none;
}

.kg-detail-type-badge {
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
    color: white;
}

/* Animations */
@keyframes pulse-node {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.kg-node.pulsing circle {
    animation: pulse-node 1s infinite;
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .knowledge-graph-container {
        background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    }

    .kg-legend,
    .kg-stats,
    .kg-controls,
    .kg-search,
    .kg-tooltip,
    .kg-detail-panel {
        background: rgba(30, 41, 59, 0.95);
    }

    .kg-legend-label,
    .kg-controls button,
    .kg-search input,
    .kg-tooltip-header strong,
    .kg-detail-header h3,
    .kg-detail-connections li {
        color: #e2e8f0;
    }

    .kg-stats,
    .kg-tooltip-body div,
    .kg-detail-section h4 {
        color: #94a3b8;
    }

    .kg-stats strong {
        color: #f8fafc;
    }

    .kg-node-label {
        fill: #e2e8f0;
        text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
    }

    .kg-tooltip-header {
        background: #334155;
        border-color: #475569;
    }

    .kg-detail-header,
    .kg-detail-connections li {
        border-color: #334155;
    }
}
