/**
 * Chatbot CSS - Classes préfixées gcb_ pour zéro conflit
 */

:root {
    --gcb-color: #4285f4;
    --gcb-border: #e0e0e0;
    --gcb-radius: 14px;
    --gcb-shadow: 0 8px 30px rgba(0,0,0,0.18);
}

/* ── Bouton flottant ── */
#gcb-widget {
    position: fixed !important;
    z-index: 2147483647 !important;
    bottom: 24px !important;
    right: 24px !important;
    width: 60px !important;
    height: 60px !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    background: none !important;
    box-shadow: none !important;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
}

#gcb-widget[data-pos="bottom-left"]  { right: auto !important; left: 24px !important; }
#gcb-widget[data-pos="top-right"]    { bottom: auto !important; top: 24px !important; }
#gcb-widget[data-pos="top-left"]     { bottom: auto !important; top: 24px !important; right: auto !important; left: 24px !important; }

#gcb-btn {
    width: 60px !important;
    height: 60px !important;
    border-radius: 50% !important;
    background: var(--gcb-color) !important;
    border: none !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    color: #fff !important;
    padding: 0 !important;
    margin: 0 !important;
    box-shadow: 0 4px 16px rgba(0,0,0,0.25) !important;
    animation: gcb-pulse 2.5s infinite !important;
    transition: transform 0.2s !important;
}
#gcb-btn:hover { transform: scale(1.08) !important; }
#gcb-btn.gcb-open { animation: none !important; }
#gcb-btn .gcb-icon-close { display: none !important; }
#gcb-btn.gcb-open .gcb-icon-chat  { display: none !important; }
#gcb-btn.gcb-open .gcb-icon-close { display: block !important; }

@keyframes gcb-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(66,133,244,0.55); }
    70%  { box-shadow: 0 0 0 14px rgba(66,133,244,0); }
    100% { box-shadow: 0 0 0 0 rgba(66,133,244,0); }
}

/* ── Fenêtre de chat ── */
/* Fermée par défaut via JS — le CSS ne touche pas display ici */
#gcb-box {
    position: fixed !important;
    z-index: 2147483646 !important;
    background: #fff !important;
    box-shadow: var(--gcb-shadow) !important;
    display: none !important; /* JS override avec flex */
    flex-direction: column !important;
    overflow: hidden !important;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
    font-size: 14px !important;
    line-height: 1.5 !important;
    color: #333 !important;
    /* Desktop : fenêtre flottante */
    bottom: 100px !important;
    right: 24px !important;
    width: 370px !important;
    height: 540px !important;
    max-width: calc(100vw - 48px) !important;
    max-height: calc(100vh - 130px) !important;
    border-radius: var(--gcb-radius) !important;
}

#gcb-box[data-pos="bottom-left"]  { right: auto !important; left: 24px !important; }
#gcb-box[data-pos="top-right"]    { bottom: auto !important; top: 100px !important; }
#gcb-box[data-pos="top-left"]     { bottom: auto !important; top: 100px !important; right: auto !important; left: 24px !important; }

/* Mobile : plein écran */
@media (max-width: 600px) {
    #gcb-box {
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        border-radius: 0 !important;
        /* interactive-widget=resizes-content dans le meta viewport
           fait que 100dvh = hauteur sans le clavier sur Android Chrome */
        height: 100dvh !important;
        height: 100vh !important;
    }
    #gcb-header {
        /* Header fixe dans le flex - ne se compresse jamais */
        flex: 0 0 auto !important;
        flex-shrink: 0 !important;
        flex-grow: 0 !important;
        min-height: 64px !important;
        z-index: 10 !important;
    }
    #gcb-messages {
        /* Prend tout l'espace restant */
        flex: 1 1 auto !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
        overscroll-behavior: contain !important;
        min-height: 0 !important;
    }
    #gcb-input-bar {
        flex: 0 0 auto !important;
        flex-shrink: 0 !important;
        padding-bottom: max(12px, env(safe-area-inset-bottom)) !important;
    }
    #gcb-typing { flex: 0 0 auto !important; flex-shrink: 0 !important; }
    #gcb-footer { flex: 0 0 auto !important; flex-shrink: 0 !important; }
    /* Cacher bouton flottant quand chat ouvert */
    #gcb-btn.gcb-open { display: none !important; }
}

/* ── En-tête ── */
#gcb-header {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    background: var(--gcb-color) !important;
    color: #fff !important;
    padding: 14px 16px !important;
    flex-shrink: 0 !important;
    min-height: 66px !important;
    box-sizing: border-box !important;
}
#gcb-header-left {
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
}
#gcb-avatar {
    width: 38px !important;
    height: 38px !important;
    border-radius: 50% !important;
    background: rgba(255,255,255,0.25) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex-shrink: 0 !important;
}
#gcb-name {
    font-size: 15px !important;
    font-weight: 700 !important;
    color: #fff !important;
    display: block !important;
    margin: 0 !important;
    padding: 0 !important;
    background: none !important;
    border: none !important;
    line-height: 1.3 !important;
}
#gcb-status {
    font-size: 12px !important;
    color: rgba(255,255,255,0.85) !important;
    display: block !important;
}
#gcb-close {
    width: 36px !important;
    height: 36px !important;
    border-radius: 50% !important;
    background: rgba(255,255,255,0.2) !important;
    border: none !important;
    color: #fff !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex-shrink: 0 !important;
    padding: 0 !important;
    transition: background 0.2s !important;
    /* Zone de clic large pour mobile */
    -webkit-tap-highlight-color: transparent !important;
    touch-action: manipulation !important;
}
#gcb-close:hover,
#gcb-close:active { background: rgba(255,255,255,0.4) !important; }

/* ── Zone messages ── */
#gcb-messages {
    flex: 1 !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    padding: 16px !important;
    background: #f0f2f5 !important;
    -webkit-overflow-scrolling: touch !important;
    overscroll-behavior: contain !important;
    box-sizing: border-box !important;
}

.gcb-msg {
    display: flex !important;
    gap: 8px !important;
    margin-bottom: 12px !important;
    align-items: flex-end !important;
}
.gcb-msg-bot {}
.gcb-msg-user { flex-direction: row-reverse !important; }

.gcb-avatar {
    width: 30px !important;
    height: 30px !important;
    border-radius: 50% !important;
    background: var(--gcb-color) !important;
    color: #fff !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex-shrink: 0 !important;
}
.gcb-msg-user .gcb-avatar { background: #ccc !important; color: #666 !important; }

.gcb-bubble {
    max-width: 72% !important;
}
.gcb-bubble-text {
    background: #fff !important;
    color: #222 !important;
    padding: 10px 13px !important;
    border-radius: 16px 16px 16px 4px !important;
    font-size: 13.5px !important;
    line-height: 1.5 !important;
    word-wrap: break-word !important;
    word-break: break-word !important;
    box-shadow: 0 1px 2px rgba(0,0,0,0.08) !important;
    margin: 0 !important;
    border: none !important;
    display: block !important;
}
.gcb-msg-user .gcb-bubble-text {
    background: var(--gcb-color) !important;
    color: #fff !important;
    border-radius: 16px 16px 4px 16px !important;
}
.gcb-bubble-time {
    font-size: 11px !important;
    color: #aaa !important;
    margin-top: 3px !important;
    display: block !important;
    padding: 0 4px !important;
}
.gcb-msg-user .gcb-bubble-time { text-align: right !important; }

/* ── Typing ── */
#gcb-typing {
    display: none !important;
    align-items: center !important;
    gap: 8px !important;
    padding: 10px 16px !important;
    background: #f0f2f5 !important;
    border-top: 1px solid var(--gcb-border) !important;
    flex-shrink: 0 !important;
    box-sizing: border-box !important;
}
.gcb-dots { display: flex !important; gap: 4px !important; }
.gcb-dots span {
    width: 7px !important; height: 7px !important;
    border-radius: 50% !important;
    background: #aaa !important;
    display: inline-block !important;
    animation: gcb-bounce 1.4s infinite ease-in-out !important;
}
.gcb-dots span:nth-child(2) { animation-delay: 0.2s !important; }
.gcb-dots span:nth-child(3) { animation-delay: 0.4s !important; }
@keyframes gcb-bounce {
    0%,60%,100% { transform: translateY(0); opacity: 0.4; }
    30%          { transform: translateY(-7px); opacity: 1; }
}
#gcb-typing-label { font-size: 12px !important; color: #888 !important; }

/* ── Zone saisie ── */
#gcb-input-bar {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    padding: 10px 12px !important;
    background: #fff !important;
    border-top: 1px solid var(--gcb-border) !important;
    flex-shrink: 0 !important;
    box-sizing: border-box !important;
    /* Safe area iPhone */
    padding-bottom: max(10px, env(safe-area-inset-bottom)) !important;
}
#gcb-input {
    flex: 1 !important;
    border: 1.5px solid #ddd !important;
    border-radius: 22px !important;
    padding: 9px 16px !important;
    font-size: 14px !important;
    font-family: inherit !important;
    background: #fff !important;
    color: #333 !important;
    outline: none !important;
    -webkit-appearance: none !important;
    appearance: none !important;
    box-shadow: none !important;
    height: 40px !important;
    box-sizing: border-box !important;
    line-height: 1.4 !important;
}
#gcb-input:focus { border-color: var(--gcb-color) !important; }
#gcb-send {
    width: 40px !important; height: 40px !important;
    border-radius: 50% !important;
    background: var(--gcb-color) !important;
    border: none !important;
    color: #fff !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex-shrink: 0 !important;
    padding: 0 !important;
    -webkit-tap-highlight-color: transparent !important;
    touch-action: manipulation !important;
}
#gcb-send:disabled { opacity: 0.45 !important; cursor: not-allowed !important; }

/* ── Footer ── */
#gcb-footer {
    padding: 5px 14px !important;
    background: #fff !important;
    border-top: 1px solid var(--gcb-border) !important;
    font-size: 11px !important;
    color: #ccc !important;
    text-align: center !important;
    flex-shrink: 0 !important;
}

/* ===== SUGGESTIONS ===== */
#gcb-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 4px 0 8px 0;
}
.gcb-suggestion-btn {
    background: #fff;
    border: 1.5px solid var(--gcb-color);
    color: var(--gcb-color);
    border-radius: 20px;
    padding: 7px 14px;
    font-size: 12.5px;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    line-height: 1.3;
}
.gcb-suggestion-btn:hover {
    background: var(--gcb-color);
    color: #fff;
}

/* ===== ÉCRAN PRÉNOM ===== */
#gcb-prenom-screen {
    position: absolute;
    top: 66px;
    left: 0; right: 0; bottom: 0;
    background: #f0f2f5;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10;
    padding: 20px;
}
#gcb-prenom-inner {
    background: #fff;
    border-radius: 16px;
    padding: 28px 24px;
    width: 100%;
    max-width: 300px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    text-align: center;
}
#gcb-prenom-label {
    font-size: 15px;
    font-weight: 600;
    color: #333;
    margin: 0 0 16px 0;
}
#gcb-prenom-input {
    width: 100%;
    border: 1.5px solid #ddd;
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    box-sizing: border-box;
    margin-bottom: 14px;
    -webkit-appearance: none;
}
#gcb-prenom-input:focus { border-color: var(--gcb-color); }
#gcb-prenom-btns {
    display: flex;
    gap: 10px;
    justify-content: center;
}
#gcb-prenom-skip {
    background: transparent;
    border: 1.5px solid #ddd;
    color: #888;
    border-radius: 10px;
    padding: 9px 16px;
    font-size: 13px;
    cursor: pointer;
    font-family: inherit;
}
#gcb-prenom-start {
    background: var(--gcb-color);
    border: none;
    color: #fff;
    border-radius: 10px;
    padding: 9px 18px;
    font-size: 13px;
    cursor: pointer;
    font-family: inherit;
    font-weight: 600;
}
