/* ── Chat Widget – MyAIBot ─────────────────────────────────────────────── */
.aicb-chat-container {
    --aicb-desktop-width-sm: 340px;
    --aicb-desktop-height-sm: 500px;
    --aicb-desktop-width-md: 420px;
    --aicb-desktop-height-md: 620px;
    --aicb-desktop-width-lg: 560px;
    --aicb-desktop-height-lg: 760px;
    --aicb-widget-min-width: 320px;
    --aicb-widget-min-height: 440px;
    --aicb-widget-max-width: min(680px, calc(100vw - 32px));
    --aicb-widget-max-height: min(820px, calc(100vh - 120px));
    --aicb-widget-width: var(--aicb-desktop-width-md);
    --aicb-widget-height: var(--aicb-desktop-height-md);
    --aicb-mobile-viewport-height: 100dvh;
    --aicb-mobile-viewport-top: 0px;
    direction: rtl;
    position: fixed;
    bottom: 28px;
    right: 28px;
    z-index: 99999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    font-size: 14px;
}

.aicb-chat-container[dir="ltr"] {
    direction: ltr;
}

body.aicb-chat-open-mobile {
    overflow: hidden;
}

.aicb-chat-container.aicb-chat-open .aicb-bubble {
    opacity: 0;
    pointer-events: none;
    transform: scale(.92);
}

.aicb-sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

#aicb-launcher.aicb-bubble,
.aicb-bubble {
    width: 62px !important;
    height: 62px !important;
    min-width: 62px !important;
    min-height: 62px !important;
    max-width: 62px !important;
    max-height: 62px !important;
    border-radius: 50% !important;
    cursor: pointer;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: var(--aicb-color, #1f2937) !important;
    box-shadow: 0 6px 20px rgba(0,0,0,.28);
    transition: transform .2s, box-shadow .2s, opacity .2s;
    overflow: hidden !important;
    border: none !important;
    padding: 0 !important;
    margin: 0 !important;
    appearance: none;
    -webkit-appearance: none;
    text-align: center;
    line-height: 1;
    position: relative !important;
    flex: 0 0 62px !important;
}

.aicb-bubble:hover {
    transform: scale(1.08);
    box-shadow: 0 8px 24px rgba(0,0,0,.35);
}

#aicb-launcher {
    z-index: 4;
}

#aicb-launcher:focus,
#aicb-launcher:focus-visible {
    outline: 3px solid var(--aicb-focus-color, #111827) !important;
    outline-offset: 4px !important;
    box-shadow: 0 0 0 4px rgba(255,255,255,.95), 0 0 0 8px rgba(17,24,39,.32), 0 10px 26px rgba(0,0,0,.35) !important;
    transform: scale(1.06);
}

.aicb-chat-container[data-position="left"] .aicb-bubble {
    left: 0;
    right: auto;
}

.aicb-chat-container[data-position="right"] .aicb-bubble {
    right: 0;
    left: auto;
}

#aicb-launcher .aicb-m-icon,
#aicb-launcher video.aicb-m-icon,
#aicb-launcher img.aicb-m-icon,
.aicb-bubble .aicb-m-icon,
.aicb-bubble video.aicb-m-icon,
.aicb-bubble img.aicb-m-icon {
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    max-height: 100% !important;
    display: block !important;
    object-fit: cover !important;
    object-position: center center !important;
    border-radius: 50% !important;
    margin: 0 auto !important;
    position: absolute !important;
    inset: 0 !important;
}

.aicb-launcher-svg {
    width: 28px;
    height: 28px;
    display: block;
    margin: 0 auto;
    fill: none;
    stroke: #ffffff;
    stroke-width: 1.9;
    stroke-linejoin: round;
    stroke-linecap: round;
    flex: 0 0 auto;
    position: relative;
    z-index: 1;
}

.aicb-chat-win {
    position: absolute;
    bottom: 76px;
    width: min(var(--aicb-widget-width), var(--aicb-widget-max-width));
    height: min(var(--aicb-widget-height), var(--aicb-widget-max-height));
    min-width: min(var(--aicb-widget-min-width), var(--aicb-widget-max-width));
    min-height: min(var(--aicb-widget-min-height), var(--aicb-widget-max-height));
    max-width: var(--aicb-widget-max-width);
    max-height: var(--aicb-widget-max-height);
    background: #fff;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 12px 40px rgba(0,0,0,.18);
    border: 1px solid #e2e8f0;
    transition: width .18s ease, height .18s ease, max-width .18s ease, max-height .18s ease;
    resize: none;
}

.aicb-chat-container[data-position="right"] .aicb-chat-win {
    right: 0;
    left: auto;
}

.aicb-chat-container[data-position="left"] .aicb-chat-win {
    left: 0;
    right: auto;
}

.aicb-chat-win.aicb-size-sm {
    --aicb-widget-width: var(--aicb-desktop-width-sm);
    --aicb-widget-height: var(--aicb-desktop-height-sm);
}

.aicb-chat-win.aicb-size-md {
    --aicb-widget-width: var(--aicb-desktop-width-md);
    --aicb-widget-height: var(--aicb-desktop-height-md);
}

.aicb-chat-win.aicb-size-lg {
    --aicb-widget-width: var(--aicb-desktop-width-lg);
    --aicb-widget-height: var(--aicb-desktop-height-lg);
}

.aicb-chat-win.aicb-has-custom-size {
    transition: none;
}

.aicb-chat-win.aicb-is-mobile {
    transition: opacity .18s ease;
}

.aicb-chat-win.aicb-is-resizing {
    user-select: none;
    transition: none;
}

.aicb-resize-handle {
    position: absolute;
    width: 18px;
    height: 18px;
    opacity: .86;
    z-index: 3;
    display: block;
    touch-action: none;
    background: transparent;
    border: none;
    padding: 0;
}

.aicb-chat-container[data-position="right"] .aicb-resize-handle {
    top: 0;
    left: 0;
    right: auto;
    bottom: auto;
    cursor: nesw-resize;
    border-top-left-radius: 14px;
}

.aicb-chat-container[data-position="left"] .aicb-resize-handle {
    top: 0;
    right: 0;
    left: auto;
    bottom: auto;
    cursor: nwse-resize;
    border-top-right-radius: 14px;
}

.aicb-chat-container[data-position="right"] .aicb-resize-handle::before,
.aicb-chat-container[data-position="right"] .aicb-resize-handle::after {
    content: "";
    position: absolute;
    top: 4px;
    left: 4px;
    width: 8px;
    height: 8px;
    border-top: 2px solid rgba(100,116,139,.92);
    border-left: 2px solid rgba(100,116,139,.92);
}

.aicb-chat-container[data-position="right"] .aicb-resize-handle::after {
    width: 12px;
    height: 12px;
    top: 2px;
    left: 2px;
    opacity: .72;
}

.aicb-chat-container[data-position="left"] .aicb-resize-handle::before,
.aicb-chat-container[data-position="left"] .aicb-resize-handle::after {
    content: "";
    position: absolute;
    top: 4px;
    right: 4px;
    width: 8px;
    height: 8px;
    border-top: 2px solid rgba(100,116,139,.92);
    border-right: 2px solid rgba(100,116,139,.92);
}

.aicb-chat-container[data-position="left"] .aicb-resize-handle::after {
    width: 12px;
    height: 12px;
    top: 2px;
    right: 2px;
    opacity: .72;
}

.aicb-header {
    background: var(--aicb-color, #1f2937);
    color: var(--aicb-header-text, #fff);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-shrink: 0;
}

.aicb-chat-container[dir="ltr"] .aicb-header {
    text-align: left;
}

.aicb-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.aicb-header-title {
    font-weight: 700;
    font-size: 15px;
}

.aicb-header-subtitle {
    font-size: 11px;
    opacity: .88;
    margin-top: 1px;
}

.aicb-header-actions {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
    justify-content: flex-end;
    align-items: center;
}

.aicb-chat-container[dir="ltr"] .aicb-header-actions {
    justify-content: flex-start;
}

.aicb-header-btn {
    background: rgba(255,255,255,.15);
    border: none !important;
    color: #fff;
    cursor: pointer;
    width: 28px;
    min-width: 28px;
    max-width: 28px;
    height: 28px;
    min-height: 28px;
    padding: 0 !important;
    border-radius: 7px;
    font-size: 13px;
    transition: background .15s, opacity .15s, transform .15s, box-shadow .15s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    appearance: none;
    -webkit-appearance: none;
    text-align: center;
    box-sizing: border-box;
}

.aicb-header-btn:hover:not(:disabled) {
    background: rgba(255,255,255,.25);
    transform: translateY(-1px);
}

.aicb-header-btn:disabled {
    opacity: .38;
    cursor: not-allowed;
}

.aicb-header-btn-icon {
    color: var(--aicb-action-icon-color, #ffffff);
}

.aicb-svg-icon,
.aicb-send-svg {
    width: 16px;
    height: 16px;
    display: block;
    fill: none !important;
    stroke: currentColor !important;
    stroke-width: 2.2;
    stroke-linejoin: round;
    stroke-linecap: round;
    flex: 0 0 auto;
    margin: 0 auto;
    pointer-events: none;
}

.aicb-send-svg {
    width: 18px;
    height: 18px;
    stroke-width: 3;
}

.aicb-bot-avatar-header {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255,255,255,.3);
}

.aicb-chat-body {
    flex: 1;
    padding: 14px;
    overflow-y: auto;
    background: #f8fafc;
    scroll-behavior: smooth;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    text-align: right;
}

.aicb-chat-container[dir="ltr"] .aicb-chat-body {
    text-align: left;
}

.aicb-welcome {
    text-align: center;
    padding: 20px 10px;
}

.aicb-welcome-avatar {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    object-fit: cover;
    margin-bottom: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,.12);
}

.aicb-welcome p {
    color: #334155;
    margin-bottom: 14px;
    line-height: 1.6;
}

.aicb-empty-topics {
    color: #475569;
    font-size: 13px;
    line-height: 1.6;
}

.aicb-topic-btn {
    display: block;
    width: 100%;
    margin: 6px 0;
    padding: 11px 14px;
    border: 1.5px solid #cbd5e1;
    background: #fff;
    cursor: pointer;
    border-radius: 10px;
    text-align: right;
    font-size: 14px;
    color: #0f172a;
    transition: border-color .15s, background .15s, transform .1s, box-shadow .15s;
    appearance: none;
    -webkit-appearance: none;
}

.aicb-chat-container[dir="ltr"] .aicb-topic-btn {
    text-align: left;
}

.aicb-topic-btn:hover {
    border-color: var(--aicb-topic-hover-border, var(--aicb-color, #1f2937));
    background: var(--aicb-topic-hover-bg, #f0f4ff);
    transform: translateX(-2px);
}

.aicb-chat-container[dir="ltr"] .aicb-topic-btn:hover {
    transform: translateX(2px);
}

.aicb-msg {
    display: flex;
    flex-direction: column;
    margin-bottom: 10px;
    max-width: 85%;
}

.aicb-msg-user {
    align-items: flex-start;
    align-self: flex-start;
    margin-left: auto;
}

.aicb-msg-bot {
    align-items: flex-end;
    align-self: flex-end;
}

.aicb-chat-container[dir="ltr"] .aicb-msg-user {
    align-items: flex-end;
    align-self: flex-end;
    margin-left: 0;
    margin-right: auto;
}

.aicb-chat-container[dir="ltr"] .aicb-msg-bot {
    align-items: flex-start;
    align-self: flex-start;
}

.aicb-msg-bubble {
    padding: 9px 13px;
    border-radius: 14px;
    line-height: 1.65;
    word-break: break-word;
    white-space: pre-wrap;
}

.aicb-msg-user .aicb-msg-bubble {
    background: var(--aicb-user-bubble-bg, #1d4ed8);
    color: var(--aicb-user-bubble-text, #fff);
    border-bottom-left-radius: 4px;
}

.aicb-chat-container[dir="ltr"] .aicb-msg-user .aicb-msg-bubble {
    border-bottom-left-radius: 14px;
    border-bottom-right-radius: 4px;
}

.aicb-msg-bot .aicb-msg-bubble {
    background: #fff;
    color: #1e293b;
    border: 1px solid #cbd5e1;
    border-bottom-right-radius: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
}

.aicb-chat-container[dir="ltr"] .aicb-msg-bot .aicb-msg-bubble {
    border-bottom-right-radius: 14px;
    border-bottom-left-radius: 4px;
}

.aicb-msg-time {
    font-size: 10px;
    color: #64748b;
    margin-top: 3px;
    padding: 0 4px;
}

.aicb-typing-dots {
    display: flex;
    gap: 5px;
    padding: 12px 16px;
    background: #fff;
    border: 1px solid #cbd5e1;
    border-radius: 14px;
    border-bottom-right-radius: 4px;
    width: fit-content;
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
}

.aicb-chat-container[dir="ltr"] .aicb-typing-dots {
    border-bottom-right-radius: 14px;
    border-bottom-left-radius: 4px;
}

.aicb-typing-dots span {
    display: block;
    width: 8px;
    height: 8px;
    background: #64748b;
    border-radius: 50%;
    animation: aicb-bounce 1.2s infinite ease-in-out;
}

.aicb-typing-dots span:nth-child(1) { animation-delay: 0s; }
.aicb-typing-dots span:nth-child(2) { animation-delay: .2s; }
.aicb-typing-dots span:nth-child(3) { animation-delay: .4s; }

@keyframes aicb-bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-6px); }
}

.aicb-chat-footer {
    padding: 10px 12px;
    border-top: 1px solid #e2e8f0;
    display: flex;
    gap: 8px;
    align-items: center;
    background: #fff;
    flex-shrink: 0;
}

#aicb-user-input {
    flex: 1;
    border: 1.5px solid #94a3b8;
    padding: 9px 14px;
    border-radius: 22px;
    outline: none;
    font-size: 14px;
    transition: border-color .15s, background .15s, box-shadow .15s;
    direction: rtl;
    text-align: right;
    background: #f9fafb;
    color: #0f172a;
}

.aicb-chat-container[dir="ltr"] #aicb-user-input {
    direction: ltr;
    text-align: left;
}

#aicb-user-input::placeholder {
    color: #64748b;
    opacity: 1;
}

#aicb-user-input:focus {
    border-color: #1d4ed8;
    background: #fff;
}

#aicb-send-btn {
    width: 42px !important;
    min-width: 42px !important;
    height: 42px !important;
    min-height: 42px !important;
    border: none !important;
    border-radius: 50% !important;
    background: var(--aicb-send-bg, #1d4ed8) !important;
    color: #ffffff !important;
    fill: none !important;
    cursor: pointer;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex-shrink: 0;
    transition: transform .15s, box-shadow .15s, opacity .15s;
    box-shadow: 0 6px 16px rgba(37,99,235,.28);
    padding: 0 !important;
    appearance: none;
    -webkit-appearance: none;
    text-align: center;
    line-height: 1;
    box-sizing: border-box;
}

#aicb-send-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    background: var(--aicb-send-bg-hover, var(--aicb-send-bg, #1e40af)) !important;
    box-shadow: 0 8px 18px rgba(37,99,235,.34);
}

#aicb-send-btn:disabled {
    opacity: .5;
    cursor: not-allowed;
    box-shadow: none;
}

#aicb-send-btn .aicb-send-svg {
    color: #ffffff !important;
    stroke: #ffffff !important;
    fill: none !important;
    margin: 0 auto;
}

.aicb-bubble:focus-visible,
.aicb-header-btn:focus-visible,
.aicb-topic-btn:focus-visible,
#aicb-user-input:focus-visible,
#aicb-send-btn:focus-visible,
#aicb-chat-window:focus-visible,
#aicb-flow:focus-visible,
.aicb-resize-handle:focus-visible {
    outline: 3px solid var(--aicb-focus-color, #111827);
    outline-offset: 2px;
    box-shadow: 0 0 0 3px rgba(255,255,255,.9), 0 0 0 6px rgba(17,24,39,.28);
}

.aicb-chat-body::-webkit-scrollbar { width: 6px; }
.aicb-chat-body::-webkit-scrollbar-track { background: transparent; }
.aicb-chat-body::-webkit-scrollbar-thumb {
    background: #94a3b8;
    border-radius: 4px;
}

@media (prefers-reduced-motion: reduce) {
    .aicb-bubble,
    .aicb-chat-win,
    .aicb-header-btn,
    .aicb-topic-btn,
    #aicb-send-btn,
    .aicb-typing-dots span {
        transition: none !important;
        animation: none !important;
        scroll-behavior: auto !important;
    }
}

@media (max-width: 1024px) {
    .aicb-chat-container {
        bottom: 20px;
        --aicb-widget-min-width: 300px;
        --aicb-widget-min-height: 420px;
        --aicb-widget-max-width: min(520px, calc(100vw - 24px));
        --aicb-widget-max-height: min(720px, calc(100vh - 96px));
    }

    .aicb-chat-container[data-position="right"] {
        right: 20px;
        left: auto;
    }

    .aicb-chat-container[data-position="left"] {
        left: 20px;
        right: auto;
    }

    .aicb-chat-win {
        bottom: 72px;
        width: min(440px, var(--aicb-widget-max-width));
        height: min(680px, var(--aicb-widget-max-height));
    }
}

@media (max-width: 767px) {
    .aicb-chat-container {
        bottom: 0;
        right: 0;
        left: 0;
        width: auto;
    }

    .aicb-chat-container[data-position="right"] .aicb-bubble {
        bottom: 16px;
        right: 16px;
        left: auto;
        position: fixed;
    }

    .aicb-chat-container[data-position="left"] .aicb-bubble {
        bottom: 16px;
        left: 16px;
        right: auto;
        position: fixed;
    }

    .aicb-chat-win,
    .aicb-chat-win.aicb-size-sm,
    .aicb-chat-win.aicb-size-md,
    .aicb-chat-win.aicb-size-lg {
        position: fixed;
        top: var(--aicb-mobile-viewport-top);
        left: 0;
        right: 0;
        bottom: auto;
        width: 100vw;
        min-width: 100vw;
        max-width: 100vw;
        height: var(--aicb-mobile-viewport-height);
        min-height: var(--aicb-mobile-viewport-height);
        max-height: var(--aicb-mobile-viewport-height);
        border-radius: 0;
    }

    .aicb-chat-body {
        padding: 12px;
    }

    .aicb-header {
        padding: calc(14px + env(safe-area-inset-top)) 14px 12px;
    }

    .aicb-header-actions {
        gap: 4px;
    }

    .aicb-header-btn {
        width: 30px;
        min-width: 30px;
        max-width: 30px;
        height: 30px;
        min-height: 30px;
    }

    .aicb-chat-footer {
        padding-bottom: max(10px, env(safe-area-inset-bottom));
    }

    .aicb-resize-handle {
        display: none;
    }
}