/**
 * Knowledge Graph Visualization Styles
 * Matches the YonEarth design system with earth-inspired colors
 */

/* Base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    color: #333333;
    overflow: hidden;
}

/* Main container */
#knowledge-graph-container {
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* Header section */
.graph-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 15px 20px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    z-index: 100;
}

.view-selector {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.view-btn {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.view-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

.view-btn.active {
    background: white;
    color: #667eea;
}

.title-section {
    color: white;
}

.title-section h1 {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 5px;
}

.subtitle {
    font-size: 14px;
    opacity: 0.9;
}

/* Version selector */
.version-selector {
    margin-top: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.version-selector label {
    font-size: 14px;
    font-weight: 500;
    color: white;
    opacity: 0.9;
}

.version-selector select {
    padding: 8px 12px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.95);
    color: #667eea;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    max-width: 400px;
}

.version-selector select:hover {
    border-color: rgba(255, 255, 255, 0.5);
    background: white;
}

.version-selector select:focus {
    outline: none;
    border-color: white;
    background: white;
}

/* Main content area */
.main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
    gap: 0;
}

/* Controls panel */
.controls-panel {
    width: 300px;
    background: white;
    border-right: 1px solid #e0e0e0;
    overflow-y: auto;
    padding: 20px;
    box-shadow: 2px 0 5px rgba(0,0,0,0.05);
}

.control-section {
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 1px solid #f0f0f0;
}

.control-section:last-child {
    border-bottom: none;
}

.control-section h3 {
    font-size: 14px;
    font-weight: 600;
    color: #667eea;
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Search box */
.search-box {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.search-box input {
    padding: 10px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.3s ease;
}

.search-box input:focus {
    outline: none;
    border-color: #667eea;
}

.search-box button {
    padding: 8px 12px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.search-box button:hover {
    background: #5568d3;
    transform: translateY(-1px);
}

#clear-search-btn {
    background: #e0e0e0 !important;
    color: #666 !important;
}

#clear-search-btn:hover {
    background: #d0d0d0 !important;
}

#search-results {
    margin-top: 10px;
    max-height: 200px;
    overflow-y: auto;
}

.search-result-item {
    padding: 8px;
    background: #f5f5f5;
    border-radius: 4px;
    margin-bottom: 5px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 13px;
}

.search-result-item:hover {
    background: #e8e8ff;
}

/* Filter groups */
.filter-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.filter-group.scrollable {
    max-height: 250px;
    overflow-y: auto;
    padding-right: 5px;
}

.filter-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px;
    border-radius: 4px;
    transition: background 0.2s ease;
}

.filter-item:hover {
    background: #f5f5f5;
}

.filter-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.filter-item label {
    font-size: 13px;
    cursor: pointer;
    flex: 1;
    display: flex;
    align-items: center;
    gap: 6px;
}

.color-indicator {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: inline-block;
}

/* Sliders */
.slider-container {
    margin-bottom: 15px;
}

.slider-container label {
    display: block;
    font-size: 13px;
    margin-bottom: 8px;
    color: #666;
}

.slider-container input[type="range"] {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: #e0e0e0;
    outline: none;
    cursor: pointer;
}

.slider-container input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
}

.slider-container input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
    border: none;
}

.layout-controls {
    margin-top: 10px;
}

#reset-view-btn {
    width: 100%;
    padding: 10px;
    background: #764ba2;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    margin-top: 10px;
    transition: all 0.3s ease;
}

#reset-view-btn:hover {
    background: #653996;
    transform: translateY(-1px);
}

/* Statistics display */
.stats-display {
    font-size: 12px;
    color: #666;
    line-height: 1.6;
}

.stats-display .stat-item {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
}

.stats-display .stat-label {
    font-weight: 500;
}

.stats-display .stat-value {
    color: #667eea;
    font-weight: 600;
}

/* Visualization area */
.visualization-area {
    flex: 1;
    position: relative;
    background: #ffffff;
    overflow: hidden;
}

#graph-svg-container {
    width: 100%;
    height: 100%;
}

/* SVG styles */
.node {
    cursor: pointer;
    transition: all 0.3s ease;
}

.node:hover {
    filter: brightness(1.2);
}

.node circle {
    stroke: white;
    stroke-width: 2px;
}

.node.highlighted circle {
    stroke: #ffeb3b;
    stroke-width: 4px;
}

.node.dimmed {
    opacity: 0.2;
}

.node text {
    font-size: 10px;
    pointer-events: none;
    fill: #333;
    text-anchor: middle;
    font-weight: 500;
}

.link {
    stroke: #999;
    stroke-opacity: 0.3;
    fill: none;
}

.link.highlighted {
    stroke: #667eea;
    stroke-opacity: 0.8;
    stroke-width: 2px;
}

.link.dimmed {
    stroke-opacity: 0.05;
}

/* Legend panel */
.legend-panel {
    position: absolute;
    bottom: 20px;
    left: 20px;
    background: rgba(255, 255, 255, 0.95);
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    max-width: 250px;
    max-height: 400px;
    overflow-y: auto;
}

.legend-section {
    margin-bottom: 15px;
}

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

.legend-section h4 {
    font-size: 12px;
    font-weight: 600;
    color: #667eea;
    margin-bottom: 8px;
    text-transform: uppercase;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    font-size: 12px;
}

.size-legend .size-item {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    font-size: 12px;
}

/* Details panel */
.details-panel {
    width: 350px;
    background: white;
    border-left: 1px solid #e0e0e0;
    overflow-y: auto;
    box-shadow: -2px 0 5px rgba(0,0,0,0.05);
}

.details-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.details-header h3 {
    font-size: 18px;
    font-weight: 600;
}

.close-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 24px;
    line-height: 1;
    transition: all 0.3s ease;
}

.close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

.details-content {
    padding: 20px;
}

.empty-state {
    text-align: center;
    color: #999;
    padding: 40px 20px;
    font-size: 14px;
}

.entity-name {
    font-size: 22px;
    font-weight: 700;
    color: #333;
    margin-bottom: 10px;
}

.entity-type {
    display: inline-block;
    background: #667eea;
    color: white;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    margin-bottom: 15px;
}

.entity-domains {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 15px;
}

.domain-tag {
    padding: 4px 10px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 500;
    color: white;
}

.entity-description {
    font-size: 14px;
    line-height: 1.6;
    color: #555;
    margin-bottom: 15px;
    padding: 12px;
    background: #f9f9f9;
    border-radius: 6px;
}

.entity-meta {
    font-size: 13px;
    color: #666;
    line-height: 1.8;
}

.entity-meta strong {
    color: #333;
    font-weight: 600;
}

.episodes-list {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 5px;
}

.episode-badge {
    background: #e8e8ff;
    color: #667eea;
    padding: 2px 8px;
    border-radius: 8px;
    font-size: 11px;
    font-weight: 500;
}

.wiki-link {
    display: inline-block;
    margin-top: 15px;
    padding: 10px 16px;
    background: #667eea;
    color: white;
    text-decoration: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.wiki-link:hover {
    background: #5568d3;
    transform: translateY(-2px);
}

/* Entity Relationships */
.entity-relationships {
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid #e0e0e0;
}

.relationship-section {
    margin-bottom: 15px;
}

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

.relationship-section strong {
    display: block;
    font-size: 12px;
    color: #667eea;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.relationship-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.relationship-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    background: #f9f9f9;
    border-radius: 4px;
    font-size: 11px;
    line-height: 1.4;
}

.relationship-subject,
.relationship-object {
    font-weight: 500;
    color: #333;
}

.relationship-type {
    font-size: 10px;
    padding: 2px 6px;
    background: #667eea;
    color: white;
    border-radius: 3px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    font-weight: 600;
    white-space: nowrap;
}

.relationship-more {
    font-size: 11px;
    color: #999;
    font-style: italic;
    margin-top: 4px;
    text-align: center;
}

/* Tooltip */
.tooltip {
    position: absolute;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 10px 12px;
    border-radius: 6px;
    font-size: 13px;
    pointer-events: none;
    z-index: 1000;
    display: none;
    max-width: 250px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.tooltip.visible {
    display: block;
}

/* Loading overlay */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

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

.loader {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-overlay p {
    margin-top: 20px;
    font-size: 16px;
    color: #667eea;
    font-weight: 500;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #c0c0c0;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a0a0a0;
}

/* Responsive design */
@media (max-width: 1200px) {
    .controls-panel {
        width: 250px;
    }

    .details-panel {
        width: 300px;
    }
}

@media (max-width: 900px) {
    .controls-panel,
    .details-panel {
        position: absolute;
        height: 100%;
        z-index: 200;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }

    .details-panel {
        transform: translateX(100%);
    }

    .controls-panel.open,
    .details-panel.open {
        transform: translateX(0);
    }
}
