/* =========================================================
   AL-EHSAN ASSISTANT
   Local Al-Ehsan Media content assistant
========================================================= */

.am-assistant {
    --am-assistant-blue: #0082DE;
    --am-assistant-red: #E8553E;
    --am-assistant-soft: #ECF7FF;
    --am-assistant-dark: #10283B;
    --am-assistant-muted: #657887;
    --am-assistant-border: #DCECF6;

    position: relative;
    z-index: 2147481000;
}


/* =========================================================
   LAUNCHER
========================================================= */

.am-assistant__launcher {
    position: fixed;

    right: 22px;
    bottom: 88px;

    z-index: 2147481002;

    min-height: 58px;

    display: inline-flex;
    align-items: center;
    gap: 10px;

    padding: 7px 18px 7px 7px;

    border: 0;
    border-radius: 999px;

    background: #ffffff;

    color: var(--am-assistant-dark);

    font: inherit;
    font-weight: 700;

    cursor: pointer;

    box-shadow:
        0 12px 36px rgba(14, 55, 82, .18),
        0 2px 8px rgba(14, 55, 82, .08);

    transition:
        transform .2s ease,
        box-shadow .2s ease,
        opacity .2s ease;
}

.am-assistant__launcher:hover {
    transform: translateY(-2px);

    box-shadow:
        0 16px 42px rgba(14, 55, 82, .22),
        0 3px 10px rgba(14, 55, 82, .10);
}

.am-assistant__launcher:focus-visible {
    outline:
        3px solid rgba(0, 130, 222, .22);

    outline-offset: 3px;
}


.am-assistant__launcher-logo {
    width: 44px;
    height: 44px;

    flex: 0 0 44px;

    display: grid;
    place-items: center;

    overflow: hidden;

    border-radius: 50%;

    background: var(--am-assistant-soft);
}

.am-assistant__launcher-logo img {
    width: 38px;
    height: 38px;

    object-fit: contain;
}


.am-assistant__launcher-label {
    white-space: nowrap;

    font-size: 14px;
    line-height: 1;
}


/* =========================================================
   PANEL
========================================================= */

.am-assistant__panel {
    position: fixed;

    right: 22px;
    bottom: 158px;

    z-index: 2147481003;

    width: min(390px, calc(100vw - 32px));
    height: min(610px, calc(100vh - 190px));

    display: flex;
    flex-direction: column;

    overflow: hidden;

    border:
        1px solid rgba(0, 130, 222, .14);

    border-radius: 22px;

    background: #ffffff;

    box-shadow:
        0 24px 70px rgba(12, 48, 72, .22),
        0 4px 14px rgba(12, 48, 72, .08);

    opacity: 0;
    visibility: hidden;

    transform:
        translateY(14px)
        scale(.985);

    transform-origin:
        bottom right;

    pointer-events: none;

    transition:
        opacity .2s ease,
        visibility .2s ease,
        transform .2s ease;
}


.am-assistant.is-open
.am-assistant__panel {
    opacity: 1;
    visibility: visible;

    transform:
        translateY(0)
        scale(1);

    pointer-events: auto;
}


/* =========================================================
   HEADER
========================================================= */

.am-assistant__header {
    min-height: 72px;

    display: flex;
    align-items: center;
    justify-content: space-between;

    gap: 16px;

    padding: 12px 14px 12px 16px;

    border-bottom:
        1px solid var(--am-assistant-border);

    background:
        linear-gradient(
            135deg,
            #ffffff 0%,
            #f4fbff 100%
        );
}


.am-assistant__identity {
    min-width: 0;

    display: flex;
    align-items: center;

    gap: 11px;
}


.am-assistant__brand {
    width: 45px;
    height: 45px;

    flex: 0 0 45px;

    display: grid;
    place-items: center;

    border-radius: 50%;

    background: #ffffff;

    box-shadow:
        0 2px 10px rgba(0, 130, 222, .10);
}

.am-assistant__brand img {
    width: 39px;
    height: 39px;

    object-fit: contain;
}


.am-assistant__identity-copy {
    min-width: 0;
}

.am-assistant__identity-copy h2 {
    margin: 0;

    color: var(--am-assistant-dark);

    font-size: 16px;
    font-weight: 800;
    line-height: 1.25;
}

.am-assistant__identity-copy p {
    position: relative;

    margin: 3px 0 0;

    padding-left: 11px;

    color: var(--am-assistant-muted);

    font-size: 11px;
    line-height: 1.3;
}

.am-assistant__identity-copy p::before {
    content: "";

    position: absolute;

    left: 0;
    top: 50%;

    width: 6px;
    height: 6px;

    border-radius: 50%;

    background: var(--am-assistant-blue);

    transform: translateY(-50%);
}


.am-assistant__close {
    width: 38px;
    height: 38px;

    flex: 0 0 38px;

    display: grid;
    place-items: center;

    border: 0;
    border-radius: 50%;

    background: transparent;

    color: #617583;

    cursor: pointer;

    transition:
        background .18s ease,
        color .18s ease;
}

.am-assistant__close:hover {
    background: var(--am-assistant-soft);
    color: var(--am-assistant-blue);
}


/* =========================================================
   CONVERSATION
========================================================= */

.am-assistant__conversation {
    flex: 1;

    min-height: 0;

    overflow-y: auto;

    padding: 18px 14px 20px;

    overscroll-behavior: contain;

    scrollbar-width: thin;
    scrollbar-color:
        #c6dce9 transparent;

    background:
        linear-gradient(
            180deg,
            #ffffff 0%,
            #fbfdff 100%
        );
}


.am-assistant__message {
    display: flex;

    gap: 8px;

    margin-bottom: 14px;
}


.am-assistant__message--user {
    justify-content: flex-end;
}


.am-assistant__message-avatar {
    width: 30px;
    height: 30px;

    flex: 0 0 30px;

    display: grid;
    place-items: center;

    margin-top: 2px;

    overflow: hidden;

    border-radius: 50%;

    background: var(--am-assistant-soft);
}

.am-assistant__message-avatar img {
    width: 27px;
    height: 27px;

    object-fit: contain;
}


.am-assistant__bubble {
    max-width: 84%;

    padding: 11px 13px;

    border:
        1px solid var(--am-assistant-border);

    border-radius:
        5px 16px 16px 16px;

    background: #ffffff;

    color: #263b4a;

    font-size: 13px;
    line-height: 1.65;

    box-shadow:
        0 4px 16px rgba(26, 68, 95, .05);

    overflow-wrap: anywhere;
}


.am-assistant__message--user
.am-assistant__bubble {
    border-color:
        rgba(0, 130, 222, .18);

    border-radius:
        16px 5px 16px 16px;

    background: var(--am-assistant-blue);

    color: #ffffff;

    box-shadow:
        0 5px 16px rgba(0, 130, 222, .16);
}


.am-assistant__bubble strong {
    display: block;

    margin-bottom: 4px;

    font-weight: 800;
}


.am-assistant__bubble p {
    margin: 0;
}

.am-assistant__bubble p + p {
    margin-top: 7px;
}


.am-assistant__source-note {
    color: #708492;

    font-size: 11px;
}

.am-assistant__message--rtl
.am-assistant__bubble {
    direction: rtl;
    text-align: right;
}


/* =========================================================
   SUGGESTIONS
========================================================= */

.am-assistant__suggestions {
    display: flex;
    flex-wrap: wrap;

    gap: 7px;

    margin:
        2px 0 15px
        38px;
}


.am-assistant__suggestions button {
    padding:
        7px 10px;

    border:
        1px solid rgba(0, 130, 222, .18);

    border-radius: 999px;

    background:
        var(--am-assistant-soft);

    color:
        #14669d;

    font: inherit;

    font-size: 11px;
    font-weight: 700;

    cursor: pointer;

    transition:
        background .18s ease,
        border-color .18s ease,
        transform .18s ease;
}


.am-assistant__suggestions button:hover {
    border-color:
        rgba(0, 130, 222, .38);

    background:
        #dff2ff;

    transform:
        translateY(-1px);
}


/* =========================================================
   RESULT CARDS
========================================================= */

.am-assistant__results {
    display: grid;

    gap: 8px;

    margin-top: 10px;
}


.am-assistant__result {
    display: block;

    padding: 10px;

    border:
        1px solid var(--am-assistant-border);

    border-radius: 12px;

    background: #ffffff;

    color: inherit;

    text-decoration: none;

    transition:
        border-color .18s ease,
        box-shadow .18s ease,
        transform .18s ease;
}


.am-assistant__result:hover {
    border-color:
        rgba(0, 130, 222, .36);

    color: inherit;

    text-decoration: none;

    transform:
        translateY(-1px);

    box-shadow:
        0 6px 18px rgba(0, 130, 222, .08);
}


.am-assistant__result-top {
    display: flex;
    align-items: center;
    justify-content: space-between;

    gap: 8px;

    margin-bottom: 5px;
}


.am-assistant__result-type {
    display: inline-flex;

    padding:
        3px 7px;

    border-radius: 999px;

    background:
        var(--am-assistant-soft);

    color:
        var(--am-assistant-blue);

    font-size: 9px;
    font-weight: 800;

    line-height: 1.4;

    letter-spacing: .02em;
}


.am-assistant__result-arrow {
    color:
        var(--am-assistant-blue);

    font-size: 10px;
}


.am-assistant__result-title {
    margin: 0;

    color:
        #16374d;

    font-size: 12px;
    font-weight: 800;

    line-height: 1.55;
}


.am-assistant__result-snippet {
    margin:
        5px 0 0;

    color:
        #697e8c;

    font-size: 10px;
    line-height: 1.6;

    display: -webkit-box;

    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;

    overflow: hidden;
}


.am-assistant__result-author {
    margin-top: 6px;

    color:
        #78909f;

    font-size: 9px;
    line-height: 1.4;
}


.am-assistant__result--rtl {
    direction: rtl;
    text-align: right;
}


/* =========================================================
   LOADING
========================================================= */

.am-assistant__typing {
    display: inline-flex;
    align-items: center;

    gap: 4px;

    min-height: 18px;
}


.am-assistant__typing span {
    width: 5px;
    height: 5px;

    border-radius: 50%;

    background:
        var(--am-assistant-blue);

    opacity: .35;

    animation:
        amAssistantTyping
        1s ease-in-out
        infinite;
}


.am-assistant__typing span:nth-child(2) {
    animation-delay: .14s;
}

.am-assistant__typing span:nth-child(3) {
    animation-delay: .28s;
}


@keyframes amAssistantTyping {

    0%,
    100% {
        transform: translateY(0);
        opacity: .3;
    }

    50% {
        transform: translateY(-3px);
        opacity: 1;
    }

}


/* =========================================================
   COMPOSER
========================================================= */

.am-assistant__composer {
    flex: 0 0 auto;

    padding:
        10px 12px 9px;

    border-top:
        1px solid var(--am-assistant-border);

    background: #ffffff;
}


.am-assistant__input-wrap {
    display: flex;
    align-items: flex-end;

    gap: 7px;

    padding:
        6px 6px 6px 12px;

    border:
        1px solid #d7e7f1;

    border-radius: 15px;

    background:
        #fafdff;

    transition:
        border-color .18s ease,
        box-shadow .18s ease;
}


.am-assistant__input-wrap:focus-within {
    border-color:
        rgba(0, 130, 222, .55);

    box-shadow:
        0 0 0 3px rgba(0, 130, 222, .08);
}


.am-assistant__input {
    width: 100%;

    min-height: 36px;
    max-height: 92px;

    resize: none;

    overflow-y: auto;

    padding:
        8px 0 6px;

    border: 0;
    outline: 0;

    background: transparent;

    color:
        #243b4a;

    font: inherit;

    font-size: 12px;
    line-height: 1.5;
}


.am-assistant__input::placeholder {
    color:
        #91a2ad;
}


.am-assistant__send {
    width: 37px;
    height: 37px;

    flex: 0 0 37px;

    display: grid;
    place-items: center;

    border: 0;
    border-radius: 11px;

    background:
        var(--am-assistant-blue);

    color: #ffffff;

    cursor: pointer;

    transition:
        background .18s ease,
        transform .18s ease,
        opacity .18s ease;
}


.am-assistant__send:hover {
    background:
        #0074c7;

    transform:
        translateY(-1px);
}


.am-assistant__send:disabled {
    opacity: .48;
    cursor: wait;
    transform: none;
}


.am-assistant__composer-note {
    margin-top: 6px;

    text-align: center;

    color:
        #91a1ab;

    font-size: 9px;
    line-height: 1.4;
}


/* =========================================================
   BACKDROP
========================================================= */

.am-assistant__backdrop {
    display: none;
}


/* =========================================================
   REDUCED MOTION
========================================================= */

@media (prefers-reduced-motion: reduce) {

    .am-assistant__launcher,
    .am-assistant__panel,
    .am-assistant__result,
    .am-assistant__suggestions button,
    .am-assistant__send {
        transition: none !important;
    }

    .am-assistant__typing span {
        animation: none !important;
    }

}


/* =========================================================
   TABLET / MOBILE
========================================================= */

@media (max-width: 767.98px) {

    .am-assistant__launcher {
        right: 14px;
        bottom: 76px;

        width: 58px;
        height: 58px;
        min-height: 58px;

        justify-content: center;

        padding: 7px;

        border-radius: 50%;
    }

    .am-assistant__launcher-logo {
        width: 44px;
        height: 44px;
    }

    .am-assistant__launcher-label {
        display: none;
    }


    .am-assistant__backdrop {
        position: fixed;
        inset: 0;

        z-index: 2147481001;

        display: block;

        background:
            rgba(8, 27, 40, .32);

        opacity: 0;
        visibility: hidden;

        pointer-events: none;

        transition:
            opacity .2s ease,
            visibility .2s ease;
    }


    .am-assistant.is-open
    .am-assistant__backdrop {
        opacity: 1;
        visibility: visible;

        pointer-events: auto;
    }


    .am-assistant__panel {
        left: 10px;
        right: 10px;

        bottom: 10px;

        width: auto;

        height:
            min(72vh, 620px);

        max-height:
            calc(100vh - 20px);

        border-radius:
            20px;

        transform:
            translateY(18px)
            scale(.99);

        transform-origin:
            bottom center;
    }


    .am-assistant.is-open
    .am-assistant__panel {
        transform:
            translateY(0)
            scale(1);
    }


    .am-assistant__conversation {
        padding:
            15px 12px 18px;
    }


    .am-assistant__suggestions {
        margin-left: 38px;
    }

}


@media (max-width: 420px) {

    .am-assistant__header {
        min-height: 68px;

        padding:
            10px 11px 10px 13px;
    }

    .am-assistant__brand {
        width: 42px;
        height: 42px;

        flex-basis: 42px;
    }

    .am-assistant__brand img {
        width: 36px;
        height: 36px;
    }

    .am-assistant__identity-copy h2 {
        font-size: 15px;
    }

    .am-assistant__bubble {
        max-width: 88%;

        font-size: 12px;
    }

    .am-assistant__result-title {
        font-size: 11px;
    }

}
