/* ══════════════════════════════════════════════════════════════════════
   GoEvents — Chat (front-end)
   ══════════════════════════════════════════════════════════════════════ */

.ge-chat {
    --ge-chat-primary: #4F46E5;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    font-size: .9375rem;
    line-height: 1.45;
    color: #1d2327;
    box-sizing: border-box;
}
.ge-chat *, .ge-chat *::before, .ge-chat *::after { box-sizing: inherit; }

/* ── Bulle flottante ─────────────────────────────────────────────────── */

.ge-chat--floating {
    position: fixed;
    bottom: 20px;
    z-index: 99990;
}
.ge-chat--right { right: 20px; }
.ge-chat--left  { left: 20px; }

.ge-chat-toggle {
    position: relative;
    width: 56px;
    height: 56px;
    border: none;
    border-radius: 50%;
    background: var(--ge-chat-primary);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 20px rgba(15,23,42,.25);
    transition: transform .15s;
}
.ge-chat-toggle:hover { transform: scale(1.06); }
.ge-chat-toggle svg { position: relative; z-index: 1; }
/* Icône de chat quand le panneau est fermé, croix quand il est ouvert */
.ge-chat-toggle-close,
.ge-chat.is-open .ge-chat-toggle-open { display: none; }
.ge-chat.is-open .ge-chat-toggle-close { display: block; }

/* Ondes qui partent de l'icône tant que le chat est fermé */
.ge-chat-toggle::before,
.ge-chat-toggle::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: var(--ge-chat-primary);
    opacity: 0;
    pointer-events: none;
}
.ge-chat--floating:not(.is-open) .ge-chat-toggle::before { animation: ge-chat-wave 2.4s ease-out infinite; }
.ge-chat--floating:not(.is-open) .ge-chat-toggle::after  { animation: ge-chat-wave 2.4s ease-out 1.2s infinite; }

@keyframes ge-chat-wave {
    0%   { transform: scale(1);   opacity: .45; }
    100% { transform: scale(2.1); opacity: 0; }
}

/* Info-bulle « Discuter avec nous », pointée vers l'icône */
.ge-chat-teaser {
    position: absolute;
    bottom: 28px;
    transform: translateY(50%);
    max-width: calc(100vw - 110px);
    padding: 9px 14px;
    border: none;
    border-radius: 999px;
    background: #fff;
    color: #1d2327;
    font: inherit;
    font-size: .875rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    box-shadow: 0 6px 20px rgba(15,23,42,.18);
    cursor: pointer;
    animation: ge-chat-teaser-in .4s ease-out .6s both, ge-chat-teaser-nudge 2.4s ease-in-out 1s infinite;
}
.ge-chat--right .ge-chat-teaser { right: 74px; --ge-chat-nudge: 5px; }
.ge-chat--left  .ge-chat-teaser { left: 74px;  --ge-chat-nudge: -5px; }
/* Pointe tournée vers l'icône */
.ge-chat-teaser::after {
    content: "";
    position: absolute;
    top: 50%;
    width: 10px;
    height: 10px;
    background: #fff;
    transform: translateY(-50%) rotate(45deg);
}
.ge-chat--right .ge-chat-teaser::after { right: -4px; }
.ge-chat--left  .ge-chat-teaser::after { left: -4px; }
.ge-chat--floating.is-open .ge-chat-teaser { display: none; }

@keyframes ge-chat-teaser-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}
/* Léger mouvement vers l'icône, au rythme des ondes */
@keyframes ge-chat-teaser-nudge {
    0%, 100% { translate: 0 0; }
    50%      { translate: var(--ge-chat-nudge) 0; }
}
.ge-chat-toggle:focus-visible,
.ge-chat-close:focus-visible,
.ge-chat-send:focus-visible {
    outline: 2px solid var(--ge-chat-primary);
    outline-offset: 2px;
}

/* ── Panneau ─────────────────────────────────────────────────────────── */

.ge-chat-panel {
    display: flex;
    flex-direction: column;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    overflow: hidden;
}
.ge-chat-panel[hidden] { display: none; }

.ge-chat--floating .ge-chat-panel {
    position: absolute;
    bottom: 70px;
    width: 360px;
    max-width: calc(100vw - 40px);
    height: 580px;
    max-height: calc(100vh - 110px);
    box-shadow: 0 12px 40px rgba(15,23,42,.22);
}
.ge-chat--right .ge-chat-panel { right: 0; }
.ge-chat--left  .ge-chat-panel { left: 0; }

.ge-chat--inline { max-width: 560px; margin: 0 auto; }
.ge-chat--inline .ge-chat-panel { height: 560px; }

/* ── Vues (accueil / conversation) et onglets ────────────────────────── */

.ge-chat-view {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}
.ge-chat-view[hidden] { display: none; }

.ge-chat-hero {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    gap: 10px;
    padding: 22px 24px 64px;
    background:
        linear-gradient(160deg, rgba(255,255,255,.14), rgba(255,255,255,0) 60%),
        var(--ge-chat-primary);
    color: #fff;
}
.ge-chat-hero-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: auto;
    padding-bottom: 24px;
}
.ge-chat-hero .ge-chat-avatar { width: 46px; height: 46px; }
.ge-chat-hero-title {
    margin: 0;
    font-size: 1.875rem;
    font-weight: 700;
    line-height: 1.15;
    color: inherit;
}
.ge-chat-hero-text {
    margin: 0;
    font-size: 1.0625rem;
    line-height: 1.4;
    color: inherit;
    opacity: .95;
    white-space: pre-line;
}

.ge-chat-home-body {
    padding: 0 16px 16px;
    background: #fff;
}
.ge-chat-card {
    position: relative;
    width: 100%;
    margin-top: -40px;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 18px;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    background: #fff;
    color: #1d2327;
    font: inherit;
    text-align: left;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(15,23,42,.10);
    transition: box-shadow .15s, transform .15s;
}
.ge-chat-card:hover { box-shadow: 0 10px 28px rgba(15,23,42,.16); transform: translateY(-1px); }
.ge-chat-card-text { flex: 1; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.ge-chat-card-text strong { font-size: 1rem; font-weight: 600; }
.ge-chat-card-text span { font-size: .875rem; color: #64748b; }
.ge-chat-card svg { flex-shrink: 0; color: var(--ge-chat-primary); }

.ge-chat-tabs {
    display: flex;
    border-top: 1px solid #e2e8f0;
    background: #fff;
}
.ge-chat-tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 9px 8px 10px;
    border: none;
    background: transparent;
    color: #64748b;
    font: inherit;
    font-size: .8125rem;
    font-weight: 600;
    cursor: pointer;
}
.ge-chat-tab:hover { color: #1d2327; }
.ge-chat-tab.is-active { color: #1d2327; }
.ge-chat-tab.is-active svg { color: var(--ge-chat-primary); fill: var(--ge-chat-primary); }

.ge-chat-card:focus-visible,
.ge-chat-tab:focus-visible {
    outline: 2px solid var(--ge-chat-primary);
    outline-offset: -2px;
}

.ge-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    background: var(--ge-chat-primary);
    color: #fff;
}
.ge-chat-identity {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}
.ge-chat-avatar {
    position: relative;
    flex-shrink: 0;
    width: 40px;
    height: 40px;
}
/* Cadrage sur la tête du robot : l'image est agrandie dans un cercle */
.ge-chat-avatar-frame {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    overflow: hidden;
    background: #fff;
    border: 2px solid rgba(255,255,255,.85);
}
.ge-chat-avatar img {
    display: block;
    width: 150%;
    max-width: none;
    height: 150%;
    margin: -2% 0 0 -12%;
    object-fit: cover;
}
/* Pastille « en ligne » */
.ge-chat-avatar::after {
    content: "";
    position: absolute;
    right: 0;
    bottom: 0;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: #22c55e;
    border: 2px solid var(--ge-chat-primary);
}
.ge-chat-title { font-size: 1rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ge-chat-close {
    border: none;
    background: transparent;
    color: #fff;
    font-size: 1.5rem;
    line-height: 1;
    padding: 0 4px;
    cursor: pointer;
    opacity: .85;
}
.ge-chat-close:hover { opacity: 1; }
.ge-chat-close:focus-visible { outline-color: #fff; }
.ge-chat-hero .ge-chat-close { font-size: 1.75rem; }

/* ── Messages ────────────────────────────────────────────────────────── */

.ge-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: #f8fafc;
}

.ge-chat-msg {
    max-width: 85%;
    padding: 9px 13px;
    border-radius: 14px;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}
.ge-chat-msg--bot {
    align-self: flex-start;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-bottom-left-radius: 4px;
}
.ge-chat-msg--user {
    align-self: flex-end;
    background: var(--ge-chat-primary);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.ge-chat-msg--typing { color: #94a3b8; letter-spacing: 2px; }

/* Réponses du chatbot en HTML */
.ge-chat-msg--html { white-space: normal; }
.ge-chat-msg--html > :first-child { margin-top: 0; }
.ge-chat-msg--html > :last-child  { margin-bottom: 0; }
.ge-chat-msg--html p,
.ge-chat-msg--html ul,
.ge-chat-msg--html ol,
.ge-chat-msg--html blockquote,
.ge-chat-msg--html pre,
.ge-chat-msg--html table { margin: 0 0 8px; }
.ge-chat-msg--html ul,
.ge-chat-msg--html ol { padding-left: 20px; }
.ge-chat-msg--html li { margin: 0 0 2px; }
.ge-chat-msg--html h1,
.ge-chat-msg--html h2,
.ge-chat-msg--html h3,
.ge-chat-msg--html h4,
.ge-chat-msg--html h5,
.ge-chat-msg--html h6 { margin: 10px 0 6px; font-size: 1em; font-weight: 700; line-height: 1.3; color: inherit; }
.ge-chat-msg--html a { color: var(--ge-chat-primary); text-decoration: underline; }
.ge-chat-msg--html blockquote { padding-left: 10px; border-left: 3px solid #e2e8f0; color: #475569; }
.ge-chat-msg--html code { padding: 1px 4px; border-radius: 4px; background: #f1f5f9; font-size: .875em; }
.ge-chat-msg--html pre { padding: 8px 10px; border-radius: 6px; background: #f1f5f9; overflow-x: auto; }
.ge-chat-msg--html pre code { padding: 0; background: none; }
.ge-chat-msg--html table { display: block; overflow-x: auto; border-collapse: collapse; font-size: .875em; }
.ge-chat-msg--html th,
.ge-chat-msg--html td { padding: 4px 8px; border: 1px solid #e2e8f0; text-align: left; }
.ge-chat-msg--html hr { margin: 8px 0; border: 0; border-top: 1px solid #e2e8f0; }
.ge-chat-msg--error {
    background: #fef2f2;
    border-color: #fecaca;
    color: #b91c1c;
}

/* Relance par e-mail quand le chatbot n'a pas la réponse */
.ge-chat-lead {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
    white-space: normal;
}
.ge-chat-lead-email {
    flex: 1 1 140px;
    min-width: 0;
    border: 1.5px solid #e2e8f0;
    border-radius: 8px;
    padding: 6px 10px;
    font: inherit;
    color: inherit;
    background: #fff;
    outline: none;
}
.ge-chat-lead-email:focus { border-color: var(--ge-chat-primary); }
.ge-chat-lead-send {
    border: none;
    border-radius: 8px;
    padding: 6px 12px;
    background: var(--ge-chat-primary);
    color: #fff;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}
.ge-chat-lead-send:disabled { opacity: .5; cursor: not-allowed; }
.ge-chat-lead-send:focus-visible { outline: 2px solid var(--ge-chat-primary); outline-offset: 2px; }
.ge-chat-lead-error { flex-basis: 100%; margin: 0; color: #b91c1c; font-size: .8125rem; }

/* ── Saisie ──────────────────────────────────────────────────────────── */

.ge-chat-form {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid #e2e8f0;
    background: #fff;
}
.ge-chat-input {
    flex: 1;
    min-height: 40px;
    max-height: 120px;
    resize: none;
    border: 1.5px solid #e2e8f0;
    border-radius: 8px;
    padding: 8px 12px;
    font: inherit;
    color: inherit;
    background: #fff;
    outline: none;
    transition: border-color .15s;
}
.ge-chat-input:focus { border-color: var(--ge-chat-primary); }
.ge-chat-input::placeholder { color: #94a3b8; }

.ge-chat-send {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 8px;
    background: var(--ge-chat-primary);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity .15s;
}
.ge-chat-send:hover    { opacity: .9; }
.ge-chat-send:disabled { opacity: .5; cursor: not-allowed; }

@media (max-width: 480px) {
    .ge-chat--floating { bottom: 12px; }
    .ge-chat--right { right: 12px; }
    .ge-chat--left  { left: 12px; }
    .ge-chat--floating .ge-chat-panel { max-width: calc(100vw - 24px); }
}

@media (prefers-reduced-motion: reduce) {
    .ge-chat-toggle, .ge-chat-input, .ge-chat-send, .ge-chat-card { transition: none; }
    .ge-chat--floating:not(.is-open) .ge-chat-toggle::before,
    .ge-chat--floating:not(.is-open) .ge-chat-toggle::after,
    .ge-chat-teaser { animation: none; }
}
