/* ════════════════════════════════════════════════════════════════════════
 * AGENCE Web-Conseil-Digital — Widget de chat Axelle (v2)
 * Palette : bleu nuit + or chaud + crème (cohérence avec le site)
 * Mobile-first, accessible, performant.
 * ════════════════════════════════════════════════════════════════════════ */

:root {
    --cw-axelle-ink:        #0c1a3a;
    --cw-axelle-ink-soft:   #1a2a55;
    --cw-axelle-cream:      #f7f1e3;
    --cw-axelle-gold:       #d4a14a;
    --cw-axelle-gold-deep:  #b9852f;
    --cw-axelle-text:       #1d2434;
    --cw-axelle-muted:      #6c728a;
    --cw-axelle-border:     rgba(12, 26, 58, 0.12);
    --cw-axelle-shadow-sm:  0 4px 14px rgba(12, 26, 58, 0.10);
    --cw-axelle-shadow-md:  0 12px 30px rgba(12, 26, 58, 0.18);
    --cw-axelle-shadow-lg:  0 24px 60px rgba(12, 26, 58, 0.30);
    --cw-axelle-radius:     20px;
}

.cw-axelle {
    position: fixed;
    z-index: 9999;
    bottom: 22px;
    right: 22px;
    font-family: inherit;
    color: var(--cw-axelle-text);
    line-height: 1.45;
}

/* ── Bulle d'invitation ─────────────────────────────────────────────── */
.cw-axelle__bubble {
    display: inline-flex;
    align-items: center;
    gap: 14px;
    padding: 8px 18px 8px 8px;
    border: 1px solid var(--cw-axelle-border);
    border-radius: 999px;
    background: linear-gradient(135deg, #ffffff 0%, var(--cw-axelle-cream) 100%);
    box-shadow: var(--cw-axelle-shadow-md);
    cursor: pointer;
    transition: transform .18s ease, box-shadow .18s ease;
    color: var(--cw-axelle-ink);
    font-family: inherit;
}
.cw-axelle__bubble:hover,
.cw-axelle__bubble:focus-visible {
    transform: translateY(-2px);
    box-shadow: var(--cw-axelle-shadow-lg);
    outline: none;
}

.cw-axelle__bubble-photo {
    position: relative;
    width: 54px;
    height: 54px;
    border-radius: 50%;
    overflow: visible;
    flex-shrink: 0;
}
.cw-axelle__bubble-photo img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--cw-axelle-gold);
    box-shadow: 0 2px 8px rgba(180, 130, 50, 0.4);
    background: var(--cw-axelle-cream);
}
.cw-axelle__bubble-pulse {
    position: absolute;
    bottom: 1px;
    right: 1px;
    width: 13px;
    height: 13px;
    background: #2ecc71;
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 0 0 0 rgba(46, 204, 113, 0.55);
    animation: cw-pulse 2s infinite;
}
@keyframes cw-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(46, 204, 113, 0.55); }
    70%  { box-shadow: 0 0 0 10px rgba(46, 204, 113, 0); }
    100% { box-shadow: 0 0 0 0 rgba(46, 204, 113, 0);    }
}

.cw-axelle__bubble-label {
    display: flex;
    flex-direction: column;
    text-align: left;
    line-height: 1.2;
}
.cw-axelle__bubble-label strong {
    font-weight: 700;
    font-size: 15px;
    color: var(--cw-axelle-ink);
    white-space: nowrap;
}
.cw-axelle__bubble-label em {
    font-style: normal;
    font-size: 12px;
    color: var(--cw-axelle-muted);
    margin-top: 2px;
    white-space: nowrap;
}
.cw-axelle__bubble-arrow {
    color: var(--cw-axelle-gold);
    margin-left: 2px;
    transition: transform .18s ease;
}
.cw-axelle__bubble:hover .cw-axelle__bubble-arrow {
    transform: translateX(2px);
}

/* ── Backdrop ─────────────────────────────────────────────────────── */
.cw-axelle__backdrop[hidden] { display: none !important; }
.cw-axelle__backdrop {
    position: fixed;
    inset: 0;
    background: rgba(12, 26, 58, 0.55);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    z-index: 9998;
    animation: cw-fade-in .2s ease-out;
}
@keyframes cw-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ── Panel ─────────────────────────────────────────────────────────── */
.cw-axelle__panel[hidden] { display: none !important; }
.cw-axelle__panel {
    position: fixed;
    right: 22px;
    bottom: 22px;
    width: min(420px, calc(100vw - 32px));
    height: min(640px, calc(100dvh - 80px));
    background: #ffffff;
    border: 1px solid var(--cw-axelle-border);
    border-radius: var(--cw-axelle-radius);
    box-shadow: var(--cw-axelle-shadow-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform-origin: bottom right;
    animation: cw-slide-up .28s cubic-bezier(.18,.78,.34,1.05);
    z-index: 9999;
}
@keyframes cw-slide-up {
    from { transform: translateY(20px) scale(.96); opacity: 0; }
    to   { transform: translateY(0) scale(1);     opacity: 1; }
}

/* ── Header ────────────────────────────────────────────────────────── */
.cw-axelle__header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: linear-gradient(135deg, var(--cw-axelle-ink) 0%, var(--cw-axelle-ink-soft) 100%);
    color: #fff;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.cw-axelle__header-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    overflow: hidden;
    border: 2px solid var(--cw-axelle-gold);
    flex-shrink: 0;
    background: var(--cw-axelle-cream);
}
.cw-axelle__header-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.cw-axelle__header-meta {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
    flex: 1;
    min-width: 0;
}
.cw-axelle__header-meta strong { font-size: 15px; font-weight: 700; }
.cw-axelle__header-meta span { font-size: 12px; opacity: .8; }
.cw-axelle__status {
    display: inline-flex !important;
    align-items: center;
    gap: 5px;
    margin-top: 2px;
    color: #b1f0c5 !important;
    font-size: 11px !important;
}
.cw-axelle__status::before {
    content: '';
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #2ecc71;
    box-shadow: 0 0 6px rgba(46, 204, 113, 0.7);
}
.cw-axelle__close {
    background: rgba(255, 255, 255, 0.08);
    border: none;
    color: #fff;
    cursor: pointer;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    transition: background .15s ease, transform .15s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.cw-axelle__close:hover {
    background: rgba(255, 255, 255, 0.18);
    transform: rotate(90deg);
}

/* ── Messages ──────────────────────────────────────────────────────── */
.cw-axelle__messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: linear-gradient(180deg, #fbfaf6 0%, #ffffff 100%);
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}
.cw-axelle__msg {
    max-width: 84%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 14.5px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-wrap: break-word;
}
.cw-axelle__msg--bot {
    align-self: flex-start;
    background: #fff;
    border: 1px solid var(--cw-axelle-border);
    box-shadow: var(--cw-axelle-shadow-sm);
    color: var(--cw-axelle-text);
    border-bottom-left-radius: 4px;
}
.cw-axelle__msg--user {
    align-self: flex-end;
    background: linear-gradient(135deg, var(--cw-axelle-ink) 0%, var(--cw-axelle-ink-soft) 100%);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.cw-axelle__msg--typing {
    display: inline-flex;
    gap: 4px;
    padding: 12px 16px;
}
.cw-axelle__msg--typing span {
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--cw-axelle-muted);
    opacity: .3;
    animation: cw-bounce 1.2s infinite;
}
.cw-axelle__msg--typing span:nth-child(2) { animation-delay: .15s; }
.cw-axelle__msg--typing span:nth-child(3) { animation-delay: .30s; }
@keyframes cw-bounce {
    0%, 80%, 100% { transform: translateY(0);   opacity: .3; }
    40%           { transform: translateY(-5px); opacity: 1; }
}

/* ── Note « Conversation reprise » ──────────────────────────────── */
.cw-axelle__resume-note {
    align-self: center;
    font-size: 11px;
    color: var(--cw-axelle-muted);
    background: var(--cw-axelle-cream);
    padding: 4px 12px;
    border-radius: 999px;
    margin-bottom: 4px;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

/* ── Bouton « Écouter » (fallback autoplay bloqué) ──────────────── */
.cw-axelle__listen {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    padding: 5px 12px;
    border-radius: 999px;
    background: var(--cw-axelle-cream);
    color: var(--cw-axelle-ink);
    border: 1px solid rgba(180, 130, 50, 0.35);
    font-family: inherit;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    transition: transform .15s ease, box-shadow .15s ease;
}
.cw-axelle__listen:hover {
    transform: translateY(-1px);
    box-shadow: var(--cw-axelle-shadow-sm);
}

/* ── Boutons d'action ─────────────────────────────────────────────── */
.cw-axelle__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}
.cw-axelle__action {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    transition: transform .15s ease, box-shadow .15s ease;
    cursor: pointer;
    border: 0;
}
.cw-axelle__action--call {
    background: linear-gradient(135deg, var(--cw-axelle-gold) 0%, var(--cw-axelle-gold-deep) 100%);
    color: #fff;
    box-shadow: 0 4px 14px rgba(180, 130, 50, 0.35);
}
.cw-axelle__action--email {
    background: #fff;
    color: var(--cw-axelle-ink);
    border: 1px solid var(--cw-axelle-border);
    box-shadow: var(--cw-axelle-shadow-sm);
}
.cw-axelle__action--link {
    background: var(--cw-axelle-cream);
    color: var(--cw-axelle-ink);
    border: 1px solid rgba(180, 130, 50, 0.25);
}
.cw-axelle__action:hover {
    transform: translateY(-1px);
    box-shadow: var(--cw-axelle-shadow-md);
}

/* ── Form ──────────────────────────────────────────────────────────── */
.cw-axelle__form {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid var(--cw-axelle-border);
    background: #fff;
}
.cw-axelle__voice-toggle {
    cursor: pointer;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--cw-axelle-cream);
    color: var(--cw-axelle-ink);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    transition: background .15s ease, color .15s ease;
    flex-shrink: 0;
}
.cw-axelle__voice-toggle input { display: none; }
.cw-axelle__voice-on, .cw-axelle__voice-off {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.cw-axelle__voice-toggle .cw-axelle__voice-on  { display: none; }
.cw-axelle__voice-toggle .cw-axelle__voice-off { display: inline-flex; }
.cw-axelle__voice-toggle:has(input:checked) {
    background: linear-gradient(135deg, var(--cw-axelle-gold) 0%, var(--cw-axelle-gold-deep) 100%);
    color: #fff;
}
.cw-axelle__voice-toggle:has(input:checked) .cw-axelle__voice-on  { display: inline-flex; }
.cw-axelle__voice-toggle:has(input:checked) .cw-axelle__voice-off { display: none; }
.cw-axelle__voice-toggle:hover { filter: brightness(1.05); }

#cw-axelle-input {
    flex: 1;
    border: 1px solid var(--cw-axelle-border);
    border-radius: 999px;
    padding: 9px 16px;
    font-size: 14.5px;
    outline: none;
    background: #fbfaf6;
    color: var(--cw-axelle-text);
    transition: border-color .15s ease, background .15s ease;
}
#cw-axelle-input:focus {
    border-color: var(--cw-axelle-gold);
    background: #fff;
}
.cw-axelle__send {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 0;
    background: linear-gradient(135deg, var(--cw-axelle-ink) 0%, var(--cw-axelle-ink-soft) 100%);
    color: #fff;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform .15s ease, box-shadow .15s ease;
    box-shadow: 0 4px 12px rgba(12, 26, 58, 0.25);
    flex-shrink: 0;
}
.cw-axelle__send:hover {
    transform: scale(1.06);
    box-shadow: 0 6px 18px rgba(12, 26, 58, 0.35);
}
.cw-axelle__send:disabled {
    opacity: .5;
    cursor: not-allowed;
}

/* ── Footer ────────────────────────────────────────────────────────── */
.cw-axelle__footer {
    text-align: center;
    font-size: 11px;
    padding: 8px 14px;
    color: var(--cw-axelle-muted);
    border-top: 1px solid var(--cw-axelle-border);
    background: #fbfaf6;
}

/* ── Mode ouvert : on cache la bulle ──────────────────────────────── */
.cw-axelle.is-open .cw-axelle__bubble { display: none; }

/* ── Body lock quand chat ouvert (pas de double scroll) ──────────── */
body.cw-axelle-open {
    overflow: hidden;
    /* On laisse la position normale pour ne pas casser le scroll restoration */
}

/* ════════════════════════════════════════════════════════════════════
 * MOBILE — Bottom sheet aéré, PAS plein écran brut
 * On garde une marge en haut, des coins arrondis et un overlay sombre.
 * ════════════════════════════════════════════════════════════════════ */
@media (max-width: 540px) {
    /* Sur mobile, la bulle flottante est CACHÉE :
       c'est le sticky CTA qui contient le bouton "Parler à Axelle". */
    .cw-axelle:not(.is-open) .cw-axelle__bubble { display: none; }

    .cw-axelle__panel {
        right: 0;
        left: 0;
        bottom: 0;
        width: 100vw;
        height: 88dvh;
        max-height: 88dvh;
        border-radius: 22px 22px 0 0;
        animation: cw-slide-up-mobile .3s cubic-bezier(.18,.78,.34,1.05);
    }
    @keyframes cw-slide-up-mobile {
        from { transform: translateY(100%); }
        to   { transform: translateY(0); }
    }

    /* Petite barre de drag visuelle en haut du panel */
    .cw-axelle__panel::before {
        content: '';
        position: absolute;
        top: 8px;
        left: 50%;
        width: 38px;
        height: 4px;
        margin-left: -19px;
        background: rgba(255, 255, 255, 0.35);
        border-radius: 999px;
        z-index: 1;
        pointer-events: none;
    }

    .cw-axelle__header {
        padding-top: 22px; /* place pour la barre de drag */
    }
}

/* ════════════════════════════════════════════════════════════════════
 * STICKY MOBILE-CTA : bouton "Parler à Axelle"
 * ════════════════════════════════════════════════════════════════════ */
.mobile-cta__btn--axelle {
    background: linear-gradient(135deg, var(--cw-axelle-ink) 0%, var(--cw-axelle-ink-soft) 100%);
    color: #fff;
    border: 0;
    cursor: pointer;
    font: inherit;
}
.mobile-cta__btn--axelle:hover {
    filter: brightness(1.08);
}

/* ── Réduit : a11y ─────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    .cw-axelle__bubble-pulse { animation: none; }
    .cw-axelle__panel,
    .cw-axelle__backdrop { animation: none; }
    .cw-axelle__msg--typing span { animation: none; opacity: .6; }
}
