* {
    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;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

header {
    text-align: center;
    margin-bottom: 30px;
}

header h1 {
    color: white;
    font-size: 2.5rem;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.controls-section {
    background: white;
    border-radius: 15px;
    padding: 25px;
    margin-bottom: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
}

.input-controls {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.input-group {
    display: flex;
    flex-direction: column;
}

.input-group label {
    font-weight: 600;
    margin-bottom: 8px;
    color: #555;
}

.input-group input,
.input-group select {
    padding: 12px;
    border: 2px solid #e1e5e9;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.3s ease;
}

.input-group input:focus,
.input-group select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.action-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 20px;
    justify-content: center;
}

.btn {
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 120px;
    justify-content: center;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

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

.btn-primary {
    background: #667eea;
    color: white;
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-success {
    background: #28a745;
    color: white;
}

.btn-warning {
    background: #ffc107;
    color: #212529;
}

.btn-danger {
    background: #dc3545;
    color: white;
}

.speed-control {
    display: flex;
    align-items: center;
    gap: 15px;
    justify-content: center;
}

.speed-control label {
    font-weight: 600;
    color: #555;
}

.speed-control input[type="range"] {
    width: 200px;
    height: 6px;
    border-radius: 3px;
    background: #e1e5e9;
    outline: none;
    /* webkit-appearance: none; */
}

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

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

#speedValue {
    font-weight: 600;
    color: #667eea;
    min-width: 20px;
    text-align: center;
}

.info-section {
    background: white;
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

.algorithm-info {
    display: flex;
    flex-wrap: wrap;
    gap: 30px;
    justify-content: center;
    font-weight: 600;
    color: #555;
}

.algorithm-info span {
    padding: 8px 16px;
    background: #f8f9fa;
    border-radius: 20px;
    border: 2px solid #e9ecef;
}

.visualization-container {
    background: white;
    border-radius: 15px;
    padding: 30px;
    margin-bottom: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    min-height: 400px;
}

.array-container {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 2px;
    height: 300px;
    padding: 20px 0;
}

.array-bar {
    min-width: 8px;
    border-radius: 4px 4px 0 0;
    position: relative;
    transition: all 0.3s ease;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 12px;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.7);
}

.array-bar.default {
    background: linear-gradient(45deg, #3498db, #2980b9);
}

.array-bar.comparing {
    background: linear-gradient(45deg, #f39c12, #e67e22);
    transform: scale(1.1);
}

.array-bar.swapping {
    background: linear-gradient(45deg, #e74c3c, #c0392b);
    transform: scale(1.15);
}

.array-bar.sorted {
    background: linear-gradient(45deg, #27ae60, #2ecc71);
}

.array-bar.pivot {
    background: linear-gradient(45deg, #9b59b6, #8e44ad);
    transform: scale(1.1);
}

.legend {
    background: white;
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    justify-content: center;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    color: #555;
}

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

.legend-color.default {
    background: linear-gradient(45deg, #3498db, #2980b9);
}

.legend-color.comparing {
    background: linear-gradient(45deg, #f39c12, #e67e22);
}

.legend-color.swapping {
    background: linear-gradient(45deg, #e74c3c, #c0392b);
}

.legend-color.sorted {
    background: linear-gradient(45deg, #27ae60, #2ecc71);
}

.legend-color.pivot {
    background: linear-gradient(45deg, #9b59b6, #8e44ad);
}

.error-message {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    border-radius: 8px;
    padding: 15px;
    margin-top: 20px;
    display: none;
    text-align: center;
    font-weight: 600;
}

.error-message.show {
    display: block;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    .input-controls {
        grid-template-columns: 1fr;
    }
    
    .action-controls {
        flex-direction: column;
        align-items: center;
    }
    
    .btn {
        width: 100%;
        max-width: 200px;
    }
    
    .algorithm-info {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }
    
    .legend {
        flex-direction: column;
        align-items: center;
    }
    
    .array-bar {
        min-width: 6px;
        font-size: 10px;
    }
    
    .speed-control {
        flex-direction: column;
        gap: 10px;
    }
    
    .speed-control input[type="range"] {
        width: 150px;
    }
}

@media (max-width: 480px) {
    .array-container {
        gap: 1px;
        height: 250px;
    }
    
    .array-bar {
        min-width: 4px;
        font-size: 8px;
    }
    
    .visualization-container {
        padding: 15px;
        min-height: 300px;
    }
}
