/* AI Customer Chat – Widget Styles */

#ai-chat-widget *,
#ai-chat-widget *::before,
#ai-chat-widget *::after {
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    margin: 0; padding: 0;
}

#ai-chat-widget {
    position: fixed;
    bottom: 24px;
    z-index: 999999;
}
#ai-chat-widget.pos-right { right: 24px; }
#ai-chat-widget.pos-left  { left: 24px; }

/* ── Toggle button ────────────────────────────────────────── */
#ai-chat-toggle {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0,0,0,.25);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform .2s, box-shadow .2s;
    position: relative;
    overflow: hidden;
}
#ai-chat-toggle:hover { transform: scale(1.08); box-shadow: 0 6px 20px rgba(0,0,0,.3); }

#ai-chat-toggle .ico {
    font-size: 24px;
    line-height: 1;
    transition: opacity .2s, transform .2s;
    position: absolute;
}
#ai-chat-toggle .ico-close {
    opacity: 0;
    transform: rotate(-90deg);
}
#ai-chat-widget.open #ai-chat-toggle .ico-chat  { opacity: 0; transform: rotate(90deg); }
#ai-chat-widget.open #ai-chat-toggle .ico-close { opacity: 1; transform: rotate(0deg); }

/* ── Chat window ──────────────────────────────────────────── */
#ai-chat-window {
    position: absolute;
    bottom: 70px;
    width: 340px;
    max-height: 520px;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0,0,0,.18);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #fff;
    opacity: 0;
    pointer-events: none;
    transform: translateY(12px) scale(.97);
    transition: opacity .2s, transform .2s;
}
#ai-chat-widget.pos-right #ai-chat-window { right: 0; }
#ai-chat-widget.pos-left  #ai-chat-window { left: 0; }

#ai-chat-widget.open #ai-chat-window {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0) scale(1);
}

/* Header */
#ai-chat-header {
    padding: 14px 18px;
    display: flex;
    align-items: center;
    gap: 12px;
    color: #fff;
    flex-shrink: 0;
}
.ai-chat-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255,255,255,.25);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}
.ai-chat-header-text { display: flex; flex-direction: column; }
.ai-chat-header-name { font-size: 14px; font-weight: 600; line-height: 1.3; }
.ai-chat-header-sub  { font-size: 11px; opacity: .8; }
.ai-chat-online-dot  { width: 8px; height: 8px; border-radius: 50%; background: #4ade80; margin-left: auto; flex-shrink: 0; box-shadow: 0 0 0 2px rgba(255,255,255,.4); }

/* Messages */
#ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #f8fafc;
    scroll-behavior: smooth;
}

.ai-chat-msg {
    max-width: 82%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 13.5px;
    line-height: 1.5;
    word-break: break-word;
}
.ai-chat-msg.bot {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
    color: #1e293b;
}
.ai-chat-msg.user {
    color: #fff;
    border-bottom-right-radius: 4px;
    align-self: flex-end;
}

/* Typing indicator */
.ai-chat-typing {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
}
.ai-chat-typing span {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: #94a3b8;
    animation: ai-bounce .9s infinite;
}
.ai-chat-typing span:nth-child(2) { animation-delay: .15s; }
.ai-chat-typing span:nth-child(3) { animation-delay: .30s; }

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

/* Input row */
#ai-chat-input-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid #e2e8f0;
    background: #fff;
    flex-shrink: 0;
}

#ai-chat-input {
    flex: 1;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    padding: 9px 14px;
    font-size: 13.5px;
    outline: none;
    background: #f8fafc;
    color: #1e293b;
    transition: border-color .2s;
}
#ai-chat-input:focus { border-color: #94a3b8; background: #fff; }
#ai-chat-input:disabled { opacity: .5; }

#ai-chat-send {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    color: #fff;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity .15s, transform .15s;
    flex-shrink: 0;
}
#ai-chat-send:hover   { opacity: .88; transform: scale(1.05); }
#ai-chat-send:disabled { opacity: .4; cursor: default; }

/* Powered by */
#ai-chat-footer {
    text-align: center;
    font-size: 10px;
    color: #94a3b8;
    padding: 6px;
    background: #fff;
    border-top: 1px solid #f1f5f9;
}

/* Mobile */
@media (max-width: 400px) {
    #ai-chat-window { width: calc(100vw - 24px); }
    #ai-chat-widget.pos-right { right: 12px; bottom: 12px; }
    #ai-chat-widget.pos-left  { left:  12px; bottom: 12px; }
}
