﻿/* ========== CODE HIGHLIGHTING STYLES (Non-scoped for dynamic content) ========== */

/* Wrapper pour les blocs de code */
.code-block-wrapper {
    position: relative;
    margin: 1.5rem 0;
    border-radius: 8px;
    overflow: hidden;
    background: #1e1e1e;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* En-tête du bloc de code */
.code-block-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 1rem;
    background: rgba(0, 0, 0, 0.3);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    min-height: 2.5rem;
}

/* Nom du langage */
.code-block-language {
    font-size: 0.75rem;
    font-weight: 600;
    color: #9cdcfe;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    flex-shrink: 0;
}

/* Bouton de copie */
.code-copy-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.35rem 0.65rem;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    color: #d4d4d4;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
    flex-shrink: 0;
    margin-left: auto;
}

.code-copy-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.3);
    color: #ffffff;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.code-copy-btn:active {
    transform: translateY(0);
    box-shadow: none;
}

.code-copy-btn.copied {
    background: rgba(76, 175, 80, 0.15);
    border-color: rgba(76, 175, 80, 0.5);
    color: #4caf50;
}

.code-copy-btn.copied:hover {
    background: rgba(76, 175, 80, 0.2);
    transform: translateY(-1px);
}

.code-copy-btn i {
    font-size: 0.875rem;
}

.copy-text {
    font-weight: 500;
    font-size: 0.75rem;
    letter-spacing: 0.02em;
}

/* Zone de code */
.code-block-wrapper pre {
    margin: 0;
    padding: 1rem;
    background: transparent;
    overflow-x: auto;
    font-size: 0.875rem;
    line-height: 1.6;
}

.code-block-wrapper code {
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    background: transparent;
    padding: 0;
    border-radius: 0;
    color: #d4d4d4;
    display: block;
    white-space: pre;
    overflow-wrap: normal;
    word-break: normal;
}

/* Scrollbar personnalisée pour les blocs de code */
.code-block-wrapper pre::-webkit-scrollbar {
    height: 8px;
}

.code-block-wrapper pre::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
}

.code-block-wrapper pre::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 4px;
}

.code-block-wrapper pre::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.4);
}

/* Responsive */
@media (max-width: 767.98px) {
    .code-block-wrapper {
        margin: 1rem -1rem;
        border-radius: 0;
        border-left: none;
        border-right: none;
    }

    .code-block-header {
        padding: 0.4rem 0.75rem;
        min-height: 2.25rem;
    }
    
    .code-block-language {
        font-size: 0.7rem;
    }

    .code-copy-btn .copy-text {
        display: none;
    }

    .code-copy-btn {
        padding: 0.3rem 0.5rem;
        min-width: 32px;
        gap: 0;
    }
    
    .code-copy-btn i {
        font-size: 0.875rem;
    }
}

/* Support du thème clair */
[data-bs-theme="light"] .code-block-wrapper {
    background: #f8f9fa;
    border-color: #dee2e6;
}

[data-bs-theme="light"] .code-block-header {
    background: rgba(0, 0, 0, 0.03);
    border-bottom-color: #dee2e6;
}

[data-bs-theme="light"] .code-block-language {
    color: #0066cc;
}

[data-bs-theme="light"] .code-copy-btn {
    background: transparent;
    border-color: rgba(0, 0, 0, 0.15);
    color: #495057;
}

[data-bs-theme="light"] .code-copy-btn:hover {
    background: rgba(0, 0, 0, 0.05);
    border-color: rgba(0, 0, 0, 0.3);
    color: #212529;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

[data-bs-theme="light"] .code-copy-btn.copied {
    background: rgba(76, 175, 80, 0.1);
    border-color: rgba(76, 175, 80, 0.4);
    color: #2e7d32;
}

[data-bs-theme="light"] .code-copy-btn.copied:hover {
    background: rgba(76, 175, 80, 0.15);
}

[data-bs-theme="light"] .code-block-wrapper code {
    color: #212529;
}

/* Animation de chargement pour Prism */
@keyframes prism-loading {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

.code-block-wrapper code:not(.prism-highlighted) {
    animation: prism-loading 1.5s ease-in-out infinite;
}

/* Animation pour le bouton copié */
@keyframes copy-success {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.code-copy-btn.copied {
    animation: copy-success 0.3s ease-out;
}

/* ========== MERMAID DIAGRAMS ========== */

/* Wrapper pour les diagrammes Mermaid - similaire aux blocs de code */
.mermaid-wrapper {
    position: relative;
    margin: 1.5rem 0;
    border-radius: 8px;
    overflow: hidden;
    background: #1e1e1e;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* En-tête du diagramme Mermaid */
.mermaid-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 1rem;
    background: rgba(0, 0, 0, 0.3);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    min-height: 2.5rem;
}

/* Label du diagramme */
.mermaid-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: #9cdcfe;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    flex-shrink: 0;
}

/* Groupe de boutons dans l'en-tête */
.mermaid-buttons {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: auto;
}

/* Boutons de la barre d'outils Mermaid */
.mermaid-copy-btn,
.mermaid-fullscreen-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.35rem 0.65rem;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    color: #d4d4d4;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
    flex-shrink: 0;
}

.mermaid-copy-btn:hover,
.mermaid-fullscreen-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.3);
    color: #ffffff;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.mermaid-copy-btn:active,
.mermaid-fullscreen-btn:active {
    transform: translateY(0);
    box-shadow: none;
}

.mermaid-copy-btn.copied {
    background: rgba(76, 175, 80, 0.15);
    border-color: rgba(76, 175, 80, 0.5);
    color: #4caf50;
}

.mermaid-copy-btn.copied:hover {
    background: rgba(76, 175, 80, 0.2);
    transform: translateY(-1px);
}

.mermaid-copy-btn i,
.mermaid-fullscreen-btn i {
    font-size: 0.875rem;
}

.mermaid-copy-text,
.mermaid-fullscreen-text {
    font-weight: 500;
    font-size: 0.75rem;
    letter-spacing: 0.02em;
}

/* Conteneur du diagramme */
.mermaid-content {
    padding: 1.5rem;
    background: transparent;
    overflow-x: auto;
    display: flex;
    justify-content: center;
    align-items: center;
}

.mermaid-wrapper.mermaid-rendered .mermaid-content {
    padding: 1rem;
}

/* Diagrammes Mermaid avant rendu */
pre.mermaid {
    background: transparent;
    border: none;
    color: #d4d4d4;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.875rem;
    padding: 0;
    margin: 0;
    white-space: pre;
}

/* Conteneur du diagramme Mermaid rendu */
.mermaid-content div.mermaid {
    width: 100%;
}

/* Diagrammes Mermaid après rendu */
.mermaid-content svg {
    width: 100%;
    max-width: 100%;
    height: auto;
    display: block;
}

/* Modal plein écran pour Mermaid */
.mermaid-fullscreen-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    z-index: 9999;
    padding: 4rem 1rem 1rem 1rem;
    overflow-y: auto;
    overflow-x: hidden;
}

.mermaid-fullscreen-modal.active {
    display: block;
}

.mermaid-fullscreen-content {
    width: 100%;
    min-height: 100%;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 1rem 0;
}

.mermaid-fullscreen-content svg {
    width: 100% !important;
    height: auto !important;
    max-width: none !important;
    display: block;
    transition: transform 0.2s ease;
    cursor: zoom-in;
}

.mermaid-fullscreen-content svg.zoomed {
    cursor: zoom-out;
}

/* Barre d'outils en plein écran */
.mermaid-fullscreen-toolbar {
    position: fixed;
    top: 1rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 0.5rem;
    background: rgba(0, 0, 0, 0.8);
    padding: 0.5rem;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    backdrop-filter: blur(4px);
    z-index: 10001;
}

.mermaid-fullscreen-zoom-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 6px;
    color: #ffffff;
    font-size: 1rem;
    width: 2.5rem;
    height: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.mermaid-fullscreen-zoom-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.mermaid-fullscreen-zoom-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.mermaid-fullscreen-zoom-level {
    display: flex;
    align-items: center;
    color: #ffffff;
    font-size: 0.875rem;
    padding: 0 0.5rem;
    min-width: 4rem;
    justify-content: center;
}

.mermaid-fullscreen-close {
    position: fixed;
    top: 1rem;
    right: 1rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 6px;
    color: #ffffff;
    font-size: 1.5rem;
    width: 3rem;
    height: 3rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    backdrop-filter: blur(4px);
    z-index: 10000;
}

.mermaid-fullscreen-close:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

/* Erreur de rendu Mermaid */
pre.mermaid.mermaid-error {
    color: #f44336;
    padding: 1rem;
    background: rgba(244, 67, 54, 0.1);
    border: 1px solid rgba(244, 67, 54, 0.3);
    border-radius: 4px;
    font-size: 0.75rem;
    max-height: 200px;
    overflow: auto;
}

/* Alerte d'erreur Mermaid */
.mermaid-wrapper .alert {
    font-size: 0.875rem;
}

.mermaid-wrapper details {
    font-size: 0.75rem;
}

.mermaid-wrapper details summary {
    padding: 0.5rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
}

.mermaid-wrapper details[open] summary {
    margin-bottom: 0.5rem;
}

/* Thème clair pour Mermaid */
[data-bs-theme="light"] .mermaid-wrapper {
    background: #f8f9fa;
    border-color: #dee2e6;
}

[data-bs-theme="light"] .mermaid-header {
    background: rgba(0, 0, 0, 0.03);
    border-bottom-color: #dee2e6;
}

[data-bs-theme="light"] .mermaid-label {
    color: #0066cc;
}

[data-bs-theme="light"] .mermaid-copy-btn,
[data-bs-theme="light"] .mermaid-fullscreen-btn {
    background: transparent;
    border-color: rgba(0, 0, 0, 0.15);
    color: #495057;
}

[data-bs-theme="light"] .mermaid-copy-btn:hover,
[data-bs-theme="light"] .mermaid-fullscreen-btn:hover {
    background: rgba(0, 0, 0, 0.05);
    border-color: rgba(0, 0, 0, 0.3);
    color: #212529;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

[data-bs-theme="light"] .mermaid-copy-btn.copied {
    background: rgba(76, 175, 80, 0.1);
    border-color: rgba(76, 175, 80, 0.4);
    color: #2e7d32;
}

[data-bs-theme="light"] .mermaid-copy-btn.copied:hover {
    background: rgba(76, 175, 80, 0.15);
}

[data-bs-theme="light"] pre.mermaid {
    color: #212529;
}

[data-bs-theme="light"] pre.mermaid.mermaid-error {
    color: #c62828;
    background: rgba(198, 40, 40, 0.1);
    border-color: rgba(198, 40, 40, 0.3);
}

[data-bs-theme="light"] .mermaid-fullscreen-modal {
    background: rgba(255, 255, 255, 0.95);
}

[data-bs-theme="light"] .mermaid-fullscreen-toolbar {
    background: rgba(255, 255, 255, 0.9);
    border-color: rgba(0, 0, 0, 0.3);
}

[data-bs-theme="light"] .mermaid-fullscreen-zoom-btn {
    background: rgba(0, 0, 0, 0.05);
    border-color: rgba(0, 0, 0, 0.3);
    color: #212529;
}

[data-bs-theme="light"] .mermaid-fullscreen-zoom-btn:hover {
    background: rgba(0, 0, 0, 0.1);
}

[data-bs-theme="light"] .mermaid-fullscreen-zoom-level {
    color: #212529;
}

[data-bs-theme="light"] .mermaid-fullscreen-close {
    background: rgba(0, 0, 0, 0.1);
    border-color: rgba(0, 0, 0, 0.3);
    color: #212529;
}

[data-bs-theme="light"] .mermaid-fullscreen-close:hover {
    background: rgba(0, 0, 0, 0.2);
}

/* Animation de chargement pour Mermaid */
@keyframes mermaid-pulse {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

pre.mermaid:not(.mermaid-rendered):not(.mermaid-error) {
    animation: mermaid-pulse 1.5s ease-in-out infinite;
}

/* Responsive pour Mermaid */
@media (max-width: 767.98px) {
    .mermaid-wrapper {
        margin: 1rem -1rem;
        border-radius: 0;
        border-left: none;
        border-right: none;
    }
    
    .mermaid-header {
        padding: 0.4rem 0.75rem;
        min-height: 2.25rem;
    }
    
    .mermaid-label {
        font-size: 0.7rem;
    }
    
    .mermaid-content {
        padding: 1rem;
    }
    
    .mermaid-wrapper.mermaid-rendered .mermaid-content {
        padding: 0.75rem;
    }
    
    .mermaid-copy-btn .mermaid-copy-text,
    .mermaid-fullscreen-btn .mermaid-fullscreen-text {
        display: none;
    }

    .mermaid-copy-btn,
    .mermaid-fullscreen-btn {
        padding: 0.3rem 0.5rem;
        min-width: 32px;
        gap: 0;
    }
    
    .mermaid-copy-btn i,
    .mermaid-fullscreen-btn i {
        font-size: 0.875rem;
    }
    
    .mermaid-fullscreen-modal {
        padding: 1rem;
    }
    
    .mermaid-fullscreen-toolbar {
        top: 0.5rem;
        padding: 0.4rem;
        gap: 0.4rem;
    }
    
    .mermaid-fullscreen-zoom-btn {
        width: 2rem;
        height: 2rem;
        font-size: 0.875rem;
    }
    
    .mermaid-fullscreen-zoom-level {
        font-size: 0.75rem;
        min-width: 3rem;
        padding: 0 0.25rem;
    }
    
    .mermaid-fullscreen-close {
        width: 2.5rem;
        height: 2.5rem;
        font-size: 1.25rem;
        top: 0.5rem;
        right: 0.5rem;
    }
}

/* ========== YOUTUBE VIDEOS ========== */

/* Wrapper pour les vidéos YouTube avec ratio 16:9 */
.youtube-video-wrapper {
    margin: 1.5rem 0;
    width: 100%;
}

.youtube-video-container {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%; /* Ratio 16:9 */
    height: 0;
    overflow: hidden;
    border-radius: 8px;
    background: #000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.youtube-video-container iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
    border-radius: 8px;
}

/* Lien vers une chaîne YouTube */
.youtube-channel {
    margin: 1.5rem 0;
    padding: 1.25rem;
    background: linear-gradient(135deg, #FF0000 0%, #CC0000 100%);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(255, 0, 0, 0.2);
}

.youtube-channel-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: white !important;
    text-decoration: none !important;
    font-weight: 500;
    font-size: 1rem;
    transition: opacity 0.2s ease;
}

.youtube-channel-link:hover {
    opacity: 0.9;
}

.youtube-icon {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
}

/* Thème clair */
[data-bs-theme="light"] .youtube-video-container {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Responsive */
@media (max-width: 767.98px) {
    .youtube-video-wrapper {
        margin: 1rem -0.5rem;
    }
    
    .youtube-channel {
        margin: 1rem -0.5rem;
        border-radius: 4px;
    }
}
