/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    user-select: none; /* Prevent text selection during rapid clicking */
}

body {
    font-family: 'Arial', sans-serif;
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.6;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Navigation Bar */
.navbar {
    background-color: #34495e;
    color: white;
    padding: 1rem 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.nav-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.nav-title {
    font-size: 1.5rem;
    font-weight: bold;
    color: #ecf0f1;
    text-align: center;
}

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

.nav-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.right {
    margin-left: auto;
}

.divider {
    width: 1px;
    height: 30px;
    background-color: #7f8c8d;
    margin: 0 0.5rem;
}

/* Buttons */
.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s ease;
    background-color: transparent;
    color: #ecf0f1;
}

.btn:hover:not(:disabled) {
    background-color: rgba(255, 255, 255, 0.1);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-secondary {
    background-color: #2c3e50; /* Darker blue */
}

.btn-secondary:hover:not(:disabled) {
    background-color: #34495e;
}

.btn-algo {
    color: #bdc3c7;
}

.btn-algo.active {
    color: #3498db;
    font-weight: bold;
}

.btn-primary {
    background-color: #3498db;
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background-color: #2980b9;
}

.btn-warning {
    background-color: #f39c12;
    color: white;
}

.btn-warning:hover:not(:disabled) {
    background-color: #e67e22;
}

.btn-danger {
    background-color: #e74c3c; /* Red */
    color: white;
}

.btn-danger:hover:not(:disabled) {
    background-color: #c0392b;
}

/* Sliders */
.control-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 0 0.5rem;
}

.control-group label {
    font-size: 0.75rem;
    color: #bdc3c7;
    margin-bottom: 2px;
}

input[type="range"] {
    width: 100px;
    cursor: pointer;
}

/* Legend */
.legend {
    display: flex;
    justify-content: center;
    padding: 1rem;
    background-color: white;
    margin-bottom: 2px;
}

.legend-item {
    display: flex;
    align-items: center;
    margin: 0 1rem;
    font-size: 0.9rem;
}

.legend-box {
    width: 20px;
    height: 20px;
    margin-right: 5px;
    border-radius: 2px;
}

.default-bar {
    background-color: #40E0D0; /* Turquoise */
}

.compare-bar {
    background-color: #e74c3c; /* Red */
}

.swap-bar {
    background-color: #f1c40f; /* Yellow */
}

.sorted-bar {
    background-color: #2ecc71; /* Green */
}

/* Visualizer Container */
#visualizer-container {
    flex: 1;
    background-color: #ecf0f1; /* Light gray background */
    display: flex;
    align-items: flex-end; /* Align bars to bottom */
    justify-content: center;
    padding: 20px;
    overflow: hidden;
    position: relative;
}

.array-bar {
    background-color: #40E0D0; /* Default: Turquoise */
    margin: 0 1px;
    display: inline-block;
    transition: background-color 0.1s ease;
    /* Optional: Add a slight border or shadow for visual separation */
    /* border-top-left-radius: 3px; */
    /* border-top-right-radius: 3px; */
}

/* Responsive */
@media (max-width: 900px) {
    .nav-controls {
        flex-direction: column;
        align-items: stretch;
    }
    .right {
        margin-left: 0;
        justify-content: center;
    }
    .nav-group {
        justify-content: center;
    }
}
