:root[data-theme="light"] {
    --bg-primary: #ffffff;
    --bg-secondary: #f3f4f6;
    --text-primary: #1f2937;
    --text-secondary: #4b5563;
    --accent-primary: #3b82f6;
    --accent-secondary: #60a5fa;
    --border-color: #e5e7eb;
    --bar-color: #3b82f6;
    --bar-compare: #f59e0b;
    --bar-sorted: #10b981;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --danger-primary: #ef4444;
    --danger-secondary: #dc2626;
}

:root[data-theme="dark"] {
    --bg-primary: #111827;
    --bg-secondary: #1f2937;
    --text-primary: #f9fafb;
    --text-secondary: #d1d5db;
    --accent-primary: #60a5fa;
    --accent-secondary: #93c5fd;
    --border-color: #374151;
    --bar-color: #60a5fa;
    --bar-compare: #fbbf24;
    --bar-sorted: #34d399;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    --danger-primary: #ef4444;
    --danger-secondary: #dc2626;
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    transition: background-color 0.3s, color 0.3s;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding: 1rem 0;
}

h1 {
    font-size: 2rem;
    font-weight: 600;
    color: var(--text-primary);
}

.theme-toggle {
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
}

.theme-toggle:hover {
    background-color: var(--bg-secondary);
}

.sun-icon {
    display: none;
}

[data-theme="dark"] .sun-icon {
    display: block;
}

[data-theme="dark"] .moon-icon {
    display: none;
}

.controls {
    background-color: var(--bg-secondary);
    border-radius: 0.5rem;
    padding: 1.5rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow);
}

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

.control-group:last-child {
    margin-bottom: 0;
}

h3 {
    color: var(--text-secondary);
    font-size: 1rem;
    font-weight: 500;
    margin-bottom: 1rem;
}

.algorithm-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.btn {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s;
}

.btn:hover {
    background-color: var(--bg-secondary);
}

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

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

.btn.danger {
    background-color: #ef4444;
    color: white;
    border: none;
}

.btn.danger:hover {
    background-color: #dc2626;
}

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

.settings {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: center;
}

.setting {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.slider {
    width: 150px;
    height: 4px;
    -webkit-appearance: none;
    background: var(--border-color);
    border-radius: 2px;
    outline: none;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    background: var(--accent-primary);
    border-radius: 50%;
    cursor: pointer;
    transition: background-color 0.2s;
}

.slider::-webkit-slider-thumb:hover {
    background: var(--accent-secondary);
}

.visualization-container {
    background-color: var(--bg-secondary);
    border-radius: 0.5rem;
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.array-container {
    height: 400px;
    display: flex;
    align-items: flex-end;
    gap: 1px;
    padding: 1rem;
    background-color: var(--bg-primary);
    border-radius: 0.375rem;
    margin-bottom: 1rem;
}

.bar {
    background-color: var(--bar-color);
    flex: 1;
    transition: height 0.1s ease-in-out;
}

.bar.comparing {
    background-color: var(--bar-compare);
}

.bar.sorted {
    background-color: var(--bar-sorted);
}

.info-panel {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.info-card {
    background-color: var(--bg-primary);
    padding: 1rem;
    border-radius: 0.375rem;
    text-align: center;
}

.info-card h3 {
    margin-bottom: 0.5rem;
}

.complexity,
.status {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.btn.algorithm-btn {
    position: relative;
    transition: all 0.2s ease;
}

.btn.algorithm-btn.active {
    background-color: var(--accent-primary);
    color: white;
    border-color: var(--accent-primary);
    font-weight: 600;
}

.btn.algorithm-btn.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 100%;
    height: 2px;
    background-color: var(--accent-primary);
    border-radius: 2px;
}

.complexity {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.complexity-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem;
    background-color: var(--bg-secondary);
    border-radius: 0.25rem;
    transition: background-color 0.2s;
}

.complexity-item:hover {
    background-color: var(--border-color);
}

.complexity-item span:first-child {
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.875rem;
}

.complexity-item span:last-child {
    font-family: 'Consolas', monospace;
    color: var(--accent-primary);
    font-weight: 600;
    font-size: 0.875rem;
}

@media (max-width: 768px) {
    .container {
        padding: 0.5rem;
    }
    .header {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
    .algorithm-buttons {
        justify-content: center;
    }
    .settings {
        flex-direction: column;
        align-items: stretch;
    }
    .setting {
        flex-direction: column;
        align-items: stretch;
    }
    .slider {
        width: 100%;
    }
}