/* סוכן תמיכה ציבורי — צד ימין פיזי (נגישות שמאל). direction:ltr כדי שלא יידחף לשמאל ב-RTL */
.nons-smart-agent.nons-smart-agent--public {
    position: fixed !important;
    right: max(18px, env(safe-area-inset-right, 0px)) !important;
    left: auto !important;
    inset-inline-end: auto !important;
    inset-inline-start: auto !important;
    bottom: max(22px, env(safe-area-inset-bottom, 0px)) !important;
    z-index: 2147483635;
    font-family: 'Heebo', 'Assistant', system-ui, -apple-system, sans-serif;
    direction: ltr;
    text-align: right;
}

html[dir="rtl"] .nons-smart-agent.nons-smart-agent--public,
body[dir="rtl"] .nons-smart-agent.nons-smart-agent--public {
    right: max(18px, env(safe-area-inset-right, 0px)) !important;
    left: auto !important;
    inset-inline-end: auto !important;
    inset-inline-start: auto !important;
}

body.ph-drawer-open .nons-smart-agent.nons-smart-agent--public {
    right: max(18px, env(safe-area-inset-right, 0px)) !important;
    left: auto !important;
    inset-inline-end: auto !important;
    inset-inline-start: auto !important;
}

.nons-public-chat__backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.42);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    z-index: 2147483634;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.28s ease, visibility 0.28s ease;
    pointer-events: none;
}

.nons-public-chat__backdrop.is-visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.nons-public-chat__launcher {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    flex-direction: row;
}

/* כפתור צ׳אט עגול */
.nons-smart-agent--public .nons-public-chat__fab {
    position: relative;
    width: 62px;
    height: 62px;
    min-width: 62px;
    padding: 0;
    border-radius: 50%;
    justify-content: center;
    gap: 0;
    background: linear-gradient(145deg, #2ac1da 0%, #1a9fb8 48%, #48bcb4 100%);
    box-shadow:
        0 10px 32px rgba(42, 193, 218, 0.42),
        0 4px 12px rgba(15, 23, 42, 0.14);
    border: 2px solid rgba(255, 255, 255, 0.92);
}

.nons-smart-agent--public .nons-public-chat__fab:hover,
.nons-smart-agent--public .nons-public-chat__fab:focus-visible {
    transform: translateY(-3px) scale(1.03);
    box-shadow:
        0 14px 36px rgba(42, 193, 218, 0.5),
        0 6px 16px rgba(15, 23, 42, 0.16);
    outline: none;
}

.nons-public-chat__fab-pulse {
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    border: 2px solid rgba(42, 193, 218, 0.55);
    animation: nons-public-chat-pulse 2.4s ease-out infinite;
    pointer-events: none;
}

@keyframes nons-public-chat-pulse {
    0% {
        transform: scale(1);
        opacity: 0.75;
    }
    70% {
        transform: scale(1.18);
        opacity: 0;
    }
    100% {
        transform: scale(1.18);
        opacity: 0;
    }
}

.nons-public-chat__fab-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    color: #fff;
}

.nons-public-chat__svg {
    display: block;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.12));
}

.nons-smart-agent--public .nons-public-chat__fab-label {
    display: none;
}

/* בועת הזמנה — משמאל לכפתור (לכיוון מרכז המסך) */
.nons-public-chat__teaser {
    position: relative;
    direction: rtl;
    text-align: right;
    max-width: min(272px, calc(100vw - 100px));
    padding: 11px 14px 11px 34px;
    background: #fff;
    color: #1e293b;
    border-radius: 14px 14px 4px 14px;
    box-shadow:
        0 12px 36px rgba(15, 23, 42, 0.14),
        0 2px 8px rgba(15, 23, 42, 0.06);
    border: 1px solid rgba(42, 193, 218, 0.32);
    animation: nons-public-teaser-in 0.45s cubic-bezier(0.22, 1, 0.36, 1);
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.nons-public-chat__teaser::after {
    content: '';
    position: absolute;
    bottom: 10px;
    right: -7px;
    width: 14px;
    height: 14px;
    background: #fff;
    border-right: 1px solid rgba(42, 193, 218, 0.32);
    border-bottom: 1px solid rgba(42, 193, 218, 0.32);
    transform: rotate(-45deg);
    border-radius: 0 0 3px 0;
}

.nons-public-chat__teaser:hover {
    transform: translateY(-2px);
    box-shadow:
        0 16px 40px rgba(15, 23, 42, 0.16),
        0 4px 12px rgba(42, 193, 218, 0.12);
}

.nons-public-chat__teaser[hidden] {
    display: none !important;
}

.nons-public-chat__teaser.is-hiding {
    animation: nons-public-teaser-out 0.28s ease forwards;
}

@keyframes nons-public-teaser-in {
    from {
        opacity: 0;
        transform: translateX(-10px) scale(0.94);
    }
    to {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

@keyframes nons-public-teaser-out {
    to {
        opacity: 0;
        transform: translateX(-8px) scale(0.96);
    }
}

.nons-public-chat__teaser-text {
    margin: 0;
    font-size: 13.5px;
    line-height: 1.45;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.nons-public-chat__teaser-close {
    position: absolute;
    top: 6px;
    left: 8px;
    width: 22px;
    height: 22px;
    padding: 0;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: #94a3b8;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.nons-public-chat__teaser-close:hover {
    background: #f1f5f9;
    color: #64748b;
}

/* פאנל צ׳אט — נפתח מימין */
.nons-smart-agent--public .nons-public-chat__panel {
    position: fixed;
    right: max(12px, env(safe-area-inset-right, 0px));
    bottom: max(88px, calc(22px + env(safe-area-inset-bottom, 0px) + 62px));
    left: auto;
    width: min(400px, calc(100vw - 24px));
    max-height: min(560px, calc(100dvh - 110px));
    display: none;
    flex-direction: column;
    border-radius: 18px;
    box-shadow:
        0 22px 56px rgba(15, 23, 42, 0.22),
        0 8px 24px rgba(42, 193, 218, 0.12);
    z-index: 2147483636;
    transform-origin: bottom right;
}

.nons-smart-agent--public.is-open .nons-public-chat__panel {
    display: flex !important;
    animation: nons-public-panel-in 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes nons-public-panel-in {
    from {
        opacity: 0;
        transform: translateY(16px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.nons-smart-agent--public.is-open .nons-public-chat__teaser,
.nons-smart-agent--public.is-open .nons-public-chat__fab-pulse {
    display: none;
}

.nons-public-chat__head {
    background: linear-gradient(135deg, #1e3a5f 0%, #2c5282 55%, #2ac1da 140%);
}

.nons-public-chat__avatar {
    border-radius: 14px;
}

.nons-public-chat__log {
    background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
    direction: rtl;
}

.nons-public-chat__composer textarea {
    border-radius: 12px !important;
    border: 1px solid #e2e8f0 !important;
    font-size: 14px;
    resize: none;
}

.nons-public-chat__send {
    border-radius: 12px !important;
    min-width: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nons-public-chat__send svg {
    display: block;
}

/* מובייל — מגירה מימין, מעל כפתור הנגישות (שמאל) */
@media (max-width: 767px) {
    .nons-smart-agent.nons-smart-agent--public {
        right: max(14px, env(safe-area-inset-right, 0px)) !important;
        bottom: max(18px, env(safe-area-inset-bottom, 0px));
    }

    .nons-smart-agent--public .nons-public-chat__fab {
        width: 56px;
        height: 56px;
        min-width: 56px;
    }

    .nons-public-chat__launcher {
        flex-direction: column;
        align-items: flex-end;
        gap: 10px;
    }

    .nons-public-chat__teaser {
        max-width: min(248px, calc(100vw - 28px));
        padding: 10px 12px 10px 32px;
        border-radius: 12px 12px 4px 12px;
    }

    .nons-public-chat__teaser-text {
        font-size: 12.5px;
        line-height: 1.4;
    }

    .nons-smart-agent--public.is-open .nons-public-chat__panel {
        top: 0;
        right: 0;
        bottom: 0;
        left: auto;
        width: min(92vw, 400px);
        max-height: 100dvh;
        border-radius: 16px 0 0 16px;
        bottom: 0;
        animation: nons-public-drawer-in 0.34s cubic-bezier(0.22, 1, 0.36, 1);
    }

    @keyframes nons-public-drawer-in {
        from {
            opacity: 0;
            transform: translateX(100%);
        }
        to {
            opacity: 1;
            transform: translateX(0);
        }
    }
}

/* כפתור נגישות — תמיד שמאל פיזי */
.acc-fab {
    left: max(24px, env(safe-area-inset-left, 0px)) !important;
    right: auto !important;
    inset-inline-start: auto !important;
    inset-inline-end: auto !important;
}

@media (max-width: 480px) {
    .acc-fab {
        left: max(12px, env(safe-area-inset-left, 0px)) !important;
        right: auto !important;
        bottom: max(18px, env(safe-area-inset-bottom, 0px)) !important;
    }
}

@media (prefers-reduced-motion: reduce) {
    .nons-public-chat__fab-pulse,
    .nons-public-chat__teaser,
    .nons-smart-agent--public.is-open .nons-public-chat__panel {
        animation: none !important;
    }
}
