:root {
    --nexus-primary: #00d2ff;
    --nexus-secondary: #008299;
    --nexus-bg-dark: rgba(23, 28, 38, 0.95);
    --nexus-text: #e1e8ed;
    --nexus-glass: rgba(255, 255, 255, 0.05);
    --nexus-border: rgba(255, 255, 255, 0.1);
    --nexus-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

#nexus-chatbot-wrapper {
    position: fixed;
    bottom: 40px; /* Descendu pour un meilleur équilibre visuel */
    right: 30px;
    z-index: 10000;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

/* ============================
   ICÔNES SVG SPRITE (MMI V3)
   ============================
   Le framework injecte des <symbol> dans le <head>.
   Les boutons utilisent <svg class="icon"><use href="#ph-xxx"/></svg>.
   Sans ces règles, les SVG sont 0×0.
*/
#nexus-chatbot-wrapper svg.icon {
    display: inline-block;
    width: 1.25em;
    height: 1.25em;
    fill: currentColor;
    vertical-align: middle;
    flex-shrink: 0;
}

/* TOGGLE BUTTON */
#nexus-chatbot-toggle {
    width: 75px; 
    height: 75px;
    background: transparent;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    overflow: hidden; /* Détourage parfait du cercle */
    z-index: 100; /* Toujours au-dessus de la fenêtre pour rester cliquable */
}

#nexus-chatbot-toggle img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: all 0.3s ease;
}

#nexus-chatbot-toggle:hover img {
    transform: scale(1.1) rotate(5deg);
}

#nexus-chatbot-toggle:hover {
    transform: scale(1.1) rotate(8deg);
    box-shadow: 0 12px 40px rgba(224, 160, 0, 0.6);
}

.nexus-pulse::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 3px solid #E0A000;
    animation: nexus-ripple 2s infinite;
    z-index: -1;
    left: 0;
    top: 0;
}

@keyframes nexus-ripple {
    0% { transform: scale(1); opacity: 0.8; }
    100% { transform: scale(1.6); opacity: 0; }
}

/* CHAT WINDOW */
#nexus-chatbot-window {
    position: absolute;
    bottom: 85px; /* Relevé légèrement (était à 20px) pour ne plus recouvrir le bouton */
    right: 0;
    z-index: 99;
    width: 400px;
    height: 600px;
    max-height: calc(100vh - 120px);
    background: var(--nexus-bg-dark);
    backdrop-filter: blur(15px);
    border: 1px solid var(--nexus-border);
    border-radius: 24px;
    box-shadow: var(--nexus-shadow);
    display: none;
    flex-direction: column;
    overflow: hidden;
}

/* HEADER */
.nexus-chatbot-header {
    background: rgba(255, 255, 255, 0.03);
    padding: 20px;
    border-bottom: 1px solid var(--nexus-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nexus-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.nexus-avatar {
    width: 45px;
    height: 45px;
    background: #E0A000; /* Fond doré pour uniformiser avec le bouton toggle */
    border-radius: 50%; /* Cercle parfait pour l'avatar */
    padding: 0;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.nexus-avatar img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.nexus-name {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    color: var(--nexus-primary);
    letter-spacing: 0.5px;
}

.nexus-tagline {
    font-size: 11px;
    color: #8899a6;
    display: block;
}

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

.nexus-btn-icon {
    background: none;
    border: none;
    color: #8899a6;
    font-size: 20px;
    cursor: pointer;
    padding: 4px;
    border-radius: 8px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.nexus-btn-icon:hover {
    background: rgba(255, 68, 68, 0.2); /* Fond rouge léger au survol pour la fermeture */
    color: #ff4444;
}

/* MESSAGES */
.nexus-chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    scrollbar-width: thin;
    scrollbar-color: var(--nexus-secondary) transparent;
}

.nexus-msg {
    max-width: 85%;
    display: flex;
}

.nexus-msg-content {
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.5;
}

.nexus-msg-avatar {
    width: 32px;
    height: 32px;
    background: #E0A000;
    border-radius: 50%;
    margin-right: 12px;
    flex-shrink: 0;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.nexus-msg-avatar img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.nexus-bot { align-self: flex-start; }
.nexus-bot .nexus-msg-content {
    background: var(--nexus-glass);
    color: var(--nexus-text);
    border-bottom-left-radius: 4px;
    border: 1px solid var(--nexus-border);
}

.nexus-user { align-self: flex-end; }
.nexus-user .nexus-msg-content {
    background: linear-gradient(135deg, var(--nexus-secondary), var(--nexus-primary));
    color: white;
    border-bottom-right-radius: 4px;
}

/* FOOTER & INPUT */
.nexus-chatbot-footer {
    padding: 0 20px 20px 20px;
}

.nexus-quick-actions {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    overflow-x: auto;
    padding-bottom: 5px;
}

.nexus-quick-btn {
    background: var(--nexus-glass);
    border: 1px solid var(--nexus-border);
    color: #8899a6;
    padding: 6px 12px;
    border-radius: 10px;
    font-size: 12px;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
}

.nexus-quick-btn:hover {
    background: rgba(0, 210, 255, 0.1);
    border-color: var(--nexus-primary);
    color: var(--nexus-primary);
}

.nexus-input-group {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--nexus-border);
    border-radius: 16px;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    focus-within: {
        border-color: var(--nexus-primary);
        box-shadow: 0 0 0 2px rgba(0, 210, 255, 0.2);
    }
}

#nexus-chat-input {
    flex: 1;
    background: none;
    border: none;
    color: white;
    font-size: 14px;
    outline: none;
    padding: 8px 0;
}

.nexus-input-actions {
    display: flex;
    gap: 5px;
}

.nexus-action-btn {
    background: none;
    border: none;
    color: #8899a6;
    font-size: 18px;
    cursor: pointer;
    padding: 8px;
    border-radius: 10px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

/* Taille spécifique des icônes dans les boutons action */
.nexus-action-btn svg.icon {
    width: 1.4em;
    height: 1.4em;
}

/* Icônes dans les boutons header (fermer, config) */
.nexus-btn-icon svg.icon {
    width: 1.3em;
    height: 1.3em;
}

/* Icônes dans les boutons rapides */
.nexus-quick-btn svg.icon {
    width: 1em;
    height: 1em;
}

.nexus-action-btn:hover {
    background: var(--nexus-glass);
    color: white;
}

.nexus-btn-primary {
    color: var(--nexus-primary) !important;
}

/* LOADING DOTS */
.nexus-typing {
    display: flex;
    gap: 4px;
    padding: 10px;
}
.nexus-dot {
    width: 6px;
    height: 6px;
    background: var(--nexus-primary);
    border-radius: 50%;
    animation: nexus-bounce 1.4s infinite ease-in-out both;
}
.nexus-dot:nth-child(1) { animation-delay: -0.32s; }
.nexus-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes nexus-bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1.0); }
}

/* RESPONSIVE */
@media (max-width: 480px) {
    #nexus-chatbot-window {
        width: calc(100vw - 40px);
        bottom: 70px;
    }
}
