.faheem-site-widget {
    --faheem-navy: #003ea2;
    --faheem-navy-deep: #052b66;
    --faheem-gold: #be962d;
    --faheem-ink: #172033;
    --faheem-muted: #526078;
    --faheem-canvas: #f7f9fc;
    --faheem-border: #dce3ee;
    --faheem-success: #188654;
    position: fixed;
    inset-inline-end: max(20px, env(safe-area-inset-right));
    bottom: max(20px, env(safe-area-inset-bottom));
    z-index: 130;
    color: var(--faheem-ink);
    font-family: "Outfit", "IBM Plex Sans Arabic", system-ui, sans-serif;
}

.faheem-site-widget[dir="rtl"],
[dir="rtl"] .faheem-site-widget {
    font-family: "IBM Plex Sans Arabic", "Outfit", system-ui, sans-serif;
}

.faheem-site-widget [hidden] {
    display: none !important;
}

.faheem-site-launcher {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 72px;
    padding: 5px 5px 5px 17px;
    border: 0;
    border-radius: 999px;
    background: var(--faheem-navy-deep);
    color: #fff;
    box-shadow: 0 6px 8px rgba(5, 43, 102, 0.22);
    cursor: pointer;
    transition: transform 180ms cubic-bezier(.22, 1, .36, 1), background-color 180ms ease;
}

[dir="rtl"] .faheem-site-launcher {
    padding: 5px 17px 5px 5px;
}

.faheem-site-launcher:hover {
    background: var(--faheem-navy);
    transform: translateY(-2px);
}

.faheem-site-launcher:focus-visible,
.faheem-site-icon-button:focus-visible,
.faheem-site-options button:focus-visible,
.faheem-site-composer textarea:focus-visible,
.faheem-site-composer button:focus-visible,
.faheem-site-message a:focus-visible {
    outline: 3px solid rgba(190, 150, 45, 0.52);
    outline-offset: 3px;
}

.faheem-site-launcher-copy {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    min-width: 92px;
    line-height: 1.2;
}

[dir="rtl"] .faheem-site-launcher-copy {
    align-items: flex-end;
}

.faheem-site-launcher-copy strong {
    font-size: 0.92rem;
    font-weight: 700;
}

.faheem-site-launcher-copy small {
    margin-top: 4px;
    color: rgba(255, 255, 255, 0.78);
    font-size: 0.7rem;
}

.faheem-site-launcher-avatar {
    position: relative;
    display: grid;
    width: 62px;
    height: 62px;
    flex: 0 0 62px;
    place-items: center;
    overflow: hidden;
    border: 2px solid rgba(255, 255, 255, 0.88);
    border-radius: 50%;
    background: #fff;
}

.faheem-site-launcher-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.faheem-site-launcher-status {
    position: absolute;
    inset-inline-end: 3px;
    bottom: 4px;
    width: 12px;
    height: 12px;
    border: 2px solid #fff;
    border-radius: 50%;
    background: #35c77a;
}

.faheem-site-panel {
    position: absolute;
    inset-inline-end: 0;
    bottom: 86px;
    display: flex;
    width: min(390px, calc(100vw - 32px));
    height: 650px;
    max-height: calc(100vh - 126px);
    max-height: calc(100dvh - 126px);
    min-height: 430px;
    flex-direction: column;
    overflow: hidden;
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 10px 24px rgba(5, 43, 102, 0.22);
    transform-origin: bottom right;
    animation: faheem-panel-in 200ms cubic-bezier(.22, 1, .36, 1);
    z-index: 2;
}

[dir="rtl"] .faheem-site-panel {
    transform-origin: bottom left;
}

@keyframes faheem-panel-in {
    from { opacity: 0; transform: translateY(12px) scale(.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.faheem-site-header {
    display: flex;
    min-height: 76px;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 11px 12px 11px 14px;
    background: var(--faheem-navy-deep);
    color: #fff;
}

.faheem-site-identity {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: 11px;
}

.faheem-site-identity > span:last-child {
    display: flex;
    min-width: 0;
    flex-direction: column;
}

.faheem-site-identity strong {
    font-size: 1rem;
    font-weight: 700;
}

.faheem-site-identity small {
    margin-top: 2px;
    overflow: hidden;
    color: rgba(255, 255, 255, 0.78);
    font-size: 0.76rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.faheem-site-avatar {
    position: relative;
    width: 50px;
    height: 50px;
    flex: 0 0 50px;
    overflow: hidden;
    border: 2px solid rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    background: #fff;
}

.faheem-site-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.faheem-site-online-dot {
    position: absolute;
    inset-inline-end: 1px;
    bottom: 2px;
    width: 11px;
    height: 11px;
    border: 2px solid #fff;
    border-radius: 50%;
    background: #35c77a;
}

.faheem-site-header-actions {
    display: flex;
    flex: 0 0 auto;
    gap: 3px;
}

.faheem-site-icon-button {
    display: grid;
    width: 40px;
    height: 40px;
    place-items: center;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: #fff;
    cursor: pointer;
    transition: background-color 150ms ease;
}

.faheem-site-icon-button:hover {
    background: rgba(255, 255, 255, 0.12);
}

.faheem-site-icon-button svg,
.faheem-site-composer button svg {
    width: 21px;
    height: 21px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.8;
}

.faheem-site-messages {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    gap: 10px;
    min-height: 0;
    padding: 16px;
    overflow-y: auto;
    overscroll-behavior: contain;
    background: var(--faheem-canvas);
    scrollbar-width: thin;
    scrollbar-color: #bec8d8 transparent;
}

.faheem-site-message-row {
    display: flex;
    width: 100%;
}

.faheem-site-message-row.is-user {
    justify-content: flex-end;
}

.faheem-site-message {
    max-width: 84%;
    padding: 10px 12px 8px;
    border-radius: 12px;
    background: #fff;
    color: var(--faheem-ink);
    font-size: 0.9rem;
    line-height: 1.55;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.faheem-site-message-row.is-bot .faheem-site-message {
    border: 1px solid var(--faheem-border);
    border-start-start-radius: 4px;
}

.faheem-site-message-row.is-user .faheem-site-message {
    border-end-end-radius: 4px;
    background: var(--faheem-navy);
    color: #fff;
}

.faheem-site-message time {
    display: block;
    margin-top: 5px;
    color: var(--faheem-muted);
    font-size: 0.64rem;
    line-height: 1;
    text-align: end;
}

.faheem-site-message-row.is-user time {
    color: rgba(255, 255, 255, 0.72);
}

.faheem-site-message a {
    display: inline-flex;
    min-height: 40px;
    align-items: center;
    justify-content: center;
    margin-top: 10px;
    padding: 8px 12px;
    border-radius: 9px;
    background: var(--faheem-gold);
    color: #172033;
    font-size: 0.8rem;
    font-weight: 700;
    text-decoration: none;
}

.faheem-site-options {
    display: flex;
    flex: 0 0 auto;
    max-height: 180px;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 14px;
    overflow-y: auto;
    border-top: 1px solid var(--faheem-border);
    background: #f8faff;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.02);
    z-index: 2;
}

.faheem-site-options[hidden] {
    display: none !important;
}

.faheem-site-options button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 38px;
    padding: 7px 14px;
    border: 1.5px solid #003ea2;
    border-radius: 9999px;
    background: #ffffff;
    color: #001a5e;
    font: inherit;
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0, 30, 94, 0.08);
    transition: all 160ms cubic-bezier(0.16, 1, 0.3, 1);
    white-space: normal;
    text-align: center;
}

.faheem-site-options button:hover {
    border-color: #001a5e;
    background: #003ea2;
    color: #ffffff;
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(0, 62, 162, 0.22);
}

.faheem-site-options button.is-navigation {
    border-color: #be962d;
    background: #fffdf5;
    color: #855d08;
}

.faheem-site-options button.is-navigation:hover {
    border-color: #a37e1f;
    background: #be962d;
    color: #172033;
}

.faheem-site-options button.is-resend {
    border-color: #003ea2;
    background: #003ea2;
    color: #ffffff;
    font-weight: 800;
}

.faheem-site-options button.is-resend:hover {
    border-color: #002868;
    background: #002868;
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(0, 62, 162, 0.35);
}

.faheem-site-typing {
    display: flex;
    min-height: 32px;
    align-items: center;
    gap: 4px;
    padding: 6px 16px;
    border-top: 1px solid var(--faheem-border);
    background: #fff;
    color: var(--faheem-muted);
}

.faheem-site-typing span {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--faheem-navy);
    animation: faheem-typing 900ms ease-in-out infinite alternate;
}

.faheem-site-typing span:nth-child(2) { animation-delay: 150ms; }
.faheem-site-typing span:nth-child(3) { animation-delay: 300ms; }

.faheem-site-typing em {
    margin-inline-start: 5px;
    font-size: 0.7rem;
    font-style: normal;
}

@keyframes faheem-typing {
    to { opacity: .3; transform: translateY(-2px); }
}

.faheem-site-composer {
    display: flex;
    flex: 0 0 auto;
    align-items: flex-end;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid var(--faheem-border);
    background: #fff;
}

.faheem-site-composer textarea {
    width: 100%;
    min-height: 44px;
    max-height: 110px;
    resize: none;
    border: 1px solid #bdc9da;
    border-radius: 11px;
    background: #fff;
    color: var(--faheem-ink);
    font: inherit;
    font-size: 0.9rem;
    line-height: 1.4;
    padding: 11px 12px;
}

.faheem-site-composer textarea::placeholder {
    color: #667085;
}

.faheem-site-composer button {
    display: grid;
    width: 44px;
    height: 44px;
    flex: 0 0 44px;
    place-items: center;
    border: 0;
    border-radius: 11px;
    background: var(--faheem-navy);
    color: #fff;
    cursor: pointer;
    transition: background-color 150ms ease, transform 150ms ease;
}

.faheem-site-composer button:hover {
    background: var(--faheem-navy-deep);
    transform: translateY(-1px);
}

.faheem-site-composer button:disabled,
.faheem-site-composer textarea:disabled {
    cursor: not-allowed;
    opacity: .58;
}

.faheem-site-privacy {
    margin: 0;
    padding: 0 12px 8px;
    background: #fff;
    color: var(--faheem-muted);
    font-size: 0.65rem;
    text-align: center;
}

.faheem-site-backdrop {
    position: fixed;
    inset: 0;
    z-index: 0;
    background: rgba(5, 22, 49, 0.42);
}

@media (min-width: 641px) {
    .faheem-site-backdrop {
        display: none !important;
    }
}

@media (max-width: 640px) {
    body.faheem-chat-open {
        overflow: hidden;
    }

    .faheem-site-widget {
        inset-inline: 0;
        bottom: 0;
        pointer-events: none;
    }

    .faheem-site-launcher {
        position: fixed;
        inset-inline-end: max(14px, env(safe-area-inset-right));
        bottom: max(14px, env(safe-area-inset-bottom));
        min-height: 64px;
        padding: 3px;
        pointer-events: auto;
    }

    .faheem-site-launcher-copy {
        display: none;
    }

    .faheem-site-launcher-avatar {
        width: 58px;
        height: 58px;
        flex-basis: 58px;
    }

    .faheem-site-panel {
        position: fixed;
        inset: auto 0 0;
        width: 100%;
        height: min(84dvh, 720px);
        max-height: 84vh;
        max-height: 84dvh;
        min-height: 430px;
        border-radius: 16px 16px 0 0;
        padding-bottom: env(safe-area-inset-bottom);
        pointer-events: auto;
        transform-origin: bottom center;
    }

    .faheem-site-backdrop {
        pointer-events: auto;
    }

    .faheem-site-message {
        max-width: 88%;
        font-size: 0.92rem;
    }
}

@media (max-height: 560px) and (orientation: landscape) {
    .faheem-site-panel {
        height: 100dvh;
        border-radius: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    .faheem-site-panel,
    .faheem-site-launcher,
    .faheem-site-typing span {
        animation: none !important;
        transition-duration: 0.01ms !important;
    }
}

@media print {
    .faheem-site-widget {
        display: none !important;
    }
}
