/* ==========================================================================
   LexPro website assistant — chat widget (inc/chatbot.php, assets/js/chatbot.js)
   ========================================================================== */

.lxc {
    --lxc-navy: #0c2d4a;
    --lxc-navy-2: #145282;
    --lxc-gold: #d4930a;
    --lxc-bg: #ffffff;
    --lxc-body: #f4f7fb;
    --lxc-text: #13233a;
    --lxc-muted: #5b6b80;
    --lxc-line: #e2e8f0;
    --lxc-bot: #ffffff;
    --lxc-user: #145282;
    --lxc-chip: #e6f2fa;
    --lxc-chip-text: #0f3d66;
    --lxc-shadow: 0 24px 60px -12px rgb(7 26 46 / 0.35), 0 8px 20px -8px rgb(7 26 46 / 0.2);
    --lxc-gap: 24px;
    position: fixed;
    inset-inline-end: var(--lxc-gap);
    bottom: var(--lxc-gap);
    z-index: 2147483000;
    font-family: var(--font-primary, Inter, 'IBM Plex Sans Arabic', system-ui, sans-serif);
    font-size: 15px;
    line-height: 1.6;
    color: var(--lxc-text);
}
.lxc[lang="ar"] {
    font-family: var(--font-arabic, 'IBM Plex Sans Arabic', Inter, system-ui, sans-serif);
}
html.dark .lxc {
    --lxc-bg: #0f1a2a;
    --lxc-body: #0b1422;
    --lxc-text: #e6edf6;
    --lxc-muted: #93a4ba;
    --lxc-line: #1f2e44;
    --lxc-bot: #16243a;
    --lxc-user: #2980c4;
    --lxc-chip: #13304d;
    --lxc-chip-text: #b3d9f2;
    --lxc-shadow: 0 24px 60px -12px rgb(0 0 0 / 0.7), 0 0 0 1px rgb(255 255 255 / 0.06);
}
.lxc *,
.lxc *::before,
.lxc *::after {
    box-sizing: border-box;
}
.lxc [hidden] {
    display: none !important;
}

/* Back-to-top shares this corner: lift it above the launcher. The teaser
   sits beside the launcher (not above it) so it never covers the button. */
body.lxc-on .back-to-top {
    bottom: calc(var(--space-8, 32px) + 72px);
}
/* While the panel is open it fills the space above the launcher, so the
   button moves beside the launcher instead. */
body:has(.lxc-open) .back-to-top {
    bottom: calc(var(--lxc-gap, 24px) + 6px);
    right: calc(var(--lxc-gap, 24px) + 72px);
}
[dir="rtl"] body:has(.lxc-open) .back-to-top {
    right: auto;
    left: calc(var(--lxc-gap, 24px) + 72px);
}

/* ---------- launcher ---------- */

.lxc-launch {
    position: relative;
    width: 60px;
    height: 60px;
    border: 0;
    border-radius: 50%;
    padding: 0;
    cursor: pointer;
    color: #fff;
    background: linear-gradient(145deg, var(--lxc-navy-2), var(--lxc-navy));
    box-shadow: 0 10px 28px -6px rgb(12 45 74 / 0.55), inset 0 0 0 1px rgb(255 255 255 / 0.08);
    display: grid;
    place-items: center;
    transition: transform 200ms cubic-bezier(0.4, 0, 0.2, 1), box-shadow 200ms;
    margin-inline-start: auto;
}
.lxc-launch::after {
    content: "";
    position: absolute;
    top: 3px;
    inset-inline-end: 3px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--lxc-gold);
    border: 2px solid #fff;
    transition: opacity 200ms;
}
.lxc-open .lxc-launch::after {
    opacity: 0;
}
.lxc-launch:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 32px -6px rgb(12 45 74 / 0.6), inset 0 0 0 1px rgb(255 255 255 / 0.1);
}
.lxc-launch:focus-visible,
.lxc button:focus-visible,
.lxc a:focus-visible,
.lxc-input:focus-visible {
    outline: 3px solid var(--lxc-gold);
    outline-offset: 2px;
}
.lxc-launch-ico {
    grid-area: 1 / 1;
    display: grid;
    place-items: center;
    transition: transform 220ms cubic-bezier(0.4, 0, 0.2, 1), opacity 180ms;
}
.lxc-launch-ico svg {
    width: 28px;
    height: 28px;
}
.lxc-ico-chat svg {
    color: #fff;
}
.lxc-ico-x {
    opacity: 0;
    transform: rotate(-90deg) scale(0.6);
}
.lxc-ico-x svg {
    width: 24px;
    height: 24px;
}
.lxc-open .lxc-ico-chat {
    opacity: 0;
    transform: rotate(90deg) scale(0.6);
}
.lxc-open .lxc-ico-x {
    opacity: 1;
    transform: none;
}

/* ---------- teaser bubble ---------- */

.lxc-teaser {
    position: absolute;
    bottom: 0;
    inset-inline-end: 72px;
    width: max-content;
    max-width: min(280px, calc(100vw - 120px));
    display: flex;
    align-items: flex-start;
    gap: 4px;
    padding: 12px 8px 12px 16px;
    padding-inline: 16px 8px;
    background: var(--lxc-bg);
    color: var(--lxc-text);
    border: 1px solid var(--lxc-line);
    border-radius: 16px;
    border-end-end-radius: 4px;
    box-shadow: var(--lxc-shadow);
    animation: lxc-pop 320ms cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.lxc-teaser-text {
    all: unset;
    cursor: pointer;
    font-size: 14px;
    line-height: 1.5;
    font-weight: 500;
}
.lxc-teaser-x {
    all: unset;
    cursor: pointer;
    color: var(--lxc-muted);
    width: 22px;
    height: 22px;
    display: grid;
    place-items: center;
    border-radius: 6px;
    flex: none;
}
.lxc-teaser-x svg {
    width: 14px;
    height: 14px;
}

/* ---------- panel ---------- */

.lxc-panel {
    position: absolute;
    bottom: 76px;
    inset-inline-end: 0;
    width: 384px;
    height: min(620px, calc(100vh - 120px));
    height: min(620px, calc(100dvh - 120px));
    display: flex;
    flex-direction: column;
    background: var(--lxc-body);
    border-radius: 20px;
    overflow: hidden;
    box-shadow: var(--lxc-shadow);
    border: 1px solid var(--lxc-line);
    transform-origin: bottom right;
    animation: lxc-pop 260ms cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.lxc[dir="rtl"] .lxc-panel {
    transform-origin: bottom left;
}
@keyframes lxc-pop {
    from { opacity: 0; transform: translateY(12px) scale(0.96); }
    to { opacity: 1; transform: none; }
}

.lxc-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 14px 14px 16px;
    padding-inline: 16px 10px;
    color: #fff;
    background:
        radial-gradient(120% 140% at 100% 0%, rgb(212 147 10 / 0.18), transparent 55%),
        linear-gradient(135deg, var(--lxc-navy-2), var(--lxc-navy));
    flex: none;
}
.lxc-avatar {
    position: relative;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    font-weight: 800;
    font-size: 19px;
    font-family: Inter, system-ui, sans-serif;
    color: var(--lxc-navy);
    background: linear-gradient(145deg, #fff, #e6f2fa);
    flex: none;
}
.lxc-avatar i {
    position: absolute;
    bottom: -3px;
    inset-inline-end: -3px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #10b981;
    border: 2px solid var(--lxc-navy);
}
.lxc-who {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
    line-height: 1.3;
}
.lxc-who strong {
    font-size: 15.5px;
    font-weight: 700;
}
.lxc-who small {
    font-size: 12.5px;
    opacity: 0.8;
}
.lxc-hbtn {
    all: unset;
    cursor: pointer;
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border-radius: 10px;
    color: rgb(255 255 255 / 0.85);
    transition: background 150ms, color 150ms;
    flex: none;
}
.lxc-hbtn:hover {
    background: rgb(255 255 255 / 0.12);
    color: #fff;
}
.lxc-hbtn svg {
    width: 19px;
    height: 19px;
}

/* ---------- messages ---------- */

.lxc-body {
    flex: 1;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 18px 14px 8px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
}
.lxc-msg {
    display: flex;
    animation: lxc-in 220ms ease-out;
}
@keyframes lxc-in {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: none; }
}
.lxc-user {
    justify-content: flex-end;
}
.lxc-bubble {
    max-width: 86%;
    padding: 10px 14px;
    border-radius: 16px;
    word-wrap: break-word;
    overflow-wrap: anywhere;
}
.lxc-bot .lxc-bubble {
    background: var(--lxc-bot);
    color: var(--lxc-text);
    border: 1px solid var(--lxc-line);
    border-end-start-radius: 4px;
    box-shadow: 0 1px 2px rgb(7 26 46 / 0.04);
}
.lxc-user .lxc-bubble {
    background: var(--lxc-user);
    color: #fff;
    border-end-end-radius: 4px;
}
.lxc-err .lxc-bubble {
    border-color: rgb(239 68 68 / 0.35);
}
.lxc-bubble p {
    margin: 0;
}
.lxc-bubble p + p,
.lxc-bubble p + ul,
.lxc-bubble p + ol,
.lxc-bubble ul + p,
.lxc-bubble ol + p {
    margin-top: 8px;
}
.lxc-bubble ul,
.lxc-bubble ol {
    margin: 0;
    padding-inline-start: 20px;
}
.lxc-bubble li + li {
    margin-top: 3px;
}
.lxc-bubble strong {
    font-weight: 700;
}
.lxc-bubble a {
    color: var(--lxc-navy-2);
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 2px;
    text-decoration-thickness: 1px;
}
html.dark .lxc .lxc-bubble a {
    color: #7fbde6;
}
.lxc-user .lxc-bubble a {
    color: #fff;
}

.lxc-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}
.lxc-bubble a.lxc-action {
    display: inline-flex;
    align-items: center;
    padding: 7px 14px;
    border-radius: 999px;
    background: linear-gradient(135deg, var(--lxc-navy-2), var(--lxc-navy));
    color: #fff;
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 600;
    transition: transform 150ms, box-shadow 150ms;
}
.lxc-bubble a.lxc-action:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 14px -6px rgb(12 45 74 / 0.6);
}
.lxc-bubble a.lxc-action:first-child {
    background: var(--lxc-gold);
    color: #1d1300;
}
html.dark .lxc .lxc-bubble a.lxc-action {
    color: #fff;
}
html.dark .lxc .lxc-bubble a.lxc-action:first-child {
    color: #1d1300;
}

.lxc-retry {
    all: unset;
    cursor: pointer;
    display: inline-block;
    margin-top: 8px;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--lxc-navy-2);
    text-decoration: underline;
}

.lxc-dots {
    display: inline-flex;
    gap: 4px;
    padding: 4px 2px;
}
.lxc-dots i {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--lxc-muted);
    animation: lxc-dot 1.2s infinite ease-in-out;
}
.lxc-dots i:nth-child(2) { animation-delay: 0.15s; }
.lxc-dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes lxc-dot {
    0%, 60%, 100% { opacity: 0.35; transform: none; }
    30% { opacity: 1; transform: translateY(-4px); }
}

/* ---------- quick replies ---------- */

.lxc-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 4px 14px 10px;
    flex: none;
}
.lxc-chip {
    all: unset;
    cursor: pointer;
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 13.5px;
    line-height: 1.4;
    font-weight: 500;
    background: var(--lxc-chip);
    color: var(--lxc-chip-text);
    border: 1px solid transparent;
    transition: border-color 150ms, transform 150ms;
}
.lxc-chip:hover {
    border-color: var(--lxc-navy-2);
    transform: translateY(-1px);
}

/* ---------- composer ---------- */

.lxc-form {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    margin: 0 12px;
    padding: 6px;
    padding-inline-start: 14px;
    background: var(--lxc-bg);
    border: 1px solid var(--lxc-line);
    border-radius: 16px;
    flex: none;
    transition: border-color 150ms, box-shadow 150ms;
}
.lxc-form:focus-within {
    border-color: var(--lxc-navy-2);
    box-shadow: 0 0 0 3px rgb(26 107 171 / 0.15);
}
.lxc .lxc-input {
    flex: 1;
    min-width: 0;
    border: 0;
    outline: 0;
    resize: none;
    background: transparent;
    color: var(--lxc-text);
    font: inherit;
    font-size: 15px;
    line-height: 1.5;
    padding: 7px 0;
    max-height: 120px;
    box-shadow: none;
}
.lxc .lxc-input:focus-visible {
    outline: 0;
}
.lxc .lxc-input::placeholder {
    color: var(--lxc-muted);
    opacity: 1;
}
.lxc-send {
    all: unset;
    cursor: pointer;
    width: 38px;
    height: 38px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    color: #fff;
    background: var(--lxc-navy-2);
    transition: background 150ms, opacity 150ms;
    flex: none;
}
.lxc-send:hover {
    background: var(--lxc-navy);
}
.lxc-send:disabled {
    opacity: 0.4;
    cursor: default;
}
.lxc-send svg {
    width: 19px;
    height: 19px;
}
.lxc[dir="rtl"] .lxc-send svg {
    transform: scaleX(-1);
}
.lxc-foot {
    margin: 0;
    padding: 7px 14px 10px;
    text-align: center;
    font-size: 11.5px;
    color: var(--lxc-muted);
    flex: none;
}

/* ---------- phones: full screen ---------- */

@media (max-width: 560px) {
    .lxc {
        --lxc-gap: 16px;
    }
    .lxc-launch {
        width: 56px;
        height: 56px;
    }
    .lxc-panel {
        position: fixed;
        inset: 0;
        width: auto;
        height: 100%;
        border-radius: 0;
        border: 0;
    }
    .lxc-open .lxc-launch {
        display: none;
    }
    .lxc-head {
        padding-top: max(14px, env(safe-area-inset-top));
    }
    .lxc-foot {
        padding-bottom: max(10px, env(safe-area-inset-bottom));
    }
    .lxc .lxc-input {
        font-size: 16px; /* stops iOS zooming into the field */
    }
    html.lxc-lock,
    html.lxc-lock body {
        overflow: hidden;
    }
}

@media (prefers-reduced-motion: reduce) {
    .lxc *,
    .lxc *::before,
    .lxc *::after {
        animation: none !important;
        transition: none !important;
    }
}

@media print {
    .lxc {
        display: none;
    }
}
