/**
 * BCS Frontend Chat CSS — v1.9.1 (PATCH PRODUCTION)
 * UX-01 : indicateur de frappe 3 points (remplace animation blink sur texte)
 * UX-05 : focus visible amélioré pour accessibilité
 */

:root {
    --bcs-chat-primary:   #0073aa;
    --bcs-chat-secondary: #f0f0f1;
    --bcs-chat-text:      #333333;
    --bcs-chat-bg:        #ffffff;
    --bcs-chat-radius:    12px;
}

/* ── Floating Action Button ── */
.bcs-chat-fab {
    position: fixed;
    bottom: 85px;
    right: 24px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background-color: var(--bcs-chat-primary);
    color: white;
    border: none;
    box-shadow: 0 4px 14px rgba(0,0,0,.20);
    cursor: pointer;
    z-index: 2147483647;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform .2s ease, box-shadow .2s ease;
}
.bcs-chat-fab:hover  { transform: scale(1.08); box-shadow: 0 6px 18px rgba(0,0,0,.25); }
.bcs-chat-fab:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
.bcs-chat-fab .dashicons { font-size: 30px; width: 30px; height: 30px; }

/* ── Widget container ── */
.bcs-chat-widget {
    position: fixed;
    bottom: 160px;
    right: 24px;
    width: 350px;
    max-width: calc(100vw - 48px);
    height: 500px;
    max-height: calc(100vh - 180px);
    background-color: var(--bcs-chat-bg);
    border-radius: var(--bcs-chat-radius);
    box-shadow: 0 6px 30px rgba(0,0,0,.22);
    display: flex;
    flex-direction: column;
    z-index: 2147483647;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

/* ── Header ── */
.bcs-chat-header {
    background-color: var(--bcs-chat-primary);
    color: white;
    padding: 14px 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}
.bcs-chat-title      { font-weight: 600; font-size: 16px; }
.bcs-chat-toggle-btn { background: none; border: none; color: white; font-size: 24px; cursor: pointer; padding: 0; line-height: 1; }
.bcs-chat-toggle-btn:hover { opacity: .8; }

/* ── Corps / messages ── */
.bcs-chat-body {
    flex-grow: 1;
    padding: 14px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background-color: #f9f9f9;
}

.bcs-chat-msg {
    max-width: 82%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}
.bcs-chat-msg a { color: inherit; text-decoration: underline; }

.bcs-chat-assistant {
    align-self: flex-start;
    background-color: var(--bcs-chat-secondary);
    color: var(--bcs-chat-text);
    border-bottom-left-radius: 4px;
}
.bcs-chat-user {
    align-self: flex-end;
    background-color: var(--bcs-chat-primary);
    color: white;
    border-bottom-right-radius: 4px;
}

/* ── Indicateur de frappe 3 points (UX-01) ── */
.bcs-chat-typing {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 12px 16px;
}
.bcs-chat-typing span {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #aaa;
    animation: bcs-bounce .9s infinite ease-in-out;
}
.bcs-chat-typing span:nth-child(2) { animation-delay: .15s; }
.bcs-chat-typing span:nth-child(3) { animation-delay: .30s; }

@keyframes bcs-bounce {
    0%, 60%, 100% { transform: translateY(0);    opacity: .5; }
    30%           { transform: translateY(-6px); opacity: 1;   }
}

/* ── Footer / formulaire ── */
.bcs-chat-footer {
    padding: 12px 14px;
    background-color: white;
    border-top: 1px solid #eee;
    flex-shrink: 0;
}
#bcs-chat-form  { display: flex; gap: 10px; margin: 0; }
#bcs-chat-input {
    flex-grow: 1;
    padding: 10px 14px;
    border: 1px solid #ddd;
    border-radius: 20px;
    font-size: 14px;
    outline: none;
    transition: border-color .2s;
}
#bcs-chat-input:focus { border-color: var(--bcs-chat-primary); }

#bcs-chat-submit {
    background-color: var(--bcs-chat-primary);
    color: white;
    border: none;
    border-radius: 50%;
    width: 42px;
    height: 42px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: filter .2s;
}
#bcs-chat-submit:hover    { filter: brightness(1.12); }
#bcs-chat-submit:disabled { opacity: .5; cursor: not-allowed; }

/* ── Message d'escalade vers support humain (UX-1) ── */
.bcs-chat-escalated {
    align-self: flex-start;
    background-color: #fff3cd;
    color: #664d03;
    border: 1px solid #ffc107;
    border-bottom-left-radius: 4px;
}
.bcs-chat-escalated::before {
    content: "👤 ";
    margin-right: 4px;
    font-style: normal;
}

/* ── Message de limite de messages atteinte (FIX M4) ── */
.bcs-chat-limit {
    align-self: center;
    background-color: #fff0f0;
    color: #b91c1c;
    border: 1px solid #fca5a5;
    border-radius: 8px;
    font-size: 12px;
    padding: 8px 14px;
    text-align: center;
    max-width: 90%;
}
.bcs-chat-limit-icon {
    margin-right: 4px;
}
.bcs-chat-upgrade-link {
    display: inline-block;
    margin-top: 6px;
    font-size: 11px;
    font-weight: 600;
    color: #b91c1c;
    text-decoration: underline;
}

/* ── Responsive mobile ── */
@media (max-width: 400px) {
    .bcs-chat-widget { width: calc(100vw - 20px); right: 10px; bottom: 145px; }
    .bcs-chat-fab    { bottom: 75px; right: 14px; }
}
