/* ============================================================
   ANW Solutions – Widget Chatbot
   public/assets/css/chatbot.css
   ============================================================ */

/* ── Variables locales ───────────────────────────────────── */
#anw-chat {
    --cb-primary:    #1A4E8C;
    --cb-primary-dk: #133a6a;
    --cb-wa:         #25D366;
    --cb-white:      #ffffff;
    --cb-light:      #f0f4f8;
    --cb-border:     #e2e8f0;
    --cb-text:       #1A1A2E;
    --cb-text-lt:    #64748b;
    --cb-radius:     14px;
    --cb-shadow:     0 8px 32px rgba(26,78,140,.18), 0 2px 8px rgba(0,0,0,.08);
    --cb-tr:         220ms cubic-bezier(.16,1,.3,1);
    font-family: 'Inter', system-ui, sans-serif;
}

/* ── Bulle flottante ─────────────────────────────────────── */
.anw-chat__bubble {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9998;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--cb-primary);
    color: var(--cb-white);
    box-shadow: 0 4px 16px rgba(26,78,140,.45);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform var(--cb-tr), box-shadow var(--cb-tr), background var(--cb-tr);
    cursor: pointer;
    border: none;
    padding: 0;
}

.anw-chat__bubble:hover {
    background: var(--cb-primary-dk);
    transform: scale(1.08);
    box-shadow: 0 6px 20px rgba(26,78,140,.55);
}

.anw-chat__bubble:focus-visible {
    outline: 3px solid rgba(26,78,140,.45);
    outline-offset: 3px;
}

.anw-chat__icon-chat,
.anw-chat__icon-close {
    width: 24px;
    height: 24px;
    position: absolute;
    transition: opacity var(--cb-tr), transform var(--cb-tr);
}

.anw-chat__icon-close {
    opacity: 0;
    transform: rotate(-90deg) scale(.6);
}

#anw-chat-toggle[aria-expanded="true"] .anw-chat__icon-chat {
    opacity: 0;
    transform: rotate(90deg) scale(.6);
}
#anw-chat-toggle[aria-expanded="true"] .anw-chat__icon-close {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

/* Badge d'attention */
.anw-chat__badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #dc2626;
    color: #fff;
    font-size: .625rem;
    font-weight: 700;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: cb-badge-pulse 2s infinite;
    pointer-events: none;
}

@keyframes cb-badge-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(220,38,38,.55); }
    50%       { box-shadow: 0 0 0 6px rgba(220,38,38,0); }
}

/* ── Fenêtre de chat ─────────────────────────────────────── */
.anw-chat__window {
    position: fixed;
    bottom: 92px;
    right: 24px;
    z-index: 9999;
    width: 360px;
    max-height: 530px;
    background: var(--cb-white);
    border-radius: var(--cb-radius);
    box-shadow: var(--cb-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: cb-slide-in var(--cb-tr) both;
}

@keyframes cb-slide-in {
    from { opacity: 0; transform: translateY(14px) scale(.97); }
    to   { opacity: 1; transform: translateY(0)    scale(1);   }
}

.anw-chat__window[hidden] { display: none !important; }

/* ── En-tête ─────────────────────────────────────────────── */
.anw-chat__header {
    background: linear-gradient(135deg, var(--cb-primary) 0%, var(--cb-primary-dk) 100%);
    color: var(--cb-white);
    padding: .875rem 1rem;
    display: flex;
    align-items: center;
    gap: .75rem;
    flex-shrink: 0;
}

.anw-chat__avatar {
    width: 38px;
    height: 38px;
    background: rgba(255,255,255,.18);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .625rem;
    font-weight: 700;
    letter-spacing: .05em;
    flex-shrink: 0;
    border: 1.5px solid rgba(255,255,255,.25);
}

.anw-chat__header-name {
    font-size: .875rem;
    font-weight: 600;
    line-height: 1.3;
}

.anw-chat__header-status {
    font-size: .6875rem;
    opacity: .8;
    display: flex;
    align-items: center;
    gap: .3rem;
    margin-top: .1rem;
}

.anw-chat__header-status::before {
    content: '';
    width: 7px;
    height: 7px;
    background: #4ade80;
    border-radius: 50%;
    flex-shrink: 0;
}

.anw-chat__close-btn {
    margin-left: auto;
    background: none;
    border: none;
    color: rgba(255,255,255,.65);
    cursor: pointer;
    font-size: 1.125rem;
    line-height: 1;
    padding: .25rem .375rem;
    border-radius: 4px;
    transition: color var(--cb-tr), background var(--cb-tr);
    flex-shrink: 0;
    font-family: inherit;
}

.anw-chat__close-btn:hover {
    color: var(--cb-white);
    background: rgba(255,255,255,.12);
}

/* ── Zone messages ───────────────────────────────────────── */
.anw-chat__messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: .625rem;
    scroll-behavior: smooth;
    min-height: 80px;
}

.anw-chat__messages::-webkit-scrollbar { width: 4px; }
.anw-chat__messages::-webkit-scrollbar-thumb {
    background: var(--cb-border);
    border-radius: 2px;
}

/* Bulles */
.anw-chat__msg {
    max-width: 84%;
    padding: .625rem .875rem;
    border-radius: 14px;
    font-size: .875rem;
    line-height: 1.55;
    animation: cb-msg-in 180ms ease-out both;
}

@keyframes cb-msg-in {
    from { opacity: 0; transform: translateY(5px); }
    to   { opacity: 1; transform: translateY(0);   }
}

.anw-chat__msg--bot {
    background: var(--cb-light);
    color: var(--cb-text);
    border-bottom-left-radius: 4px;
    align-self: flex-start;
}

.anw-chat__msg--user {
    background: var(--cb-primary);
    color: var(--cb-white);
    border-bottom-right-radius: 4px;
    align-self: flex-end;
}

/* Indicateur "en cours de frappe" */
.anw-chat__typing {
    display: flex;
    gap: 4px;
    align-items: center;
    padding: .625rem .875rem;
    background: var(--cb-light);
    border-radius: 14px;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
    width: 56px;
}

.anw-chat__typing span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #94a3b8;
    animation: cb-typing 1.2s ease-in-out infinite;
}

.anw-chat__typing span:nth-child(2) { animation-delay: .2s; }
.anw-chat__typing span:nth-child(3) { animation-delay: .4s; }

@keyframes cb-typing {
    0%, 60%, 100% { transform: translateY(0);   opacity: .55; }
    30%            { transform: translateY(-6px); opacity: 1;   }
}

/* ── Zone choix ──────────────────────────────────────────── */
.anw-chat__choices {
    padding: .5rem .75rem .875rem;
    display: flex;
    flex-direction: column;
    gap: .375rem;
    flex-shrink: 0;
    border-top: 1px solid var(--cb-border);
    background: var(--cb-white);
    max-height: 240px;
    overflow-y: auto;
}

.anw-chat__choices::-webkit-scrollbar { width: 3px; }
.anw-chat__choices::-webkit-scrollbar-thumb {
    background: var(--cb-border);
    border-radius: 2px;
}

.anw-chat__choice {
    background: var(--cb-white);
    border: 1.5px solid var(--cb-border);
    border-radius: 8px;
    padding: .5rem .75rem;
    font-size: .8125rem;
    color: var(--cb-text);
    text-align: left;
    cursor: pointer;
    transition: border-color var(--cb-tr), background var(--cb-tr), color var(--cb-tr);
    line-height: 1.4;
    animation: cb-msg-in 160ms ease-out both;
    font-family: inherit;
}

.anw-chat__choice:hover {
    border-color: var(--cb-primary);
    background: #eef4fb;
    color: var(--cb-primary);
}

/* ── CTAs finaux ─────────────────────────────────────────── */
.anw-chat__cta-wrap {
    display: flex;
    flex-direction: column;
    gap: .5rem;
    padding-top: .125rem;
}

.anw-chat__cta {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    padding: .625rem 1rem;
    border-radius: 8px;
    font-size: .875rem;
    font-weight: 600;
    text-decoration: none;
    transition: opacity var(--cb-tr), transform var(--cb-tr);
    cursor: pointer;
    border: none;
    font-family: inherit;
    line-height: 1.3;
}

.anw-chat__cta:hover {
    opacity: .88;
    transform: translateY(-1px);
    text-decoration: none;
}

.anw-chat__cta--wa    { background: var(--cb-wa);      color: var(--cb-white); }
.anw-chat__cta--email { background: var(--cb-primary);  color: var(--cb-white); }

.anw-chat__cta--outline {
    background: transparent;
    border: 1.5px solid var(--cb-border);
    color: var(--cb-text-lt);
    font-size: .8125rem;
    font-weight: 500;
}

.anw-chat__cta--outline:hover {
    border-color: var(--cb-primary);
    color: var(--cb-primary);
    opacity: 1;
}

.anw-chat__restart {
    background: none;
    border: none;
    color: var(--cb-text-lt);
    font-size: .75rem;
    cursor: pointer;
    text-align: center;
    padding: .25rem;
    margin-top: .125rem;
    transition: color var(--cb-tr);
    font-family: inherit;
    display: block;
    width: 100%;
}

.anw-chat__restart:hover { color: var(--cb-primary); }

/* ── Formulaire inline ───────────────────────────────────── */
.anw-chat__choices--form { max-height: 340px; }

.anw-chat__cform {
    display: flex;
    flex-direction: column;
    gap: .4375rem;
    padding-top: .125rem;
}

.anw-chat__cform-row {
    display: flex;
    gap: .4375rem;
}

.anw-chat__cform-input {
    width: 100%;
    padding: .5rem .625rem;
    border: 1.5px solid var(--cb-border);
    border-radius: 7px;
    font-size: .8125rem;
    font-family: inherit;
    color: var(--cb-text);
    background: var(--cb-white);
    transition: border-color var(--cb-tr);
    outline: none;
    min-width: 0;
}

.anw-chat__cform-input:focus {
    border-color: var(--cb-primary);
    box-shadow: 0 0 0 3px rgba(26,78,140,.1);
}

.anw-chat__cform-input::placeholder { color: var(--cb-text-lt); }

.anw-chat__cform-error {
    font-size: .75rem;
    color: #dc2626;
    margin: 0;
    animation: cb-msg-in 150ms ease-out both;
}

.anw-chat__cform-or {
    text-align: center;
    font-size: .75rem;
    color: var(--cb-text-lt);
    margin: .125rem 0 0;
}

/* ── Notice de reprise ───────────────────────────────────── */
.anw-chat__resume-notice {
    font-size: .6875rem;
    color: var(--cb-text-lt);
    text-align: center;
    padding: .375rem 0 .25rem;
    letter-spacing: .02em;
}

/* ── Mobile ──────────────────────────────────────────────── */
@media (max-width: 420px) {
    .anw-chat__window {
        width: calc(100vw - 24px);
        right: 12px;
        bottom: 80px;
        max-height: calc(100dvh - 100px);
    }

    .anw-chat__bubble {
        bottom: 16px;
        right: 12px;
    }
}
