[data-ai-chat-widget] {
    --ai-chat-primary: #e9457a;
    --ai-chat-primary-dark: #c92f61;
    --ai-chat-primary-light: #ff6f9c;
    --ai-chat-bg: #fff;
    --ai-chat-surface: #faf6f8;
    --ai-chat-border: #f0dce3;
    --ai-chat-text: #2a2230;
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 1050;
}

[data-ai-chat-widget] [hidden] { display: none !important; }
[data-ai-chat-widget] *, [data-ai-chat-widget] *::before, [data-ai-chat-widget] *::after { box-sizing: border-box; }

.ai-chat-notice { margin: 8px 12px; font-size: .85rem; color: #6b6470; }

.ai-chat-cards { display: grid; gap: 10px; margin: 12px 0; }
.ai-chat-card {
    padding: 12px;
    border: 1px solid var(--ai-chat-border);
    border-radius: 12px;
    background: var(--ai-chat-bg);
    color: var(--ai-chat-text);
    overflow-wrap: anywhere;
    box-shadow: 0 1px 4px rgba(42, 34, 48, .06);
}
.ai-chat-card img { width: 56px; height: 56px; object-fit: cover; border-radius: 10px; float: left; margin: 0 10px 6px 0; }
.ai-chat-card p { margin: 6px 0; font-size: .9rem; }
.ai-chat-card a {
    display: inline-block;
    margin-top: 4px;
    font-size: .82rem;
    font-weight: 600;
    color: var(--ai-chat-primary);
    text-decoration: none;
}
.ai-chat-card a:hover { text-decoration: underline; }
.ai-chat-widget__messages audio { width: 100%; }
[data-ai-chat-pending-summary] { white-space: pre-wrap; max-height: 180px; overflow: auto; }
.ai-chat-widget__messages { min-height: 80px; }

/* ---------- Bouton flottant ---------- */
.ai-chat-widget__toggle {
    width: 58px;
    height: 58px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, var(--ai-chat-primary-light), var(--ai-chat-primary) 55%, var(--ai-chat-primary-dark));
    color: #fff;
    font-size: 1.4rem;
    box-shadow: 0 6px 18px rgba(201, 47, 97, .4);
    cursor: pointer;
    display: grid;
    place-items: center;
    transition: transform .15s ease, box-shadow .15s ease;
    animation:
        ai-chat-intro .7s cubic-bezier(0.34, 1.56, 0.64, 1) .4s both,
        ai-chat-attention 4.5s ease-in-out 1.5s infinite;
}

.ai-chat-widget__toggle:hover {
    transform: translateY(-2px) scale(1.04);
    box-shadow: 0 10px 24px rgba(201, 47, 97, .5);
}

.ai-chat-widget__toggle[aria-expanded="true"] {
    animation: none;
}

@keyframes ai-chat-intro {
    from { transform: translateX(140px) scale(0.6); opacity: 0; }
    to { transform: translateX(0) scale(1); opacity: 1; }
}

@keyframes ai-chat-attention {
    0%, 76%, 100% {
        transform: translateX(0) rotate(0deg);
        box-shadow: 0 6px 18px rgba(201, 47, 97, .4), 0 0 0 0 rgba(233, 69, 122, 0.45);
    }
    80% { transform: translateX(-6px) rotate(-8deg); }
    85% { transform: translateX(5px) rotate(7deg); }
    90% {
        transform: translateX(-3px) rotate(-4deg);
        box-shadow: 0 6px 18px rgba(201, 47, 97, .4), 0 0 0 10px rgba(233, 69, 122, 0);
    }
    95% { transform: translateX(0) rotate(0deg); }
}

@media (prefers-reduced-motion: reduce) {
    .ai-chat-widget__toggle { animation: none; }
}

/* ---------- Panneau ---------- */
.ai-chat-widget__panel {
    position: absolute;
    right: 0;
    bottom: 72px;
    width: 350px;
    max-width: calc(100vw - 32px);
    height: 480px;
    max-height: min(80vh, calc(100dvh - 100px));
    background: var(--ai-chat-bg);
    border-radius: 18px;
    box-shadow: 0 18px 50px rgba(42, 34, 48, .22), 0 2px 8px rgba(42, 34, 48, .08);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: ai-chat-panel-in .22s cubic-bezier(.2, .9, .3, 1.2) both;
    transform-origin: bottom right;
}

@keyframes ai-chat-panel-in {
    from { opacity: 0; transform: translateY(12px) scale(.96); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (prefers-reduced-motion: reduce) {
    .ai-chat-widget__panel { animation: none; }
}

.ai-chat-widget__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 12px 14px;
    background: linear-gradient(120deg, var(--ai-chat-primary-dark), var(--ai-chat-primary) 60%, var(--ai-chat-primary-light));
    color: #fff;
    flex: none;
}

.ai-chat-widget__title { display: flex; align-items: center; gap: 10px; min-width: 0; }

.ai-chat-widget__avatar {
    width: 34px;
    height: 34px;
    flex: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, .22);
    display: grid;
    place-items: center;
    font-size: 1rem;
}

.ai-chat-widget__title-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.ai-chat-widget__title-text strong { font-size: .92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.ai-chat-widget__status-dot {
    font-size: .68rem;
    opacity: .9;
    display: flex;
    align-items: center;
    gap: 5px;
}
.ai-chat-widget__status-dot::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #44e07a;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, .3);
    flex: none;
}

.ai-chat-widget__close {
    background: rgba(255, 255, 255, .16);
    border: none;
    color: #fff;
    font-size: 1.1rem;
    line-height: 1;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    flex: none;
    display: grid;
    place-items: center;
    transition: background .15s ease;
}
.ai-chat-widget__close:hover { background: rgba(255, 255, 255, .3); }

.ai-chat-widget__toolbar, .ai-chat-widget__suggestions {
    padding: 8px 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    flex: none;
    background: var(--ai-chat-bg);
}
.ai-chat-widget__toolbar { border-bottom: 1px solid var(--ai-chat-border); }
.ai-chat-widget__suggestions[hidden] { display: none; }
.ai-chat-widget__suggestions button {
    border: 1px solid var(--ai-chat-border);
    border-radius: 18px;
    background: var(--ai-chat-surface);
    color: var(--ai-chat-text);
    padding: 6px 12px;
    font-size: .78rem;
    cursor: pointer;
    transition: border-color .15s ease, color .15s ease, background .15s ease, transform .1s ease;
}
.ai-chat-widget__suggestions button:hover {
    border-color: var(--ai-chat-primary);
    color: var(--ai-chat-primary-dark);
    background: #fff;
    transform: translateY(-1px);
}

.ai-chat-widget__messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: var(--ai-chat-surface);
    background-image: radial-gradient(circle at 1px 1px, rgba(42, 34, 48, .04) 1px, transparent 0);
    background-size: 16px 16px;
}
.ai-chat-widget__messages::-webkit-scrollbar { width: 8px; }
.ai-chat-widget__messages::-webkit-scrollbar-track { background: transparent; }
.ai-chat-widget__messages::-webkit-scrollbar-thumb {
    background: #e3c7d2;
    border-radius: 8px;
}
.ai-chat-widget__messages::-webkit-scrollbar-thumb:hover { background: var(--ai-chat-primary-light); }
.ai-chat-widget__messages { scrollbar-width: thin; scrollbar-color: #e3c7d2 transparent; }

.ai-chat-message {
    position: relative;
    max-width: 82%;
    padding: 9px 13px;
    border-radius: 16px;
    font-size: 0.88rem;
    line-height: 1.4;
    white-space: pre-wrap;
    word-break: break-word;
    animation: ai-chat-bubble-in .18s ease-out both;
}

@keyframes ai-chat-bubble-in {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.ai-chat-message--user {
    align-self: flex-end;
    background: linear-gradient(135deg, var(--ai-chat-primary), var(--ai-chat-primary-dark));
    color: #fff;
    border-bottom-right-radius: 4px;
    box-shadow: 0 2px 8px rgba(201, 47, 97, .25);
}

.ai-chat-message--assistant {
    align-self: flex-start;
    background: var(--ai-chat-bg);
    color: var(--ai-chat-text);
    border: 1px solid var(--ai-chat-border);
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 4px rgba(42, 34, 48, .05);
}

.ai-chat-widget__pending {
    padding: 10px 12px;
    background: #fff7e6;
    border-top: 1px solid #f0e0b8;
    flex: none;
}

.ai-chat-widget__pending-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.ai-chat-widget__form {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 10px;
    border-top: 1px solid var(--ai-chat-border);
    background: var(--ai-chat-bg);
    flex: none;
}

.ai-chat-widget__form textarea {
    flex: 1;
    min-width: 0;
    resize: none;
    max-height: 100px;
    border-radius: 18px;
    border: 1px solid var(--ai-chat-border);
    background: var(--ai-chat-surface);
    padding: 9px 14px;
    font-size: .88rem;
    transition: border-color .15s ease, box-shadow .15s ease;
}
.ai-chat-widget__form textarea:focus {
    outline: none;
    border-color: var(--ai-chat-primary);
    box-shadow: 0 0 0 3px rgba(233, 69, 122, .15);
    background: #fff;
}

.ai-chat-widget__mic,
.ai-chat-widget__send {
    flex: none;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 1px solid var(--ai-chat-border);
    background: var(--ai-chat-surface);
    color: var(--ai-chat-text);
    cursor: pointer;
    display: grid;
    place-items: center;
    transition: background .15s ease, color .15s ease, transform .1s ease, box-shadow .15s ease;
    padding: 0;
}

.ai-chat-widget__mic:hover,
.ai-chat-widget__send:hover { transform: translateY(-1px); }

.ai-chat-widget__mic.is-recording {
    background: var(--ai-chat-primary);
    color: #fff;
    border-color: var(--ai-chat-primary);
    animation: ai-chat-mic-pulse 1.4s ease-in-out infinite;
}

@keyframes ai-chat-mic-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(233, 69, 122, .45); }
    50% { box-shadow: 0 0 0 6px rgba(233, 69, 122, 0); }
}

.ai-chat-widget__send {
    background: linear-gradient(135deg, var(--ai-chat-primary-light), var(--ai-chat-primary-dark));
    color: #fff;
    border: none;
    box-shadow: 0 2px 8px rgba(201, 47, 97, .3);
}
.ai-chat-widget__send:disabled { opacity: .55; cursor: not-allowed; transform: none; }
