/* Mindmap Button */
.mindmap-button {
    position: fixed;
    top: 20px;
    right: 80px;
    background: #48bb78;
    color: white;
    border: none;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    font-size: 1.2rem;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(72, 187, 120, 0.3);
    transition: all 0.3s ease;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mindmap-button:hover {
    background: #38a169;
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(72, 187, 120, 0.4);
}

/* Mindmap Panel */
.mindmap-panel {
    position: fixed;
    top: 80px;
    right: 20px;
    width: 80vw;
    max-width: 900px;
    max-height: 80vh;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    z-index: 999;
    transform: translateX(100%);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    border: 1px solid #e1e5e9;
}

.mindmap-panel.visible {
    transform: translateX(0);
    opacity: 1;
    visibility: visible;
}

.mindmap-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #e1e5e9;
    background: #f8f9fa;
    border-radius: 12px 12px 0 0;
}

.mindmap-header h3 {
    margin: 0;
    font-size: 1.1rem;
    color: #333;
}

.mindmap-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.mindmap-control-btn {
    background: none;
    border: 1px solid #ddd;
    color: #666;
    font-size: 0.9rem;
    cursor: pointer;
    padding: 6px 8px;
    border-radius: 4px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
}

.mindmap-control-btn:hover {
    background: #e9ecef;
    color: #333;
    border-color: #bbb;
}

.mindmap-divider {
    width: 1px;
    height: 20px;
    background: #ddd;
    margin: 0 8px;
}

.mindmap-close {
    background: none;
    border: none;
    color: #666;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
}

.mindmap-close:hover {
    background: #e9ecef;
    color: #333;
}

.mindmap-content {
    padding: 1.5rem;
    max-height: calc(80vh - 80px);
    overflow: auto;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
}

.mindmap-empty {
    color: #666;
    font-style: italic;
    text-align: center;
    margin: 2rem 0;
}

.mindmap-diagram {
    width: 100%;
    height: auto;
    min-height: 500px;
    transition: transform 0.3s ease;
    transform-origin: center center;
    cursor: grab;
    user-select: none;
    background: radial-gradient(circle at center, rgba(255,255,255,0.8) 0%, rgba(248,250,252,0.9) 100%);
    border-radius: 8px;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.05);
}

.mindmap-diagram:hover {
    cursor: grab;
}

.mindmap-diagram:active {
    cursor: grabbing;
}

.mindmap-diagram.zoomed {
    cursor: grab;
}

.mindmap-diagram.zoomed:active {
    cursor: grabbing;
}

/* Mindmap text styling */
.mindmap-diagram svg text {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
    text-anchor: middle !important;
    dominant-baseline: central !important;
    font-weight: 600 !important;
    font-size: 13px !important;
}

/* Mindmap node backgrounds */
.mindmap-diagram svg .mindmap-node path,
.mindmap-diagram svg g[class*="section-"] path {
    fill: #f8f9fa !important;
    stroke: #e9ecef !important;
    stroke-width: 1px !important;
}

/* Root node styling - rectangular with prominent border */
.mindmap-diagram svg .section-root path,
.mindmap-diagram svg .section--1 path {
    rx: 0px !important;
    ry: 0px !important;
    fill: #ffffff !important;
    stroke: #333333 !important;
    stroke-width: 2px !important;
}

/* Force root node to be rectangular instead of cloud */
.mindmap-diagram svg .section-root .node-cloud,
.mindmap-diagram svg .section--1 .node-cloud {
    display: none !important;
}

.mindmap-diagram svg .section-root .node-bkg,
.mindmap-diagram svg .section--1 .node-bkg {
    display: block !important;
}


.mindmap-diagram svg .section-root text,
.mindmap-diagram svg .section--1 text {
    font-size: 10px !important;
    font-weight: 700 !important;
    fill: #333333 !important;
    text-anchor: middle !important;
    dominant-baseline: central !important;
}

/* Hide paperclip icon in root node */
.mindmap-diagram svg .section-root .icon,
.mindmap-diagram svg .section--1 .icon,
.mindmap-diagram svg .section-root use,
.mindmap-diagram svg .section--1 use {
    display: none !important;
}

/* Ensure root node is properly centered and balanced */
.mindmap-diagram svg .section-root,
.mindmap-diagram svg .section--1 {
    transform-origin: center center !important;
}


/* D3.js Interactive Mindmap Styles */
.mindmap-diagram svg {
    cursor: grab;
    filter: drop-shadow(0 2px 8px rgba(0,0,0,0.08));
}

.mindmap-diagram svg:active {
    cursor: grabbing;
}

.mindmap-diagram .node {
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.mindmap-diagram .node rect {
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.mindmap-diagram .node text {
    user-select: none;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.mindmap-diagram .links line {
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Enhanced node states */
.mindmap-diagram .node:hover {
    filter: drop-shadow(0 4px 12px rgba(0,0,0,0.15));
}

.mindmap-diagram .node.dragging {
    filter: drop-shadow(0 8px 20px rgba(0,0,0,0.25));
}

/* Legacy Mermaid.js styles (kept for compatibility) */
.mindmap-diagram svg path[stroke],
.mindmap-diagram svg line,
.mindmap-diagram svg .edgePath path,
.mindmap-diagram svg .edgePath marker,
.mindmap-diagram svg .edge,
.mindmap-diagram svg .flowchart-link,
.mindmap-diagram svg .mindmap-link {
    stroke: #cccccc !important;
    stroke-width: 1px !important;
    fill: none !important;
}

/* Fullscreen Modal */
.mindmap-fullscreen-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: linear-gradient(135deg, rgba(248,250,252,0.98) 0%, rgba(241,245,249,0.98) 100%);
    backdrop-filter: blur(20px);
    z-index: 9999;
    display: none;
    flex-direction: column;
}

.mindmap-fullscreen-modal.visible {
    display: flex;
}

.mindmap-fullscreen-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.mindmap-fullscreen-header h3 {
    margin: 0;
    font-size: 1.2rem;
    color: #333;
}

.mindmap-fullscreen-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.mindmap-fullscreen-close {
    background: none;
    border: none;
    color: #666;
    font-size: 1.4rem;
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
}

.mindmap-fullscreen-close:hover {
    background: rgba(0, 0, 0, 0.1);
    color: #333;
}

.mindmap-fullscreen-content {
    flex: 1;
    padding: 2rem;
    overflow: auto;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mindmap-fullscreen-content .mindmap-diagram {
    width: 100%;
    height: 100%;
    min-height: auto;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Responsive Design */
@media (max-width: 768px) {
    .mindmap-button {
        top: 15px;
        right: 70px;
        width: 45px;
        height: 45px;
        font-size: 1.1rem;
    }

    .mindmap-panel {
        top: 70px;
        right: 15px;
        left: 15px;
        width: auto;
        max-width: none;
        max-height: 70vh;
    }

    .mindmap-controls {
        gap: 4px;
    }

    .mindmap-control-btn {
        width: 28px;
        height: 28px;
        font-size: 0.8rem;
    }

    .mindmap-fullscreen-header {
        padding: 0.8rem 1rem;
    }

    .mindmap-fullscreen-content {
        padding: 1rem;
    }
}

/* Mindmap spider edges */
.edge-depth-0 {
	filter: brightness(0.2) !important;
}
.edge-depth-1 {
	filter: brightness(0.6) !important;
}
.edge-depth-2 {
	filter: brightness(0.9) !important;
}

/* Hide mindmap placeholder images */
.img-wrapper:has(img[src*="1x1"]), .img-wrapper:has(img[src$="1x1.png"]) {
    display: none !important;
}

/* Mindmap Type Tooltip */
.mindmap-type-tooltip {
    position: absolute;
    right: 100%;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(45, 55, 72, 0.95);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    backdrop-filter: blur(10px);
    z-index: 10001;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
    white-space: nowrap;
    margin-right: 8px;
}

.mindmap-type-tooltip.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(-50%) translateX(-4px);
}

/* Tooltip arrow */
.mindmap-type-tooltip::after {
    content: '';
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    border: 4px solid transparent;
    border-left-color: rgba(45, 55, 72, 0.95);
}

/* Container for cycle buttons to position tooltip relative to them */
.mindmap-control-btn {
    position: relative;
}