{% load static %}
<!DOCTYPE html>
<html lang="fr" data-bs-theme="dark">
<head>
    <!-- ============================================ -->
    <!-- META TAGS & SEO                              -->
    <!-- ============================================ -->
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="{{ site_settings.meta_description|default:'Portfolio Architecte Logiciel Senior - Cyberpunk Interface' }}">
    <meta name="theme-color" content="#050505">
    
    <title>{% block title %}{{ site_settings.site_title|default:'Portfolio | Architecte Logiciel' }}{% endblock %}</title>
    
    {% if site_settings.favicon %}
    <link rel="icon" type="image/png" href="{{ site_settings.favicon.url }}">
    {% endif %}
    
    <!-- ============================================ -->
    <!-- CDN DEPENDENCIES - AVEC CROSSORIGIN          -->
    <!-- ============================================ -->
    
    <!-- Bootstrap 5 -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" 
          rel="stylesheet" 
          crossorigin="anonymous">
    
    <!-- FontAwesome 6 -->
    <link rel="stylesheet" 
          href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css" 
          crossorigin="anonymous" 
          referrerpolicy="no-referrer">
    
    <!-- Google Fonts -->
    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <link href="https://fonts.googleapis.com/css2?family=Orbitron:wght@400;500;700;900&family=Rajdhani:wght@300;400;500;600;700&family=Inter:wght@300;400;500;600&display=swap" 
          rel="stylesheet">
    
    {% block extra_css %}{% endblock %}
    
    <style>
        /* ============================================ */
        /* 1. CSS VARIABLES - PALETTE GLOBALE           */
        /* ============================================ */
        :root {
            /* Couleurs Principales */
            --bg-dark: #050505;
            --bg-secondary: #0a0a12;
            --text-main: #e0e0e0;
            --text-secondary: #a0a0a0;
            --neon-cyan: #00f3ff;
            --neon-purple: #bf00ff;
            --copper: #b87333;
            --cp-yellow: #fcee0a;
            --border-subtle: rgba(0, 243, 255, 0.15);
            
            /* Dimensions */
            --sidebar-width: 300px;
            --mobile-header-height: 70px;
            --mobile-nav-height: 75px;
            
            /* Typographie */
            --font-title: 'Orbitron', sans-serif;
            --font-tech: 'Rajdhani', sans-serif;
            --font-body: 'Inter', sans-serif;
            
            /* Z-index Layers */
            --z-base: 1;
            --z-sidebar: 100;
            --z-mobile-header: 1000;
            --z-mobile-nav: 1000;
            --z-offcanvas: 1050;
            --z-global-modal: 1055;
            --z-messages: 9999;
        }
        
        /* ============================================ */
        /* 2. RESET & TYPOGRAPHIE DE BASE               */
        /* ============================================ */
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        
        html {
            scroll-behavior: smooth;
        }
        
        body {
            font-family: var(--font-body);
            background: var(--bg-dark);
            color: var(--text-main);
            line-height: 1.6;
            overflow-x: hidden;
        }
        
        h1, h2, h3, h4, h5, h6 {
            font-family: var(--font-title);
            font-weight: 700;
            color: var(--text-main);
        }
        
        p, li, span {
            font-family: var(--font-tech);
        }
        
        a {
            color: var(--neon-cyan);
            text-decoration: none;
            transition: color 0.3s ease;
        }
        
        a:hover {
            color: var(--neon-purple);
        }
        
        /* ============================================ */
        /* 3. LAYOUT DESKTOP (≥ 992px) - FLEXBOX        */
        /* ============================================ */
        .app-wrapper {
            display: flex;
            min-height: 100vh;
        }
        
        @media (min-width: 992px) {
            .sidebar-area {
                width: var(--sidebar-width);
                min-height: 100vh;
                position: fixed;
                top: 0;
                left: 0;
                background: linear-gradient(180deg, var(--bg-dark) 0%, var(--bg-secondary) 100%);
                border-right: 1px solid var(--border-subtle);
                overflow-y: auto;
                overflow-x: hidden;
                z-index: var(--z-sidebar);
            }
            
            .main-area {
                flex: 1;
                margin-left: var(--sidebar-width);
                padding: 50px 60px;
                min-height: 100vh;
                position: relative;
                z-index: var(--z-base);
            }
            
            /* Masquer les éléments mobiles sur Desktop */
            .mobile-header,
            .mobile-bottom-nav {
                display: none !important;
            }
        }
        
        /* ============================================ */
        /* 4. LAYOUT MOBILE (< 992px) - SAFE AREAS      */
        /* ============================================ */
        @media (max-width: 991px) {
            .sidebar-area {
                display: none;
            }
            
            .main-area {
                flex: 1;
                width: 100%;
                /* Safe area pour éviter le chevauchement */
                padding-top: calc(var(--mobile-header-height) + 20px);
                padding-bottom: calc(var(--mobile-nav-height) + 20px);
                padding-left: 20px;
                padding-right: 20px;
                min-height: 100vh;
            }
        }
        
        /* ============================================ */
        /* 5. MOBILE HEADER (Structure uniquement)      */
        /* ============================================ */
        .mobile-header {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            height: var(--mobile-header-height);
            background: rgba(5, 5, 5, 0.95);
            backdrop-filter: blur(10px);
            border-bottom: 1px solid var(--border-subtle);
            z-index: var(--z-mobile-header);
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 0 20px;
        }
        
        .mobile-identity {
            display: flex;
            align-items: center;
            gap: 12px;
        }
        
        .mobile-avatar {
            width: 45px;
            height: 45px;
            border-radius: 50%;
            border: 2px solid var(--neon-cyan);
            object-fit: cover;
        }
        
        /* Avatar CSS par défaut (pas d'image externe) */
        .mobile-avatar-fallback {
            width: 45px;
            height: 45px;
            border-radius: 50%;
            border: 2px solid var(--neon-cyan);
            background: linear-gradient(135deg, var(--neon-cyan) 0%, var(--neon-purple) 100%);
            display: flex;
            align-items: center;
            justify-content: center;
            font-family: var(--font-title);
            font-size: 1.2rem;
            font-weight: 900;
            color: #fff;
            text-shadow: 0 0 10px rgba(0, 243, 255, 0.8);
        }
        
        .mobile-name {
            font-family: var(--font-title);
            font-size: 0.9rem;
            font-weight: 700;
            letter-spacing: 1px;
            text-transform: uppercase;
            color: var(--neon-cyan);
            margin: 0;
        }
        
        .mobile-title {
            font-family: var(--font-tech);
            font-size: 0.75rem;
            font-weight: 300;
            color: var(--text-secondary);
            margin: 0;
            text-transform: uppercase;
            letter-spacing: 0.5px;
        }
        
        .btn-menu-toggle {
            background: rgba(0, 243, 255, 0.1);
            border: 1px solid var(--neon-cyan);
            color: var(--neon-cyan);
            width: 45px;
            height: 45px;
            border-radius: 8px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 1.2rem;
            cursor: pointer;
            transition: all 0.3s ease;
        }
        
        .btn-menu-toggle:hover {
            background: var(--neon-cyan);
            color: var(--bg-dark);
            box-shadow: 0 0 20px rgba(0, 243, 255, 0.5);
        }
        
        /* ============================================ */
        /* 6. MOBILE BOTTOM NAVIGATION                  */
        /* ============================================ */
        .mobile-bottom-nav {
            position: fixed;
            bottom: 0;
            left: 0;
            right: 0;
            height: var(--mobile-nav-height);
            background: rgba(5, 5, 5, 0.95);
            backdrop-filter: blur(10px);
            border-top: 1px solid var(--border-subtle);
            z-index: var(--z-mobile-nav);
            display: flex;
            justify-content: space-around;
            align-items: center;
            padding: 0 10px;
        }
        
        .nav-tab {
            flex: 1;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            gap: 5px;
            padding: 10px 5px;
            color: var(--text-secondary);
            text-decoration: none;
            font-family: var(--font-tech);
            font-size: 0.7rem;
            font-weight: 500;
            text-transform: uppercase;
            letter-spacing: 0.5px;
            transition: all 0.3s ease;
            border-radius: 8px;
        }
        
        .nav-tab i {
            font-size: 1.3rem;
            transition: all 0.3s ease;
        }
        
        .nav-tab:hover {
            color: var(--neon-cyan);
            background: rgba(0, 243, 255, 0.05);
        }
        
        .nav-tab.active {
            color: var(--neon-cyan);
            background: rgba(0, 243, 255, 0.1);
        }
        
        .nav-tab.active i {
            transform: scale(1.1);
            filter: drop-shadow(0 0 8px var(--neon-cyan));
        }
        
        /* ============================================ */
        /* 7. OFFCANVAS CUSTOM STYLING                 */
        /* ============================================ */
        .offcanvas {
            background: linear-gradient(180deg, var(--bg-dark) 0%, var(--bg-secondary) 100%);
            border-right: 1px solid var(--border-subtle);
        }
        
        .offcanvas-header {
            border-bottom: 1px solid var(--border-subtle);
            padding: 1.5rem;
        }
        
        .offcanvas-title {
            font-family: var(--font-title);
            letter-spacing: 2px;
            color: var(--neon-cyan) !important;
        }
        
        .btn-close {
            filter: invert(1);
            opacity: 0.7;
        }
        
        .btn-close:hover {
            opacity: 1;
        }
        
        /* ============================================ */
        /* 8. FLASH MESSAGES                            */
        /* ============================================ */
        .messages-wrapper {
            position: fixed;
            top: 20px;
            right: 20px;
            z-index: var(--z-messages);
            max-width: 400px;
        }
        
        .alert-message {
            background: rgba(10, 10, 18, 0.95);
            border: 1px solid var(--border-subtle);
            border-radius: 8px;
            padding: 1rem 1.5rem;
            margin-bottom: 10px;
            color: var(--text-main);
            font-family: var(--font-tech);
            font-size: 0.9rem;
            box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
            backdrop-filter: blur(10px);
            animation: slideInRight 0.4s ease;
        }
        
        .alert-message.success {
            border-left: 4px solid #00ff00;
        }
        
        .alert-message.error {
            border-left: 4px solid #ff0000;
        }
        
        .alert-message.warning {
            border-left: 4px solid #ffaa00;
        }
        
        .alert-message.info {
            border-left: 4px solid var(--neon-cyan);
        }
        
        /* ============================================ */
        /* 9. CONTENT CONTAINER                         */
        /* ============================================ */
        .content-container {
            /* Zone neutre qui ne force aucun style */
            width: 100%;
        }
        
        /* ============================================ */
        /* 10. GLOBAL MODAL - SYSTEM CORE CYBERPUNK    */
        /* ============================================ */
        #globalSkillModal .modal-dialog {
            max-width: 600px;
            margin: 1.75rem auto;
        }
        
        #globalSkillModal .modal-content {
            background: #000;
            border: 4px solid var(--cp-yellow);
            border-radius: 0;
            box-shadow: 0 0 30px rgba(252, 238, 10, 0.5), inset 0 0 20px rgba(252, 238, 10, 0.1);
            clip-path: polygon(0 0, calc(100% - 20px) 0, 100% 20px, 100% 100%, 20px 100%, 0 calc(100% - 20px));
            position: relative;
            overflow: hidden;
        }
        
        #globalSkillModal .modal-content::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            height: 2px;
            background: linear-gradient(90deg, transparent, var(--cp-yellow), transparent);
            animation: scanline 2s linear infinite;
        }
        
        #globalSkillModal .modal-header {
            background: linear-gradient(135deg, rgba(252, 238, 10, 0.1) 0%, transparent 100%);
            border-bottom: 2px solid var(--cp-yellow);
            padding: 1.5rem;
            position: relative;
        }
        
        #globalSkillModal .modal-title {
            font-family: var(--font-title);
            font-size: 1.5rem;
            font-weight: 900;
            text-transform: uppercase;
            letter-spacing: 3px;
            color: var(--cp-yellow);
            text-shadow: 0 0 10px rgba(252, 238, 10, 0.8);
        }
        
        #globalSkillModal .btn-close {
            filter: invert(1) brightness(2);
            opacity: 1;
            transition: all 0.3s ease;
        }
        
        #globalSkillModal .btn-close:hover {
            transform: rotate(90deg);
            filter: invert(1) brightness(2) drop-shadow(0 0 10px var(--cp-yellow));
        }
        
        #globalSkillModal .modal-body {
            padding: 2rem;
            color: var(--text-main);
        }
        
        #modalSkillDesc {
            font-family: var(--font-tech);
            font-size: 1.1rem;
            line-height: 1.8;
            margin-bottom: 2rem;
            color: var(--text-main);
        }
        
        .skill-progress-container {
            margin-top: 1.5rem;
        }
        
        .skill-progress-label {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 0.75rem;
            font-family: var(--font-tech);
            font-weight: 600;
            text-transform: uppercase;
            letter-spacing: 1px;
            color: var(--cp-yellow);
        }
        
        .skill-progress-label span:first-child {
            font-size: 0.9rem;
        }
        
        #modalSkillLevelText {
            font-size: 1.1rem;
            font-weight: 700;
            color: var(--cp-yellow);
            text-shadow: 0 0 8px rgba(252, 238, 10, 0.6);
        }
        
        .progress {
            height: 30px;
            background: rgba(252, 238, 10, 0.1);
            border: 2px solid var(--cp-yellow);
            border-radius: 0;
            overflow: visible;
            position: relative;
            box-shadow: inset 0 0 10px rgba(252, 238, 10, 0.2);
        }
        
        #modalSkillBar {
            background: linear-gradient(90deg, var(--cp-yellow) 0%, rgba(252, 238, 10, 0.7) 100%);
            height: 100%;
            transition: width 1.2s cubic-bezier(0.4, 0, 0.2, 1);
            position: relative;
            box-shadow: 0 0 20px rgba(252, 238, 10, 0.8);
        }
        
        #modalSkillBar::after {
            content: '';
            position: absolute;
            top: 0;
            right: 0;
            width: 3px;
            height: 100%;
            background: #fff;
            box-shadow: 0 0 15px var(--cp-yellow);
            animation: pulse 1s ease-in-out infinite;
        }
        
        /* ============================================ */
        /* 11. SCROLLBAR CUSTOM                         */
        /* ============================================ */
        .sidebar-area::-webkit-scrollbar,
        .main-area::-webkit-scrollbar {
            width: 6px;
        }
        
        .sidebar-area::-webkit-scrollbar-track,
        .main-area::-webkit-scrollbar-track {
            background: rgba(0, 0, 0, 0.3);
        }
        
        .sidebar-area::-webkit-scrollbar-thumb,
        .main-area::-webkit-scrollbar-thumb {
            background: var(--neon-cyan);
            border-radius: 3px;
        }
        
        .sidebar-area::-webkit-scrollbar-thumb:hover,
        .main-area::-webkit-scrollbar-thumb:hover {
            background: var(--neon-purple);
        }
        
        /* ============================================ */
        /* 12. ANIMATIONS                               */
        /* ============================================ */
        @keyframes slideInRight {
            from {
                opacity: 0;
                transform: translateX(100%);
            }
            to {
                opacity: 1;
                transform: translateX(0);
            }
        }
        
        @keyframes scanline {
            0% {
                transform: translateX(-100%);
            }
            100% {
                transform: translateX(100%);
            }
        }
        
        @keyframes pulse {
            0%, 100% {
                opacity: 1;
            }
            50% {
                opacity: 0.4;
            }
        }
        
        /* ============================================ */
        /* 13. UTILITIES (Classes réutilisables)        */
        /* ============================================ */
        .text-cyan {
            color: var(--neon-cyan);
        }
        
        .text-purple {
            color: var(--neon-purple);
        }
        
        .text-copper {
            color: var(--copper);
        }
        
        .bg-glass {
            background: rgba(10, 10, 18, 0.7);
            backdrop-filter: blur(10px);
        }
        
        .border-glow {
            border: 1px solid var(--border-subtle);
        }
    </style>
</head>

<body>
    <!-- ============================================ -->
    <!-- MOBILE HEADER (Visible uniquement < 992px)   -->
    <!-- ============================================ -->
    <header class="mobile-header d-lg-none">
        <div class="mobile-identity">
            {% if sidebar.identity.photo %}
            <img src="{{ sidebar.identity.photo.url }}" alt="{{ sidebar.identity.name }}" class="mobile-avatar">
            {% else %}
            <!-- Avatar CSS pur (pas d'image externe) -->
            <div class="mobile-avatar-fallback">
                {{ sidebar.identity.name|first|upper|default:"A" }}
            </div>
            {% endif %}
            
            <div>
                <h1 class="mobile-name">{{ sidebar.identity.name|default:"Architecte" }}</h1>
                <p class="mobile-title">{{ sidebar.identity.title|default:"Logiciel Senior" }}</p>
            </div>
        </div>
        
        <button class="btn-menu-toggle" type="button" data-bs-toggle="offcanvas" data-bs-target="#mobileSidebar" aria-label="Ouvrir le menu">
            <i class="fas fa-bars"></i>
        </button>
    </header>
    
    <!-- ============================================ -->
    <!-- APP WRAPPER (Layout Principal)               -->
    <!-- ============================================ -->
    <div class="app-wrapper">
        <!-- SIDEBAR DESKTOP (Visible uniquement ≥ 992px) -->
        <aside class="sidebar-area d-none d-lg-block">
            {% include "sidebar/sidebar_content.html" %}
        </aside>
        
        <!-- MAIN CONTENT AREA -->
        <main class="main-area">
            <!-- Flash Messages -->
            {% if messages %}
            <div class="messages-wrapper">
                {% for message in messages %}
                <div class="alert-message {{ message.tags|default:'info' }}" role="alert">
                    <i class="fas fa-circle-info me-2"></i>
                    {{ message }}
                </div>
                {% endfor %}
            </div>
            {% endif %}
            
            <!-- Content Container (Zone neutre pour le contenu) -->
            <div class="content-container">
                {% block content %}
                <!-- Le contenu des pages enfants sera injecté ici -->
                {% endblock %}
            </div>
            
            <!-- Footer Desktop -->
            <footer class="d-none d-lg-block mt-5 pt-4 text-center" style="border-top: 1px solid var(--border-subtle);">
                <small class="text-secondary" style="font-family: var(--font-tech);">
                    {{ site_settings.footer_text|default:"© 2025 Portfolio Cyberpunk. Développé avec précision." }}
                </small>
            </footer>
        </main>
    </div>
    
    <!-- ============================================ -->
    <!-- OFFCANVAS SIDEBAR (Mobile uniquement)        -->
    <!-- ============================================ -->
    <div class="offcanvas offcanvas-start d-lg-none" tabindex="-1" id="mobileSidebar" aria-labelledby="mobileSidebarLabel">
        <div class="offcanvas-header">
            <h5 class="offcanvas-title text-cyan" id="mobileSidebarLabel" style="font-family: var(--font-title); letter-spacing: 2px;">
                <i class="fas fa-user-astronaut me-2"></i>PROFIL
            </h5>
            <button type="button" class="btn-close" data-bs-dismiss="offcanvas" aria-label="Fermer"></button>
        </div>
        <div class="offcanvas-body p-0">
            {% include "sidebar/sidebar_content.html" %}
        </div>
    </div>
    
    <!-- ============================================ -->
    <!-- MOBILE BOTTOM NAVIGATION (Visible < 992px)   -->
    <!-- ============================================ -->
    <nav class="mobile-bottom-nav d-lg-none">
        <a href="{% url 'home:index' %}" class="nav-tab {% if request.resolver_match.url_name == 'index' and request.resolver_match.app_name == 'home' %}active{% endif %}">
            <i class="fas fa-home"></i>
            <span>Accueil</span>
        </a>
        
        <a href="{% url 'projects:list' %}" class="nav-tab {% if 'projects' in request.resolver_match.app_name %}active{% endif %}">
            <i class="fas fa-rocket"></i>
            <span>Projets</span>
        </a>
        
        <a href="{% url 'services:list' %}" class="nav-tab {% if 'services' in request.resolver_match.app_name %}active{% endif %}">
            <i class="fas fa-code"></i>
            <span>Services</span>
        </a>
        
        <a href="{% url 'about:index' %}" class="nav-tab {% if 'about' in request.resolver_match.app_name %}active{% endif %}">
            <i class="fas fa-user-astronaut"></i>
            <span>À propos</span>
        </a>
        
        <a href="{% url 'contact:index' %}" class="nav-tab {% if 'contact' in request.resolver_match.app_name %}active{% endif %}">
            <i class="fas fa-envelope"></i>
            <span>Contact</span>
        </a>
    </nav>
    
    <!-- ============================================ -->
    <!-- GLOBAL MODAL - SYSTEM CORE (Unique Instance) -->
    <!-- ============================================ -->
    <div class="modal fade" id="globalSkillModal" tabindex="-1" aria-labelledby="modalSkillTitle" aria-hidden="true" style="z-index: 1055;">
        <div class="modal-dialog modal-dialog-centered">
            <div class="modal-content">
                <div class="modal-header">
                    <h2 class="modal-title" id="modalSkillTitle">
                        <i class="fas fa-microchip me-2"></i>CHARGEMENT...
                    </h2>
                    <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Fermer"></button>
                </div>
                <div class="modal-body">
                    <p id="modalSkillDesc">Récupération des données...</p>
                    
                    <div class="skill-progress-container">
                        <div class="skill-progress-label">
                            <span><i class="fas fa-chart-line me-2"></i>NIVEAU DE MAÎTRISE</span>
                            <span id="modalSkillLevelText">0%</span>
                        </div>
                        <div class="progress">
                            <div id="modalSkillBar" class="progress-bar" role="progressbar" style="width: 0%;" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100"></div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    
    <!-- ============================================ -->
    <!-- JAVASCRIPT                                   -->
    <!-- ============================================ -->
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js" 
            crossorigin="anonymous"></script>
    
    <script>
        // =============================================
        // AUTO-DISMISS DES MESSAGES
        // =============================================
        document.addEventListener('DOMContentLoaded', function() {
            const messages = document.querySelectorAll('.alert-message');
            messages.forEach(function(message) {
                setTimeout(function() {
                    message.style.animation = 'slideInRight 0.4s ease reverse';
                    setTimeout(function() {
                        message.remove();
                    }, 400);
                }, 5000);
            });
            
            // Fermeture automatique de l'offcanvas lors du clic sur un lien
            const offcanvasEl = document.getElementById('mobileSidebar');
            if (offcanvasEl) {
                const links = offcanvasEl.querySelectorAll('a');
                links.forEach(function(link) {
                    link.addEventListener('click', function() {
                        const offcanvas = bootstrap.Offcanvas.getInstance(offcanvasEl);
                        if (offcanvas) {
                            offcanvas.hide();
                        }
                    });
                });
            }
        });
        
        // =============================================
        // GLOBAL MODAL CONTROLLER - EVENT DELEGATION
        // =============================================
        (function() {
            const modalEl = document.getElementById('globalSkillModal');
            if (!modalEl) return;
            
            const modal = new bootstrap.Modal(modalEl);
            const titleEl = document.getElementById('modalSkillTitle');
            const descEl = document.getElementById('modalSkillDesc');
            const barEl = document.getElementById('modalSkillBar');
            const levelTextEl = document.getElementById('modalSkillLevelText');
            
            // Event Delegation sur document.body
            document.body.addEventListener('click', function(event) {
                const trigger = event.target.closest('.trigger-skill-modal');
                
                if (!trigger) return;
                
                event.preventDefault();
                
                const skillId = trigger.getAttribute('data-id');
                const skillTitle = trigger.getAttribute('data-title');
                
                if (!skillId) {
                    console.error('Erreur: data-id manquant sur le déclencheur');
                    return;
                }
                
                // Reset du contenu
                titleEl.innerHTML = '<i class="fas fa-microchip me-2"></i>' + (skillTitle || 'CHARGEMENT...');
                descEl.textContent = 'Récupération des données...';
                barEl.style.width = '0%';
                levelTextEl.textContent = '0%';
                
                // Ouvrir la modale
                modal.show();
                
                // Fetch des données
                fetch(`/sidebar/api/skill/${skillId}/`)
                    .then(response => {
                        if (!response.ok) {
                            throw new Error(`HTTP ${response.status}`);
                        }
                        return response.json();
                    })
                    .then(data => {
                        // Mise à jour du contenu
                        titleEl.innerHTML = '<i class="fas fa-microchip me-2"></i>' + data.name;
                        descEl.textContent = data.description || 'Aucune description disponible.';
                        
                        // Animation de la barre de progression
                        setTimeout(function() {
                            barEl.style.width = data.level + '%';
                            barEl.setAttribute('aria-valuenow', data.level);
                            levelTextEl.textContent = data.level + '%';
                        }, 100);
                    })
                    .catch(error => {
                        console.error('Erreur lors du chargement de la compétence:', error);
                        titleEl.innerHTML = '<i class="fas fa-exclamation-triangle me-2"></i>ERREUR';
                        descEl.textContent = 'Impossible de charger les données. Veuillez réessayer.';
                        barEl.style.width = '0%';
                        levelTextEl.textContent = '0%';
                    });
            });
        })();
    </script>
    
    {% block extra_js %}
    <!-- Scripts supplémentaires des pages enfants -->
    {% endblock %}
    {% include "bot/widget.html" %}
</body>
</html>