/* ================================================
   AI Chatbot Widget – RTL Hebrew
   ================================================ */

#aicb-widget *,
#aicb-widget *::before,
#aicb-widget *::after {
    box-sizing: border-box;
}

#aicb-widget {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 999999;
    font-family: 'Segoe UI', 'Arial', sans-serif;
    direction: rtl;
}

/* ---- Toggle Button ---- */
#aicb-toggle {
    width: 62px;
    height: 62px;
    border-radius: 50%;
    background: var(--aicb-color, #E17B2C);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    position: relative;
    outline: none;
}

#aicb-toggle:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 28px rgba(0, 0, 0, 0.3);
}

#aicb-toggle .aicb-icon-chat,
#aicb-toggle .aicb-icon-close {
    position: absolute;
    transition: opacity 0.2s, transform 0.2s;
}
#aicb-toggle .aicb-icon-close { opacity: 0; transform: rotate(-90deg); }
#aicb-toggle.is-open .aicb-icon-chat  { opacity: 0; transform: rotate(90deg); }
#aicb-toggle.is-open .aicb-icon-close { opacity: 1; transform: rotate(0deg); }

#aicb-toggle svg {
    width: 28px;
    height: 28px;
    fill: white;
}

/* Badge */
#aicb-badge {
    position: absolute;
    top: -2px;
    left: -2px;
    width: 18px;
    height: 18px;
    background: #e53e3e;
    border-radius: 50%;
    border: 2px solid white;
    display: none;
}

/* ---- Chat Window ---- */
#aicb-window {
    position: absolute;
    bottom: 74px;
    right: 0;
    width: 340px;
    background: #ffffff;
    border-radius: 18px;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.18), 0 2px 10px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    overflow: hidden;

    /* Animate in */
    transform-origin: bottom right;
    transform: scale(0.7) translateY(20px);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1),
                opacity  0.22s ease;
}

#aicb-window.open {
    transform: scale(1) translateY(0);
    opacity: 1;
    pointer-events: all;
}

/* ---- Header ---- */
#aicb-header {
    background: var(--aicb-color, #E17B2C);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: white;
}

.aicb-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.22);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

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

.aicb-header-info .aicb-name {
    font-weight: 700;
    font-size: 15px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.aicb-header-info .aicb-status {
    font-size: 12px;
    opacity: 0.85;
    margin-top: 1px;
}

#aicb-close-btn {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 22px;
    line-height: 1;
    opacity: 0.75;
    padding: 0 0 0 4px;
    transition: opacity 0.2s;
    flex-shrink: 0;
}
#aicb-close-btn:hover { opacity: 1; }

/* ---- Messages Area ---- */
#aicb-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 180px;
    max-height: 310px;
    scroll-behavior: smooth;
}

#aicb-messages::-webkit-scrollbar { width: 4px; }
#aicb-messages::-webkit-scrollbar-thumb { background: #ddd; border-radius: 4px; }

/* Message bubbles */
.aicb-msg {
    max-width: 84%;
    padding: 9px 14px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.55;
    word-wrap: break-word;
    animation: aicbPop 0.2s ease forwards;
}

@keyframes aicbPop {
    from { transform: scale(0.85) translateY(4px); opacity: 0; }
    to   { transform: scale(1)    translateY(0);   opacity: 1; }
}

.aicb-msg.bot {
    background: #f3f4f6;
    color: #1a202c;
    align-self: flex-end;
    border-bottom-right-radius: 5px;
}

.aicb-msg.user {
    background: var(--aicb-color, #E17B2C);
    color: white;
    align-self: flex-start;
    border-bottom-left-radius: 5px;
}

/* Typing indicator */
.aicb-typing {
    display: flex;
    gap: 5px;
    padding: 10px 14px;
    background: #f3f4f6;
    border-radius: 18px;
    border-bottom-right-radius: 5px;
    align-self: flex-end;
    animation: aicbPop 0.2s ease forwards;
}

.aicb-typing span {
    width: 7px;
    height: 7px;
    background: #999;
    border-radius: 50%;
    animation: aicbBounce 1.3s infinite ease-in-out;
}
.aicb-typing span:nth-child(2) { animation-delay: 0.18s; }
.aicb-typing span:nth-child(3) { animation-delay: 0.36s; }

@keyframes aicbBounce {
    0%, 60%, 100% { transform: translateY(0); }
    30%            { transform: translateY(-7px); }
}

/* ---- Lead Form ---- */
#aicb-lead-form {
    padding: 14px 16px;
    background: #fafafa;
    border-top: 1px solid #eee;
    display: none;
}

#aicb-lead-form p.aicb-lf-title {
    margin: 0 0 10px;
    font-size: 13px;
    color: #555;
    font-weight: 600;
}

#aicb-lead-form input {
    width: 100%;
    padding: 9px 13px;
    border: 1px solid #ddd;
    border-radius: 10px;
    margin-bottom: 8px;
    font-size: 14px;
    direction: rtl;
    outline: none;
    transition: border-color 0.2s;
}

#aicb-lead-form input:focus {
    border-color: var(--aicb-color, #E17B2C);
}

#aicb-lead-form input.error {
    border-color: #e53e3e;
}

#aicb-lf-submit {
    width: 100%;
    padding: 10px;
    background: var(--aicb-color, #E17B2C);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: opacity 0.2s;
}
#aicb-lf-submit:hover { opacity: 0.88; }

/* ---- Footer / Input ---- */
#aicb-footer {
    padding: 10px 12px;
    border-top: 1px solid #eee;
    display: flex;
    align-items: center;
    gap: 8px;
    background: #fff;
}

#aicb-input {
    flex: 1;
    border: 1px solid #e2e8f0;
    border-radius: 24px;
    padding: 9px 16px;
    font-size: 14px;
    outline: none;
    direction: rtl;
    transition: border-color 0.2s;
    min-width: 0;
}

#aicb-input:focus {
    border-color: var(--aicb-color, #E17B2C);
}

#aicb-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--aicb-color, #E17B2C);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: opacity 0.2s;
    outline: none;
}
#aicb-send-btn:hover { opacity: 0.85; }
#aicb-send-btn svg { width: 18px; height: 18px; fill: white; }

/* ---- Quick Reply Buttons ---- */
#aicb-quick-replies {
    padding: 0 12px 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    justify-content: flex-end;
}

.aicb-qreply {
    background: #fff;
    border: 1.5px solid var(--aicb-color, #E17B2C);
    color: var(--aicb-color, #E17B2C);
    border-radius: 20px;
    padding: 7px 14px;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.18s, color 0.18s;
    font-family: inherit;
    white-space: nowrap;
}

.aicb-qreply:hover {
    background: var(--aicb-color, #E17B2C);
    color: #fff;
}

/* ---- Responsive ---- */
@media (max-width: 420px) {
    #aicb-widget {
        bottom: 16px;
        right: 16px;
    }
    #aicb-window {
        width: calc(100vw - 32px);
        right: -8px;
    }
}
