:root {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --accent-primary: #38bdf8;
    --accent-secondary: #818cf8;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --border-color: rgba(255, 255, 255, 0.1);
    --node-unvisited: #334155;
    --node-visiting: #f59e0b;
    --node-visited: #10b981;
}

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

body {
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    overflow: hidden;
    height: 100vh;
}

.top-nav {
    height: 60px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 2rem;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
}

.nav-brand {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--accent-primary);
    text-decoration: none;
    letter-spacing: -0.025em;
}

.nav-links {
    display: flex;
    gap: 1.5rem;
}

.nav-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: color 0.2s;
}

.nav-link:hover {
    color: var(--text-primary);
}

.simulator-container {
    display: grid;
    grid-template-columns: 280px 1fr 350px;
    height: calc(100vh - 60px);
}

/* Sidebar Styles */
.sidebar {
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 1.5rem;
}

.sidebar-header h2 {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-secondary);
}

.algo-nav {
    display: flex;
    flex-direction: column;
    padding: 0 0.75rem;
}

.algo-nav .nav-link {
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-size: 0.95rem;
    margin-bottom: 0.25rem;
}

.algo-nav .nav-link.active {
    background: rgba(56, 189, 248, 0.1);
    color: var(--accent-primary);
}

.controls-panel {
    margin-top: auto;
    padding: 1.5rem;
    border-top: 1px solid var(--border-color);
}

.controls-panel h3 {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.control-group {
    margin-bottom: 1.25rem;
}

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

.secondary-btn {
    width: 100%;
    padding: 0.6rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.85rem;
    cursor: pointer;
    margin-bottom: 0.5rem;
}

.secondary-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.main-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
}

.icon-btn {
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.25rem;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.icon-btn:hover {
    opacity: 1;
}

.play-btn {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: var(--accent-primary);
    border: none;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(56, 189, 248, 0.3);
}

/* Visualizer Area */
.visualizer-area {
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    background: #0c1220;
}

.viz-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1.5rem;
}

.algo-info h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.algo-info p {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.viz-legend {
    display: flex;
    gap: 1rem;
}

.legend-item {
    font-size: 0.75rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.dot.unvisited { background: var(--node-unvisited); }
.dot.visiting { background: var(--node-visiting); }
.dot.visited { background: var(--node-visited); }

.canvas-container {
    flex: 1;
    position: relative;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    overflow: hidden;
}

#graph-canvas {
    width: 100%;
    height: 100%;
}

.status-panel {
    margin-top: 1.5rem;
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 1rem;
    border: 1px solid var(--border-color);
}

.status-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
    text-transform: uppercase;
}

.path-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.node-chip {
    padding: 0.25rem 0.75rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--accent-primary);
    border: 1px solid var(--border-color);
    animation: slideIn 0.3s ease-out;
}

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

/* Explanation Side */
.explanation-side {
    background: var(--bg-secondary);
    border-left: 1px solid var(--border-color);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    overflow-y: auto;
}

.panel-header {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
    text-transform: uppercase;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.code-block {
    background: #0f172a;
    padding: 1rem;
    border-radius: 8px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem;
    line-height: 1.5;
    color: #e2e8f0;
    overflow-x: auto;
    border: 1px solid var(--border-color);
}

.lang-select {
    background: #0f172a;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    font-size: 0.7rem;
    padding: 2px 4px;
    border-radius: 4px;
}

.stack-view {
    display: flex;
    flex-direction: column-reverse;
    gap: 0.5rem;
    min-height: 100px;
}

.stack-frame {
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    animation: popIn 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.stack-frame.active {
    border-color: var(--accent-primary);
    background: rgba(56, 189, 248, 0.05);
}

@keyframes popIn {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

input[type="range"] {
    width: 100%;
    accent-color: var(--accent-primary);
}
