/* Falcon AI Orbital Assistant — scoped presentation override only. */
body.falcon-client .floatingbtn,
body.falcon-client .floatingwindow {
    --falcon-ai-orange: #41d8ff;
    --falcon-ai-orange-dark: #397cff;
    --falcon-ai-graphite: #111111;
    --falcon-ai-space: #080808;
    --falcon-ai-ink: #171717;
    --falcon-ai-muted: #666666;
    --falcon-ai-line: #e5e5e5;
    --falcon-ai-surface: #ffffff;
    --falcon-ai-soft: #f7f7f7;
}

body.falcon-client .floatingbtn {
    position: fixed;
    inset: auto 20px 20px auto;
    z-index: 9999;
    margin: 0;
}

html[dir="rtl"] body.falcon-client .floatingbtn {
    inset: auto auto 20px 20px;
}

body.falcon-client .floatingbtn > a {
    position: relative;
    display: inline-flex;
    min-width: 142px;
    min-height: 50px;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 8px 18px;
    overflow: hidden;
    border: 1px solid rgba(65,216,255, .58);
    border-radius: 16px;
    background: linear-gradient(145deg, #1b1b1d 0%, var(--falcon-ai-space) 72%);
    box-shadow: 0 14px 34px rgba(0, 0, 0, .28), 0 0 0 1px rgba(255, 255, 255, .04) inset;
    color: #fff;
    font-family: Inter, Tajawal, system-ui, sans-serif;
    font-size: 0;
    font-weight: 800;
    letter-spacing: .01em;
    text-decoration: none;
    transition: transform 240ms ease, border-color 240ms ease, box-shadow 240ms ease;
}

body.falcon-client .floatingbtn > a::before {
    position: absolute;
    inset: -34px auto auto -26px;
    width: 82px;
    height: 82px;
    border: 1px solid rgba(65,216,255, .2);
    border-radius: 50%;
    content: "";
    pointer-events: none;
}

body.falcon-client .floatingbtn > a::after {
    content: "Falcon AI";
    font-size: 14px;
    line-height: 1;
}

html[dir="rtl"] body.falcon-client .floatingbtn > a::after {
    content: "مساعد Falcon";
    font-family: Tajawal, Inter, system-ui, sans-serif;
}

body.falcon-client .floatingbtn > a .icon {
    width: 27px;
    height: 27px;
    flex: 0 0 27px;
    border-radius: 50%;
    background: #41d8ff url('../img/falcon-ai-orbit.svg?v=20260916-visual-core') center / 21px 21px no-repeat;
    box-shadow: 0 0 0 4px rgba(65,216,255, .11), 0 0 18px rgba(65,216,255, .23);
    filter: none;
}

body.falcon-client .floatingbtn > a:hover {
    transform: translateY(-2px);
    border-color: var(--falcon-ai-orange);
    box-shadow: 0 18px 42px rgba(0, 0, 0, .34), 0 0 22px rgba(65,216,255, .13);
    color: #fff;
}

body.falcon-client .floatingbtn > a:focus-visible {
    outline: 3px solid rgba(65,216,255, .38);
    outline-offset: 3px;
}

body.falcon-client:has(.floatingwindow[style*="display: block"]) .floatingbtn > a,
body.falcon-client:has(.floatingwindow[style*="display: flex"]) .floatingbtn > a {
    opacity: .82;
}

body.falcon-client .floatingwindow {
    position: fixed;
    inset: auto 20px 84px auto;
    z-index: 10000;
    width: min(390px, calc(100vw - 40px));
    height: min(570px, calc(100vh - 112px));
    height: min(570px, calc(100dvh - 112px));
    max-height: 570px;
    overflow: hidden;
    border: 1px solid rgba(65,216,255, .22);
    border-radius: 22px;
    background: var(--falcon-ai-surface);
    box-shadow: 0 30px 80px rgba(0, 0, 0, .35), 0 0 0 1px rgba(255, 255, 255, .06) inset;
    font-family: Inter, Tajawal, system-ui, sans-serif;
    transform-origin: bottom right;
    animation: falcon-ai-enter 240ms cubic-bezier(.2, .75, .25, 1) both;
}

html[dir="rtl"] body.falcon-client .floatingwindow {
    inset: auto auto 84px 20px;
    transform-origin: bottom left;
    font-family: Tajawal, Inter, system-ui, sans-serif;
}

@keyframes falcon-ai-enter {
    from { opacity: 0; transform: translateY(10px) scale(.985); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

body.falcon-client .floatingwindow .floatingwindow-content {
    position: relative;
    display: flex;
    height: 100%;
    min-height: 0;
    flex-direction: column;
    overflow: hidden;
    border: 0;
    border-radius: inherit;
    background: var(--falcon-ai-surface);
}

body.falcon-client .floatingwindow .floatingwindow-header {
    position: relative;
    display: flex;
    min-height: 76px;
    flex: 0 0 auto;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 13px 14px 13px 16px;
    overflow: hidden;
    border: 0;
    border-bottom: 1px solid rgba(65,216,255, .24);
    border-radius: 0;
    background: linear-gradient(135deg, #1b1b1e 0%, var(--falcon-ai-space) 78%);
    box-shadow: none;
    color: #fff;
}

body.falcon-client .floatingwindow .floatingwindow-header::after {
    position: absolute;
    inset: 0 0 auto;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--falcon-ai-orange), transparent);
    content: "";
    opacity: .82;
}

body.falcon-client .floatingwindow .floatingwindow-header > div {
    position: relative;
    display: grid !important;
    min-width: 0;
    grid-template-columns: 38px minmax(0, 1fr);
    grid-template-rows: auto auto;
    align-items: center;
    column-gap: 11px !important;
}

body.falcon-client .floatingwindow .floatingwindow-header > div::before {
    width: 38px;
    height: 38px;
    grid-row: 1 / 3;
    border: 1px solid rgba(65,216,255, .65);
    border-radius: 13px;
    background: rgba(65,216,255, .1) url('../img/falcon-ai-orbit.svg?v=20260916-visual-core') center / 27px 27px no-repeat;
    box-shadow: 0 0 20px rgba(65,216,255, .16);
    content: "";
}

body.falcon-client .floatingwindow .floatingwindow-header > div > img {
    display: none;
}

body.falcon-client .floatingwindow .floatingwindow-header > div > span {
    align-self: end;
    overflow: hidden;
    color: #fff;
    font-size: 15px;
    font-weight: 800;
    line-height: 1.15;
    text-overflow: ellipsis;
    white-space: nowrap;
}

body.falcon-client .floatingwindow .floatingwindow-header > div > span::after {
    display: block;
    margin-top: 4px;
    color: #b8b8b8;
    content: "Falcon AI Assistant";
    font-size: 10px;
    font-weight: 600;
    letter-spacing: .035em;
    line-height: 1.1;
}

html[dir="rtl"] body.falcon-client .floatingwindow .floatingwindow-header > div > span::after {
    content: "مساعد Falcon الذكي";
    letter-spacing: 0;
}

body.falcon-client .floatingwindow .close-btn {
    position: relative;
    display: grid;
    width: 42px;
    height: 42px;
    min-width: 42px;
    place-items: center;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, .14);
    border-radius: 13px;
    background: rgba(255, 255, 255, .06);
    color: #fff;
    font-size: 25px;
    font-weight: 400;
    line-height: 1;
    cursor: pointer;
    transition: border-color 180ms ease, background 180ms ease, transform 180ms ease;
}

body.falcon-client .floatingwindow .close-btn:hover {
    transform: rotate(3deg);
    border-color: rgba(65,216,255, .7);
    background: rgba(65,216,255, .14);
    color: #fff;
}

body.falcon-client .floatingwindow .close-btn:focus-visible {
    outline: 3px solid rgba(65,216,255, .4);
    outline-offset: 2px;
}

body.falcon-client .floatingwindow .floatingwindow-body {
    min-height: 0;
    flex: 1 1 auto;
    padding: 18px 16px;
    overflow-x: hidden;
    overflow-y: auto;
    scrollbar-color: rgba(65,216,255, .65) #ededed;
    scrollbar-width: thin;
    background:
        radial-gradient(circle at 100% 0, rgba(65,216,255, .055), transparent 36%),
        var(--falcon-ai-soft);
    overscroll-behavior: contain;
}

body.falcon-client .floatingwindow .floatingwindow-body::-webkit-scrollbar { width: 7px; }
body.falcon-client .floatingwindow .floatingwindow-body::-webkit-scrollbar-track { background: #ededed; }
body.falcon-client .floatingwindow .floatingwindow-body::-webkit-scrollbar-thumb {
    border: 2px solid #ededed;
    border-radius: 8px;
    background: #9c9c9c;
}
body.falcon-client .floatingwindow .floatingwindow-body::-webkit-scrollbar-thumb:hover { background: var(--falcon-ai-orange); }

body.falcon-client .floatingwindow .chat-message {
    display: flex;
    width: 100%;
    min-width: 0;
    align-items: flex-start;
    gap: 9px;
    margin: 0 0 14px;
    animation: falcon-ai-message 180ms ease-out both;
}

@keyframes falcon-ai-message {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

body.falcon-client .floatingwindow .chat-message.user {
    flex-direction: row-reverse;
    text-align: start;
}

body.falcon-client .floatingwindow .chat-message .avatar {
    position: relative;
    display: grid;
    width: 30px;
    height: 30px;
    flex: 0 0 30px;
    place-items: center;
    border: 1px solid rgba(65,216,255, .35);
    border-radius: 10px;
    background: var(--falcon-ai-graphite) none !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, .12);
}

body.falcon-client .floatingwindow .chat-message .avatar::before {
    width: 20px;
    height: 20px;
    background: url('../img/falcon-ai-orbit.svg?v=20260916-visual-core') center / contain no-repeat;
    content: "";
}

body.falcon-client .floatingwindow .chat-message.user .avatar {
    border-color: rgba(65,216,255, .25);
    background: #eef8ff none !important;
}

body.falcon-client .floatingwindow .chat-message.user .avatar::before {
    background-image: url('../img/falcon-ai-user.svg?v=20260916-visual-core');
}

body.falcon-client .floatingwindow .chat-message .text {
    width: auto;
    max-width: calc(100% - 42px);
    padding: 10px 13px;
    border: 1px solid #dedede;
    border-radius: 5px 15px 15px 15px;
    background: #fff;
    box-shadow: 0 5px 14px rgba(0, 0, 0, .045);
    color: var(--falcon-ai-ink);
    font-size: 13.5px;
    line-height: 1.7;
    overflow-wrap: anywhere;
    text-align: start;
    unicode-bidi: plaintext;
    word-break: normal;
}

html[dir="rtl"] body.falcon-client .floatingwindow .chat-message .text {
    border-radius: 15px 5px 15px 15px;
}

body.falcon-client .floatingwindow .chat-message.user .text {
    border-color: rgba(65,216,255, .24);
    border-radius: 15px 5px 15px 15px;
    background: #eef8ff;
    color: #26170b;
}

html[dir="rtl"] body.falcon-client .floatingwindow .chat-message.user .text {
    border-radius: 5px 15px 15px 15px;
}

body.falcon-client .floatingwindow .chat-message .text a {
    color: #397cff;
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 2px;
}

body.falcon-client .floatingwindow .floatingwindow-footer {
    flex: 0 0 auto;
    padding: 12px;
    border: 0;
    border-top: 1px solid var(--falcon-ai-line);
    background: #fff;
}

body.falcon-client .floatingwindow .input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    padding: 4px;
    border: 1px solid #d7d7d7;
    border-radius: 16px;
    background: var(--falcon-ai-soft);
    box-shadow: 0 0 0 0 rgba(65,216,255, 0);
    transition: border-color 180ms ease, box-shadow 180ms ease, background 180ms ease;
}

body.falcon-client .floatingwindow .input-wrapper:focus-within {
    border-color: var(--falcon-ai-orange);
    background: #fff;
    box-shadow: 0 0 0 4px rgba(65,216,255, .11);
}

body.falcon-client .floatingwindow .chatmsg {
    width: 100%;
    height: 52px;
    min-height: 52px;
    max-height: 112px;
    margin: 0;
    padding: 14px 56px 12px 12px;
    resize: none;
    border: 0;
    border-radius: 12px;
    outline: 0;
    background: transparent;
    box-shadow: none;
    color: var(--falcon-ai-ink);
    font: 500 14px/1.55 Inter, Tajawal, system-ui, sans-serif;
    text-align: start;
    unicode-bidi: plaintext;
}

html[dir="rtl"] body.falcon-client .floatingwindow .chatmsg {
    padding: 14px 12px 12px 56px;
    font-family: Tajawal, Inter, system-ui, sans-serif;
}

body.falcon-client .floatingwindow .chatmsg::placeholder { color: #767676; opacity: 1; }

body.falcon-client .floatingwindow .send-button {
    position: absolute;
    inset: 50% 7px auto auto;
    display: grid;
    width: 40px;
    height: 40px;
    place-items: center;
    padding: 0;
    border: 0;
    border-radius: 12px;
    background: linear-gradient(145deg, var(--falcon-ai-orange), var(--falcon-ai-orange-dark));
    box-shadow: 0 8px 18px rgba(232, 95, 0, .24);
    color: #fff;
    cursor: pointer;
    transform: translateY(-50%);
    transition: transform 180ms ease, box-shadow 180ms ease, filter 180ms ease;
}

html[dir="rtl"] body.falcon-client .floatingwindow .send-button {
    inset: 50% auto auto 7px;
}

body.falcon-client .floatingwindow .send-button::before {
    width: 18px;
    height: 18px;
    background: url('../img/falcon-ai-send.svg') center / contain no-repeat;
    content: "";
}

body.falcon-client .floatingwindow .send-button img { display: none; }

body.falcon-client .floatingwindow .send-button:hover {
    transform: translateY(-50%) translateY(-1px);
    box-shadow: 0 10px 22px rgba(232, 95, 0, .34);
    filter: saturate(1.08);
}

body.falcon-client .floatingwindow .send-button:focus-visible {
    outline: 3px solid rgba(65,216,255, .38);
    outline-offset: 2px;
}

body.falcon-client .floatingwindow .typing-dots {
    min-width: 58px;
    color: transparent;
}

body.falcon-client .floatingwindow .typing-dots::after {
    display: inline-block;
    color: var(--falcon-ai-orange);
    content: "•••";
    font-size: 16px;
    letter-spacing: 4px;
    animation: falcon-ai-dots 900ms ease-in-out infinite;
}

@keyframes falcon-ai-dots {
    0%, 100% { opacity: .35; transform: translateY(0); }
    50% { opacity: 1; transform: translateY(-1px); }
}

@media (max-width: 767px) {
    body.falcon-client .floatingbtn,
    html[dir="rtl"] body.falcon-client .floatingbtn {
        inset: auto 12px 14px auto;
    }

    html[dir="rtl"] body.falcon-client .floatingbtn { inset: auto auto 14px 12px; }

    body.falcon-client .floatingbtn > a {
        min-width: 128px;
        min-height: 48px;
        padding-inline: 14px;
        border-radius: 15px;
    }

    body.falcon-client .floatingwindow,
    html[dir="rtl"] body.falcon-client .floatingwindow {
        inset: auto 12px 74px 12px;
        width: auto;
        height: min(620px, calc(100vh - 92px));
        height: min(620px, calc(100dvh - 92px));
        max-height: none;
        border-radius: 20px;
        transform-origin: bottom center;
    }

    body.falcon-client .floatingwindow .floatingwindow-header { min-height: 70px; padding: 11px 12px; }
    body.falcon-client .floatingwindow .floatingwindow-body { padding: 14px 12px; }
    body.falcon-client .floatingwindow .floatingwindow-footer { padding: 10px; }
    body.falcon-client .floatingwindow .chat-message .text { max-width: calc(100% - 38px); font-size: 13.5px; }
}

@media (max-width: 374px) {
    body.falcon-client .floatingwindow,
    html[dir="rtl"] body.falcon-client .floatingwindow { inset-inline: 8px; }
    body.falcon-client .floatingwindow .floatingwindow-header > div > span::after { font-size: 9px; }
}

@media (prefers-reduced-motion: reduce) {
    body.falcon-client .floatingwindow,
    body.falcon-client .floatingwindow .chat-message,
    body.falcon-client .floatingwindow .typing-dots::after { animation: none; }
    body.falcon-client .floatingbtn > a,
    body.falcon-client .floatingwindow .close-btn,
    body.falcon-client .floatingwindow .send-button { transition: none; }
}
