/* Root Cause Analysis Mode Styles */

.rootcause-analysis-view,
.rootcause-results {
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem;
}

.analysis-header {
    text-align: center;
    margin-bottom: 2rem;
}

.analysis-header h2 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary, #2d3748);
    margin-bottom: 1rem;
}

.whys-chain {
    background: white;
    border-radius: 16px;
    padding: 2rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    margin-bottom: 2rem;
}

.why-item {
    display: flex;
    gap: 1rem;
    padding: 1.5rem;
    background: var(--bg-secondary, #f7fafc);
    border-radius: 12px;
    border-left: 4px solid var(--primary, #667eea);
}

.why-item.initial {
    border-left-color: #e53e3e;
    background: #fff5f5;
}

.why-number {
    flex-shrink: 0;
    min-width: 48px;
    height: 48px;
    padding: 0 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary, #667eea);
    color: white;
    border-radius: 24px;
    font-weight: 700;
    font-size: 1rem;
}

.why-item.initial .why-number {
    background: #e53e3e;
    font-size: 1.5rem;
}

.why-content {
    flex: 1;
}

.why-question {
    font-size: 0.875rem;
    color: var(--text-secondary, #718096);
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.why-answer {
    font-size: 1.063rem;
    color: var(--text-primary, #2d3748);
    line-height: 1.6;
    font-weight: 500;
}

.why-arrow {
    text-align: center;
    font-size: 2rem;
    color: var(--primary, #667eea);
    margin: 0.5rem 0;
}

.current-why-section {
    background: white;
    border-radius: 16px;
    padding: 2rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

.current-why-section h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary, #2d3748);
    margin-bottom: 1rem;
}

.why-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
    justify-content: flex-end;
}

/* Results View */
.results-header {
    text-align: center;
    margin-bottom: 2rem;
}

.results-header h2 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary, #2d3748);
    margin-bottom: 0.5rem;
}

.results-header p {
    font-size: 1.125rem;
    color: var(--text-secondary, #718096);
}

.root-cause-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 16px;
    padding: 2rem;
    box-shadow: 0 8px 24px rgba(102, 126, 234, 0.3);
    margin-bottom: 2rem;
    text-align: center;
}

.root-cause-card h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1rem;
    opacity: 0.95;
}

.root-cause-text {
    font-size: 1.5rem;
    font-weight: 600;
    line-height: 1.6;
}

.analysis-chain {
    background: white;
    border-radius: 16px;
    padding: 2rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    margin-bottom: 2rem;
}

.analysis-chain h3 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary, #2d3748);
    margin-bottom: 1.5rem;
}

.insights-section {
    margin-bottom: 2rem;
}

.insights-section h3 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary, #2d3748);
    margin-bottom: 1.5rem;
}

.insights-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
}

.insight-card {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    text-align: center;
}

.insight-icon {
    font-size: 2.5rem;
    margin-bottom: 0.75rem;
}

.insight-card h4 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary, #2d3748);
    margin-bottom: 0.5rem;
}

.insight-card p {
    font-size: 0.938rem;
    color: var(--text-secondary, #718096);
    line-height: 1.6;
}

.action-planning {
    background: white;
    border-radius: 16px;
    padding: 2rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    margin-bottom: 2rem;
}

.action-planning h3 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary, #2d3748);
    margin-bottom: 1rem;
}

.results-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .rootcause-analysis-view,
    .rootcause-results {
        padding: 1rem;
    }
    
    .whys-chain,
    .current-why-section,
    .analysis-chain,
    .action-planning {
        padding: 1.5rem;
    }
    
    .why-item {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .insights-grid {
        grid-template-columns: 1fr;
    }
    
    .why-actions,
    .results-actions {
        flex-direction: column;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .whys-chain,
    .current-why-section,
    .analysis-chain,
    .action-planning,
    .insight-card {
        background: #1a202c;
    }
    
    .why-item {
        background: #2d3748;
    }
    
    .why-item.initial {
        background: #742a2a;
    }
    
    .form-textarea {
        background: #2d3748;
        border-color: #4a5568;
        color: #e2e8f0;
    }
    
    .form-textarea:focus {
        background: #2d3748;
        border-color: #667eea;
        color: #e2e8f0;
    }
    
    .form-textarea::placeholder {
        color: #a0aec0;
    }
}

/* Dark Mode Overrides */
body.theme-dark .rootcause-analysis-view,
body.theme-dark .rootcause-results {
    color: #f8fafc;
}

body.theme-dark .analysis-header h2,
body.theme-dark .results-header h2 {
    color: #f8fafc;
}

body.theme-dark .results-header p {
    color: #cbd5e0;
}

body.theme-dark .whys-chain {
    background: #1e293b; /* Darker background for container */
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

body.theme-dark .why-item {
    background: #2d3748; /* Slightly lighter than container */
    border-left: 4px solid #667eea;
}

body.theme-dark .why-item.initial {
    background: rgba(229, 62, 62, 0.15); /* Dark red tint */
    border-left-color: #e53e3e;
}

body.theme-dark .why-question {
    color: #a0aec0; /* Light grey for labels */
}

body.theme-dark .why-answer {
    color: #ffffff; /* White for main text */
}

body.theme-dark .current-why-section {
    background: #1e293b;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

body.theme-dark .current-why-section h3 {
    color: #f8fafc;
}

body.theme-dark .root-cause-card {
    background: linear-gradient(135deg, #553c9a 0%, #4c51bf 100%); /* Darker gradient */
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

body.theme-dark .root-cause-text {
    color: #ffffff;
}

body.theme-dark .insight-card {
    background: #2d3748;
    border: 1px solid #4a5568;
}

body.theme-dark .insight-card h4 {
    color: #f8fafc;
}

body.theme-dark .insight-card p {
    color: #cbd5e0;
}

body.theme-dark .solution-item {
    background: rgba(255, 255, 255, 0.08) !important;
}

body.theme-dark .solution-header h5 {
    color: #f8fafc;
}

body.theme-dark .solution-item p {
    color: #cbd5e0;
}

body.theme-dark .prevention-strategy {
    background: rgba(72, 187, 120, 0.15) !important;
    border-left-color: #48bb78;
}

body.theme-dark .prevention-strategy p {
    color: #e6fffa;
}
