:root {
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --secondary-gradient: linear-gradient(135deg, #00c6fb 0%, #005bea 100%);
    --bg-color: #0f172a;
    --card-bg: rgba(30, 41, 59, 0.7);
    --text-color: #f1f5f9;
    --accent-color: #38bdf8;
    --border-color: rgba(255, 255, 255, 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', 'Inter', sans-serif;
}

body {
    background-color: var(--bg-color);
    background-image: 
        radial-gradient(at 0% 0%, hsla(253,16%,7%,1) 0, transparent 50%), 
        radial-gradient(at 50% 0%, hsla(225,39%,30%,0.5) 0, transparent 50%), 
        radial-gradient(at 100% 0%, hsla(339,49%,30%,0.5) 0, transparent 50%);
    color: var(--text-color);
    min-height: 100vh;
    overflow-x: hidden;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

header {
    text-align: center;
    margin-bottom: 3rem;
}

h1 {
    font-size: 3rem;
    font-weight: 800;
    background: var(--primary-gradient);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.5rem;
}

.subtitle {
    font-size: 1.1rem;
    color: #94a3b8;
}

.uni-info {
    font-size: 0.95rem;
    color: #94a3b8;
    margin-bottom: 0.3rem;
}

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

.card {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 2rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.controls-card {
    height: fit-content;
}

.form-group {
    margin-bottom: 1.5rem;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    font-size: 0.9rem;
}

input {
    width: 100%;
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 0.8rem 1rem;
    color: white;
    font-size: 1rem;
    transition: all 0.3s ease;
}

input:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.2);
}

.btn-group {
    display: flex;
    gap: 0.5rem;
}

button {
    flex: 1;
    padding: 0.8rem;
    border: none;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-primary {
    background: var(--primary-gradient);
    color: white;
}

.btn-delete {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-delete:hover {
    background: #ef4444;
    color: white;
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.visualization-card {
    min-height: 500px;
    display: flex;
    flex-direction: column;
}

#tree-canvas {
    flex: 1;
    background: rgba(15, 23, 42, 0.3);
    border-radius: 15px;
    margin-bottom: 1rem;
    position: relative;
    overflow: auto;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 2rem;
}

.traversals {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.traversal-item {
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.traversal-item strong {
    color: var(--accent-color);
}

.exercises {
    margin-top: 2rem;
}

.exercise-btn {
    background: rgba(255, 255, 255, 0.05);
    color: white;
    font-size: 0.8rem;
    padding: 0.5rem 1rem;
    margin: 0.2rem;
    border: 1px solid var(--border-color);
    display: inline-block;
    cursor: pointer;
    border-radius: 20px;
    transition: all 0.2s;
}

.exercise-btn:hover {
    background: var(--secondary-gradient);
    border-color: transparent;
}

/* Tree Visualization Nodes */
.node-circle {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--secondary-gradient);
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    color: white;
    box-shadow: 0 5px 15px rgba(0, 198, 251, 0.3);
    position: relative;
    z-index: 2;
}

.balance-factor {
    position: absolute;
    top: -25px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--accent-color);
    background: rgba(15, 23, 42, 0.6);
    padding: 2px 6px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
}

.tree-container {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.children {
    display: flex;
    justify-content: center;
    margin-top: 40px;
    gap: 20px;
    position: relative;
    min-width: fit-content;
}

.line {
    position: absolute;
    height: 2px;
    background: rgba(255, 255, 255, 0.2);
    top: -20px;
    z-index: 1;
    width: 30px;
}

.line-left {
    right: 50%;
    transform: rotate(-30deg);
    transform-origin: right;
}

.line-right {
    left: 50%;
    transform: rotate(30deg);
    transform-origin: left;
}
