/* ========================================
   DIAGRAM STYLES - Mermaid & ASCII Support
   ======================================== */

/* Common diagram block styling */
.diagram-block {
    margin: 15px 0;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    background: #ffffff;
}

.diagram-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.diagram-type {
    display: flex;
    align-items: center;
    gap: 8px;
}

.diagram-type i {
    font-size: 14px;
}

.diagram-actions {
    display: flex;
    gap: 8px;
}

.diagram-btn {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 4px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: all 0.2s ease;
}

.diagram-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-1px);
}

.diagram-btn:active {
    transform: translateY(0);
}

.diagram-btn i {
    font-size: 12px;
}

/* ========================================
   MERMAID DIAGRAM SPECIFIC STYLES
   ======================================== */

.mermaid-block .diagram-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.mermaid-container {
    padding: 20px;
    background: #fafafa;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 150px;
    overflow-x: auto;
}

.mermaid {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
}

.mermaid svg {
    max-width: 100%;
    height: auto;
}

/* Mermaid error display */
.mermaid-error {
    padding: 20px;
    background: #fee;
    border: 2px dashed #f88;
    border-radius: 6px;
    color: #c33;
    text-align: center;
}

.mermaid-error i {
    font-size: 24px;
    margin-bottom: 10px;
    display: block;
}

.mermaid-error p {
    margin: 10px 0;
    font-weight: 600;
}

.mermaid-error pre {
    margin-top: 15px;
    padding: 10px;
    background: #fff;
    border: 1px solid #fcc;
    border-radius: 4px;
    text-align: left;
    font-size: 12px;
    overflow-x: auto;
}

/* ========================================
   ASCII/TEXT DIAGRAM SPECIFIC STYLES
   ======================================== */

.ascii-block .diagram-header {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.ascii-diagram {
    background: #2d2d2d;
    color: #f8f8f2;
    padding: 20px;
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.4;
    overflow-x: auto;
    white-space: pre;
    margin: 0;
    border: none;
}

/* Alternative light theme for ASCII diagrams */
.ascii-diagram.light-theme {
    background: #f8f9fa;
    color: #2d3748;
    border: 1px solid #e2e8f0;
}

/* ========================================
   RESPONSIVE ADJUSTMENTS
   ======================================== */

@media (max-width: 768px) {
    .diagram-header {
        font-size: 11px;
        padding: 8px 12px;
    }
    
    .diagram-btn {
        padding: 3px 8px;
        font-size: 10px;
    }
    
    .mermaid-container {
        padding: 15px;
    }
    
    .ascii-diagram {
        font-size: 11px;
        padding: 15px;
    }
}

/* ========================================
   DARK MODE SUPPORT
   ======================================== */

@media (prefers-color-scheme: dark) {
    .diagram-block {
        background: #1e1e1e;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    }
    
    .mermaid-container {
        background: #2d2d2d;
    }
    
    /* Mermaid diagrams in dark mode */
    .mermaid svg {
        filter: brightness(0.9);
    }
}

/* ========================================
   ANIMATION & TRANSITIONS
   ======================================== */

.diagram-block {
    animation: fadeInSlide 0.3s ease-out;
}

@keyframes fadeInSlide {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ========================================
   PRINT STYLES
   ======================================== */

@media print {
    .diagram-header {
        background: #667eea !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    
    .diagram-actions {
        display: none;
    }
    
    .mermaid-container {
        background: white !important;
    }
    
    .ascii-diagram {
        background: white !important;
        color: black !important;
        border: 1px solid #ddd !important;
    }
}

/* ========================================
   ACCESSIBILITY
   ======================================== */

.diagram-btn:focus {
    outline: 2px solid rgba(255, 255, 255, 0.5);
    outline-offset: 2px;
}

.mermaid svg {
    /* Ensure diagrams are accessible */
    role: img;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .diagram-block {
        border: 2px solid currentColor;
    }
    
    .diagram-header {
        background: #000;
        color: #fff;
    }
    
    .diagram-btn {
        border: 2px solid currentColor;
    }
}
