/* Autofliper AI Chat v2.0.0 */

#afai-widget-btn {
    position: fixed;
    bottom: 28px;
    right: 28px;
    width: 60px;
    height: 60px;
    background: #B32726;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    z-index: 99998;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 24px rgba(179,39,38,0.4);
    transition: transform 0.2s, box-shadow 0.2s;
    -webkit-tap-highlight-color: transparent;
}

#afai-widget-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 32px rgba(179,39,38,0.5);
}

.afai-pulse {
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    border: 2px solid #B32726;
    animation: afai-pulse 2s ease-out infinite;
    opacity: 0;
    pointer-events: none;
}

@keyframes afai-pulse {
    0%   { transform: scale(1); opacity: 0.6; }
    100% { transform: scale(1.5); opacity: 0; }
}

#afai-badge {
    position: absolute;
    top: -3px;
    right: -3px;
    width: 20px;
    height: 20px;
    background: #fff;
    color: #B32726;
    border-radius: 50%;
    font-size: 11px;
    font-weight: 700;
    display: none;
    align-items: center;
    justify-content: center;
    font-family: sans-serif;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}

/* ─── CHAT WINDOW ─── */
#afai-chat-window {
    position: fixed;
    bottom: 100px;
    right: 28px;
    width: 380px;
    height: 560px;
    background: #fff;
    border-radius: 24px;
    box-shadow: 0 24px 80px rgba(0,0,0,0.18);
    z-index: 99999;
    display: none;
    flex-direction: column;
    overflow: hidden;
    font-family: 'DM Sans', sans-serif;
}

@keyframes afai-open {
    from { transform: scale(0.85) translateY(20px); opacity: 0; }
    to   { transform: scale(1) translateY(0); opacity: 1; }
}

/* ─── HEADER ─── */
.afai-header {
    background: #B32726;
    padding: 14px 18px;
    display: flex;
    align-items: center;
    gap: 11px;
    flex-shrink: 0;
}

.afai-avatar {
    width: 38px;
    height: 38px;
    background: rgba(255,255,255,0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
    overflow: hidden;
}

.afai-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.afai-header-info { flex: 1; min-width: 0; }

.afai-bot-name {
    font-size: 15px;
    font-weight: 700;
    color: #fff;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.afai-status {
    font-size: 11px;
    color: rgba(255,255,255,0.85);
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 1px;
}

.afai-status-dot {
    width: 6px; height: 6px;
    background: #4ade80;
    border-radius: 50%;
    display: inline-block;
    animation: afai-blink 2s infinite;
}

@keyframes afai-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

.afai-header-close {
    background: rgba(255,255,255,0.18);
    border: none;
    color: #fff;
    width: 28px; height: 28px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s;
}
.afai-header-close:hover { background: rgba(255,255,255,0.3); }

/* ─── MESSAGES ─── */
#afai-messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
    scrollbar-width: thin;
    scrollbar-color: #e0e0e0 transparent;
}

.afai-msg {
    display: flex;
    gap: 7px;
    align-items: flex-end;
    animation: afai-msg-in 0.2s ease;
    max-width: 100%;
}

@keyframes afai-msg-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.afai-msg.user { flex-direction: row-reverse; }

.afai-msg-avatar {
    width: 26px; height: 26px;
    border-radius: 50%;
    background: #B32726;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    flex-shrink: 0;
    overflow: hidden;
}

.afai-msg-avatar img {
    width: 100%; height: 100%;
    object-fit: cover;
}

.afai-msg.user .afai-msg-avatar { background: #e8e8ed; }

.afai-bubble {
    max-width: 75%;
    padding: 9px 13px;
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    font-size: 14px;
    line-height: 1.5;
    color: #1d1d1f;
    background: #f0f0f5;
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
}

.afai-msg.user .afai-bubble {
    background: #B32726;
    color: #fff;
    border-radius: 18px;
    border-bottom-right-radius: 4px;
    border-bottom-left-radius: 18px;
}

/* ─── CAR LISTING CARD ─── */
.afai-car-card {
    background: #fff;
    border: 1px solid #e8e8ed;
    border-radius: 14px;
    overflow: hidden;
    margin-top: 10px;
    max-width: 260px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.07);
}

.afai-car-card-img {
    width: 100%;
    height: 130px;
    object-fit: cover;
    display: block;
    background: #f0f0f5;
}

.afai-car-card-body { padding: 10px 12px; }

.afai-car-card-title {
    font-weight: 700;
    font-size: 14px;
    color: #1d1d1f;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.afai-car-card-meta {
    font-size: 12px;
    color: #6e6e73;
    margin-bottom: 8px;
    line-height: 1.5;
}

.afai-car-card-price {
    font-size: 15px;
    font-weight: 700;
    color: #B32726;
    margin-bottom: 8px;
}

.afai-car-card-actions {
    display: flex;
    gap: 6px;
}

.afai-car-btn {
    flex: 1;
    padding: 6px 8px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    border: none;
    transition: opacity 0.15s;
    display: inline-block;
}

.afai-car-btn:hover { opacity: 0.85; }

.afai-car-btn-primary {
    background: #B32726;
    color: #fff !important;
}

.afai-car-btn-secondary {
    background: #f0f0f5;
    color: #1d1d1f !important;
}

.afai-exchange-badge {
    display: inline-block;
    background: #d1fae5;
    color: #065f46;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 10px;
    margin-bottom: 6px;
}

/* ─── TYPING ─── */
.afai-typing-wrap {
    display: flex;
    gap: 7px;
    align-items: flex-end;
}

.afai-typing {
    display: flex;
    gap: 4px;
    padding: 11px 15px;
    background: #f0f0f5;
    border-radius: 18px;
    border-bottom-left-radius: 4px;
}

.afai-typing span {
    width: 6px; height: 6px;
    background: #9999a8;
    border-radius: 50%;
    animation: afai-bounce 1.2s infinite;
}
.afai-typing span:nth-child(2) { animation-delay: 0.2s; }
.afai-typing span:nth-child(3) { animation-delay: 0.4s; }

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

/* ─── QUICK REPLIES ─── */
#afai-quick-replies {
    padding: 6px 14px 0;
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    flex-shrink: 0;
}

.afai-quick-btn {
    background: #fff;
    border: 1.5px solid #B32726;
    color: #B32726;
    border-radius: 20px;
    padding: 5px 12px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.15s;
    white-space: nowrap;
}
.afai-quick-btn:hover { background: #B32726; color: #fff; }

/* ─── INPUT ─── */
.afai-input-row {
    padding: 10px 14px 14px;
    display: flex;
    gap: 8px;
    align-items: flex-end;
    border-top: 1px solid #f0f0f5;
    flex-shrink: 0;
}

#afai-input {
    flex: 1;
    border: 1.5px solid #e8e8ed;
    border-radius: 22px;
    padding: 9px 14px;
    font-size: 13px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
    color: #1d1d1f;
    background: #f8f8fa;
    resize: none;
    line-height: 1.4;
    max-height: 90px;
    overflow-y: auto;
    scrollbar-width: none;
}
#afai-input::-webkit-scrollbar { display: none; }
#afai-input:focus { border-color: #B32726; background: #fff; }
#afai-input::placeholder { color: #b0b0b8; }

#afai-send-btn {
    width: 38px; height: 38px;
    background: #B32726;
    border: none;
    border-radius: 50%;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s, opacity 0.15s;
    flex-shrink: 0;
}
#afai-send-btn:hover { transform: scale(1.08); }
#afai-send-btn:disabled { opacity: 0.35; cursor: not-allowed; transform: none; }

/* ─── MOBILE ─── */
@media (max-width: 480px) {
    #afai-chat-window {
        width: calc(100vw - 16px) !important;
        height: calc(100dvh - 110px) !important;
        bottom: 84px !important;
        border-radius: 20px;
    }
    #afai-widget-btn { bottom: 18px; }
}
