/* ==========================================
   GRAPH CONTAINER
   ========================================== */
.graph-container {
    position: relative;
    width: 100%;
    max-width: 1400px;
    height: 700px;
    margin: 0 auto;
    background-color: var(--bg-secondary);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: 0 4px 20px var(--shadow);
}

#graph {
    width: 100%;
    height: 100%;
    cursor: grab;
}

#graph:active {
    cursor: grabbing;
}

/* ==========================================
   GRAPH NODES
   ========================================== */
.node {
    cursor: pointer;
    transition: all 0.3s ease;
}

.node circle {
    stroke-width: 2px;
    transition: all 0.3s ease;
}

.node:hover circle {
    stroke-width: 4px;
    filter: brightness(1.2);
}

.node.active circle {
    stroke-width: 5px;
    filter: brightness(1.3);
}

.node.dimmed {
    opacity: 0.3;
}

.node text {
    font-size: 12px;
    font-weight: 600;
    pointer-events: none;
    user-select: none;
    text-anchor: middle;
    fill: var(--text-primary);
}

/* Node Categories - Color Coding */
.node.category-ai circle {
    fill: #6366f1;
    stroke: #4f46e5;
}

.node.category-ml circle {
    fill: #8b5cf6;
    stroke: #7c3aed;
}

.node.category-programming circle {
    fill: #ec4899;
    stroke: #db2777;
}

.node.category-data circle {
    fill: #14b8a6;
    stroke: #0d9488;
}

.node.category-web circle {
    fill: #f59e0b;
    stroke: #d97706;
}

.node.category-math circle {
    fill: #06b6d4;
    stroke: #0891b2;
}

.node.category-default circle {
    fill: #6b7280;
    stroke: #4b5563;
}

/* ==========================================
   GRAPH LINKS/EDGES
   ========================================== */
.link {
    stroke: var(--border-color);
    stroke-opacity: 0.6;
    stroke-width: 2px;
    fill: none;
    transition: all 0.3s ease;
}

.link:hover {
    stroke-opacity: 1;
    stroke-width: 3px;
}

.link.highlighted {
    stroke: var(--accent-primary);
    stroke-opacity: 1;
    stroke-width: 3px;
    animation: pulse 1.5s ease-in-out infinite;
}

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

@keyframes pulse {
    0%, 100% { stroke-opacity: 1; }
    50% { stroke-opacity: 0.5; }
}

/* ==========================================
   NODE TOOLTIP
   ========================================== */
.node-tooltip {
    position: fixed;
    max-width: 300px;
    padding: var(--spacing-md);
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: 0 4px 12px var(--shadow);
    pointer-events: none;
    z-index: 1000;
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.node-tooltip:not(.hidden) {
    opacity: 1;
}

.tooltip-title {
    font-size: var(--font-size-lg);
    font-weight: 700;
    margin-bottom: var(--spacing-sm);
    color: var(--text-primary);
}

.tooltip-category {
    display: inline-block;
    padding: var(--spacing-xs) var(--spacing-sm);
    background-color: var(--accent-primary);
    color: white;
    border-radius: var(--radius-sm);
    font-size: var(--font-size-sm);
    font-weight: 600;
    margin-bottom: var(--spacing-sm);
}

.tooltip-description {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    margin-bottom: var(--spacing-sm);
    line-height: 1.5;
}

.tooltip-tags {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-xs);
}

.tooltip-tag {
    padding: 2px var(--spacing-sm);
    background-color: var(--bg-secondary);
    border-radius: var(--radius-sm);
    font-size: 11px;
    color: var(--text-secondary);
}

/* ==========================================
   GRAPH CONTROLS
   ========================================== */
.graph-controls {
    position: absolute;
    bottom: var(--spacing-lg);
    right: var(--spacing-lg);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    z-index: 50;
}

.graph-control-btn {
    width: 40px;
    height: 40px;
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: var(--font-size-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    box-shadow: 0 2px 8px var(--shadow);
}

.graph-control-btn:hover {
    background-color: var(--accent-primary);
    color: white;
    border-color: var(--accent-primary);
    transform: scale(1.05);
}

/* ==========================================
   LEGEND
   ========================================== */
.graph-legend {
    position: absolute;
    top: var(--spacing-lg);
    left: var(--spacing-lg);
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--spacing-md);
    box-shadow: 0 2px 8px var(--shadow);
    max-width: 200px;
}

.graph-legend h4 {
    font-size: var(--font-size-base);
    margin-bottom: var(--spacing-sm);
    color: var(--text-primary);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-xs);
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
}

.legend-color {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid rgba(0, 0, 0, 0.2);
}

/* ==========================================
   RESPONSIVE GRAPH
   ========================================== */
@media (max-width: 768px) {
    .graph-container {
        height: 500px;
    }

    .node text {
        font-size: 10px;
    }

    .graph-legend {
        font-size: var(--font-size-sm);
        padding: var(--spacing-sm);
    }

    .graph-control-btn {
        width: 36px;
        height: 36px;
        font-size: var(--font-size-base);
    }
}

@media (max-width: 480px) {
    .graph-container {
        height: 400px;
        border-radius: var(--radius-md);
    }

    .node text {
        display: none; /* Hide labels on very small screens */
    }

    .node:hover text {
        display: block; /* Show on hover */
    }
}

/* ==========================================
   ANIMATIONS
   ========================================== */
@keyframes nodeEnter {
    from {
        opacity: 0;
        transform: scale(0);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.node {
    animation: nodeEnter 0.5s ease-out;
}

@keyframes linkEnter {
    from {
        stroke-opacity: 0;
    }
    to {
        stroke-opacity: 0.6;
    }
}

.link {
    animation: linkEnter 0.5s ease-out;
}