/* Mermaid diagram fullscreen support */
.mermaid-fullscreen-wrapper {
    position: relative;
    margin-bottom: 1em;
}

.mermaid-fullscreen-btn {
    background: var(--md-primary-fg-color);
    color: var(--md-primary-bg-color);
    border: none;
    padding: 0.5em 1em;
    border-radius: 0.2em;
    cursor: pointer;
    font-size: 0.9em;
    transition: opacity 0.2s;
}

.mermaid-fullscreen-btn:hover {
    opacity: 0.9;
}

/* Fullscreen overlay for Mermaid diagrams */
.mermaid-fullscreen-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.95);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.mermaid-fullscreen-overlay.active {
    display: flex;
}

.mermaid-fullscreen-content {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: var(--md-default-bg-color);
    cursor: grab;
    user-select: none;
    touch-action: none; /* Prevent default touch behaviors */
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

.diagram-wrapper {
    display: inline-block;
    transition: transform 0.1s ease-out;
}

.mermaid-fullscreen-close {
    position: absolute;
    top: 1em;
    right: 1em;
    background: var(--md-primary-fg-color);
    color: var(--md-primary-bg-color);
    border: none;
    width: 3em;
    height: 3em;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.5em;
    line-height: 1;
    z-index: 10000;
    transition: opacity 0.2s;
}

.mermaid-fullscreen-close:hover {
    opacity: 0.9;
}

.mermaid-fullscreen-controls {
    position: absolute;
    top: 1em;
    left: 1em;
    display: flex;
    gap: 0.5em;
    z-index: 10000;
}

.mermaid-zoom-btn {
    background: var(--md-primary-fg-color);
    color: var(--md-primary-bg-color);
    border: none;
    width: 3em;
    height: 3em;
    border-radius: 0.3em;
    cursor: pointer;
    font-size: 1.2em;
    transition: opacity 0.2s;
}

.mermaid-zoom-btn:hover {
    opacity: 0.9;
}

/* Make Mermaid diagrams horizontally scrollable on smaller screens */
.mermaid {
    overflow-x: auto;
    max-width: 100%;
    opacity: 0;
    transition: opacity 0.3s ease-in;
}

.mermaid.mermaid-ready {
    opacity: 1;
}

/* Improve readability of LR flowcharts */
.mermaid svg {
    max-width: none;
    height: auto;
}

/* Loading spinner for Mermaid diagrams */
.mermaid-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    color: var(--md-primary-fg-color);
}

.mermaid-spinner {
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 4px solid rgba(0, 0, 0, 0.1);
    border-left-color: var(--md-primary-fg-color);
    border-radius: 50%;
    animation: mermaid-spin 1s linear infinite;
}

@keyframes mermaid-spin {
    to { transform: rotate(360deg); }
}

.mermaid-loading-text {
    margin-left: 1em;
    font-size: 0.9em;
}

/* Fix diamond (decision node) colors - use Material secondary container */
.mermaid svg .node polygon {
    fill: #e8def8 !important;  /* Material secondary container (light purple) */
    stroke: #7c4dff !important;  /* Material secondary (purple) */
}

.mermaid svg .node polygon + text,
.mermaid svg .node polygon ~ text {
    fill: #1d192b !important;  /* Dark text for light background */
}
