:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --secondary-color: #ec4899;
    --background-color: #0f172a;
    --surface-color: #1e293b;
    --text-color: #f8fafc;
    --text-muted: #94a3b8;
    --node-bg: #3b82f6;
    --node-border: #60a5fa;
    --node-text: #ffffff;
    --edge-color: #64748b;
    --highlight-color: #f59e0b;
    --success-color: #10b981;
    --split-color: #ec4899;
}

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

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    padding: 1.5rem;
}

.app-container {
    width: 100%;
    max-width: 1400px;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 600;
    margin: 0;
    background: linear-gradient(to right, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    white-space: nowrap;
}

.tagline {
    color: var(--text-muted);
    font-size: 1rem;
    white-space: nowrap;
}

header p {
    color: var(--text-muted);
    font-size: 1rem;
}

.controls {
    display: flex;
    justify-content: center;
    gap: 1rem;
    background-color: var(--surface-color);
    padding: 1.5rem;
    border-radius: 1rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

input {
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    border: 1px solid var(--edge-color);
    background-color: var(--background-color);
    color: var(--text-color);
    font-family: inherit;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
}

input:focus {
    border-color: var(--primary-color);
}

button {
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    border: none;
    background-color: var(--primary-color);
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
}

button:hover {
    background-color: var(--primary-hover);
}

button:active {
    transform: scale(0.98);
}

button.secondary {
    background-color: var(--surface-color);
    border: 1px solid var(--edge-color);
}

button.secondary:hover {
    background-color: var(--edge-color);
}

.visualization-area {
    background-color: var(--surface-color);
    border-radius: 1rem;
    min-height: 520px;
    position: relative;
    overflow-x: auto;
    overflow-y: auto;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 40px 20px;
}

#tree-container {
    position: relative;
    width: 100%;
    min-width: 800px;
    height: 100%;
    min-height: 500px;
    transition: transform 0.5s ease;
}

/* B-Tree Node Styles - Rectangular with multiple keys */
.node {
    position: absolute;
    min-width: 80px;
    height: 50px;
    background-color: var(--node-bg);
    border: 3px solid var(--node-border);
    border-radius: 0.5rem;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: 600;
    color: var(--node-text);
    z-index: 10;
    transition: all 0.5s ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    padding: 0.25rem 0.5rem;
    transform: translateY(-25px);
    /* Center vertically */
}

.node-keys {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    height: 100%;
    width: 100%;
}

.key-item {
    padding: 0 0.5rem;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.key-divider {
    width: 2px;
    height: 70%;
    background-color: var(--node-border);
    opacity: 0.5;
}

/* Animation states */
.node.searching {
    background-color: var(--highlight-color);
    border-color: #fbbf24;
    transform: translateY(-25px) scale(1.05);
    box-shadow: 0 0 15px var(--highlight-color);
}

.node.inserting {
    background-color: var(--success-color);
    border-color: #34d399;
    transform: translateY(-25px) scale(1.08);
    box-shadow: 0 0 20px var(--success-color);
    animation: pulse-insert 0.6s ease;
}

.node.splitting {
    background-color: #fef08a;
    border-color: var(--split-color);
    border-style: dashed;
    color: #854d0e;
    transform: translateY(-25px) scale(1.05);
    box-shadow: 0 0 20px var(--split-color);
    animation: pulse-split 1s infinite;
}

/* Edge Styles */
.edge {
    position: absolute;
    height: 2px;
    background-color: var(--edge-color);
    transform-origin: 0 50%;
    z-index: 1;
    transition: all 0.5s ease;
}

.edge.splitting {
    background-color: var(--split-color);
    border-top: 2px dashed var(--split-color);
    background-color: transparent;
}

/* Info Panel */
.info-panel {
    background-color: var(--surface-color);
    padding: 1.5rem;
    border-radius: 1rem;
    min-height: 110px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    position: sticky;
    bottom: 0;
    border: 1px solid var(--edge-color);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.35);
    z-index: 15;
    backdrop-filter: blur(6px);
}

.info-panel.active {
    border-color: var(--split-color);
    box-shadow: 0 12px 35px rgba(236, 72, 153, 0.3), 0 0 0 1px var(--split-color);
}

#status-message {
    font-size: 1.2rem;
    margin-bottom: 1rem;
}

#status-message.error {
    color: #ef4444;
}

#status-message.split {
    color: var(--split-color);
    font-weight: 600;
}

#split-info.hidden,
.hidden {
    display: none;
}

#split-info {
    margin-top: 1rem;
    width: 100%;
}

#split-info h3 {
    color: var(--split-color);
    margin-bottom: 0.5rem;
}

#split-type {
    color: var(--text-muted);
    font-size: 1rem;
    margin-top: 0.5rem;
}

/* Animations */
@keyframes pulse-insert {

    0%,
    100% {
        transform: translateY(-25px) scale(1.08);
    }

    50% {
        transform: translateY(-25px) scale(1.15);
    }
}

@keyframes pulse-split {
    0% {
        box-shadow: 0 0 0 0 rgba(236, 72, 153, 0.7);
    }

    70% {
        box-shadow: 0 0 0 15px rgba(236, 72, 153, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(236, 72, 153, 0);
    }
}

@keyframes popIn {
    0% {
        transform: translateY(-25px) scale(0);
        opacity: 0;
    }

    100% {
        transform: translateY(-25px) scale(1);
        opacity: 1;
    }
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .controls {
        flex-direction: column;
    }

    header h1 {
        font-size: 2rem;
    }

    .title-row {
        flex-direction: column;
        align-items: flex-start;
    }

    .tagline {
        white-space: normal;
    }

    header p {
        font-size: 0.9rem;
    }

    .node {
        min-width: 60px;
        height: 40px;
    }

    .key-item {
        font-size: 0.9rem;
        padding: 0 0.3rem;
    }
}
