/* =========================
   ALGORITHM VISUALIZATION STYLES
   ========================= */

/* =========================
   ALGORITHM INFO SECTION
   ========================= */
.algorithm-info {
    max-width: 1200px;
    margin: 0 auto 2rem;
    padding: 2rem;
    background: var(--bg-secondary);
    border-radius: 16px;
    border: 1px solid var(--border-color);
}

.algorithm-title {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 1rem;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.algorithm-description {
    font-size: 1.125rem;
    color: var(--text-secondary);
    line-height: 1.8;
    margin-bottom: 1.5rem;
}

.algorithm-metrics {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

.metric-badge.difficulty-Easy {
    background-color: #28a745;
    color: #ffffff;
}
.metric-badge.difficulty-Medium {
    background-color: #ffc107;
    color: #212529;
}
.metric-badge.difficulty-Hard {
    background-color: #dc3545;
    opacity: 2.;
    color: #ffffff;
}

/* Difficulty Indicator Bullet */
.difficulty-indicator {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 0.5rem;
    background-color: #94a3b8; /* default gray */
    transition: background-color 0.3s ease;
}

.metric-badge.difficulty-Easy .difficulty-indicator {
    background-color: #28a745; /* green */
}

.metric-badge.difficulty-Medium .difficulty-indicator {
    background-color: #ffc107; /* yellow */
}

.metric-badge.difficulty-Hard .difficulty-indicator {
    background-color: #dc3545; /* red */
}

.metric-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.9rem;
    color: var(--text-secondary);
    transition: all var(--transition-normal);
}

.metric-badge:hover {
    border-color: var(--primary-color);
    color: var(--primary-light);
}

.metric-label {
    font-weight: 600;
    color: var(--text-muted);
}

.metric-value {
    color: var(--text-primary);
}

/* =========================
   VISUALIZATION LAYOUT
   ========================= */
.viz-layout {
    max-width: 1200px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
}

.viz-main-section {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
}

/* Ensure array container is visible - higher specificity to override existing styles */
.viz-layout .viz-main-section #array-container,
.viz-page .viz-layout #array-container {
    position: relative;
    height: 300px;
    margin: 40px auto;
    border-bottom: 3px solid #333;
    background: #f9fafb;
    overflow: hidden;
    max-width: 1200px;
    display: block;
    visibility: visible;
}

/* =========================
   NAVIGATION CONTROLS (Previous, Auto, Next)
   ========================= */
.viz-page .viz-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin: 1.5rem auto;
    padding: 0.75rem 1.5rem;
    background: rgba(30, 41, 59, 0.95);
    border-radius: 12px;
    border: 1px solid rgba(148, 163, 184, 0.2);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    max-width: 1200px;
    width: 100%;
}

.viz-page .viz-controls button {
    flex: 1;
    min-width: 100px;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    border: 1px solid transparent;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all var(--transition-normal);
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

.viz-page .viz-controls button:hover {
    background: var(--bg-primary);
    border-color: var(--primary-color);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(99, 102, 241, 0.3);
}

/* Previous Button */
.viz-page .viz-controls #prevBtn {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.viz-page .viz-controls #prevBtn:hover {
    background: var(--bg-primary);
    border-color: var(--primary-color);
}

/* Next Button */
.viz-page .viz-controls #nextBtn {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.viz-page .viz-controls #nextBtn:hover {
    background: var(--bg-primary);
    border-color: var(--primary-color);
}

/* Auto/Play Button - Green Primary Action */
.viz-page .viz-controls #autoBtn {
    background: linear-gradient(135deg, #22c55e, #16a34a);
    color: white;
    box-shadow: 0 4px 12px rgba(34, 197, 94, 0.4);
    font-weight: 700;
}

.viz-page .viz-controls #autoBtn:hover {
    background: linear-gradient(135deg, #16a34a, #15803d);
    box-shadow: 0 6px 16px rgba(34, 197, 94, 0.5);
    transform: translateY(-2px);
}

.viz-page .viz-controls #autoBtn:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(34, 197, 94, 0.4);
}

/* =========================
   ENHANCED CONTROLS
   ========================= */

.control-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.control-row.centered {
    justify-content: center;
}

.control-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    font-weight: 600;
    font-size: 0.95rem;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all var(--transition-normal);
    color: white;
}

.control-btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.3);
}

.control-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(99, 102, 241, 0.4);
}

.control-btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.control-btn-secondary:hover {
    background: var(--bg-primary);
    border-color: var(--primary-color);
}

.control-btn-icon {
    width: 18px;
    height: 18px;
}

.progress-container {
    flex: 1;
    min-width: 200px;
}

.progress-label {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--bg-primary);
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    transition: width 0.3s ease;
}

/* =========================
   COLOR LEGEND
   ========================= */
.color-legend {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

.legend-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1rem;
}

.legend-items {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.legend-color {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    border: 1px solid var(--border-color);
}

.legend-color.unsorted {
    background-color: steelblue;
}

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

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

.legend-color.sorted {
    background-color: #22c55e;
}

.legend-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* Color Legend Panel Styles */
#colorLegendPanel {
    max-width: 1200px;
    margin: 2rem auto 0;
    padding: 2rem;
    background: var(--bg-secondary);
    border-radius: 16px;
    border: 1px solid var(--border-color);
}

#colorLegendPanel .panel-content {
    width: 100%;
}

#colorLegendPanel .legend-items {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

#colorLegendPanel .legend-row {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    justify-content: center;
}

#colorLegendPanel .legend-box {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

#colorLegendPanel .color-box {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    flex-shrink: 0;
}

#colorLegendPanel .box-default {
    background-color: steelblue;
}

#colorLegendPanel .box-comparing {
    background-color: #facc15;
}

#colorLegendPanel .box-sorted {
    background-color: #22c55e;
}

#colorLegendPanel .box-pivot {
    background-color: #800080;
}

#colorLegendPanel .box-min {
    background-color: #ff8c00;
}

#colorLegendPanel .box-swap {
    background-color: #ef4444;
}

#colorLegendPanel .legend-label {
    font-size: 0.95rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* =========================
   RESPONSIVE
   ========================= */
@media (max-width: 768px) {
    .algorithm-info {
        padding: 1.5rem;
    }

    .algorithm-title {
        font-size: 2rem;
    }

    .algorithm-description {
        font-size: 1rem;
    }

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

    .control-btn {
        width: 100%;
    }

    .progress-container {
        width: 100%;
    }

    /* Navigation controls responsive */
    .viz-page .viz-controls {
        flex-direction: column;
        gap: 0.5rem;
        padding: 1rem;
    }

    .viz-page .viz-controls button {
        width: 100%;
        min-width: unset;
    }

    /* Color legend responsive */
    #colorLegendPanel {
        padding: 1.5rem;
        margin: 1.5rem auto 0;
    }

    #colorLegendPanel .legend-row {
        flex-direction: column;
        gap: 1rem;
        align-items: center;
    }

    #colorLegendPanel .legend-box {
        width: 100%;
        justify-content: center;
    }
}

