/* =========================================
   1. VARIABLES, THÈMES & COULEURS (Sci-Fi Pro)
   ========================================= */
:root {
    /* Thème Clair (Défaut) */
    --bg-color: #f4f7fa;
    --text-color: #1a1b26;
    --text-muted: #565f89;
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(0, 0, 0, 0.08);
    
    --font-main: 'Inter', sans-serif;
    --font-code: 'Fira Code', monospace;

    /* Couleur par défaut (Bleu) */
    --primary-color: #2563eb; 
    --primary-glow: rgba(37, 99, 235, 0.4);
}

/* --- GESTION DU THÈME SOMBRE --- */
[data-theme="dark"] {
    --bg-color: #0b0c10;
    --text-color: #e0e6ed;
    --text-muted: #94a3b8;
    --glass-bg: rgba(11, 12, 16, 0.6);
    --glass-border: rgba(255, 255, 255, 0.1);
    
    --primary-color: #66fcf1; 
    --primary-glow: rgba(102, 252, 241, 0.4);
}

/* --- GESTION DES 4 COULEURS PERSONNALISABLES --- */
[data-color="red"] { --primary-color: #ef4444; --primary-glow: rgba(239, 68, 68, 0.4); }
[data-theme="dark"][data-color="red"] { --primary-color: #ff4b4b; --primary-glow: rgba(255, 75, 75, 0.4); }

[data-color="green"] { --primary-color: #10b981; --primary-glow: rgba(16, 185, 129, 0.4); }
[data-theme="dark"][data-color="green"] { --primary-color: #00fa9a; --primary-glow: rgba(0, 250, 154, 0.4); }

[data-color="yellow"] { --primary-color: #f59e0b; --primary-glow: rgba(245, 158, 11, 0.4); }
[data-theme="dark"][data-color="yellow"] { --primary-color: #ffd700; --primary-glow: rgba(255, 215, 0, 0.4); }

[data-color="blue"] { --primary-color: #2563eb; --primary-glow: rgba(37, 99, 235, 0.4); }
[data-theme="dark"][data-color="blue"] { --primary-color: #66fcf1; --primary-glow: rgba(102, 252, 241, 0.4); }

/* =========================================
   2. RESET & BASE
   ========================================= */
* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: var(--font-main);
    line-height: 1.6;
    overflow-x: hidden;
    transition: background-color 0.4s ease, color 0.4s ease;
}
body.fade-out { opacity: 0; transition: opacity 0.4s ease; }
.container { max-width: 1200px; margin: 0 auto; padding: 0 2rem; }
.monospace { font-family: var(--font-code); }
.highlight { color: var(--primary-color); text-shadow: 0 0 10px var(--primary-glow); transition: color 0.3s, text-shadow 0.3s; }
.text-center { text-align: center; }
.mb-4 { margin-bottom: 2rem; }
.mt-4 { margin-top: 2rem; }
.page-padding { padding-top: 140px; padding-bottom: 80px; }

/* =========================================
   3. STRUCTURES VISUELLES (Verre & Relief)
   ========================================= */
#loader {
    position: fixed; inset: 0; background: var(--bg-color); 
    z-index: 10000; display: flex; justify-content: center; align-items: center; transition: opacity 0.8s;
}
#bg-canvas { position: fixed; inset: 0; z-index: -1; pointer-events: none; opacity: 0.6; }

.glass-panel {
    background: var(--glass-bg); 
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border); border-radius: 12px; 
    padding: 2rem; box-shadow: 0 8px 32px rgba(0, 0, 0, 0.05); 
    transition: all 0.4s ease;
}

.hover-effect:hover {
    transform: translateY(-10px) scale(1.02);
    border-color: var(--primary-color);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.15), 0 0 15px var(--primary-glow);
    z-index: 10;
}

/* =========================================
   4. HEADER & NAVIGATION
   ========================================= */
.main-header {
    position: fixed; top: 0; width: 100%; z-index: 1000;
    background: var(--glass-bg); border-bottom: 1px solid var(--glass-border);
    backdrop-filter: blur(10px); padding: 0.8rem 0; transition: 0.3s;
}
.nav-container { display: flex; justify-content: space-between; align-items: center; }
.logo img { height: 50px; width: auto; transition: transform 0.3s, filter 0.3s; }
.logo:hover img { transform: scale(1.05); filter: drop-shadow(0 0 8px var(--primary-color)); }

.desktop-nav ul { display: flex; list-style: none; gap: 2rem; }
.desktop-nav a { text-decoration: none; color: var(--text-color); font-weight: 500; position: relative; transition: color 0.3s; }
.desktop-nav a::after {
    content: ''; position: absolute; bottom: -5px; left: 0; width: 0%; height: 2px;
    background: var(--primary-color); transition: width 0.3s ease, background 0.3s;
}
.desktop-nav a:hover::after, .desktop-nav a.active::after { width: 100%; }

.nav-actions { display: flex; align-items: center; gap: 1rem; }

/* Menu Langues custom */
.lang-custom-select { position: relative; width: 85px; border: 1px solid var(--glass-border); border-radius: 4px; background: rgba(0,0,0,0.02); height: 36px; z-index: 1005; }
.lang-selected { display: flex; align-items: center; justify-content: center; gap: 6px; height: 100%; cursor: pointer; color: var(--text-color); font-family: var(--font-code); font-size: 0.8rem; }
.lang-selected img { width: 18px; border-radius: 2px; }
.lang-items { position: absolute; background: var(--bg-color); border: 1px solid var(--primary-color); top: 100%; left: -1px; right: -1px; display: none; flex-direction: column; border-radius: 0 0 8px 8px; box-shadow: 0 10px 30px rgba(0,0,0,0.5); }
.lang-items.show { display: flex; }
.lang-items div { display: flex; align-items: center; gap: 8px; padding: 10px; cursor: pointer; color: var(--text-color); font-family: var(--font-code); font-size: 0.8rem; transition: 0.2s; }
.lang-items div:hover { background: var(--primary-color); color: #fff; }

/* Palette de Couleurs */
.color-palette { display: flex; gap: 8px; align-items: center; padding: 0 10px; border-left: 1px solid var(--glass-border); border-right: 1px solid var(--glass-border); }
.color-btn { width: 16px; height: 16px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; transition: 0.3s; }
.color-btn:hover { transform: scale(1.2); }
.color-btn.active { border-color: var(--text-color); box-shadow: 0 0 8px currentColor; }
.c-blue { background: #2563eb; color: #2563eb; }
.c-red { background: #ef4444; color: #ef4444; }
.c-green { background: #10b981; color: #10b981; }
.c-yellow { background: #f59e0b; color: #f59e0b; }

/* Bouton Thème */
#theme-toggle { position: relative; background: none; border: none; font-size: 1.5rem; cursor: pointer; color: var(--text-color); transition: transform 0.3s; }
#theme-toggle:hover { transform: rotate(30deg); }
#theme-toggle::after {
    content: "Changer de thème"; position: absolute; top: 130%; left: 50%; transform: translateX(-50%);
    background: var(--text-color); color: var(--bg-color); padding: 5px 10px; border-radius: 4px;
    font-size: 0.7rem; font-family: var(--font-main); white-space: nowrap; opacity: 0; pointer-events: none; transition: 0.3s; z-index: 1000;
}
#theme-toggle:hover::after { opacity: 1; transform: translate(-50%, 5px); }

.burger-menu { display: none; flex-direction: column; gap: 5px; background: none; border: none; cursor: pointer; z-index: 1001; }
.burger-menu span { width: 25px; height: 2px; background-color: var(--text-color); transition: 0.3s; }

/* =========================================
   5. BOUTONS
   ========================================= */
.btn { display: inline-block; padding: 14px 28px; border-radius: 8px; text-decoration: none; font-weight: 700; transition: all 0.3s; cursor: pointer; border: none; font-family: var(--font-main); font-size: 1rem; }
.btn-sm { padding: 8px 16px; font-size: 0.9rem; }
.btn-primary { background: var(--primary-color); color: #fff; box-shadow: 0 4px 15px var(--primary-glow); }
.btn-secondary { background: transparent; border: 1px solid var(--text-color); color: var(--text-color); margin-left: 1rem; }
.btn:hover { transform: translateY(-3px); opacity: 0.9; }

/* =========================================
   6. PAGES SPÉCIFIQUES & FLIP CARD CORRIGÉE
   ========================================= */
.hero { min-height: 80vh; display: flex; align-items: center; padding-top: 100px; }
.badge { display: inline-block; padding: 4px 12px; border: 1px solid var(--primary-color); border-radius: 50px; color: var(--primary-color); font-size: 0.8rem; margin-bottom: 1.5rem; transition: 0.3s; }
.h1-seo { font-size: clamp(2.5rem, 5vw, 4.5rem); font-weight: 900; line-height: 1.1; margin-bottom: 1.5rem; }
.hero-desc { font-size: 1.2rem; color: var(--text-muted); max-width: 650px; margin-bottom: 2.5rem; }

.expertises-grid, .services-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 2rem; margin-top: 2rem; }

.portfolio-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(350px, 1fr)); gap: 2rem; }
.portfolio-item { padding: 0; overflow: hidden; }
.item-visual { position: relative; height: 250px; overflow: hidden; background: #000; border-radius: 12px 12px 0 0;}
.preview-video { width: 100%; height: 100%; object-fit: cover; opacity: 0.6; transition: 0.5s; transform: scale(1.1); }
.portfolio-item:hover .preview-video { opacity: 1; transform: scale(1); }
.item-overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(0, 0, 0, 0.5); opacity: 0; transition: 0.3s; }
.portfolio-item:hover .item-overlay { opacity: 1; }
.item-info { padding: 1.5rem; }

/* =========================================
   FLIP CARD 100% FONCTIONNELLE (Zéro Bug 3D)
   ========================================= */
.team-container { display: flex; justify-content: center; perspective: 1000px; margin-top: 2rem; }
.flip-card { background-color: transparent; width: 320px; height: 420px; }
.flip-card-inner { 
    position: relative; width: 100%; height: 100%; text-align: center; 
    transition: transform 0.8s cubic-bezier(0.4, 0.2, 0.2, 1); transform-style: preserve-3d; 
}
.flip-card:hover .flip-card-inner { transform: rotateY(180deg); }

/* Fond solide strict pour empêcher la transparence buggée */
.flip-card-front, .flip-card-back { 
    position: absolute; top: 0; left: 0; width: 100%; height: 100%; 
    -webkit-backface-visibility: hidden; backface-visibility: hidden; 
    display: flex; flex-direction: column; justify-content: center; align-items: center; 
    background-color: var(--bg-color); 
    border: 1px solid var(--primary-color); border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1); padding: 2rem; box-sizing: border-box;
}

/* Astuce technique : forcer le Webkit à comprendre l'avant et l'arrière */
.flip-card-front { z-index: 2; transform: rotateY(0deg); }
.flip-card-back { transform: rotateY(180deg); align-items: flex-start; text-align: left; }

.profile-pic-placeholder { width: 120px; height: 120px; background: var(--primary-color); border-radius: 50%; margin-bottom: 1.5rem; transition: 0.3s; }
/* Lueur au survol globale pour la carte */
.flip-card:hover .flip-card-front, .flip-card:hover .flip-card-back {
    border-color: var(--primary-color);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.15), 0 0 15px var(--primary-glow);
}

.flip-card-front { z-index: 2; transform: rotateY(0deg); }
.flip-card-back { transform: rotateY(180deg); align-items: flex-start; text-align: left; }
.profile-pic-placeholder { width: 120px; height: 120px; background: var(--primary-color); border-radius: 50%; margin-bottom: 1.5rem; transition: 0.3s; }

/* Contact Form */
form input, form textarea { width: 100%; padding: 1rem; margin-bottom: 1.5rem; background: transparent; border: 1px solid var(--glass-border); color: var(--text-color); border-radius: 4px; font-family: var(--font-main); transition: border-color 0.3s; }
form input:focus, form textarea:focus { outline: none; border-color: var(--primary-color); }

/* =========================================
   7. CHATBOT INTERACTIF
   ========================================= */
#chatbot-wrapper { position: fixed; bottom: 25px; right: 25px; z-index: 9999; }
#chatbot-trigger { background: var(--glass-bg); border: 1px solid var(--primary-color); color: var(--text-color); padding: 12px 24px; border-radius: 50px; cursor: pointer; font-weight: 700; display: flex; align-items: center; backdrop-filter: blur(10px); transition: 0.3s; }
#chatbot-trigger:hover { background: var(--primary-color); color: #fff; transform: translateY(-5px); }
#chatbot-window { width: 350px; height: 500px; display: flex; flex-direction: column; padding: 0; box-shadow: 0 15px 40px rgba(0,0,0,0.3); transform-origin: bottom right; overflow: hidden; animation: chatOpen 0.3s ease-out; }
@keyframes chatOpen { from { transform: scale(0.5); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.chatbot-header { background: var(--primary-color); color: #fff; padding: 15px; display: flex; justify-content: space-between; align-items: center; transition: background 0.3s; }
.bot-info { display: flex; align-items: center; gap: 10px; }
.chatbot-body { flex: 1; padding: 15px; overflow-y: auto; background: var(--bg-color); display: flex; flex-direction: column; }
.chat-msg { max-width: 85%; padding: 10px 14px; border-radius: 12px; margin-bottom: 12px; font-size: 0.9rem; animation: slideIn 0.3s ease; }
@keyframes slideIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.msg-bot { background: var(--glass-bg); border: 1px solid var(--glass-border); align-self: flex-start; border-bottom-left-radius: 2px; }
.msg-user { background: var(--primary-color); color: #fff; align-self: flex-end; border-bottom-right-radius: 2px; }
.chatbot-footer { padding: 15px; display: flex; flex-direction: column; gap: 8px; background: var(--glass-bg); border-top: 1px solid var(--glass-border); }
.chat-choice { background: transparent; border: 1px solid var(--primary-color); color: var(--text-color); padding: 8px 12px; border-radius: 6px; cursor: pointer; text-align: left; font-size: 0.85rem; transition: 0.2s; }
.chat-choice:hover { background: var(--primary-color); color: #fff; }
.typing-dot { display: inline-block; width: 4px; height: 4px; background: var(--text-muted); border-radius: 50%; animation: typing 1.4s infinite ease-in-out; margin: 0 2px; }
.typing-dot:nth-child(1) { animation-delay: -0.32s; } 
.typing-dot:nth-child(2) { animation-delay: -0.16s; }
@keyframes typing { 0%, 80%, 100% { transform: scale(0); } 40% { transform: scale(1); } }

/* =========================================
   8. RESPONSIVE MOBILE
   ========================================= */
@media (max-width: 768px) {
    .burger-menu { display: flex; }
    .desktop-nav { position: fixed; top: 0; left: -100%; width: 100%; height: 100vh; background: var(--bg-color); display: flex; flex-direction: column; justify-content: center; align-items: center; transition: left 0.4s ease; z-index: 1000; }
    .desktop-nav.active { left: 0; }
    .desktop-nav ul { flex-direction: column; text-align: center; font-size: 1.5rem; gap: 2rem; }
    .color-palette { border: none; padding: 15px 0; justify-content: center; }
    .hero { text-align: center; }
    .hero-actions { display: flex; flex-direction: column; gap: 1rem; }
    .btn-secondary { margin-left: 0; }
    #chatbot-window { width: 90vw; right: 5vw; height: 70vh; }

    /* =========================================
   ALIGNEMENT PAGE AGENCE (TEXTE / RECTANGLES)
   ========================================= */
.agency-alignment-grid {
    display: grid;
    grid-template-columns: 1fr 1fr; /* Divise en 2 colonnes égales */
    gap: 3rem; /* Garde une belle marge entre les deux */
    align-items: stretch; /* Force les deux colonnes à faire EXACTEMENT la même hauteur */
}

.agency-text-column {
    display: flex;
    flex-direction: column;
    justify-content: space-between; /* Magique : pousse le premier élément en haut, et le dernier tout en bas ! */
    height: 100%;
}

/* Responsive : On repasse sur 1 seule colonne sur mobile */
@media (max-width: 992px) {
    .agency-alignment-grid {
        grid-template-columns: 1fr;
        gap: 2rem;
    }
}

/* Force l'affichage du portfolio si le JS d'animation bloque */
.portfolio-item {
    opacity: 1 !important;
    transform: translateY(0) !important;
}

}