
/* achat — AI chat widget — all sizes in px to be immune to body font-size */
#achat-root {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 18px;
    line-height: 1.5;
}

/* Floating trigger button — hidden until config confirms enabled */
.achat-trigger {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: transparent;
    color: #fff;
    border: none;
    cursor: pointer;
    z-index: 9998;
    display: none;
    align-items: center;
    justify-content: center;
    filter: drop-shadow(0 4px 12px rgba(0,0,0,0.4));
    transition: transform 0.2s, filter 0.2s;
}
.achat-trigger:hover {
    transform: scale(1.1);
    filter: drop-shadow(0 6px 20px rgba(0,0,0,0.5));
}
.achat-trigger svg { width: 52px; height: 52px; }
/* When chat is open, robot docks to top-left corner of the panel */
.achat-trigger.docked {
    width: 44px;
    height: 44px;
    z-index: 10000;
    transition: all 0.2s ease;
}
.achat-trigger.docked svg { width: 40px; height: 40px; }

/* Chat panel */
.achat-panel {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 384px;
    height: 576px;
    max-height: calc(100vh - 48px);
    max-width: calc(100vw - 32px);
    background: var(--bg-card, #111518);
    border: 1px solid var(--border, #1c2428);
    border-radius: 12px;
    z-index: 9999;
    display: none;
    flex-direction: column;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
    overflow: hidden;
}
.achat-panel.open {
    display: flex;
}

/* Header */
.achat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: var(--bg, #0c1014);
    border-bottom: 1px solid var(--border, #1c2428);
    flex-shrink: 0;
}
.achat-header-title {
    font-size: 1em;
    font-weight: 700;
    color: var(--text-bright, #ffffff);
    margin: 0;
}
.achat-header-close {
    background: none;
    border: none;
    color: var(--text-subtle, #8a9aa8);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
}
.achat-header-close:hover { color: var(--text, #e8edf2); }
.achat-font-controls {
    display: flex;
    gap: 2px;
    align-items: center;
    margin-left: auto;
    margin-right: 8px;
}
.achat-font-btn {
    background: none;
    border: 1px solid var(--border, #1c2428);
    color: var(--text-subtle, #8a9aa8);
    cursor: pointer;
    border-radius: 4px;
    padding: 2px 6px;
    font-family: inherit;
    line-height: 1;
    transition: color 0.15s, border-color 0.15s;
}
.achat-font-btn:hover { color: var(--text-bright, #ffffff); border-color: var(--text-subtle, #8a9aa8); }
.achat-font-btn-sm { font-size: 12px; }
.achat-font-btn-lg { font-size: 18px; font-weight: 700; }

/* Messages area */
.achat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.achat-messages::-webkit-scrollbar { width: 4px; }
.achat-messages::-webkit-scrollbar-track { background: transparent; }
.achat-messages::-webkit-scrollbar-thumb { background: var(--border-bright, #2a3640); border-radius: 2px; }

/* Message bubbles */
.achat-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 1em;
    line-height: 1.55;
    word-wrap: break-word;
}
.achat-msg-user {
    align-self: flex-end;
    background: var(--accent-blue, #818cf8);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.achat-msg-bot {
    align-self: flex-start;
    background: var(--bg-surface, #161b22);
    color: var(--text, #e8edf2);
    border: 1px solid var(--border, #1c2428);
    border-bottom-left-radius: 4px;
}

/* Bot message markdown */
.achat-msg-bot p { margin: 6px 0; }
.achat-msg-bot p:first-child { margin-top: 0; }
.achat-msg-bot p:last-child { margin-bottom: 0; }
.achat-msg-bot strong { color: var(--text-bright, #ffffff); font-weight: 600; }
.achat-msg-bot code {
    background: rgba(129,140,248,0.15);
    color: var(--accent-blue, #818cf8);
    padding: 1px 5px;
    border-radius: 3px;
    font-family: 'JetBrains Mono', 'SF Mono', monospace;
    font-size: 0.875em;
}
.achat-msg-bot pre {
    background: var(--bg, #0c1014);
    border: 1px solid var(--border, #1c2428);
    border-radius: 6px;
    padding: 10px;
    overflow-x: auto;
    margin: 8px 0;
}
.achat-msg-bot pre code {
    background: none;
    padding: 0;
    color: var(--text, #e8edf2);
    font-size: 13px;
}
.achat-msg-bot ul, .achat-msg-bot ol { padding-left: 18px; margin: 6px 0; }
.achat-msg-bot li { margin: 3px 0; }
.achat-msg-bot a { color: var(--accent-blue, #818cf8); text-decoration: none; }
.achat-msg-bot a:hover { text-decoration: underline; }

/* Typing indicator */
.achat-typing {
    align-self: flex-start;
    padding: 10px 14px;
    background: var(--bg-surface, #161b22);
    border: 1px solid var(--border, #1c2428);
    border-radius: 12px;
    border-bottom-left-radius: 4px;
    display: none;
}
.achat-typing.active { display: flex; gap: 4px; align-items: center; }
.achat-typing-dot {
    width: 6px;
    height: 6px;
    background: var(--text-subtle, #8a9aa8);
    border-radius: 50%;
    animation: achat-bounce 1.2s infinite;
}
.achat-typing-dot:nth-child(2) { animation-delay: 0.15s; }
.achat-typing-dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes achat-bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-6px); }
}

/* Input area */
.achat-input-area {
    display: flex;
    gap: 8px;
    padding: 12px;
    border-top: 1px solid var(--border, #1c2428);
    background: var(--bg, #0c1014);
    flex-shrink: 0;
}
.achat-input {
    flex: 1;
    background: var(--bg-surface, #161b22);
    border: 1px solid var(--border, #1c2428);
    border-radius: 8px;
    padding: 8px 12px;
    color: var(--text, #e8edf2);
    font-size: 1em;
    font-family: inherit;
    resize: none;
    min-height: 36px;
    max-height: 96px;
    outline: none;
}
.achat-input:focus { border-color: var(--accent-blue, #818cf8); }
.achat-input::placeholder { color: var(--text-subtle, #8a9aa8); }
.achat-send {
    background: var(--accent-blue, #818cf8);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 0 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.achat-send:hover { opacity: 0.9; }
.achat-send:disabled { opacity: 0.4; cursor: default; }
.achat-send svg { width: 18px; height: 18px; }

/* Contact banner */
.achat-contact {
    display: none;
    padding: 10px 12px;
    background: var(--bg-card, #111518);
    border-top: 1px solid var(--border, #1c2428);
    text-align: center;
    flex-shrink: 0;
}
.achat-contact.visible { display: block; }
.achat-contact-btn {
    background: none;
    border: 1px solid var(--accent-blue, #818cf8);
    color: var(--accent-blue, #818cf8);
    padding: 6px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85em;
    font-family: inherit;
}
.achat-contact-btn:hover { background: rgba(129,140,248,0.15); }

/* Contact form */
.achat-contact-form {
    padding: 16px;
    display: none;
    flex-direction: column;
    gap: 8px;
}
.achat-contact-form.open { display: flex; }
.achat-contact-form input,
.achat-contact-form textarea {
    background: var(--bg-surface, #161b22);
    border: 1px solid var(--border, #1c2428);
    border-radius: 6px;
    padding: 8px 12px;
    color: var(--text, #e8edf2);
    font-size: 0.85em;
    font-family: inherit;
    outline: none;
}
.achat-contact-form input:focus,
.achat-contact-form textarea:focus { border-color: var(--accent-blue, #818cf8); }
.achat-contact-form textarea { resize: vertical; min-height: 48px; }
.achat-contact-submit {
    background: var(--accent-blue, #818cf8);
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 8px;
    cursor: pointer;
    font-size: 0.85em;
    font-family: inherit;
}
.achat-contact-submit:hover { opacity: 0.9; }
.achat-contact-back {
    background: none;
    border: none;
    color: var(--text-subtle, #8a9aa8);
    cursor: pointer;
    font-size: 0.8em;
    padding: 4px;
}

/* Powered-by footer */
.achat-powered {
    text-align: center;
    font-size: 0.65em;
    color: var(--text-subtle, #8a9aa8);
    padding: 4px;
    border-top: 1px solid var(--border, #1c2428);
    flex-shrink: 0;
}

/* Tablet */
@media (max-width: 768px) {
    .achat-panel {
        width: 320px;
        height: 512px;
    }
}

/* Smartphone */
@media (max-width: 480px) {
    .achat-panel {
        bottom: 0;
        right: 0;
        width: 100vw;
        height: 100vh;
        height: 100dvh;
        max-height: 100vh;
        max-width: 100vw;
        border-radius: 0;
        border: none;
    }
    .achat-trigger { bottom: 16px; right: 16px; width: 48px; height: 48px; }
    .achat-trigger svg { width: 44px; height: 44px; }
    .achat-header { padding: 16px; }
    .achat-messages { padding: 12px; }
    .achat-input-area { padding: 8px; }
    .achat-msg { max-width: 90%; font-size: 1em; }
    .achat-input { font-size: 16px; }
}

/* Print: hide everything */
@media print { #achat-root { display: none !important; } }
