/* Chat automatique A.F.3C.SNJ */
.afc-chat {
    --c: #0b7a28;
    --c-dark: #09611f;
    --c-soft: #e6f5ea;
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 2000;
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
    font-size: 15px;
    line-height: 1.5;
}
.afc-chat *, .afc-chat *::before, .afc-chat *::after { box-sizing: border-box; }

/* Bouton principal + éventail */
.afc-fab, .afc-dial a, .afc-dial button {
    width: 56px; height: 56px; border-radius: 50%;
    border: 0; padding: 0; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    color: #fff; text-decoration: none;
    box-shadow: 0 6px 18px rgba(15, 23, 42, .25);
    transition: transform .2s ease, box-shadow .2s ease;
}
.afc-fab { background: var(--c); position: relative; }
.afc-fab:hover, .afc-dial a:hover, .afc-dial button:hover { transform: scale(1.08); box-shadow: 0 10px 26px rgba(15, 23, 42, .3); }
.afc-fab svg, .afc-dial svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.afc-fab .ic-close { display: none; }
.afc-chat.is-open .afc-fab .ic-send, .afc-chat.is-dial .afc-fab .ic-send { display: none; }
.afc-chat.is-open .afc-fab .ic-close, .afc-chat.is-dial .afc-fab .ic-close { display: block; }
.afc-fab::after {
    content: ''; position: absolute; inset: 0; border-radius: 50%;
    border: 2px solid var(--c); animation: afcPulse 2.4s ease-out infinite;
}
.afc-chat.is-open .afc-fab::after, .afc-chat.is-dial .afc-fab::after { display: none; }
@keyframes afcPulse { from { transform: scale(1); opacity: .6; } to { transform: scale(1.6); opacity: 0; } }

.afc-dial {
    position: absolute; right: 0; bottom: 70px;
    display: flex; flex-direction: column; gap: 12px; align-items: center;
    visibility: hidden; pointer-events: none;
}
.afc-chat.is-dial .afc-dial { visibility: visible; pointer-events: auto; }
.afc-dial > * { opacity: 0; transform: translateY(14px) scale(.8); transition: opacity .2s ease, transform .2s ease, box-shadow .2s ease; }
.afc-chat.is-dial .afc-dial > * { opacity: 1; transform: none; }
.afc-chat.is-dial .afc-dial > *:nth-last-child(2) { transition-delay: .04s; }
.afc-chat.is-dial .afc-dial > *:nth-last-child(3) { transition-delay: .08s; }
.afc-chat.is-dial .afc-dial > *:nth-last-child(4) { transition-delay: .12s; }
.afc-dial .d-chat { background: var(--c); }
.afc-dial .d-wa { background: #25d366; }
.afc-dial .d-tel { background: #1f8a2b; }
.afc-dial .d-mail { background: #3b82f6; }
.afc-dial .d-wa svg { fill: currentColor; stroke: none; }

/* Fenêtre de discussion */
.afc-window {
    position: absolute; right: 0; bottom: 72px;
    width: 380px; max-width: calc(100vw - 40px);
    height: 560px; max-height: calc(100vh - 110px);
    background: #fff; border-radius: 20px; overflow: hidden;
    display: flex; flex-direction: column;
    box-shadow: 0 20px 60px rgba(15, 23, 42, .28);
    opacity: 0; visibility: hidden; transform: translateY(16px) scale(.98); transform-origin: bottom right;
    transition: opacity .22s ease, transform .22s ease, visibility .22s;
}
.afc-chat.is-open .afc-window { opacity: 1; visibility: visible; transform: none; }

.afc-head { background: var(--c); color: #fff; padding: 16px 18px; display: flex; align-items: center; gap: 12px; }
.afc-avatar { width: 42px; height: 42px; border-radius: 50%; background: #fff; display: flex; align-items: center; justify-content: center; overflow: hidden; flex-shrink: 0; }
.afc-avatar img { width: 30px; height: 30px; object-fit: contain; }
.afc-title { font-weight: 700; font-size: 1.05rem; letter-spacing: .01em; }
.afc-status { font-size: .75rem; opacity: .85; display: flex; align-items: center; gap: 6px; }
.afc-status::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: #7CFF9D; }
.afc-close { margin-left: auto; background: none; border: 0; color: #fff; cursor: pointer; padding: 6px; border-radius: 8px; }
.afc-close:hover { background: rgba(255, 255, 255, .15); }
.afc-close svg { width: 20px; height: 20px; stroke: currentColor; stroke-width: 2.2; fill: none; stroke-linecap: round; }

.afc-body { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; background: #fff; scroll-behavior: smooth; }
.afc-msg { max-width: 88%; padding: 11px 15px; border-radius: 14px; white-space: pre-line; word-wrap: break-word; animation: afcIn .25s ease; }
.afc-msg.bot { background: #f4f5f7; color: #222; align-self: flex-start; border-bottom-left-radius: 4px; }
.afc-msg.user { background: var(--c-soft); color: #0b3d18; align-self: flex-end; border-bottom-right-radius: 4px; }
.afc-msg a { color: var(--c); font-weight: 600; text-decoration: underline; }
@keyframes afcIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.afc-typing { display: inline-flex; gap: 4px; padding: 14px 16px; }
.afc-typing i { width: 7px; height: 7px; border-radius: 50%; background: #9aa1ab; animation: afcDot 1s infinite ease-in-out; }
.afc-typing i:nth-child(2) { animation-delay: .15s; }
.afc-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes afcDot { 0%, 80%, 100% { transform: scale(.6); opacity: .5; } 40% { transform: scale(1); opacity: 1; } }

.afc-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 2px; }
.afc-chip { background: #fff; border: 1.5px solid var(--c); color: var(--c); border-radius: 999px; padding: 6px 13px; font-size: .85rem; font-weight: 600; cursor: pointer; font-family: inherit; transition: all .15s ease; }
.afc-chip:hover { background: var(--c); color: #fff; }

.afc-foot { padding: 0 12px 12px; background: #fff; }
.afc-terms { display: flex; align-items: center; justify-content: space-between; background: #f4f5f7; border-radius: 12px 12px 0 0; padding: 6px 12px; font-size: .78rem; color: #333; }
.afc-terms button { background: none; border: 0; cursor: pointer; font-size: 1.1rem; line-height: 1; color: #333; }
.afc-form { display: flex; align-items: center; border: 1.5px solid #d4d8de; border-radius: 12px; padding: 4px 6px 4px 14px; background: #fff; }
.afc-terms + .afc-form { margin-top: 6px; }
.afc-form:focus-within { border-color: var(--c); box-shadow: 0 0 0 3px rgba(11, 122, 40, .15); }
.afc-form input { flex: 1; border: 0; outline: 0; font: inherit; padding: 10px 0; min-width: 0; background: transparent; }
.afc-form button { width: 38px; height: 38px; border: 0; border-radius: 10px; background: transparent; color: #8a919c; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.afc-form button:hover, .afc-form input:valid + button { color: var(--c); }
.afc-form button svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

@media (max-width: 480px) {
    .afc-chat { right: 14px; bottom: 14px; }
    .afc-window { position: fixed; inset: 0; width: 100%; max-width: none; height: 100%; max-height: none; border-radius: 0; }
    .afc-chat.is-open .afc-fab { display: none; }
}
@media (prefers-reduced-motion: reduce) {
    .afc-chat * { animation: none !important; transition: none !important; }
}
