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

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

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

/* Header */
.header {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    padding: 20px 0;
    text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

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

.tagline {
    color: rgba(255, 255, 255, 0.9);
    font-size: 1.2rem;
}

/* Navigation */
.nav {
    background: rgba(255, 255, 255, 0.05);
    padding: 15px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.nav-buttons {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

.nav-btn {
    padding: 10px 20px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 14px;
    font-weight: 500;
}

.nav-btn:hover,
.nav-btn.active {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

/* Main Content */
.main {
    padding: 40px 0;
    min-height: calc(100vh - 200px);
}

/* Algorithm Grid */
.algorithm-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.algorithm-card {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 15px;
    padding: 25px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    transition: all 0.3s ease;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.algorithm-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.2);
}

.algorithm-card h3 {
    color: #333;
    margin-bottom: 10px;
    font-size: 1.3rem;
}

.algorithm-card p {
    color: #666;
    font-size: 0.9rem;
    margin-bottom: 15px;
}

.complexity-badge {
    display: inline-block;
    background: #e3f2fd;
    color: #1976d2;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 500;
    margin-right: 8px;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
}

.modal-content {
    background: white;
    margin: 2% auto;
    padding: 0;
    border-radius: 15px;
    width: 95%;
    max-width: 1000px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.close-btn {
    position: absolute;
    right: 20px;
    top: 20px;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    z-index: 1001;
    color: #666;
    transition: color 0.3s ease;
}

.close-btn:hover {
    color: #333;
}

/* Algorithm Info */
.algorithm-info {
    padding: 30px;
    border-bottom: 1px solid #eee;
}

.algorithm-info h2 {
    color: #333;
    margin-bottom: 20px;
    font-size: 2rem;
}

.complexity-info {
    display: flex;
    gap: 30px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.complexity-item {
    display: flex;
    align-items: center;
    gap: 10px;
}

.complexity-item .label {
    font-weight: 600;
    color: #555;
}

.complexity-item span:last-child {
    background: #f0f8ff;
    color: #1976d2;
    padding: 4px 12px;
    border-radius: 15px;
    font-family: 'Courier New', monospace;
    font-weight: 600;
}

/* Visualization Section */
.visualization-section {
    padding: 30px;
    border-bottom: 1px solid #eee;
}

.visualization-section h3 {
    margin-bottom: 20px;
    color: #333;
}

.controls {
    display: flex;
    gap: 15px;
    margin-bottom: 30px;
    flex-wrap: wrap;
    align-items: center;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

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

.btn-primary {
    background: #2196f3;
    color: white;
}

.btn-success {
    background: #4caf50;
    color: white;
}

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

.control-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.control-group label {
    font-weight: 600;
    color: #555;
    min-width: 80px;
}

.control-group input[type="range"] {
    width: 100px;
}

.control-group span {
    min-width: 50px;
    font-weight: 600;
    color: #666;
}

/* Visualization Container */
#visualization-container {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
}

#array-container {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    height: 200px;
    gap: 2px;
    margin-bottom: 20px;
    padding: 10px;
    background: white;
    border-radius: 8px;
    box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.05);
}

.array-element {
    background: #6c757d;
    color: white;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    font-weight: bold;
    font-size: 12px;
    padding-bottom: 5px;
    border-radius: 4px 4px 0 0;
    transition: all 0.3s ease;
    min-width: 30px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.array-element.comparing {
    background: #ffc107;
    animation: pulse 0.5s ease-in-out infinite alternate;
}

.array-element.swapping {
    background: #dc3545;
    animation: shake 0.3s ease-in-out;
}

.array-element.sorted {
    background: #28a745;
    animation: bounce 0.5s ease-in-out;
}

/* Stats */
.stats {
    display: flex;
    justify-content: center;
    gap: 30px;
    flex-wrap: wrap;
}

.stat-item {
    text-align: center;
    background: white;
    padding: 15px 20px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.stat-label {
    display: block;
    font-size: 12px;
    color: #666;
    margin-bottom: 5px;
    font-weight: 600;
}

.stat-item span:last-child {
    font-size: 24px;
    font-weight: bold;
    color: #2196f3;
}

/* Legend */
.legend {
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
    margin-top: 20px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    background: white;
    padding: 8px 15px;
    border-radius: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.legend-color {
    width: 16px;
    height: 16px;
    border-radius: 3px;
}

.legend-color.default { background: #6c757d; }
.legend-color.comparing { background: #ffc107; }
.legend-color.swapping { background: #dc3545; }
.legend-color.sorted { background: #28a745; }

/* Code Section */
.code-section {
    padding: 30px;
}

.code-section h3 {
    margin-bottom: 20px;
    color: #333;
}

.code-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.code-tab {
    padding: 10px 20px;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px 8px 0 0;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
}

.code-tab.active {
    background: #2196f3;
    color: white;
    border-color: #2196f3;
}

.code-content {
    position: relative;
}

.code-block {
    background: #2d3748;
    color: #e2e8f0;
    padding: 20px;
    border-radius: 0 8px 8px 8px;
    overflow-x: auto;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.5;
    display: none;
}

.code-block.active {
    display: block;
}

.explanation-block {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 0 8px 8px 8px;
    display: none;
}

.explanation-block.active {
    display: block;
}

.explanation-block ol {
    padding-left: 20px;
}

.explanation-block li {
    margin-bottom: 10px;
    line-height: 1.6;
}

/* Animations */
@keyframes pulse {
    from { transform: scale(1); }
    to { transform: scale(1.05); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-3px); }
    75% { transform: translateX(3px); }
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

/* Footer */
.footer {
    background: rgba(0, 0, 0, 0.2);
    color: white;
    text-align: center;
    padding: 20px 0;
    margin-top: auto;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 0 15px;
    }
    
    .logo {
        font-size: 2rem;
    }
    
    .tagline {
        font-size: 1rem;
    }
    
    .nav-buttons {
        gap: 5px;
    }
    
    .nav-btn {
        padding: 8px 15px;
        font-size: 12px;
    }
    
    .algorithm-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .modal-content {
        width: 98%;
        margin: 1% auto;
    }
    
    .controls {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    
    .control-group {
        justify-content: space-between;
    }
    
    .stats {
        gap: 15px;
    }
    
    .legend {
        gap: 10px;
    }
    
    .complexity-info {
        flex-direction: column;
        gap: 10px;
    }
    
    #array-container {
        height: 150px;
    }
}