/* Enhanced Algorithm Controls - Horizontal Layout */
.enhanced-algorithm-controls {
    margin: 2rem 0 1.5rem 0;
    padding: 1rem 1.5rem;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    background: #f9fafb;
    clear: both;
    overflow: hidden;
    transition: max-height 0.3s ease-out,
                opacity 0.3s ease-out;
    max-height: 300px !important;
    opacity: 1 !important;
    display: block !important;
}

.inline-settings-label {
    font-weight: 600;
    font-size: 0.95rem;
    color: #374151;
    white-space: nowrap;
}

.control-separator {
    color: #9ca3af;
    font-weight: 400;
    font-size: 1rem;
    display: flex;
    align-items: center;
    margin: 0 0.5rem;
}

.enhanced-algorithms-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Enhanced algorithms active state - same as minimal view */
body.enhanced-algorithms-active .enhanced-algorithms-toggle .toggle-track {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

body.enhanced-algorithms-active .enhanced-algorithms-toggle .toggle-thumb {
    transform: translateX(14px);
    background: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

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

.accordion-header {
    width: 100%;
    padding: 1rem 1.5rem;
    background: #f8fafc;
    border: none;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 600;
    font-size: 1rem;
    color: #374151;
    text-align: left;
}

.accordion-header:hover {
    background: #f1f5f9;
    color: #1e40af;
}

.accordion-header[aria-expanded="true"] {
    background: #dbeafe;
    color: #1e40af;
    border-bottom-color: var(--primary-color);
}

.accordion-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.accordion-icon {
    transition: transform 0.2s ease;
    color: #6b7280;
}

.accordion-header[aria-expanded="true"] .accordion-icon {
    transform: rotate(180deg);
    color: #1e40af;
}

.accordion-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, padding 0.3s ease;
    padding: 0 1.5rem;
}

.accordion-content[aria-hidden="false"] {
    max-height: 1000px;
    padding: 1.5rem;
}

/* Enhanced Algorithm Controls */
.algorithm-config {
    margin: 1.5rem 0;
    padding: 1.5rem;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    background: #f9fafb;
    transition: all 0.3s ease;
}

.algorithm-config .config-label {
    display: block;
    font-weight: 600;
    font-size: 1rem;
    color: #374151;
    margin-bottom: 1rem;
}

.algorithm-controls {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

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

.toggle-control {
    display: flex;
    align-items: center;
}

.toggle-container {
    display: flex;
    align-items: center;
    cursor: pointer;
    user-select: none;
    gap: 0.75rem;
    position: relative;
}

.toggle-container input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 32px;
    height: 18px;
    margin: 0;
    cursor: pointer;
}

.toggle-container input[type="checkbox"]:focus {
    outline: none;
}

.toggle-container input[type="checkbox"]:focus + .toggle-track {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgba(var(--primary-color-rgb), 0.1);
}

.toggle-container input[type="checkbox"]:focus-visible + .toggle-track {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgba(var(--primary-color-rgb), 0.2);
}

.toggle-track {
    position: relative;
    width: 32px;
    height: 18px;
    background: #d1d5db;
    border: 1px solid #d1d5db;
    border-radius: 9px;
    transition: all 0.2s ease;
    cursor: pointer;
    outline: none;
    padding: 0;
}

.toggle-thumb {
    position: absolute;
    top: 1px;
    left: 1px;
    width: 14px;
    height: 14px;
    background: white;
    border-radius: 50%;
    transition: all 0.2s ease;
    border: 1px solid #d1d5db;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.toggle-container input[type="checkbox"]:checked + .toggle-track {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

.toggle-container input[type="checkbox"]:checked + .toggle-track .toggle-thumb {
    transform: translateX(14px);
}

.toggle-text {
    font-size: 0.9rem;
    color: #4b5563;
    font-weight: 500;
}

.select-control {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.select-label {
    font-size: 0.9rem;
    color: #6b7280;
    white-space: nowrap;
}

.algorithm-select {
    padding: 0.5rem 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background: white;
    font-size: 0.9rem;
    color: #374151;
    outline: none;
    transition: border-color 0.2s ease;
}

.algorithm-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(var(--primary-color-rgb), 0.1);
}

.algorithm-options {
    margin-left: 1rem;
    padding-left: 1rem;
    border-left: 2px solid #e5e7eb;
}

.enhanced-algorithm-controls.disabled .algorithm-options-row {
    opacity: 0.5;
    pointer-events: none;
}

.enhanced-algorithm-controls.disabled .algorithm-options-row * {
    pointer-events: none;
}

/* Quality Metrics Panel */
.quality-metrics-panel {
    margin: 1.5rem 0;
    padding: 1.5rem;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    transition: all 0.3s ease;
}

.quality-metrics-panel .config-label {
    display: block;
    font-weight: 600;
    font-size: 1rem;
    color: #0f172a;
    margin-bottom: 1rem;
}

.quality-metrics-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1rem;
}

.metric-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.75rem 1rem;
    background: white;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    flex: 1;
    min-width: 120px;
}

.metric-label {
    font-size: 0.85rem;
    color: #6b7280;
    margin-bottom: 0.5rem;
    text-align: center;
}

.metric-value {
    font-size: 1.5rem;
    font-weight: 700;
    text-align: center;
}

.metric-excellent {
    color: #059669;
}

.metric-good {
    color: #0284c7;
}

.metric-fair {
    color: #d97706;
}

.metric-poor {
    color: #dc2626;
}

.quality-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #e5e7eb;
}

.detail-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem;
    background: rgba(255,255,255,0.5);
    border-radius: 6px;
}

.detail-label {
    font-size: 0.8rem;
    color: #6b7280;
    font-weight: 500;
}

.detail-value {
    font-size: 0.8rem;
    color: #374151;
    font-weight: 600;
}

/* Preview Algorithm Indicator */
.preview-algorithm-indicator {
    position: absolute;
    top: 1rem;
    right: 1rem;
    padding: 0.5rem 1rem;
    background: rgba(0,0,0,0.1);
    border-radius: 20px;
    font-size: 0.8rem;
    color: #6b7280;
    transition: all 0.3s ease;
}

.preview-algorithm-indicator.enhanced-active {
    background: linear-gradient(135deg, var(--primary-color), #1d4ed8);
    color: white;
    box-shadow: 0 4px 12px rgba(var(--primary-color-rgb), 0.3);
}

/* Responsive Design */
@media (max-width: 768px) {
    .control-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    
    .quality-metrics-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }
    
    .quality-details {
        grid-template-columns: 1fr;
    }
}

/* Dark Theme Support */
@media (prefers-color-scheme: dark) {
    .advanced-settings-accordion {
        background: #1f2937;
        border-color: #374151;
    }
    
    .accordion-header {
        background: #374151;
        border-bottom-color: #4b5563;
        color: #f9fafb;
    }
    
    .accordion-header:hover {
        background: #4b5563;
        color: #60a5fa;
    }
    
    .accordion-header[aria-expanded="true"] {
        background: #1e3a8a;
        color: #60a5fa;
        border-bottom-color: var(--primary-color);
    }
    
    .accordion-icon {
        color: #9ca3af;
    }
    
    .accordion-header[aria-expanded="true"] .accordion-icon {
        color: #60a5fa;
    }
    
    .algorithm-config,
    .quality-metrics-panel,
    .enhanced-algorithm-controls {
        background: #1f2937;
        border-color: #374151;
    }
    
    .algorithm-config .config-label,
    .quality-metrics-panel .config-label,
    .inline-settings-label {
        color: #f9fafb;
    }
    
    .control-separator {
        color: #6b7280;
    }
    
    /* Toggle controls in dark mode */
    .enhanced-algorithm-controls .toggle-text {
        color: #d1d5db;
    }
    
    .enhanced-algorithm-controls .toggle-track {
        background: #374151;
        border-color: #4b5563;
    }
    
    .enhanced-algorithm-controls .toggle-thumb {
        background: #1f2937;
        border-color: #4b5563;
    }
    
    .enhanced-algorithm-controls .toggle-container input[type="checkbox"]:checked + .toggle-track {
        background: var(--primary-color);
        border-color: var(--primary-color);
    }
    
    .enhanced-algorithm-controls .toggle-container input[type="checkbox"]:checked + .toggle-track .toggle-thumb {
        background: #ffffff;
        border-color: rgba(255, 255, 255, 0.2);
    }
    
    /* Select control in dark mode */
    .enhanced-algorithm-controls .select-label {
        color: #9ca3af;
    }
    
    .enhanced-algorithm-controls .algorithm-select {
        background: #374151;
        border-color: #4b5563;
        color: #f9fafb;
    }
    
    .enhanced-algorithm-controls .algorithm-select:focus {
        border-color: var(--primary-color);
        box-shadow: 0 0 0 3px rgba(var(--primary-color-rgb), 0.3);
    }
    
    .toggle-text {
        color: #d1d5db;
    }
    
    .select-label {
        color: #9ca3af;
    }
    
    .algorithm-select {
        background: #374151;
        border-color: #4b5563;
        color: #f9fafb;
    }
    
    .algorithm-select:focus {
        border-color: var(--primary-color);
        box-shadow: 0 0 0 3px rgba(var(--primary-color-rgb), 0.3);
    }
    
    .metric-item {
        background: #374151;
        color: #f9fafb;
    }
    
    .detail-item {
        background: rgba(55, 65, 81, 0.5);
    }
    
    .detail-label {
        color: #9ca3af;
    }
    
    .detail-value {
        color: #f3f4f6;
    }
}