/* ============================================================
   A2Z Converter — Chatbot Module (self-contained)
   Scoped under .a2z-chat so it never collides with the page.
   ============================================================ */
.a2z-chat {
    --c-accent:   #FF4C29;
    --c-accent-2: #e63e1c;
    --c-bg:       #ffffff;
    --c-panel:    #f7f7f8;
    --c-border:   #e3e3e7;
    --c-text:     #0a0a0a;
    --c-muted:    #5c5c66;
    --c-bot:      #f0f0f2;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ---- Launcher button ---- */
.a2z-chat-launcher {
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 2000;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    color: #fff;
    background: linear-gradient(135deg, var(--c-accent), var(--c-accent-2));
    box-shadow: 0 10px 28px rgba(255, 76, 41, .42);
    transition: transform .18s ease, box-shadow .18s ease;
}
.a2z-chat-launcher:hover { transform: translateY(-2px) scale(1.04); box-shadow: 0 14px 34px rgba(255, 76, 41, .5); }
.a2z-chat-launcher svg { width: 26px; height: 26px; stroke-width: 2; }
.a2z-chat-launcher .a2z-chat-icon-close { display: none; }
.a2z-chat.is-open .a2z-chat-launcher .a2z-chat-icon-open { display: none; }
.a2z-chat.is-open .a2z-chat-launcher .a2z-chat-icon-close { display: inline-flex; }

/* small unread ping dot */
.a2z-chat-ping {
    position: absolute;
    top: 2px; right: 2px;
    width: 12px; height: 12px;
    border-radius: 50%;
    background: #22c55e;
    border: 2px solid #fff;
}
.a2z-chat.is-open .a2z-chat-ping { display: none; }

/* ---- Window ---- */
.a2z-chat-window {
    position: fixed;
    right: 22px;
    bottom: 94px;
    z-index: 2000;
    width: 380px;
    max-width: calc(100vw - 32px);
    height: 560px;
    max-height: calc(100vh - 130px);
    display: flex;
    flex-direction: column;
    background: var(--c-bg);
    border: 1px solid var(--c-border);
    border-radius: 18px;
    overflow: hidden;
    box-shadow: 0 24px 60px rgba(10, 10, 10, .22);
    opacity: 0;
    transform: translateY(16px) scale(.97);
    pointer-events: none;
    transition: opacity .2s ease, transform .2s ease;
}
.a2z-chat.is-open .a2z-chat-window {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* ---- Header ---- */
.a2z-chat-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    color: #fff;
    background: linear-gradient(135deg, var(--c-accent), var(--c-accent-2));
}
.a2z-chat-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px; height: 38px;
    border-radius: 12px;
    background: rgba(255, 255, 255, .18);
}
.a2z-chat-avatar svg { width: 22px; height: 22px; stroke-width: 2; }
.a2z-chat-htext { line-height: 1.25; }
.a2z-chat-htext strong { display: block; font-size: 15px; font-weight: 700; }
.a2z-chat-htext span { font-size: 12px; opacity: .9; display: inline-flex; align-items: center; gap: 5px; }
.a2z-chat-status-dot { width: 7px; height: 7px; border-radius: 50%; background: #4ade80; display: inline-block; }
.a2z-chat-end,
.a2z-chat-close {
    background: rgba(255, 255, 255, .16);
    border: none;
    color: #fff;
    width: 32px; height: 32px;
    border-radius: 9px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background .15s ease;
}
.a2z-chat-end { margin-left: auto; }
.a2z-chat-close { margin-left: 6px; }
.a2z-chat-end:hover { background: rgba(239, 68, 68, .9); }
.a2z-chat-close:hover { background: rgba(255, 255, 255, .3); }
.a2z-chat-end svg,
.a2z-chat-close svg { width: 18px; height: 18px; }

/* ---- Messages ---- */
.a2z-chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: var(--c-bg);
    scrollbar-width: thin;
}
.a2z-chat-body::-webkit-scrollbar { width: 6px; }
.a2z-chat-body::-webkit-scrollbar-thumb { background: #d4d4da; border-radius: 6px; }

.a2z-msg {
    max-width: 84%;
    font-size: 14px;
    line-height: 1.5;
    padding: 10px 13px;
    border-radius: 14px;
    animation: a2z-pop .22s ease;
}
@keyframes a2z-pop { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

.a2z-msg-bot {
    align-self: flex-start;
    background: var(--c-bot);
    color: var(--c-text);
    border-bottom-left-radius: 5px;
}
.a2z-msg-user {
    align-self: flex-end;
    background: var(--c-accent);
    color: #fff;
    border-bottom-right-radius: 5px;
}

/* ---- Tool result cards ---- */
.a2z-tool-card {
    align-self: flex-start;
    width: 84%;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--c-bg);
    border: 1px solid var(--c-border);
    border-radius: 14px;
    cursor: pointer;
    text-align: left;
    transition: border-color .15s ease, transform .15s ease, box-shadow .15s ease;
    animation: a2z-pop .22s ease;
}
.a2z-tool-card:hover {
    border-color: var(--c-accent);
    transform: translateY(-1px);
    box-shadow: 0 8px 20px rgba(255, 76, 41, .14);
}
.a2z-tool-ico {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px; height: 42px;
    border-radius: 11px;
    background: var(--c-panel);
    color: var(--c-accent);
}
.a2z-tool-ico svg { width: 22px; height: 22px; }
.a2z-tool-meta { flex: 1; min-width: 0; }
.a2z-tool-meta strong { display: block; font-size: 14px; color: var(--c-text); }
.a2z-tool-meta span { display: block; font-size: 12px; color: var(--c-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.a2z-tool-go {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    font-weight: 600;
    color: var(--c-accent);
}
.a2z-tool-go svg { width: 15px; height: 15px; }

/* ---- Quick reply chips ---- */
.a2z-chat-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 0 16px 4px;
}
.a2z-chip {
    font-size: 12.5px;
    font-weight: 500;
    color: var(--c-accent);
    background: #fff;
    border: 1px solid var(--c-accent);
    border-radius: 999px;
    padding: 6px 12px;
    cursor: pointer;
    transition: background .15s ease, color .15s ease;
}
.a2z-chip:hover { background: var(--c-accent); color: #fff; }

/* ---- Typing indicator ---- */
.a2z-typing { display: inline-flex; gap: 4px; align-items: center; }
.a2z-typing span {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: var(--c-muted);
    opacity: .5;
    animation: a2z-blink 1.2s infinite ease-in-out;
}
.a2z-typing span:nth-child(2) { animation-delay: .2s; }
.a2z-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes a2z-blink { 0%, 80%, 100% { transform: scale(.7); opacity: .4; } 40% { transform: scale(1); opacity: 1; } }

/* ---- Input bar ---- */
.a2z-chat-input {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    border-top: 1px solid var(--c-border);
    background: var(--c-bg);
}
.a2z-chat-input input {
    flex: 1;
    border: 1px solid var(--c-border);
    border-radius: 12px;
    padding: 11px 14px;
    font-size: 14px;
    font-family: inherit;
    color: var(--c-text);
    outline: none;
    transition: border-color .15s ease;
}
.a2z-chat-input input:focus { border-color: var(--c-accent); }
.a2z-chat-send {
    flex-shrink: 0;
    width: 42px; height: 42px;
    border: none;
    border-radius: 12px;
    background: var(--c-accent);
    color: #fff;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background .15s ease, transform .12s ease;
}
.a2z-chat-send:hover { background: var(--c-accent-2); }
.a2z-chat-send:active { transform: scale(.94); }
.a2z-chat-send svg { width: 19px; height: 19px; }

/* ---- Responsive ---- */
@media (max-width: 480px) {
    .a2z-chat-window {
        right: 12px;
        left: 12px;
        bottom: 86px;
        width: auto;
        height: calc(100vh - 110px);
    }
    .a2z-chat-launcher { right: 16px; bottom: 16px; }
}
