/* ─────────────────────────────────────────────
   Antonin Chatbot — chat.css
   Thème : Antonin.systems (light, purple accent)
   ───────────────────────────────────────────── */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;1,9..40,400&display=swap');

:root {
    --ac-bg:           #f0f0f3;
    --ac-surface:      #ffffff;
    --ac-border:       rgba(0, 0, 0, 0.07);
    --ac-accent:       #7c5cf0;
    --ac-accent-light: rgba(124, 92, 240, 0.1);
    --ac-text:         #1a1a1a;
    --ac-text-muted:   #9a9aaa;
    --ac-radius:       20px;
    --ac-radius-sm:    12px;
    --ac-radius-pill:  100px;
    --ac-font:         'DM Sans', 'Helvetica Neue', sans-serif;
    --ac-shadow:       0 4px 32px rgba(0, 0, 0, 0.08), 0 1px 4px rgba(0,0,0,0.04);
    --ac-max-width:    720px;
}

/* ── Wrapper ── */
.ac-wrapper {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: var(--ac-max-width);
    height: 500px;
    margin: 0 auto;
    background: var(--ac-surface);
    border: 1px solid var(--ac-border);
    border-radius: var(--ac-radius);
    box-shadow: var(--ac-shadow);
    font-family: var(--ac-font);
    overflow: hidden;
}

/* ── Messages zone ── */
.ac-messages {
    flex: 1;
    overflow-y: scroll;
    overscroll-behavior: contain;
    padding: 24px 20px 12px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    scroll-behavior: smooth;
    background: var(--ac-bg);
    background-image: radial-gradient(circle, rgba(0,0,0,0.10) 1px, transparent 1px);
    background-size: 20px 20px;
}

.ac-messages::-webkit-scrollbar { width: 4px; }
.ac-messages::-webkit-scrollbar-track { background: transparent; }
.ac-messages::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.12);
    border-radius: 4px;
}

/* ── Messages ── */
.ac-message {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    animation: ac-fadeIn 0.22s ease;
}

@keyframes ac-fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to   { opacity: 1; transform: translateY(0); }
}

.ac-message--user {
    flex-direction: row-reverse;
}

.ac-bubble {
    max-width: 72%;
    padding: 11px 16px;
    font-size: 0.875rem;
    line-height: 1.65;
    color: var(--ac-text);
    word-break: break-word;
    white-space: pre-wrap;
}

.ac-message--bot .ac-bubble {
    background: var(--ac-surface);
    border: 1px solid var(--ac-border);
    border-radius: var(--ac-radius-sm);
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 6px rgba(0,0,0,0.05);
}

.ac-message--user .ac-bubble {
    background: var(--ac-accent);
    border-radius: var(--ac-radius-sm);
    border-bottom-right-radius: 4px;
    color: #ffffff;
    font-size: 0.86rem;
}

/* Avatar bot */
.ac-message--bot::before {
    content: 'A·';
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    min-width: 28px;
    border-radius: 8px;
    background: var(--ac-accent);
    color: #fff;
    font-size: 0.6rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    margin-bottom: 2px;
    flex-shrink: 0;
}

/* ── Loader dots ── */
.ac-loader {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 2px 0;
}
.ac-loader span {
    display: block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--ac-accent);
    opacity: 0.4;
    animation: ac-dot 1.2s infinite ease-in-out;
}
.ac-loader span:nth-child(2) { animation-delay: 0.18s; }
.ac-loader span:nth-child(3) { animation-delay: 0.36s; }

@keyframes ac-dot {
    0%, 60%, 100% { opacity: 0.25; transform: scale(0.85); }
    30%            { opacity: 1;   transform: scale(1.15); }
}

/* ── Input area ── */
.ac-input-area {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    padding: 14px 16px 16px;
    background: var(--ac-surface);
    border-top: 1px solid var(--ac-border);
}

.ac-input {
    flex: 1;
    background: var(--ac-bg);
    border: 1.5px solid transparent;
    border-radius: var(--ac-radius-pill);
    color: var(--ac-text);
    font-family: var(--ac-font);
    font-size: 0.875rem;
    line-height: 1.5;
    padding: 10px 18px;
    resize: none;
    outline: none;
    min-height: 42px;
    max-height: 120px;
    overflow-y: auto;
    transition: border-color 0.2s, background 0.2s;
}

.ac-input::placeholder {
    color: var(--ac-text-muted);
}

.ac-input:focus {
    background: #fff;
    border-color: var(--ac-accent);
}

/* ── Send button ── */
.ac-send {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    min-width: 42px;
    border-radius: var(--ac-radius-pill);
    border: none;
    background: #1a1a1a;
    color: #fff;
    cursor: pointer;
    transition: transform 0.15s, background 0.2s, opacity 0.2s;
    flex-shrink: 0;
}

.ac-send svg {
    width: 15px;
    height: 15px;
}

.ac-send:hover {
    background: var(--ac-accent);
    transform: scale(1.06);
}

.ac-send:active {
    transform: scale(0.95);
}

.ac-send:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    transform: none;
}

/* ── Erreur ── */
.ac-message--error .ac-bubble {
    background: #fff2f2;
    border-color: rgba(220, 60, 60, 0.2);
    color: #c0392b;
    font-size: 0.82rem;
}

/* ── Responsive ── */
@media (max-width: 600px) {
    .ac-wrapper {
        height: 440px;
        border-radius: 14px;
    }
    .ac-bubble {
        max-width: 88%;
    }
}

/* Messages restaurés depuis sessionStorage : pas d'animation */
.ac-message.ac-no-anim {
    animation: none;
}

/* Liens dans les bulles */
.ac-bubble a {
    color: var(--ac-accent);
    text-decoration: underline;
    text-underline-offset: 2px;
}
.ac-message--user .ac-bubble a {
    color: rgba(255,255,255,0.85);
}

/* ── Markdown dans les bulles bot ── */
.ac-bubble strong { font-weight: 600; }
.ac-bubble em     { font-style: italic; }

.ac-bubble ul {
    margin: 6px 0 6px 4px;
    padding-left: 16px;
    list-style: disc;
}
.ac-bubble ul li {
    margin-bottom: 3px;
    line-height: 1.55;
}

/* Liens */
.ac-bubble a {
    color: var(--ac-accent);
    text-decoration: underline;
    text-underline-offset: 2px;
    word-break: break-word;
}
.ac-message--user .ac-bubble a {
    color: rgba(255, 255, 255, 0.85);
}

/* Messages restaurés : pas d'animation */
.ac-message.ac-no-anim { animation: none; }
