/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
}

/* Navigation Bar */
.navbar {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 1rem 0;
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-title {
    font-size: 1.8rem;
    font-weight: 700;
    background: linear-gradient(45deg, #667eea, #764ba2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.nav-info {
    font-weight: 500;
    color: #666;
}

#status {
    padding: 0.5rem 1rem;
    background: #f0f0f0;
    border-radius: 20px;
    font-size: 0.9rem;
}

/* Control Panel */
.controls {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 2rem;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    align-items: end;
}

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

.control-group label {
    font-weight: 600;
    color: white;
    font-size: 0.9rem;
}

select, input[type="range"] {
    padding: 0.75rem;
    border: none;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.9);
    font-size: 1rem;
    transition: all 0.3s ease;
}

select:focus, input[type="range"]:focus {
    outline: none;
    background: white;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.3);
}

/* Range Slider Styling */
input[type="range"] {
    -webkit-appearance: none;
    height: 8px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 4px;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    background: #667eea;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    background: #5a6fd8;
}

input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: #667eea;
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

.control-buttons {
    display: flex;
    gap: 1rem;
    grid-column: 1 / -1;
    justify-content: center;
    margin-top: 1rem;
}

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-primary {
    background: linear-gradient(45deg, #667eea, #764ba2);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.9);
    color: #333;
}

.btn-secondary:hover:not(:disabled) {
    background: white;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

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

/* Visualization Container */
.visualization-container {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 2rem;
}

.array-container {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: end;
    justify-content: center;
    gap: 2px;
    min-height: 400px;
    overflow-x: auto;
}

/* Array Bars */
.array-bar {
    background: #3498db;
    border-radius: 4px 4px 0 0;
    transition: all 0.3s ease;
    position: relative;
    min-width: 4px;
    display: flex;
    align-items: end;
    justify-content: center;
}

.array-bar.comparing {
    background: #e74c3c !important;
    transform: scale(1.05);
}

.array-bar.swapping {
    background: #f39c12 !important;
    transform: scale(1.1);
}

.array-bar.sorted {
    background: #27ae60 !important;
}

.array-bar.pivot {
    background: #9b59b6 !important;
    transform: scale(1.05);
}

/* Bar Value Labels */
.bar-value {
    position: absolute;
    top: -25px;
    font-size: 0.7rem;
    font-weight: 600;
    color: #333;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.array-bar:hover .bar-value {
    opacity: 1;
}

/* Information Panel */
.info-panel {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 2rem;
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 2rem;
}

.algorithm-info {
    background: rgba(255, 255, 255, 0.95);
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.algorithm-info h3 {
    color: #667eea;
    margin-bottom: 0.5rem;
    font-size: 1.3rem;
}

.algorithm-info p {
    color: #666;
    line-height: 1.6;
    margin-bottom: 1rem;
}

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

.complexity {
    background: #f8f9fa;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
}

/* Legend */
.legend {
    background: rgba(255, 255, 255, 0.95);
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.legend h4 {
    color: #333;
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.legend-color {
    width: 20px;
    height: 20px;
    border-radius: 4px;
}

.legend-color.default {
    background: #3498db;
}

.legend-color.comparing {
    background: #e74c3c;
}

.legend-color.swapping {
    background: #f39c12;
}

.legend-color.sorted {
    background: #27ae60;
}

/* Responsive Design */
@media (max-width: 768px) {
    .nav-container {
        padding: 0 1rem;
        flex-direction: column;
        gap: 1rem;
    }

    .nav-title {
        font-size: 1.5rem;
    }

    .controls {
        padding: 0 1rem;
        grid-template-columns: 1fr;
    }

    .control-buttons {
        flex-direction: column;
    }

    .visualization-container {
        padding: 0 1rem;
    }

    .array-container {
        padding: 1rem;
        min-height: 300px;
    }

    .info-panel {
        padding: 0 1rem;
        grid-template-columns: 1fr;
    }

    .complexity-info {
        flex-direction: column;
    }
}

@media (max-width: 480px) {
    .array-container {
        gap: 1px;
    }
    
    .array-bar {
        min-width: 3px;
    }
}

/* Loading Animation */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.sorting {
    animation: pulse 1s infinite;
}