/* ── NPSM Chatbot — Bulle de Chat IA ─────────────────────── */

/* Bouton flottant */
.npsm-chatbot-btn {
    position: fixed;
    bottom: 25px;
    width: var(--npsm-bubble-size, 60px) !important;
    height: var(--npsm-bubble-size, 60px) !important;
    min-width: var(--npsm-bubble-size, 60px) !important;
    min-height: var(--npsm-bubble-size, 60px) !important;
    max-width: var(--npsm-bubble-size, 60px) !important;
    max-height: var(--npsm-bubble-size, 60px) !important;
    background: linear-gradient(135deg, var(--npsm-primary, #3858e9) 0%, var(--npsm-secondary, #2a44c2) 100%);
    color: #ffffff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    z-index: 999998;
    transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease, width 0.3s ease, height 0.3s ease;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    box-sizing: border-box !important;
}

.npsm-chatbot-btn:hover {
    transform: translateY(-2px) scale(1.06);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.25);
}

.npsm-chatbot-btn:active {
    transform: scale(0.95);
}

/* Morphing des icônes à l'intérieur du bouton */
.npsm-chatbot-btn .npsm-icon-chat,
.npsm-chatbot-btn .npsm-icon-close {
    position: absolute;
    top: 50%;
    left: 50%;
    transform-origin: center center;
    transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.25s ease;
    color: #ffffff;
}

.npsm-chatbot-btn .npsm-icon-chat {
    width: var(--npsm-bubble-icon-size, 28px) !important;
    height: var(--npsm-bubble-icon-size, 28px) !important;
    transform: translate(-50%, -50%) rotate(0deg) scale(1);
    opacity: 1;
}

.npsm-chatbot-btn .npsm-icon-close {
    width: var(--npsm-bubble-close-size, 24px) !important;
    height: var(--npsm-bubble-close-size, 24px) !important;
    transform: translate(-50%, -50%) rotate(-90deg) scale(0.4);
    opacity: 0;
}

/* État ouvert : le bouton reste actif, tourne et affiche la croix */
.npsm-chatbot-btn.npsm-chatbot-btn-open {
    box-shadow: 0 6px 22px rgba(0, 0, 0, 0.25);
}

.npsm-chatbot-btn.npsm-chatbot-btn-open:hover {
    transform: translateY(-2px) scale(1.06);
}

.npsm-chatbot-btn.npsm-chatbot-btn-open .npsm-icon-chat {
    transform: translate(-50%, -50%) rotate(90deg) scale(0.4);
    opacity: 0;
}

.npsm-chatbot-btn.npsm-chatbot-btn-open .npsm-icon-close {
    transform: translate(-50%, -50%) rotate(0deg) scale(1);
    opacity: 1;
}

/* Bulle d'accroche / Notification Proactive (Teaser) */
.npsm-chatbot-teaser {
    position: fixed;
    bottom: calc(var(--npsm-bubble-size, 60px) + 42px);
    z-index: 999997;
    max-width: 320px;
    cursor: pointer;
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.25s ease;
    user-select: none;
    box-sizing: border-box;
    transform-origin: bottom center;
}

.npsm-chatbot-teaser:hover {
    transform: translateY(-3px) scale(1.02);
}

.npsm-chatbot-teaser.npsm-teaser-anim {
    animation: npsmTeaserPopIn 0.55s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.npsm-chatbot-teaser-inner {
    background: #ffffff;
    padding: 12px 34px 12px 14px;
    border-radius: 16px;
    box-shadow: 0 14px 40px rgba(0, 0, 0, 0.16), 0 2px 8px rgba(0, 0, 0, 0.06);
    border: 1px solid #e2e8f0;
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    box-sizing: border-box;
}

.npsm-chatbot-teaser-avatar {
    position: relative;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--npsm-primary, #3858e9) 0%, var(--npsm-secondary, #2a44c2) 100%);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 2px;
}

.npsm-teaser-status-dot {
    position: absolute;
    bottom: -1px;
    right: -1px;
    width: 10px;
    height: 10px;
    background: #10b981;
    border: 2px solid #ffffff;
    border-radius: 50%;
    animation: npsmDotPulse 2s infinite;
}

.npsm-chatbot-teaser-body {
    flex: 1;
    min-width: 0;
}

.npsm-chatbot-teaser-author {
    font-size: 12px;
    font-weight: 700;
    color: #0f172a;
    margin-bottom: 3px;
    line-height: 1.2;
}

.npsm-chatbot-teaser-text {
    margin: 0;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.4;
    color: #334155;
    word-break: break-word;
}

.npsm-chatbot-teaser-close {
    position: absolute;
    top: 6px;
    right: 8px;
    background: none;
    border: none;
    color: #94a3b8;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    padding: 4px;
    border-radius: 50%;
    transition: color 0.2s, transform 0.2s;
}

.npsm-chatbot-teaser-close:hover {
    color: #0f172a;
    transform: scale(1.2);
}

.npsm-chatbot-teaser-arrow {
    position: absolute;
    bottom: -7px;
    right: calc(var(--npsm-bubble-size, 60px) / 2 - 7px);
    width: 14px;
    height: 14px;
    background: #ffffff;
    transform: rotate(45deg);
    border-bottom: 1px solid #e2e8f0;
    border-right: 1px solid #e2e8f0;
    box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.04);
}

.npsm-chatbot-teaser[style*="left: 25px"] .npsm-chatbot-teaser-arrow {
    left: calc(var(--npsm-bubble-size, 60px) / 2 - 7px);
    right: auto;
}

/* Animation d'apparition rebondissante et douce */
@keyframes npsmTeaserPopIn {
    0% {
        opacity: 0;
        transform: translateY(16px) scale(0.85);
    }
    65% {
        opacity: 1;
        transform: translateY(-4px) scale(1.03);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes npsmDotPulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.2);
        opacity: 0.85;
    }
}

@keyframes npsmBtnGlowPulse {
    0%, 100% {
        box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
    }
    50% {
        box-shadow: 0 6px 28px rgba(56, 88, 233, 0.55), 0 0 0 5px rgba(56, 88, 233, 0.25);
    }
}

.npsm-chatbot-btn.npsm-has-teaser-glow {
    animation: npsmBtnGlowPulse 2.4s infinite ease-in-out;
}

/* Fenêtre de chat */
.npsm-chatbot-window {
    position: fixed;
    bottom: calc(var(--npsm-bubble-size, 60px) + 38px);
    width: 380px;
    max-height: 540px;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 12px 45px rgba(0, 0, 0, 0.18);
    z-index: 999999;
    display: flex;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    overflow: hidden;
}

.npsm-chatbot-window.npsm-chatbot-active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* Header */
.npsm-chatbot-header {
    background: linear-gradient(135deg, var(--npsm-primary, #3858e9) 0%, var(--npsm-secondary, #2a44c2) 100%);
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--npsm-header-text, #ffffff);
    flex-shrink: 0;
}

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

.npsm-chatbot-avatar {
    width: 38px;
    height: 38px;
    background: var(--npsm-header-avatar-bg, rgba(255, 255, 255, 0.2));
    color: var(--npsm-header-avatar-color, #ffffff);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.npsm-chatbot-avatar svg {
    stroke: var(--npsm-header-avatar-color, #ffffff);
}

.npsm-chatbot-header-text {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 1px;
}

.npsm-chatbot-header h4,
.npsm-chatbot-header .npsm-chatbot-title {
    margin: 0 !important;
    padding: 0 !important;
    font-size: 15px !important;
    font-weight: 600 !important;
    color: var(--npsm-header-text, #ffffff) !important;
    line-height: 1.15 !important;
}

.npsm-chatbot-status {
    font-size: 12px !important;
    color: var(--npsm-header-subtext, rgba(255, 255, 255, 0.85)) !important;
    display: block !important;
    margin: 0 !important;
    padding: 0 !important;
    line-height: 1.15 !important;
}

.npsm-chatbot-close {
    font-size: 24px;
    cursor: pointer;
    color: var(--npsm-header-close, #ffffff) !important;
    opacity: 0.85;
    transition: opacity 0.2s, transform 0.2s;
    line-height: 1;
    user-select: none;
}

.npsm-chatbot-close:hover {
    opacity: 1;
    transform: scale(1.15);
}

/* Zone de messages */
.npsm-chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 280px;
    max-height: 340px;
    background: #f8f9fc;
}

/* Bulles de message */
.npsm-chat-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    animation: npsmChatFadeIn 0.3s ease;
}

.npsm-chat-msg-user {
    align-self: flex-end;
    background: linear-gradient(135deg, var(--npsm-primary, #3858e9) 0%, var(--npsm-secondary, #2a44c2) 100%);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.npsm-chat-msg-bot {
    align-self: flex-start;
    background: #ffffff;
    color: #333;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

/* Animation de typing */
.npsm-chat-typing {
    align-self: flex-start;
    background: #ffffff;
    padding: 12px 18px;
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
    display: flex;
    gap: 4px;
    align-items: center;
}

.npsm-chat-typing span {
    width: 8px;
    height: 8px;
    background: #aab;
    border-radius: 50%;
    animation: npsmTypingBounce 1.4s infinite;
}

.npsm-chat-typing span:nth-child(2) {
    animation-delay: 0.2s;
}

.npsm-chat-typing span:nth-child(3) {
    animation-delay: 0.4s;
}

/* Champ de saisie */
.npsm-chatbot-input-area {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border-top: 1px solid #edf2f7;
    gap: 10px;
    background: #ffffff;
    flex-shrink: 0;
    box-sizing: border-box;
}

.npsm-chatbot-input-area input {
    flex: 1;
    border: 1.5px solid #e2e8f0 !important;
    border-radius: 24px !important;
    padding: 11px 18px 11px 18px !important;
    font-size: 13.5px !important;
    line-height: 1.4 !important;
    outline: none !important;
    transition: all 0.2s ease !important;
    background: #f8fafc !important;
    color: #1e293b !important;
    box-sizing: border-box !important;
    box-shadow: none !important;
}

.npsm-chatbot-input-area input::placeholder {
    color: #94a3b8 !important;
    opacity: 1 !important;
}

.npsm-chatbot-input-area input:focus {
    border-color: var(--npsm-primary, #3858e9) !important;
    background: #ffffff !important;
    box-shadow: 0 0 0 3px rgba(56, 88, 233, 0.12) !important;
}

#npsm-chatbot-send {
    width: 40px;
    height: 40px;
    border: none;
    background: linear-gradient(135deg, var(--npsm-primary, #3858e9) 0%, var(--npsm-secondary, #2a44c2) 100%);
    color: #fff;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, box-shadow 0.2s;
    flex-shrink: 0;
}

#npsm-chatbot-send:hover {
    transform: scale(1.08);
    box-shadow: 0 3px 10px rgba(102, 126, 234, 0.4);
}

#npsm-chatbot-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Message limite atteinte */
.npsm-chat-limit {
    text-align: center;
    font-size: 12px;
    color: #999;
    padding: 8px 14px;
    background: #f0f0f1;
    border-radius: 8px;
}

/* Animations */
@keyframes npsmChatFadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes npsmTypingBounce {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-6px);
    }
}

/* Responsive Mobile (<= 600px) */
@media screen and (max-width: 600px) {
    #npsm-chatbot-window,
    .npsm-chatbot-window {
        position: fixed !important;
        top: 0 !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        width: 100vw !important;
        max-width: 100vw !important;
        height: 100% !important;
        height: 100dvh !important;
        max-height: 100% !important;
        max-height: 100dvh !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        margin: 0 !important;
        z-index: 999999 !important;
        display: flex !important;
        flex-direction: column !important;
        transform: translateY(100%) !important;
    }

    #npsm-chatbot-window.npsm-chatbot-active,
    .npsm-chatbot-window.npsm-chatbot-active {
        transform: translateY(0) !important;
        opacity: 1 !important;
        visibility: visible !important;
    }

    .npsm-chatbot-header {
        padding: 14px 16px !important;
        flex-shrink: 0 !important;
    }

    .npsm-chatbot-close {
        width: 36px !important;
        height: 36px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        font-size: 28px !important;
        cursor: pointer !important;
        touch-action: manipulation;
    }

    .npsm-chatbot-messages {
        flex: 1 1 auto !important;
        max-height: none !important;
        height: auto !important;
        padding: 14px 14px !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }

    .npsm-chatbot-input-area {
        padding: 10px 14px !important;
        flex-shrink: 0 !important;
        background: #ffffff !important;
        border-top: 1px solid #e2e8f0 !important;
    }

    .npsm-chatbot-input-area input {
        font-size: 15px !important;
        padding: 10px 14px !important;
    }

    .npsm-chatbot-privacy-notice {
        padding: 4px 10px 6px 10px !important;
        font-size: 10.5px !important;
    }

    #npsm-chatbot-btn,
    .npsm-chatbot-btn {
        bottom: 16px !important;
    }

    /* Quand le chatbot est ouvert sur mobile, masquer le bouton rond pour ne pas gêner */
    .npsm-chatbot-btn.npsm-chatbot-btn-open {
        opacity: 0 !important;
        visibility: hidden !important;
        pointer-events: none !important;
    }

    #npsm-chatbot-teaser,
    .npsm-chatbot-teaser {
        left: 12px !important;
        right: 12px !important;
        bottom: calc(var(--npsm-bubble-size, 60px) + 24px) !important;
        max-width: calc(100vw - 24px) !important;
    }
}

/* Notice RGPD */
.npsm-chatbot-privacy-notice {
    padding: 6px 14px 8px 14px;
    font-size: 11px;
    line-height: 1.35;
    color: #64748b;
    background: #ffffff;
    text-align: center;
    border-top: 1px solid #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    flex-shrink: 0;
    box-sizing: border-box;
}

.npsm-chatbot-privacy-notice svg {
    flex-shrink: 0;
    color: #94a3b8;
}

/* Ecran / Overlay Lead Form */
.npsm-chatbot-lead-overlay {
    position: absolute;
    inset: 0;
    background: #ffffff;
    z-index: 10;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 24px 20px;
    overflow-y: auto;
    animation: npsmChatFadeIn 0.3s ease;
}

.npsm-lead-card-header {
    text-align: center;
    margin-bottom: 20px;
}

.npsm-lead-icon-box {
    width: 44px;
    height: 44px;
    background: #eff6ff;
    color: var(--npsm-primary, #3858e9);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 12px auto;
}

.npsm-lead-card-header h4 {
    margin: 0 0 6px 0;
    font-size: 16px;
    font-weight: 700;
    color: #0f172a;
}

.npsm-lead-card-header p {
    margin: 0;
    font-size: 13px;
    color: #64748b;
    line-height: 1.4;
}

.npsm-lead-field {
    margin-bottom: 12px;
}

.npsm-lead-field input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 13px;
    outline: none;
    box-sizing: border-box;
    transition: border-color 0.2s;
}

.npsm-lead-field input:focus {
    border-color: var(--npsm-primary, #3858e9);
}

.npsm-lead-submit {
    width: 100%;
    background: linear-gradient(135deg, var(--npsm-primary, #3858e9) 0%, var(--npsm-secondary, #2a44c2) 100%);
    color: #ffffff;
    border: none;
    padding: 12px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    margin-top: 8px;
    transition: opacity 0.2s;
}

.npsm-lead-submit:hover {
    opacity: 0.9;
}

.npsm-lead-skip {
    background: none;
    border: none;
    color: #64748b;
    font-size: 12px;
    width: 100%;
    margin-top: 10px;
    cursor: pointer;
    text-decoration: underline;
}
