/* Flowchart Block Styles - Scoped to prevent conflicts */

.flowchart-block-container {
    margin: 2rem 0;
    padding: 0;
}

.flowchart-wrapper {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.05));
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.37);
}

.flowchart-heading {
    color: #fff;
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    text-align: center;
    font-family: inherit;
}

.flowchart-content {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 200px;
    max-width: 100%;
    overflow: hidden;
}

/* Mermaid.js Custom Theme Overrides */
.flowchart-block-container .mermaid-flowchart {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
}

/* Custom Mermaid SVG styling */
.flowchart-block-container .mermaid-flowchart svg {
    max-width: 100%;
    max-height: 500px;
    height: auto;
    width: auto !important;
}

/* Specific adjustments for different diagram types */
.flowchart-block-container .mermaid-flowchart svg[data-type*="sequence"] {
    max-height: 600px;
}

.flowchart-block-container .mermaid-flowchart svg[data-type*="gantt"] {
    max-height: 400px;
    max-width: 100%;
}

.flowchart-block-container .mermaid-flowchart svg[data-type*="pie"] {
    max-height: 350px;
    max-width: 350px;
}

/* Override Mermaid default styles to match theme */
.flowchart-block-container .mermaid-flowchart .node rect,
.flowchart-block-container .mermaid-flowchart .node circle,
.flowchart-block-container .mermaid-flowchart .node ellipse,
.flowchart-block-container .mermaid-flowchart .node polygon {
    fill: rgba(59, 130, 246, 0.9) !important;
    stroke: rgba(255, 255, 255, 0.3) !important;
    stroke-width: 2px !important;
}

.flowchart-block-container .mermaid-flowchart .nodeLabel {
    color: #fff !important;
    font-family: inherit !important;
    font-size: 14px !important;
    font-weight: 500 !important;
}

.flowchart-block-container .mermaid-flowchart .edgePath .path {
    stroke: rgba(255, 255, 255, 0.6) !important;
    stroke-width: 2px !important;
}

.flowchart-block-container .mermaid-flowchart .arrowheadPath {
    fill: rgba(255, 255, 255, 0.6) !important;
    stroke: rgba(255, 255, 255, 0.6) !important;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .flowchart-wrapper {
        padding: 1.5rem;
        margin: 1rem 0;
    }
    
    .flowchart-heading {
        font-size: 1.25rem;
        margin-bottom: 1rem;
    }
    
    .flowchart-block-container .mermaid-flowchart .nodeLabel {
        font-size: 12px !important;
    }
}

@media (max-width: 480px) {
    .flowchart-wrapper {
        padding: 1rem;
    }
    
    .flowchart-heading {
        font-size: 1.125rem;
    }
    
    .flowchart-block-container .mermaid-flowchart .nodeLabel {
        font-size: 11px !important;
    }
}

/* Loading state */
.flowchart-block-container .mermaid-flowchart[data-processed="false"] {
    min-height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.6);
    font-style: italic;
}

.flowchart-block-container .mermaid-flowchart[data-processed="false"]:before {
    content: "Loading flowchart...";
}

/* Error state */
.flowchart-block-container .mermaid-flowchart.error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 8px;
    padding: 1rem;
    color: #fca5a5;
    text-align: center;
}

/* Accessibility improvements */
.flowchart-block-container .mermaid-flowchart svg {
    outline: none;
}

.flowchart-block-container .mermaid-flowchart svg:focus {
    outline: 2px solid rgba(59, 130, 246, 0.5);
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .flowchart-block-container .mermaid-flowchart .node rect,
    .flowchart-block-container .mermaid-flowchart .node circle,
    .flowchart-block-container .mermaid-flowchart .node ellipse,
    .flowchart-block-container .mermaid-flowchart .node polygon {
        stroke: #fff !important;
        stroke-width: 3px !important;
    }
    
    .flowchart-block-container .mermaid-flowchart .edgePath .path,
    .flowchart-block-container .mermaid-flowchart .arrowheadPath {
        stroke: #fff !important;
        stroke-width: 3px !important;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .flowchart-block-container .mermaid-flowchart * {
        animation: none !important;
        transition: none !important;
    }
}