:root {
    --bg-dark: #0a0a0c;
    --card-bg: rgba(22, 22, 26, 0.7);
    --border-color: rgba(255, 255, 255, 0.1);
    --text-primary: #f0f0f0;
    --text-secondary: #94a3b8;
    --accent-primary: #3b82f6;
    --accent-secondary: #06b6d4;
    --success: #22c55e;
    --warning: #eab308;
    --error: #ef4444;
    --bar-default: #94a3b8;
    --bar-compare: #ef4444;
    --bar-sorted: #22c55e;
    --bar-glow: rgba(34, 197, 94, 0.4);

    --font-main: 'Outfit', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
}

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

body {
    background-color: var(--bg-dark);
    color: var(--text-primary);
    font-family: var(--font-main);
    overflow-x: hidden;
    min-height: 100vh;
}

/* Background Grid Pattern */
.background-grid {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image:
        linear-gradient(var(--border-color) 1px, transparent 1px),
        linear-gradient(90deg, var(--border-color) 1px, transparent 1px);
    background-size: 40px 40px;
    mask-image: radial-gradient(circle at 50% 50%, black, transparent 80%);
    pointer-events: none;
    z-index: -1;
}

.app-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* Header & Controls */
.app-header {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.logo {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -1px;
    color: var(--text-primary);
}

.logo span {
    color: var(--accent-primary);
}

.glass {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: 1rem;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

.controls-panel {
    padding: 1.5rem;
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    align-items: flex-end;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex: 1;
    min-width: 150px;
}

.control-group label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

select,
input[type="range"] {
    width: 100%;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 0.5rem;
    color: var(--text-primary);
    outline: none;
    transition: all 0.2s;
}

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

.actions {
    display: flex;
    gap: 0.75rem;
}

.btn {
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    white-space: nowrap;
}

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

.btn.primary:hover {
    background: #2563eb;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

.btn.secondary {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

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

.icon-btn {
    padding: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

/* Info Section */
.info-section {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 2rem;
}

.algo-details h2 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.algo-details p {
    color: var(--text-secondary);
    max-width: 600px;
    line-height: 1.6;
}

.complexity-card {
    padding: 1.5rem;
    min-width: 300px;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.complexity-badges {
    display: flex;
    gap: 1rem;
}

.badge {
    font-family: var(--font-mono);
    font-size: 0.875rem;
    padding: 0.25rem 0.75rem;
    border-radius: 99px;
    background: rgba(59, 130, 246, 0.1);
    color: var(--accent-primary);
    border: 1px solid rgba(59, 130, 246, 0.2);
}

.live-stats {
    display: flex;
    gap: 2rem;
    border-top: 1px solid var(--border-color);
    padding-top: 1rem;
}

.stat-item {
    display: flex;
    flex-direction: column;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.stat-value {
    font-family: var(--font-mono);
    font-size: 1.25rem;
    font-weight: 700;
}

/* Visualizer Area */
.visualizer-container {
    height: 400px;
    padding: 2rem;
    display: flex;
    align-items: flex-end;
    overflow: hidden;
}

.bars-container {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: flex-end;
    gap: 2px;
}

.bar {
    background-color: var(--bar-default);
    border-radius: 4px 4px 0 0;
    transition: height 0.2s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.2s;
    flex: 1;
}

.bar.comparing {
    background-color: var(--bar-compare);
    box-shadow: 0 0 15px var(--bar-compare);
}

.bar.sorted {
    background-color: var(--bar-sorted);
    box-shadow: 0 0 20px var(--bar-glow);
}

/* Responsive */
@media (max-width: 768px) {
    .app-container {
        padding: 1rem;
    }

    .info-section {
        flex-direction: column;
        align-items: flex-start;
    }

    .complexity-card {
        width: 100%;
    }
}