/* ============================================
   Diagram Embed - Public View Styles
   Красивое отображение диаграмм в публичной части
   ============================================ */

.article-diagram {
    display: block;
    margin: 32px 0;
    border-radius: 12px;
    overflow: hidden;
    background: #ffffff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 
                0 4px 12px rgba(0, 0, 0, 0.04);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.article-diagram:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12),
                0 8px 24px rgba(0, 0, 0, 0.08);
    transform: translateY(-2px);
}

/* Header с градиентом и иконкой */
.article-diagram__header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 24px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.article-diagram__icon {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    opacity: 0.9;
}

.article-diagram__title {
    flex: 1;
    font-size: 16px;
    font-weight: 600;
    letter-spacing: -0.01em;
    margin: 0;
}

/* SVG контейнер */
.article-diagram__content {
    padding: 32px;
    background: linear-gradient(135deg, #fafbfc 0%, #f7f9fc 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    position: relative;
    overflow: auto;
}

/* Декоративная сетка на фоне */
.article-diagram__content::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: 
        linear-gradient(rgba(0, 0, 0, 0.02) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 0, 0, 0.02) 1px, transparent 1px);
    background-size: 20px 20px;
    pointer-events: none;
    opacity: 0.5;
}

.article-diagram__svg {
    position: relative;
    z-index: 1;
    max-width: 100%;
    height: auto;
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.06));
}

.article-diagram__svg svg {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Footer с кнопкой полноэкранного просмотра */
.article-diagram__footer {
    display: flex;
    justify-content: flex-end;
    padding: 12px 24px;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
}

.article-diagram__fullscreen {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: white;
    color: #64748b;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.article-diagram__fullscreen:hover {
    background: #f1f5f9;
    border-color: #94a3b8;
    color: #475569;
}

.article-diagram__fullscreen svg {
    width: 16px;
    height: 16px;
}

/* Fullscreen modal */
.diagram-fullscreen-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10000;
    background: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(4px);
    animation: fadeIn 0.2s ease;
}

.diagram-fullscreen-modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.diagram-fullscreen-modal__content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    overflow: auto;
    animation: zoomIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.diagram-fullscreen-modal__svg {
    display: block;
}

.diagram-fullscreen-modal__svg svg {
    max-width: 100%;
    height: auto;
    display: block;
    background: white;
    border-radius: 8px;
    padding: 24px;
}

.diagram-fullscreen-modal__close {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    color: white;
    cursor: pointer;
    transition: all 0.2s;
    backdrop-filter: blur(8px);
}

.diagram-fullscreen-modal__close:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: rotate(90deg);
}

.diagram-fullscreen-modal__title {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    padding: 12px 24px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 24px;
    color: white;
    font-size: 14px;
    font-weight: 500;
    backdrop-filter: blur(8px);
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes zoomIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Responsive */
@media (max-width: 768px) {
    .article-diagram {
        margin: 24px -16px;
        border-radius: 0;
    }
    
    .article-diagram__header {
        padding: 12px 16px;
    }
    
    .article-diagram__title {
        font-size: 14px;
    }
    
    .article-diagram__content {
        padding: 24px 16px;
    }
    
    .diagram-fullscreen-modal.active {
        padding: 20px;
    }
    
    .diagram-fullscreen-modal__svg svg {
        padding: 16px;
    }
}

/* Dark theme support — привязано к теме сайта (data-theme), а не к ОС,
 * иначе контейнер темнеет по системной теме, рассинхронизируясь со светлой
 * темой страницы и со светлой SVG внутри. */
[data-theme="dark"] .article-diagram {
    background: #1e293b;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3),
                0 4px 12px rgba(0, 0, 0, 0.2);
}

[data-theme="dark"] .article-diagram__content {
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
}

[data-theme="dark"] .article-diagram__footer {
    background: #0f172a;
    border-top-color: #334155;
}

[data-theme="dark"] .article-diagram__fullscreen {
    background: #1e293b;
    border-color: #475569;
    color: #cbd5e1;
}

[data-theme="dark"] .article-diagram__fullscreen:hover {
    background: #334155;
    border-color: #64748b;
    color: #e2e8f0;
}
