/* =============================================
   WhatsApp Chat Widget — Come'N'Work Lyon
   ============================================= */

/* --- Conteneur principal --- */
#whatsapp-widget {
    position: fixed;
    bottom: 28px;
    right: 28px;
    z-index: 10000;
    font-family: 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 12px;
}

/* --- Bulle de bienvenue (s'affiche au 1er chargement) --- */
#wa-greeting {
    background: #fff;
    border-radius: 16px 16px 4px 16px;
    padding: 12px 18px;
    box-shadow: 0 6px 25px rgba(0,0,0,0.15);
    font-size: 0.92rem;
    color: #333;
    max-width: 240px;
    line-height: 1.4;
    position: relative;
    animation: waBounceIn 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    opacity: 0;
    transform-origin: bottom right;
}

#wa-greeting::after {
    content: '';
    position: absolute;
    bottom: -8px;
    right: 22px;
    border-width: 8px 8px 0 0;
    border-style: solid;
    border-color: #fff transparent transparent transparent;
}

#wa-greeting .wa-greeting-close {
    position: absolute;
    top: 6px;
    right: 8px;
    background: none;
    border: none;
    cursor: pointer;
    color: #999;
    font-size: 1rem;
    line-height: 1;
    padding: 0;
    transition: color 0.2s;
}

#wa-greeting .wa-greeting-close:hover {
    color: #333;
}

/* Animation bulle d'accueil */
@keyframes waBounceIn {
    0%   { opacity: 0; transform: scale(0.4) translateY(20px); }
    60%  { opacity: 1; transform: scale(1.05) translateY(-4px); }
    80%  { transform: scale(0.97); }
    100% { opacity: 1; transform: scale(1) translateY(0); }
}

/* --- Bouton principal (icône WhatsApp) --- */
#wa-btn {
    width: 60px;
    height: 60px;
    background: #25D366;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 6px 25px rgba(37, 211, 102, 0.5);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    position: relative;
    border: none;
    outline: none;
}

#wa-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 8px 32px rgba(37, 211, 102, 0.65);
}

#wa-btn i {
    font-size: 2rem;
    color: #fff;
    transition: transform 0.3s ease;
}

/* Animation "coucou" - le bouton fait des petits rebonds */
@keyframes waWave {
    0%  { transform: rotate(0deg) scale(1); }
    10% { transform: rotate(-10deg) scale(1.1); }
    20% { transform: rotate(10deg) scale(1.1); }
    30% { transform: rotate(-8deg) scale(1.05); }
    40% { transform: rotate(8deg) scale(1.05); }
    50% { transform: rotate(0deg) scale(1); }
    100% { transform: rotate(0deg) scale(1); }
}

#wa-btn.wave-anim {
    animation: waWave 1.4s ease 0.8s 2;
}

/* Pastille de notification */
#wa-btn .wa-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    background: #e60023;
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
    animation: pulseBadge 2s infinite;
}

@keyframes pulseBadge {
    0%   { box-shadow: 0 0 0 0 rgba(230, 0, 35, 0.5); }
    70%  { box-shadow: 0 0 0 7px rgba(230, 0, 35, 0); }
    100% { box-shadow: 0 0 0 0 rgba(230, 0, 35, 0); }
}

/* --- Panneau de chat --- */
#wa-chat-panel {
    background: #fff;
    border-radius: 18px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.18);
    width: 320px;
    overflow: hidden;
    display: none;
    flex-direction: column;
    transform-origin: bottom right;
    animation: waChatOpen 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

#wa-chat-panel.open {
    display: flex;
}

@keyframes waChatOpen {
    from { opacity: 0; transform: scale(0.7) translateY(20px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* En-tête du chat */
#wa-chat-header {
    background: #075E54;
    padding: 16px 18px;
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
}

#wa-chat-header .wa-avatar {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: #25D366;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    color: #fff;
    flex-shrink: 0;
    overflow: hidden;
}

#wa-chat-header .wa-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

#wa-chat-header .wa-info {
    flex: 1;
}

#wa-chat-header .wa-info strong {
    display: block;
    color: #fff;
    font-size: 1rem;
    font-weight: 700;
}

#wa-chat-header .wa-info span {
    color: rgba(255,255,255,0.75);
    font-size: 0.78rem;
}

#wa-chat-header .wa-status-dot {
    width: 10px;
    height: 10px;
    background: #25D366;
    border-radius: 50%;
    border: 2px solid #fff;
    position: absolute;
    bottom: 18px;
    left: 56px;
}

#wa-close-chat {
    background: none;
    border: none;
    color: rgba(255,255,255,0.8);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 4px;
    border-radius: 50%;
    transition: background 0.2s, color 0.2s;
    line-height: 1;
}

#wa-close-chat:hover {
    background: rgba(255,255,255,0.15);
    color: #fff;
}

/* Zone de messages */
#wa-chat-body {
    background: #ece5dd url("data:image/svg+xml,%3Csvg width='400' height='400' xmlns='http://www.w3.org/2000/svg'%3E%3Crect width='400' height='400' fill='%23ece5dd'/%3E%3C/svg%3E");
    padding: 16px 14px;
    min-height: 160px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Bulle de message */
.wa-bubble {
    background: #fff;
    border-radius: 8px 8px 8px 0;
    padding: 10px 14px;
    max-width: 85%;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    font-size: 0.88rem;
    line-height: 1.5;
    color: #333;
    position: relative;
    animation: waBubbleIn 0.3s ease;
}

@keyframes waBubbleIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.wa-bubble .wa-time {
    display: block;
    text-align: right;
    font-size: 0.68rem;
    color: #999;
    margin-top: 4px;
}

/* Zone de saisie + bouton d'envoi */
#wa-chat-footer {
    padding: 12px 14px;
    background: #f0f0f0;
    display: flex;
    align-items: center;
    gap: 10px;
    border-top: 1px solid #ddd;
}

#wa-chat-footer input {
    flex: 1;
    border: none;
    background: #fff;
    border-radius: 24px;
    padding: 10px 16px;
    font-size: 0.88rem;
    outline: none;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    font-family: inherit;
}

#wa-chat-footer input::placeholder {
    color: #aaa;
}

#wa-send-btn {
    width: 42px;
    height: 42px;
    background: #25D366;
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s, transform 0.2s;
    flex-shrink: 0;
}

#wa-send-btn:hover {
    background: #128C7E;
    transform: scale(1.07);
}

#wa-send-btn i {
    color: #fff;
    font-size: 1rem;
}

/* Note de redirection */
#wa-chat-note {
    text-align: center;
    font-size: 0.72rem;
    color: #888;
    padding: 6px 14px 10px;
    background: #f0f0f0;
}

/* Responsive mobile */
@media (max-width: 768px) {
    #whatsapp-widget {
        bottom: 20px;
        right: 20px;
        gap: 8px;
    }

    #wa-btn {
        width: 52px;
        height: 52px;
    }

    #wa-btn i {
        font-size: 1.6rem;
    }

    #wa-greeting {
        font-size: 0.85rem;
        padding: 10px 14px;
        max-width: 200px;
    }

    #wa-chat-panel {
        width: calc(100vw - 40px);
        max-width: 320px;
        bottom: 70px; /* Se place au dessus du bouton */
    }
}

@media (max-width: 480px) {
    #wa-greeting {
        display: none !important; /* On cache la bulle sur les très petits écrans pour libérer de l'espace */
    }
}
