/* Essiow Chat Widget — 1.2.0 : même direction que l'admin (surfaces neutres,
   coins 16 px, ombre douce, icônes SVG), couleur d'accent = réglage de l'agent
   (--essiow-color posé par chat-widget.js). Classes inchangées. */

:root {
    --essiow-color: #4F46E5;
    --essiow-text: #0f172a;
    --essiow-text-light: #64748b;
    --essiow-bg: #ffffff;
    --essiow-bg-light: #f1f5f9;
    --essiow-border: #e2e8f0;
    --essiow-user-bg: var(--essiow-color);
    --essiow-user-text: #ffffff;
    --essiow-radius: 16px;
    --essiow-shadow: 0 12px 32px rgba(15, 23, 42, 0.16);
    --essiow-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
}

/* ── Bubble ───────────────────────────────────────── */
.essiow-bubble {
    position: fixed;
    bottom: 24px;
    z-index: 99999;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--essiow-color);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease;
    padding: 0;
    border: none;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.22);
    overflow: visible;
    -webkit-tap-highlight-color: transparent;
    font-family: var(--essiow-font);
}

.essiow-bubble:hover { transform: translateY(-2px) scale(1.04); box-shadow: 0 12px 28px rgba(15, 23, 42, 0.26); }
.essiow-bubble:focus-visible { outline: 3px solid #fff; outline-offset: 2px; box-shadow: 0 0 0 5px var(--essiow-color); }
.essiow-bubble--right { right: 24px; }
.essiow-bubble--left { left: 24px; }

.essiow-bubble__icon,
.essiow-bubble__close {
    display: flex;
    align-items: center;
    justify-content: center;
}

.essiow-bubble__icon svg,
.essiow-bubble__close svg {
    width: 28px;
    height: 28px;
}

.essiow-bubble__photo {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    object-fit: cover;
    display: block;
    clip-path: circle(50%);
}

.essiow-bubble__close { display: none; }

.essiow-bubble.active .essiow-bubble__icon,
.essiow-bubble.active .essiow-bubble__photo { display: none; }

.essiow-bubble.active .essiow-bubble__close { display: flex; }

/* When photo is shown, remove background color padding */
.essiow-bubble--has-photo {
    padding: 0;
    background: transparent;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.22);
}

.essiow-bubble--has-photo.active {
    background: var(--essiow-color);
}

/* Online indicator dot on bubble */
.essiow-bubble__online {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 14px;
    height: 14px;
    background: #22c55e;
    border-radius: 50%;
    border: 3px solid #fff;
    z-index: 1;
}

.essiow-bubble.active .essiow-bubble__online { display: none; }

/* ── Tooltip ──────────────────────────────────────── */
.essiow-tooltip {
    position: fixed;
    bottom: 96px;
    z-index: 99998;
    background: var(--essiow-bg);
    color: var(--essiow-text);
    padding: 12px 16px;
    border-radius: 14px;
    border: 1px solid var(--essiow-border);
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
    font-family: var(--essiow-font);
    font-size: 14px;
    line-height: 1.45;
    max-width: 280px;
    cursor: pointer;
    animation: essiow-fade-up 0.3s ease;
}
.essiow-tooltip--right { right: 24px; border-bottom-right-radius: 4px; }
.essiow-tooltip--left { left: 24px; border-bottom-left-radius: 4px; }

@keyframes essiow-fade-up {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ── Chat Window ──────────────────────────────────── */
.essiow-chat {
    position: fixed;
    bottom: 100px;
    z-index: 99999;
    width: 380px;
    max-height: 600px;
    height: calc(100vh - 140px);
    background: var(--essiow-bg);
    border: 1px solid var(--essiow-border);
    border-radius: var(--essiow-radius);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: essiow-slide-up 0.25s ease;
    box-shadow: var(--essiow-shadow);
    font-family: var(--essiow-font);
    color: var(--essiow-text);
}
.essiow-chat--right { right: 24px; }
.essiow-chat--left { left: 24px; }

@keyframes essiow-slide-up {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ── Header ───────────────────────────────────────── */
.essiow-chat__header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: var(--essiow-color);
    color: #fff;
    flex-shrink: 0;
}

.essiow-chat__avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    background: rgba(255, 255, 255, 0.22);
    flex-shrink: 0;
}

.essiow-chat__avatar--placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
}
.essiow-chat__avatar--placeholder svg { width: 20px; height: 20px; }

.essiow-chat__header-info { flex: 1; min-width: 0; }
.essiow-chat__name { font-weight: 600; font-size: 15px; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.essiow-chat__status { font-size: 12px; opacity: 0.85; display: flex; align-items: center; gap: 5px; }
.essiow-chat__status::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: #4ade80; }

.essiow-chat__close {
    width: 32px !important;
    height: 32px !important;
    min-width: 32px !important;
    min-height: 32px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 50% !important;
    background: rgba(255,255,255,0.18) !important;
    border: none !important;
    color: #fff !important;
    cursor: pointer !important;
    line-height: 1 !important;
    flex-shrink: 0 !important;
    transition: background 0.2s !important;
    padding: 0 !important;
    margin: 0 !important;
    -webkit-tap-highlight-color: transparent;
    box-shadow: none !important;
    outline: none !important;
    text-decoration: none !important;
}
.essiow-chat__close svg { width: 16px; height: 16px; }
.essiow-chat__close:hover { background: rgba(255,255,255,0.32) !important; }
.essiow-chat__close:focus-visible { box-shadow: 0 0 0 2px #fff !important; }

/* ── Messages ─────────────────────────────────────── */
.essiow-chat__messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: var(--essiow-bg);
    overscroll-behavior: contain;
}

.essiow-message {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    overflow-wrap: anywhere;
    animation: essiow-fade-up 0.2s ease;
}

.essiow-message--assistant {
    align-self: flex-start;
    background: var(--essiow-bg-light);
    color: var(--essiow-text);
    border-bottom-left-radius: 4px;
}

.essiow-message--user {
    align-self: flex-end;
    background: var(--essiow-user-bg);
    color: var(--essiow-user-text);
    border-bottom-right-radius: 4px;
}

.essiow-message a { color: var(--essiow-color); text-decoration: underline; }
.essiow-message--user a { color: #fff; }
.essiow-message ul, .essiow-message ol { margin: 4px 0; padding-left: 20px; }
.essiow-message p { margin: 0 0 6px; }
.essiow-message p:last-child { margin-bottom: 0; }

/* ── Typing Indicator ─────────────────────────────── */
.essiow-typing {
    display: flex;
    gap: 4px;
    padding: 12px 14px;
    align-self: flex-start;
    background: var(--essiow-bg-light);
    border-radius: 16px;
    border-bottom-left-radius: 4px;
}

.essiow-typing__dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--essiow-text-light);
    animation: essiow-bounce 1.4s ease-in-out infinite;
}
.essiow-typing__dot:nth-child(2) { animation-delay: 0.2s; }
.essiow-typing__dot:nth-child(3) { animation-delay: 0.4s; }

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

/* ── Input ────────────────────────────────────────── */
.essiow-chat__footer {
    border-top: 1px solid var(--essiow-border);
    flex-shrink: 0;
    background: var(--essiow-bg);
}

.essiow-chat__input {
    display: flex;
    gap: 8px;
    padding: 12px 12px 8px;
}

/* 1.1.79 — mention de confidentialité */
.essiow-chat__consent {
    padding: 0 14px 10px;
    font-size: 11px;
    line-height: 1.4;
    color: var(--essiow-text-light);
}
.essiow-chat__consent a { color: var(--essiow-text-light); text-decoration: underline; }
.essiow-chat__consent a:hover { color: var(--essiow-color); }

.essiow-chat__input input {
    flex: 1;
    border: 1px solid var(--essiow-border);
    border-radius: 22px;
    padding: 10px 16px;
    font-size: 14px;
    outline: none;
    font-family: inherit;
    color: var(--essiow-text);
    background: var(--essiow-bg);
    min-width: 0;
    height: 42px;
    box-sizing: border-box;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.essiow-chat__input input:focus { border-color: var(--essiow-color); box-shadow: 0 0 0 3px color-mix(in srgb, var(--essiow-color) 22%, transparent); }
.essiow-chat__input input::placeholder { color: var(--essiow-text-light); }

.essiow-chat__send {
    width: 42px;
    height: 42px;
    min-width: 42px;
    min-height: 42px;
    border: none;
    border-radius: 50%;
    background: var(--essiow-color);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: opacity 0.2s, transform 0.15s;
    padding: 0;
    line-height: 1;
    -webkit-tap-highlight-color: transparent;
}
.essiow-chat__send svg { width: 18px; height: 18px; }
.essiow-chat__send:hover { opacity: 0.9; }
.essiow-chat__send:active { transform: scale(0.92); }
.essiow-chat__send:focus-visible { outline: 2px solid var(--essiow-color); outline-offset: 2px; }
.essiow-chat__send:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Responsive (Mobile) ─────────────────────────── */
@media screen and (max-width: 480px) {
    .essiow-chat {
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
        border: none;
        box-shadow: none;
    }

    .essiow-chat__close {
        width: 36px !important;
        height: 36px !important;
    }

    .essiow-tooltip { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    .essiow-bubble, .essiow-chat, .essiow-message, .essiow-tooltip { animation: none; transition: none; }
    .essiow-typing__dot { animation-duration: 2.8s; }
}
