/**
 * ACBIZ GLOBAL — AI Features CSS
 * Chatbot widget + AI recommendation cards + insight bar
 */

/* ── Variables (inherit platform tokens) ─────────────────────── */
:root {
    --ai-blue:    #1d4ed8;
    --ai-indigo:  #4f46e5;
    --ai-purple:  #7c3aed;
    --ai-grad:    linear-gradient(135deg, #1d4ed8, #7c3aed);
    --ai-glow:    0 0 0 3px rgba(79,70,229,.18);
    --ai-radius:  16px;
    --ai-shadow:  0 12px 40px rgba(0,0,0,.18);
}

/* ════════════════════════════════════════════════════════════════
   CHATBOT WIDGET
   ════════════════════════════════════════════════════════════════ */

/* FAB trigger button */
#acbizChatBtn {
    position: fixed;
    bottom: 28px;
    right: 28px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--ai-grad);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(79,70,229,.45);
    z-index: 9990;
    transition: transform .2s, box-shadow .2s;
}
#acbizChatBtn:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 28px rgba(79,70,229,.6);
}
#acbizChatBtn i { font-size: 22px; color: #fff; transition: opacity .2s; }
#acbizChatBtn .chat-icon-open  { display: flex; }
#acbizChatBtn .chat-icon-close { display: none; }
#acbizChatBtn.open .chat-icon-open  { display: none; }
#acbizChatBtn.open .chat-icon-close { display: flex; }

/* Unread dot */
#acbizChatBtn .chat-dot {
    position: absolute;
    top: 3px; right: 3px;
    width: 12px; height: 12px;
    background: #f59e0b;
    border-radius: 50%;
    border: 2px solid #fff;
    animation: chatDotPulse 1.8s infinite;
}
@keyframes chatDotPulse {
    0%,100% { transform: scale(1); opacity: 1; }
    50%      { transform: scale(1.3); opacity: .7; }
}

/* Chat window */
#acbizChatWindow {
    position: fixed;
    bottom: 96px;
    right: 28px;
    width: 370px;
    max-height: 580px;
    background: #fff;
    border-radius: var(--ai-radius);
    box-shadow: var(--ai-shadow);
    display: flex;
    flex-direction: column;
    z-index: 9989;
    opacity: 0;
    transform: translateY(16px) scale(.97);
    pointer-events: none;
    transition: opacity .22s, transform .22s;
    overflow: hidden;
    border: 1px solid #e2e8f0;
}
#acbizChatWindow.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

/* Chat header */
.chat-header {
    background: var(--ai-grad);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}
.chat-header-avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: rgba(255,255,255,.18);
    display: flex; align-items: center; justify-content: center;
    font-size: 16px; color: #fff; flex-shrink: 0;
}
.chat-header-info { flex: 1; }
.chat-header-name {
    font-size: 14px; font-weight: 700; color: #fff; line-height: 1.2;
}
.chat-header-status {
    font-size: 11px; color: rgba(255,255,255,.72);
    display: flex; align-items: center; gap: 4px;
}
.chat-header-status::before {
    content: '';
    width: 6px; height: 6px;
    background: #4ade80; border-radius: 50%;
    display: inline-block;
}
.chat-header-close {
    background: none; border: none; color: rgba(255,255,255,.7);
    font-size: 16px; cursor: pointer; padding: 4px; border-radius: 6px;
    transition: background .15s;
}
.chat-header-close:hover { background: rgba(255,255,255,.15); color: #fff; }

/* Messages area */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 0;
    scroll-behavior: smooth;
}
.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-thumb { background: #e2e8f0; border-radius: 4px; }

/* Message bubbles */
.chat-msg { display: flex; align-items: flex-end; gap: 8px; max-width: 90%; }
.chat-msg.user { align-self: flex-end; flex-direction: row-reverse; }
.chat-msg.bot  { align-self: flex-start; }

.chat-msg-avatar {
    width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center; font-size: 12px;
}
.chat-msg.bot  .chat-msg-avatar { background: var(--ai-grad); color: #fff; }
.chat-msg.user .chat-msg-avatar { background: #e0e7ff; color: #3730a3; font-weight: 700; font-size: 11px; }

.chat-msg-bubble {
    padding: 10px 13px;
    border-radius: 14px;
    font-size: 13.5px;
    line-height: 1.55;
    max-width: 100%;
    word-break: break-word;
}
.chat-msg.bot  .chat-msg-bubble {
    background: #f8fafc;
    color: #0f172a;
    border: 1px solid #e9eef5;
    border-bottom-left-radius: 4px;
}
.chat-msg.user .chat-msg-bubble {
    background: var(--ai-grad);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.chat-msg-tools {
    font-size: 11px;
    color: #94a3b8;
    margin-bottom: 5px;
    display: flex;
    align-items: center;
    gap: 5px;
}
.chat-msg-tools i { font-size: 10px; }

.chat-confirm-bubble { background: #fffbeb !important; border-color: #fde68a !important; }
.chat-confirm-summary { font-size: 13px; color: #78350f; margin-bottom: 10px; line-height: 1.5; }
.chat-confirm-actions { display: flex; gap: 8px; align-items: center; }
.chat-confirm-btn {
    border: none;
    border-radius: 7px;
    padding: 7px 16px;
    font-size: 12.5px;
    font-weight: 700;
    cursor: pointer;
}
.chat-confirm-btn.confirm { background: #16a34a; color: #fff; }
.chat-confirm-btn.cancel { background: #f1f5f9; color: #475569; }
.chat-confirm-pending { font-size: 12px; color: #94a3b8; }
.chat-confirm-result { font-size: 12.5px; font-weight: 600; display: flex; align-items: center; gap: 5px; }
.chat-confirm-result.done { color: #16a34a; }
.chat-confirm-result.failed { color: #dc2626; }
.chat-confirm-result.cancelled { color: #64748b; }

/* Typing indicator */
.chat-typing {
    display: flex; align-items: center; gap: 5px;
    padding: 10px 14px;
    background: #f8fafc;
    border: 1px solid #e9eef5;
    border-radius: 14px; border-bottom-left-radius: 4px;
    width: fit-content;
}
.chat-typing span {
    width: 7px; height: 7px;
    background: #94a3b8; border-radius: 50%;
    animation: typingBounce .9s infinite;
}
.chat-typing span:nth-child(2) { animation-delay: .18s; }
.chat-typing span:nth-child(3) { animation-delay: .36s; }
@keyframes typingBounce {
    0%,80%,100% { transform: translateY(0); }
    40%          { transform: translateY(-6px); }
}

/* Quick suggestions */
.chat-suggestions {
    padding: 0 16px 10px;
    display: flex; flex-wrap: wrap; gap: 6px;
    flex-shrink: 0;
}
.chat-suggestion-btn {
    background: #f1f5f9; border: 1px solid #e2e8f0;
    border-radius: 20px; padding: 5px 12px;
    font-size: 12px; color: #475569; cursor: pointer;
    transition: background .15s, color .15s;
    white-space: nowrap;
}
.chat-suggestion-btn:hover { background: #e0e7ff; color: #3730a3; border-color: #c7d2fe; }

/* Input bar */
.chat-input-bar {
    padding: 12px 14px;
    border-top: 1px solid #f1f5f9;
    display: flex; gap: 8px; align-items: flex-end;
    flex-shrink: 0;
    background: #fff;
}
#chatInput {
    flex: 1;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 9px 12px;
    font-size: 13.5px;
    font-family: inherit;
    resize: none;
    max-height: 80px;
    min-height: 38px;
    line-height: 1.4;
    outline: none;
    transition: border-color .15s;
    color: #0f172a;
}
#chatInput:focus { border-color: #818cf8; box-shadow: var(--ai-glow); }
#chatInput::placeholder { color: #94a3b8; }

#chatSendBtn {
    width: 38px; height: 38px; border-radius: 10px;
    background: var(--ai-grad);
    border: none; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    transition: opacity .15s, transform .15s;
}
#chatSendBtn:hover  { opacity: .88; transform: scale(1.05); }
#chatSendBtn:active { transform: scale(.97); }
#chatSendBtn i { color: #fff; font-size: 14px; }
#chatSendBtn:disabled { opacity: .45; cursor: not-allowed; transform: none; }

/* Chat footer */
.chat-footer {
    padding: 6px 14px 8px;
    text-align: center;
    font-size: 10.5px;
    color: #94a3b8;
    border-top: 1px solid #f8fafc;
    flex-shrink: 0;
}

/* ════════════════════════════════════════════════════════════════
   AI RECOMMENDATION CARDS
   ════════════════════════════════════════════════════════════════ */

.ai-rec-section {
    margin: 32px 0;
}
.ai-rec-header {
    display: flex; align-items: center; gap: 10px;
    margin-bottom: 18px;
}
.ai-rec-badge {
    display: inline-flex; align-items: center; gap: 6px;
    background: linear-gradient(135deg, #ede9fe, #dbeafe);
    color: #4f46e5;
    font-size: 11px; font-weight: 700; letter-spacing: .4px;
    padding: 4px 10px; border-radius: 20px;
    text-transform: uppercase;
}
.ai-rec-title { font-size: 18px; font-weight: 700; color: #0f172a; }
.ai-rec-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
}
.ai-rec-card {
    background: #fff;
    border: 1px solid #e9eef5;
    border-radius: 14px;
    padding: 18px;
    display: flex; flex-direction: column; gap: 10px;
    transition: box-shadow .18s, transform .18s;
    text-decoration: none; color: inherit;
}
.ai-rec-card:hover {
    box-shadow: 0 8px 24px rgba(79,70,229,.12);
    transform: translateY(-2px);
}
.ai-rec-card-icon {
    width: 42px; height: 42px; border-radius: 11px;
    display: flex; align-items: center; justify-content: center;
    font-size: 18px; flex-shrink: 0;
}
.ai-rec-card-name { font-size: 14px; font-weight: 700; color: #0f172a; }
.ai-rec-card-tag  { font-size: 11.5px; color: #64748b; }
.ai-rec-card-meta {
    display: flex; align-items: center; gap: 6px;
    font-size: 11.5px; color: #94a3b8;
}
.ai-rec-card-stars i { color: #f59e0b; font-size: 10px; }
.ai-rec-card-price {
    font-size: 13px; font-weight: 700;
    color: #1d4ed8; margin-top: auto;
}
.ai-rec-card-cta {
    display: inline-flex; align-items: center; gap: 5px;
    font-size: 12px; font-weight: 600; color: #4f46e5;
    margin-top: 4px;
}
.ai-rec-loading {
    display: flex; align-items: center; gap: 10px;
    color: #94a3b8; font-size: 13px; padding: 20px 0;
}

/* ════════════════════════════════════════════════════════════════
   AI SEARCH AUTOCOMPLETE
   ════════════════════════════════════════════════════════════════ */

.ai-search-wrap { position: relative; }
.ai-search-dropdown {
    position: absolute; top: calc(100% + 4px); left: 0; right: 0;
    background: #fff; border: 1px solid #e2e8f0; border-radius: 12px;
    box-shadow: 0 8px 28px rgba(0,0,0,.12); z-index: 999;
    overflow: hidden; display: none;
}
.ai-search-dropdown.open { display: block; }
.ai-search-item {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 14px; cursor: pointer; transition: background .12s;
    text-decoration: none; color: inherit;
}
.ai-search-item:hover { background: #f8fafc; }
.ai-search-item-icon {
    width: 30px; height: 30px; border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; flex-shrink: 0;
}
.ai-search-item-name { font-size: 13px; font-weight: 600; color: #0f172a; }
.ai-search-item-sub  { font-size: 11px; color: #94a3b8; }
.ai-search-ai-label  {
    padding: 6px 14px; font-size: 10.5px; color: #94a3b8;
    border-top: 1px solid #f1f5f9;
    display: flex; align-items: center; gap: 5px;
}

/* ════════════════════════════════════════════════════════════════
   RESPONSIVE
   ════════════════════════════════════════════════════════════════ */

@media (max-width: 480px) {
    #acbizChatWindow {
        width: calc(100vw - 24px);
        right: 12px; bottom: 88px;
        max-height: 70vh;
    }
    #acbizChatBtn { right: 16px; bottom: 16px; }
    .acbiz-wa-btn { right: 16px; bottom: 88px; }
}

/* ══════════════════════════════════════════════════════════
   FLOATING WHATSAPP BUTTON
   Stacked directly above #acbizChatBtn (56px tall, bottom:28px)
   with a consistent gap at every screen size — the two are
   intentionally kept in sync here since they always appear together.
   ══════════════════════════════════════════════════════════ */
.acbiz-wa-btn {
    position: fixed;
    bottom: 100px;
    right: 28px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #25D366;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(37,211,102,.45);
    z-index: 9989;
    transition: transform .2s, box-shadow .2s;
    text-decoration: none;
}
.acbiz-wa-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 28px rgba(37,211,102,.6);
}

