/* Sorting Visualizer Styles */

/* Page Header */
.page-header {
    padding: 120px 20px 60px;
    background: var(--gradient-primary);
    text-align: center;
    color: white;
}

.page-title {
    font-size: clamp(2rem, 5vw, 3rem);
    font-weight: 700;
    margin-bottom: 10px;
    opacity: 0;
    animation: fadeInUp 0.8s ease-out forwards;
}

.page-subtitle {
    font-size: 1.1rem;
    opacity: 0;
    animation: fadeInUp 0.8s ease-out 0.2s forwards;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Visualizer Section */
.visualizer-section {
    padding: 40px 20px 80px;
    background: var(--bg-primary);
}

/* Control Panel */
.control-panel {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 25px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-md);
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    align-items: end;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.control-group label {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
}

.control-group select,
.control-group input[type="range"] {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.9rem;
}

.control-group select:focus,
.control-group input[type="range"]:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

/* Range Slider Styling */
input[type="range"] {
    -webkit-appearance: none;
    height: 6px;
    background: var(--border-color);
    border-radius: 3px;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: var(--accent-color);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
}

input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: var(--accent-color);
    border-radius: 50%;
    cursor: pointer;
    border: none;
    box-shadow: var(--shadow-sm);
}

/* Button Group */
.button-group {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--accent-color);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: #2563eb;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: var(--text-secondary);
    color: white;
}

.btn-secondary:hover:not(:disabled) {
    background: #4b5563;
    transform: translateY(-1px);
}

.btn-warning {
    background: #f59e0b;
    color: white;
}

.btn-warning:hover:not(:disabled) {
    background: #d97706;
    transform: translateY(-1px);
}

.btn-danger {
    background: #ef4444;
    color: white;
}

.btn-danger:hover:not(:disabled) {
    background: #dc2626;
    transform: translateY(-1px);
}

/* Statistics Panel */
.stats-panel {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-md);
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 20px;
}

.stat-item {
    text-align: center;
    padding: 10px;
}

.stat-label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 5px;
    font-weight: 500;
}

.stat-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent-color);
    font-family: 'Fira Code', monospace;
}

/* Visualization Container */
.visualization-container {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 30px 20px;
    margin-bottom: 30px;
    box-shadow: var(--shadow-md);
    min-height: 400px;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

#bars-container {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 2px;
    width: 100%;
    height: 350px;
}

/* Bar Styling */
.bar {
    background: var(--text-secondary);
    border-radius: 2px 2px 0 0;
    transition: all 0.3s ease;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    color: white;
    font-size: 10px;
    font-weight: 600;
    min-width: 8px;
}

.bar.comparing {
    background: #ef4444;
    transform: scale(1.05);
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.5);
}

.bar.swapping {
    background: #f59e0b;
    transform: scale(1.05);
    box-shadow: 0 0 10px rgba(245, 158, 11, 0.5);
}

.bar.pivot {
    background: #8b5cf6;
    transform: scale(1.05);
    box-shadow: 0 0 10px rgba(139, 92, 246, 0.5);
}

.bar.sorted {
    background: #10b981;
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.3);
}

/* Algorithm Information */
.algorithm-info {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 30px;
    box-shadow: var(--shadow-md);
}

#algo-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 20px;
    text-align: center;
}

.complexity-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.complexity-item {
    padding: 15px;
    background: var(--bg-primary);
    border-radius: 8px;
    border-left: 4px solid var(--accent-color);
}

.complexity-item strong {
    color: var(--text-primary);
    display: block;
    margin-bottom: 5px;
    font-size: 0.9rem;
}

.complexity-item span {
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-family: 'Fira Code', monospace;
}

.description {
    margin-bottom: 25px;
}

.description p {
    color: var(--text-primary);
    line-height: 1.6;
    font-size: 1rem;
}

/* Legend */
.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    justify-content: center;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.legend-color {
    width: 20px;
    height: 20px;
    border-radius: 2px;
}

.legend-color.default {
    background: var(--text-secondary);
}

.legend-color.comparing {
    background: #ef4444;
}

.legend-color.swapping {
    background: #f59e0b;
}

.legend-color.pivot {
    background: #8b5cf6;
}

.legend-color.sorted {
    background: #10b981;
}

/* Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

.sorting-active .bar {
    animation: pulse 2s infinite;
}

/* Responsive Design */
@media (max-width: 768px) {
    .control-panel {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .button-group {
        grid-column: 1 / -1;
        justify-content: center;
    }
    
    .btn {
        flex: 1;
        min-width: 80px;
    }
    
    .stats-panel {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .visualization-container {
        padding: 20px 10px;
        min-height: 300px;
    }
    
    #bars-container {
        height: 250px;
        gap: 1px;
    }
    
    .bar {
        min-width: 6px;
        font-size: 8px;
    }
    
    .complexity-info {
        grid-template-columns: 1fr;
    }
    
    .legend {
        gap: 15px;
    }
}

@media (max-width: 480px) {
    .stats-panel {
        grid-template-columns: 1fr;
    }
    
    .stat-value {
        font-size: 1.2rem;
    }
    
    .bar {
        min-width: 4px;
        font-size: 0;
    }
    
    .algorithm-info {
        padding: 20px;
    }
}

/* ================================
   Extended Sections (Analysis / Concepts / Insights / Theory)
   ================================ */

/* Shared section scaffolding */
.algorithm-analysis,
.data-structures-section,
.practical-insights,
.complexity-theory {
  padding: 64px 20px;
  background: var(--bg-primary);
}

.section-title {
  font-size: clamp(1.6rem, 3vw, 2rem);
  font-weight: 700;
  color: var(--text-primary);
  text-align: center;
  margin: 0 0 12px;
  letter-spacing: .3px;
}

.section-intro {
  max-width: 850px;
  margin: 0 auto 28px;
  color: var(--text-secondary);
  text-align: center;
  line-height: 1.7;
}

/* Cards (used in Algorithm Analysis) */
.algorithm-card {
  background: var(--bg-secondary);
  border-radius: 14px;
  padding: 28px;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border-color);
  margin: 20px 0;
  transition: transform .25s ease, box-shadow .25s ease, border-color .25s ease;
}

.algorithm-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 30px rgba(0,0,0,.08);
  border-color: rgba(59,130,246,.25); /* accent hint */
}

.algorithm-card h3 {
  margin: 0 0 12px;
  font-size: 1.25rem;
  color: var(--text-primary);
}

.algorithm-content h4 {
  margin: 18px 0 8px;
  font-size: 1rem;
  color: var(--text-primary);
}

.algorithm-content p {
  color: var(--text-primary);
  line-height: 1.7;
}

.algorithm-content ul {
  margin: 8px 0 12px 1rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.algorithm-content li + li { margin-top: 6px; }

/* “Info stripe” look for nested bullet sections */
.algorithm-content ul ul {
  margin-top: 8px;
  padding-left: 1rem;
  border-left: 3px solid var(--border-color);
}

/* Concept grid (Data Structures & Concepts) */
.concept-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 18px;
  margin-top: 24px;
}

.concept-card {
  grid-column: span 6;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 20px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .25s ease, transform .25s ease, border-color .2s ease;
}

.concept-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(0,0,0,.08);
  border-color: rgba(59,130,246,.25);
}

.concept-card h3 {
  margin: 0 0 8px;
  font-size: 1.05rem;
  color: var(--text-primary);
}

.concept-card p {
  margin: 0;
  color: var(--text-secondary);
  line-height: 1.7;
}

/* Insights section (two-column blocks + comparison table) */
.insights-container {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 18px;
  margin-top: 24px;
}

.insight-block {
  grid-column: span 6;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.insight-block h3 {
  margin: 0 0 10px;
  color: var(--text-primary);
}

.insight-block p,
.insight-block ul {
  color: var(--text-secondary);
  line-height: 1.7;
}

.insight-block ul { margin-left: 1rem; }

.comparison-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin-top: 10px;
  font-size: .95rem;
  overflow: hidden;
  border-radius: 10px;
  border: 1px solid var(--border-color);
}

.comparison-table thead th {
  background: linear-gradient(0deg, rgba(59,130,246,.07), rgba(59,130,246,.07));
  color: var(--text-primary);
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-color);
}

.comparison-table tbody td {
  padding: 12px 14px;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-color);
}

.comparison-table tbody tr:hover {
  background: rgba(59,130,246,.05);
}

/* Complexity Theory section */
.theory-content {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 18px;
  margin-top: 24px;
}

.theory-block {
  grid-column: span 4;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.theory-block h3 {
  margin: 0 0 8px;
  color: var(--text-primary);
  font-size: 1.05rem;
}

.theory-block p,
.theory-block ul {
  color: var(--text-secondary);
  line-height: 1.7;
}

/* Accent rule to tie sections together */
.algorithm-card,
.concept-card,
.insight-block,
.theory-block {
  position: relative;
}
.algorithm-card::before,
.concept-card::before,
.insight-block::before,
.theory-block::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  border-radius: 12px 12px 0 0;
  background: linear-gradient(90deg, var(--accent-color), transparent 60%);
  opacity: .8;
}

/* Subtle reveal animation on scroll (optional) */
@keyframes cardFadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
.algorithm-card,
.concept-card,
.insight-block,
.theory-block {
  animation: cardFadeUp .5s ease both;
}

/* Responsive */
@media (max-width: 1024px) {
  .concept-card,
  .insight-block { grid-column: span 12; }
  .theory-block  { grid-column: span 6; }
}
@media (max-width: 640px) {
  .theory-block { grid-column: span 12; }
  .section-intro { text-align: left; }
}
