/* ========================================
   CSS Variables & Reset
======================================== */

:root {
    --primary-color: #2E9EF7;
    --secondary-color: #FF6D00;
    --bg-dark: #0D1117;
    --bg-darker: #010409;
    --bg-card: #161B22;
    --text-primary: #FFFFFF;
    --text-secondary: #8B949E;
    --accent-green: #00C853;
    --accent-purple: #D500F9;
    --glow-color: rgba(46, 158, 247, 0.6);
    --glow-spread: 0 0 20px var(--glow-color);
}

[data-theme="light"] {
    --bg-dark: #FFFFFF;
    --bg-darker: #F6F8FA;
    --bg-card: #FFFFFF;
    --text-primary: #24292F;
    --text-secondary: #57606A;
}

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

body {
    font-family: 'Fira Code', monospace;
    background-color: var(--bg-dark);
    color: var(--text-primary);
    overflow-x: hidden;
    min-height: 100vh;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* ========================================
   Particle Background
======================================== */

.particle-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    opacity: 0.4;
    pointer-events: none;
}

/* ========================================
   Main Container
======================================== */

.tech-tree-container {
    position: relative;
    max-width: 1600px;
    margin: 0 auto;
    padding: 2rem;
    z-index: 1;
}

/* ========================================
   Header & Controls
======================================== */

.tree-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 3rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.tree-title {
    font-size: 2.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    display: flex;
    align-items: center;
    gap: 1rem;
    animation: fadeInDown 0.8s ease;
}

.tree-title i {
    background: var(--primary-color);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.controls {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.control-btn {
    padding: 0.8rem 1.5rem;
    background: var(--bg-card);
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
    border-radius: 8px;
    cursor: pointer;
    font-family: 'Fira Code', monospace;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
}

.control-btn:hover {
    background: var(--primary-color);
    color: white;
    transform: translateY(-2px);
    box-shadow: var(--glow-spread);
}

.control-btn:active {
    transform: translateY(0);
}

.theme-toggle {
    width: 50px;
    padding: 0.8rem;
    justify-content: center;
}

/* ========================================
   Stats Dashboard
======================================== */

.stats-dashboard {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-bottom: 3rem;
    animation: fadeInUp 0.8s ease 0.2s both;
}

.stat-card {
    background: var(--bg-card);
    padding: 1.5rem;
    border-radius: 12px;
    border: 1px solid rgba(46, 158, 247, 0.2);
    transition: all 0.3s ease;
}

.stat-card:hover {
    border-color: var(--primary-color);
    transform: translateY(-5px);
    box-shadow: var(--glow-spread);
}

.stat-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.stat-bar {
    height: 6px;
    background: var(--bg-dark);
    border-radius: 3px;
    overflow: hidden;
}

.stat-progress {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    border-radius: 3px;
    transition: width 1s ease;
    width: 0;
}

/* ========================================
   Radar Chart
======================================== */

.radar-chart-container {
    background: var(--bg-card);
    padding: 2rem;
    border-radius: 12px;
    border: 1px solid rgba(46, 158, 247, 0.2);
    margin-bottom: 3rem;
    display: flex;
    justify-content: center;
    animation: fadeIn 0.8s ease 0.4s both;
}

#radarChart {
    max-width: 500px;
    max-height: 500px;
}

/* ========================================
   Connection Lines SVG
======================================== */

.connection-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}

.connection-line {
    stroke: var(--primary-color);
    stroke-width: 2;
    fill: none;
    opacity: 0;
    transition: opacity 0.5s ease;
    filter: drop-shadow(0 0 5px var(--glow-color));
    animation: pulse 2s ease-in-out infinite;
}

.connection-line.active {
    opacity: 0.6;
}

/* ========================================
   Tech Tree
======================================== */

.tech-tree {
    position: relative;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 3rem;
    padding: 2rem 0;
    z-index: 1;
}

.tree-branch {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2rem;
    animation: fadeInUp 0.8s ease both;
}

.tree-branch:nth-child(1) { animation-delay: 0.1s; }
.tree-branch:nth-child(2) { animation-delay: 0.2s; }
.tree-branch:nth-child(3) { animation-delay: 0.3s; }
.tree-branch:nth-child(4) { animation-delay: 0.4s; }
.tree-branch:nth-child(5) { animation-delay: 0.5s; }
.tree-branch:nth-child(6) { animation-delay: 0.6s; }

/* ========================================
   Main Nodes
======================================== */

.main-node {
    position: relative;
    width: 150px;
    height: 150px;
    background: var(--bg-card);
    border: 3px solid var(--primary-color);
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    cursor: pointer;
    transition: all 0.4s ease;
    z-index: 2;
}

.main-node:hover {
    transform: scale(1.1) rotate(5deg);
    box-shadow: 0 0 40px var(--glow-color), 0 0 80px var(--glow-color);
    border-color: var(--secondary-color);
}

.main-node:focus {
    outline: 3px solid var(--primary-color);
    outline-offset: 5px;
}

.main-node.active {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border-color: var(--secondary-color);
    animation: nodeActivate 0.6s ease;
}

.node-icon {
    font-size: 3rem;
    filter: drop-shadow(0 0 10px var(--glow-color));
}

.node-label {
    font-size: 1rem;
    font-weight: 600;
    text-align: center;
    color: var(--text-primary);
}

.main-node.active .node-label {
    color: white;
}

.node-glow {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: radial-gradient(circle, var(--glow-color) 0%, transparent 70%);
    opacity: 0;
    transition: opacity 0.4s ease;
    pointer-events: none;
}

.main-node:hover .node-glow,
.main-node.active .node-glow {
    opacity: 1;
    animation: glowPulse 2s ease-in-out infinite;
}

/* ========================================
   Sub Nodes
======================================== */

.sub-nodes {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 1rem;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: all 0.5s ease;
    width: 100%;
}

.sub-nodes.expanded {
    max-height: 1000px;
    opacity: 1;
}

.sub-node {
    background: var(--bg-card);
    border: 2px solid rgba(46, 158, 247, 0.3);
    border-radius: 12px;
    padding: 1.2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.8rem;
    cursor: pointer;
    transition: all 0.3s ease;
    transform: scale(0.8);
    opacity: 0;
}

.sub-nodes.expanded .sub-node {
    animation: subNodeAppear 0.5s ease forwards;
}

.sub-node:nth-child(1) { animation-delay: 0.1s; }
.sub-node:nth-child(2) { animation-delay: 0.15s; }
.sub-node:nth-child(3) { animation-delay: 0.2s; }
.sub-node:nth-child(4) { animation-delay: 0.25s; }
.sub-node:nth-child(5) { animation-delay: 0.3s; }
.sub-node:nth-child(6) { animation-delay: 0.35s; }
.sub-node:nth-child(7) { animation-delay: 0.4s; }
.sub-node:nth-child(8) { animation-delay: 0.45s; }

.sub-node:hover {
    border-color: var(--primary-color);
    transform: translateY(-5px) scale(1);
    box-shadow: 0 5px 20px var(--glow-color);
}

.sub-node:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 3px;
}

.sub-node i {
    font-size: 2rem;
    color: var(--primary-color);
    transition: all 0.3s ease;
}

.sub-node:hover i {
    transform: scale(1.2);
    filter: drop-shadow(0 0 10px var(--glow-color));
}

.sub-node span {
    font-size: 0.9rem;
    font-weight: 500;
    text-align: center;
    color: var(--text-primary);
}

/* ========================================
   Tooltip Panel
======================================== */

.tooltip-panel {
    position: fixed;
    right: -400px;
    top: 50%;
    transform: translateY(-50%);
    width: 380px;
    max-height: 80vh;
    background: var(--bg-card);
    border: 2px solid var(--primary-color);
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    z-index: 1000;
    transition: right 0.4s ease;
    overflow-y: auto;
}

.tooltip-panel.active {
    right: 2rem;
}

.tooltip-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.tooltip-close:hover {
    color: var(--primary-color);
    transform: rotate(90deg);
}

.tooltip-icon {
    font-size: 4rem;
    text-align: center;
    margin-bottom: 1rem;
    filter: drop-shadow(0 0 10px var(--glow-color));
}

.tooltip-title {
    font-size: 1.8rem;
    color: var(--primary-color);
    margin-bottom: 1rem;
    text-align: center;
}

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

.tooltip-proficiency {
    margin-bottom: 1.5rem;
}

.proficiency-label {
    display: block;
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.proficiency-bar {
    height: 10px;
    background: var(--bg-dark);
    border-radius: 5px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.proficiency-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    border-radius: 5px;
    transition: width 1s ease;
    width: 0;
}

.proficiency-value {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary-color);
}

.tooltip-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.tooltip-tag {
    background: var(--bg-dark);
    padding: 0.4rem 0.8rem;
    border-radius: 5px;
    font-size: 0.8rem;
    border: 1px solid rgba(46, 158, 247, 0.3);
}

/* ========================================
   AI Assistant
======================================== */

.ai-assistant {
    position: fixed;
    bottom: 2rem;
    left: 2rem;
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 1rem;
    animation: fadeInLeft 1s ease 1s both;
}

.assistant-avatar {
    position: relative;
    width: 60px;
    height: 60px;
    cursor: pointer;
}

.avatar-core {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border-radius: 50%;
    box-shadow: 0 0 20px var(--glow-color);
    animation: avatarPulse 2s ease-in-out infinite;
}

.avatar-ring,
.avatar-ring-2 {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border: 2px solid var(--primary-color);
    border-radius: 50%;
    animation: avatarRing 3s ease-in-out infinite;
}

.avatar-ring {
    width: 50px;
    height: 50px;
}

.avatar-ring-2 {
    width: 60px;
    height: 60px;
    animation-delay: 1.5s;
}

.assistant-message {
    background: var(--bg-card);
    border: 2px solid var(--primary-color);
    border-radius: 12px;
    padding: 1rem 1.5rem;
    max-width: 300px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
    position: relative;
    animation: messageBounce 0.5s ease;
}

.assistant-message::before {
    content: '';
    position: absolute;
    left: -10px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-top: 10px solid transparent;
    border-bottom: 10px solid transparent;
    border-right: 10px solid var(--primary-color);
}

.assistant-message p {
    margin: 0;
    font-size: 0.9rem;
    line-height: 1.4;
    color: var(--text-primary);
}

/* ========================================
   Animations
======================================== */

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInLeft {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes glowPulse {
    0%, 100% {
        opacity: 0.5;
        transform: scale(1);
    }
    50% {
        opacity: 1;
        transform: scale(1.2);
    }
}

@keyframes pulse {
    0%, 100% {
        stroke-dashoffset: 0;
    }
    50% {
        stroke-dashoffset: 10;
    }
}

@keyframes nodeActivate {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
    }
}

@keyframes subNodeAppear {
    from {
        opacity: 0;
        transform: scale(0.5) translateY(20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

@keyframes avatarPulse {
    0%, 100% {
        transform: translate(-50%, -50%) scale(1);
        box-shadow: 0 0 20px var(--glow-color);
    }
    50% {
        transform: translate(-50%, -50%) scale(1.1);
        box-shadow: 0 0 40px var(--glow-color);
    }
}

@keyframes avatarRing {
    0% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
    100% {
        transform: translate(-50%, -50%) scale(1.5);
        opacity: 0;
    }
}

@keyframes messageBounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

/* ========================================
   Responsive Design
======================================== */

@media (max-width: 768px) {
    .tech-tree-container {
        padding: 1rem;
    }

    .tree-title {
        font-size: 1.8rem;
    }

    .tree-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .stats-dashboard {
        grid-template-columns: repeat(2, 1fr);
    }

    .tech-tree {
        grid-template-columns: 1fr;
        gap: 2rem;
    }

    .main-node {
        width: 120px;
        height: 120px;
    }

    .node-icon {
        font-size: 2.5rem;
    }

    .tooltip-panel {
        width: 90%;
        right: -100%;
        top: auto;
        bottom: 0;
        transform: none;
        border-radius: 12px 12px 0 0;
    }

    .tooltip-panel.active {
        right: 0;
        left: 0;
        margin: 0 auto;
    }

    .ai-assistant {
        bottom: 1rem;
        left: 1rem;
    }

    .assistant-message {
        max-width: 200px;
        font-size: 0.8rem;
        padding: 0.8rem 1rem;
    }
}

/* ========================================
   Scrollbar Styling
======================================== */

::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: var(--bg-darker);
}

::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--secondary-color);
}