/* =========================================================
   BookPlay Assistant V0.4.2 FINAL
   Clean Desktop + Mobile Responsive UI
   ========================================================= */


/* =========================================================
   ROOT
   ========================================================= */

#bookplay-assistant {
    position: fixed;
    right: 22px;
    bottom: 22px;

    z-index: 99999;

    font-family: Arial, sans-serif;
}


/* =========================================================
   FLOATING LAUNCHER
   ========================================================= */

.bp-assistant-launcher {
    border: 0;

    background: #66745B;
    color: #ffffff;

    height: 54px;
    padding: 0 18px;

    border-radius: 28px;

    display: flex;
    align-items: center;

    gap: 8px;

    font-size: 15px;
    font-weight: 600;

    cursor: pointer;

    box-shadow:
        0 6px 18px rgba(0, 0, 0, 0.18);

    transition:
        transform 0.2s ease,
        box-shadow 0.2s ease,
        opacity 0.2s ease;
}


.bp-assistant-launcher:hover {
    transform: translateY(-2px);

    box-shadow:
        0 8px 22px rgba(0, 0, 0, 0.22);
}


.bp-assistant-icon {
    font-size: 21px;
    line-height: 1;
}


/* =========================================================
   CHAT WINDOW
   ========================================================= */

.bp-assistant-window {
    position: absolute;

    right: 0;
    bottom: 68px;

    width: 350px;
    max-height: 560px;

    background: #ffffff;

    border-radius: 16px;

    overflow: hidden;

    box-shadow:
        0 12px 38px rgba(0, 0, 0, 0.22);

    opacity: 0;
    visibility: hidden;

    transform: translateY(12px) scale(0.98);

    transition:
        opacity 0.2s ease,
        transform 0.2s ease,
        visibility 0.2s;
}


/* Open state */

#bookplay-assistant.bp-open .bp-assistant-window {
    opacity: 1;
    visibility: visible;

    transform: translateY(0) scale(1);
}


/* =========================================================
   HEADER
   ========================================================= */

.bp-assistant-header {
    background: #66745B;
    color: #ffffff;

    padding: 15px 16px;

    display: flex;
    align-items: center;
    justify-content: space-between;
}


.bp-assistant-title {
    font-size: 16px;
    font-weight: 700;
}


.bp-assistant-close {
    border: 0;

    background: transparent;
    color: #ffffff;

    font-size: 24px;
    line-height: 1;

    cursor: pointer;

    padding: 0 2px;
}


/* =========================================================
   BODY
   ========================================================= */

.bp-assistant-body {
    padding: 11px 12px 12px;

    max-height: 500px;

    overflow-y: auto;

    background: #fbf4e8;
}


/* =========================================================
   ASSISTANT MESSAGE
   ========================================================= */

.bp-assistant-message {
    background: #ffffff;

    padding: 9px 11px;

    margin-bottom: 9px;

    border-radius: 10px;

    font-size: 13px;
    line-height: 1.4;

    color: #333333;

    box-shadow:
        0 2px 8px rgba(0, 0, 0, 0.06);
}


/* =========================================================
   QUESTION / MENU BUTTONS
   ========================================================= */

.bp-assistant-options {
    display: flex;
    flex-direction: column;

    gap: 5px;
}


.bp-assistant-option {
    width: 100%;

    min-height: 34px;

    border:
        1px solid rgba(102, 116, 91, 0.25);

    background: #ffffff;
    color: #333333;

    padding: 7px 10px;

    border-radius: 8px;

    text-align: left;

    font-size: 12px;
    line-height: 1.25;

    cursor: pointer;

    transition:
        background 0.18s ease,
        border-color 0.18s ease,
        transform 0.18s ease;
}


.bp-assistant-option:hover {
    background: #f5f7f2;

    border-color: #66745B;

    transform: translateX(1px);
}


/* =========================================================
   NAVIGATION ACTION
   ========================================================= */

.bp-assistant-action {
    display: block;

    box-sizing: border-box;

    background: #66745B;

    color: #ffffff !important;

    text-decoration: none !important;

    font-weight: 600;
}


.bp-assistant-action:hover,
.bp-assistant-action:focus {
    background: #59664f;

    color: #ffffff !important;
}


/* =========================================================
   "ЭСВЭЛ АСУУЛТАА БИЧЭЭРЭЙ"
   ========================================================= */

.bp-assistant-or {
    margin: 8px 0 5px;

    text-align: center;

    color: #6b6b6b;

    font-size: 11px;
}


/* =========================================================
   QUESTION FORM
   ========================================================= */

.bp-assistant-question-form {
    display: flex;
    align-items: center;

    gap: 6px;

    margin: 0;
}


/* =========================================================
   QUESTION INPUT
   ========================================================= */

.bp-assistant-input {
    flex: 1;

    min-width: 0;

    height: 36px;

    padding: 0 10px;

    border:
        1px solid rgba(102, 116, 91, 0.35);

    border-radius: 8px;

    background: #ffffff;
    color: #333333;

    font-size: 12px;

    outline: none;

    box-sizing: border-box;
}


.bp-assistant-input:focus {
    border-color: #66745B;

    box-shadow:
        0 0 0 2px rgba(102, 116, 91, 0.12);
}


/* =========================================================
   SEND BUTTON
   ========================================================= */

.bp-assistant-send {
    flex: 0 0 36px;

    width: 36px;
    height: 36px;

    padding: 0;

    border: 0;

    border-radius: 8px;

    background: #66745B;
    color: #ffffff;

    font-size: 16px;

    cursor: pointer;
}


.bp-assistant-send:hover,
.bp-assistant-send:focus {
    background: #59664f;
}


/* =========================================================
   USER QUESTION BUBBLE
   ========================================================= */

.bp-user-message {
    width: fit-content;

    max-width: 84%;

    margin:
        0
        0
        8px
        auto;

    padding: 7px 10px;

    border-radius:
        12px
        12px
        3px
        12px;

    background: #66745B;
    color: #ffffff;

    font-size: 12px;
    line-height: 1.35;

    word-break: break-word;
}


/* =========================================================
   MOBILE RESPONSIVE FINAL
   iPhone / Galaxy / Android
   ========================================================= */

@media (max-width: 480px) {

    /* -----------------------------------------
       Assistant root
       ----------------------------------------- */

    #bookplay-assistant {
        right: 12px;
        bottom: 12px;
    }


    /* -----------------------------------------
       Compact floating launcher
       ----------------------------------------- */

    .bp-assistant-launcher {
        height: 42px;
        min-height: 42px;

        padding: 0 13px;

        border-radius: 22px;

        gap: 6px;

        font-size: 12px;
        line-height: 1;
    }


    .bp-assistant-icon {
        font-size: 15px;
    }


    /*
     * When assistant is open,
     * hide launcher on mobile.
     */

    #bookplay-assistant.bp-open
    .bp-assistant-launcher {
        opacity: 0;
        visibility: hidden;

        pointer-events: none;
    }


    /* -----------------------------------------
       Chat window
       ----------------------------------------- */

    .bp-assistant-window {
        position: fixed;

        left: auto;
        right: 10px;

        bottom: 14px;

        width: calc(100vw - 20px);
        max-width: 350px;

        max-height: calc(100dvh - 90px);

        border-radius: 12px;
    }


    /* Fallback for older mobile browsers */

    @supports not (height: 100dvh) {

        .bp-assistant-window {
            max-height: calc(100vh - 90px);
        }

    }


    /* -----------------------------------------
       Header
       ----------------------------------------- */

    .bp-assistant-header {
        min-height: 42px;

        padding: 9px 12px;
    }


    .bp-assistant-title {
        font-size: 13px;
    }


    .bp-assistant-close {
        width: 28px;
        height: 28px;

        padding: 0;

        font-size: 18px;
    }


    /* -----------------------------------------
       Main content
       ----------------------------------------- */

    .bp-assistant-body {
        padding: 9px 10px 10px;

        max-height: calc(100dvh - 145px);

        overflow-y: auto;

        -webkit-overflow-scrolling: touch;
    }


    @supports not (height: 100dvh) {

        .bp-assistant-body {
            max-height: calc(100vh - 145px);
        }

    }


    /* -----------------------------------------
       Greeting / answer
       ----------------------------------------- */

    .bp-assistant-message {
        margin-bottom: 7px;

        padding: 8px 9px;

        border-radius: 8px;

        font-size: 11px;
        line-height: 1.35;
    }


    /* -----------------------------------------
       Menu buttons
       ----------------------------------------- */

    .bp-assistant-options {
        gap: 4px;
    }


    .bp-assistant-option {
        min-height: 31px;

        padding: 6px 8px;

        border-radius: 7px;

        font-size: 10.5px;
        line-height: 1.2;
    }


    /* Disable desktop hover movement on touch */

    .bp-assistant-option:hover {
        transform: none;
    }


    /* -----------------------------------------
       "эсвэл асуултаа бичээрэй"
       ----------------------------------------- */

    .bp-assistant-or {
        margin: 6px 0 4px;

        font-size: 9px;
    }


    /* -----------------------------------------
       Question form
       ----------------------------------------- */

    .bp-assistant-question-form {
        gap: 5px;
    }


    /* -----------------------------------------
       Input
       ----------------------------------------- */

    .bp-assistant-input {
        height: 34px;

        padding: 0 9px;

        border-radius: 7px;

        font-size: 11px;
    }


    /* -----------------------------------------
       Send button
       ----------------------------------------- */

    .bp-assistant-send {
        flex: 0 0 34px;

        width: 34px;
        height: 34px;

        border-radius: 7px;

        font-size: 15px;
    }


    /* -----------------------------------------
       User question
       ----------------------------------------- */

    .bp-user-message {
        max-width: 84%;

        margin-bottom: 7px;

        padding: 6px 8px;

        font-size: 10.5px;
        line-height: 1.3;
    }

}


/* =========================================================
   VERY SMALL PHONES
   ========================================================= */

@media (max-width: 360px) {

    .bp-assistant-window {
        right: 7px;

        width: calc(100vw - 14px);
    }


    .bp-assistant-body {
        padding: 8px;
    }


    .bp-assistant-option {
        padding: 5px 7px;

        font-size: 10px;
    }


    .bp-assistant-message {
        font-size: 10.5px;
    }


    .bp-assistant-launcher {
        height: 40px;
        min-height: 40px;

        padding: 0 12px;

        font-size: 11.5px;
    }

}