/* ============================================================
   BONASORT AI ASSISTANT
   ============================================================ */

.bs-ai-widget {
    --ai-dark: #263540;
    --ai-dark-hover: #1e2a32;
    --ai-steel: #536979;
    --ai-steel-light: #e8edf0;
    --ai-paper: #f4f5f5;
    --ai-border: #dce1e4;
    --ai-text: #1f2529;
    --ai-muted: #6d777e;
    --ai-white: #ffffff;

    position: fixed;
    left: 22px;
    bottom: 22px;
    z-index: 9990;

    color: var(--ai-text);

    font-family:
        "IBM Plex Sans",
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;
}


/* ============================================================
   TRIGGER
   ============================================================ */

.bs-ai-trigger {
    position: relative;

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

    display: flex;
    align-items: center;
    justify-content: center;
    gap: 9px;

    margin-left: auto;
    padding: 0 18px;

    background: var(--ai-dark);
    border: 0;
    border-radius: 29px;

    box-shadow:
        0 10px 30px rgba(23, 34, 41, 0.22);

    color: var(--ai-white);

    cursor: pointer;

    transition:
        background-color 160ms ease,
        transform 160ms ease,
        box-shadow 160ms ease;
}

.bs-ai-trigger::before {
    position: absolute;
    inset: -6px;
    z-index: -1;

    content: "";

    border: 2px solid rgba(83, 105, 121, 0.38);
    border-radius: 36px;

    animation: bs-ai-pulse 2.4s ease-out infinite;
}

.bs-ai-trigger svg {
    width: 24px;
    height: 24px;
    flex: 0 0 24px;
}

.bs-ai-trigger__label {
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

.bs-ai-widget.is-open .bs-ai-trigger {
    display: none;
}

@media (hover: hover) {
    .bs-ai-trigger:hover {
        background: var(--ai-dark-hover);

        box-shadow:
            0 14px 34px rgba(23, 34, 41, 0.28);

        transform: translateY(-2px);
    }
}

@keyframes bs-ai-pulse {
    0% {
        opacity: 0.8;
        transform: scale(0.9);
    }

    70%,
    100% {
        opacity: 0;
        transform: scale(1.18);
    }
}


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

.bs-ai-panel {
    width: 380px;
    height: 520px;

    display: grid;
    grid-template-rows:
        auto
        minmax(0, 1fr)
        auto
        auto
        auto;

    overflow: hidden;

    background: var(--ai-white);
    border: 1px solid var(--ai-border);
    border-radius: 10px;

    box-shadow:
        0 22px 70px rgba(20, 29, 34, 0.24);
}

.bs-ai-panel[hidden] {
    display: none;
}


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

.bs-ai-header {
    min-height: 70px;

    display: grid;
    grid-template-columns:
        42px
        minmax(0, 1fr)
        38px;
    align-items: center;
    gap: 10px;

    padding: 12px 14px;

    background: var(--ai-dark);
    color: var(--ai-white);
}

.bs-ai-header__avatar {
    width: 40px;
    height: 40px;

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

    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 50%;

    font-size: 20px;
}

.bs-ai-header__text {
    min-width: 0;

    display: flex;
    flex-direction: column;
}

.bs-ai-header__text strong {
    font-size: 14px;
    line-height: 1.3;
}

.bs-ai-header__text span {
    margin-top: 2px;

    color: rgba(255, 255, 255, 0.66);

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

.bs-ai-close {
    width: 36px;
    height: 36px;

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

    padding: 0;

    background: transparent;
    border: 0;
    border-radius: 4px;

    color: rgba(255, 255, 255, 0.76);

    cursor: pointer;
}

.bs-ai-close svg {
    width: 20px;
    height: 20px;
}

@media (hover: hover) {
    .bs-ai-close:hover {
        background: rgba(255, 255, 255, 0.08);
        color: var(--ai-white);
    }
}


/* ============================================================
   MESSAGES
   ============================================================ */

.bs-ai-messages {
    min-height: 0;
    overflow-y: auto;

    padding: 17px 14px;

    background: var(--ai-paper);

    overscroll-behavior: contain;
    scrollbar-width: thin;
}

.bs-ai-message {
    display: flex;
    align-items: flex-end;
    gap: 8px;

    margin-bottom: 14px;
}

.bs-ai-message:last-child {
    margin-bottom: 0;
}

.bs-ai-message--user {
    justify-content: flex-end;
}

.bs-ai-message__avatar {
    width: 28px;
    height: 28px;
    flex: 0 0 28px;

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

    background: var(--ai-white);
    border: 1px solid var(--ai-border);
    border-radius: 50%;

    color: var(--ai-muted);

    font-size: 10px;
    font-weight: 700;
}

.bs-ai-message--user .bs-ai-message__avatar {
    display: none;
}

.bs-ai-message__bubble {
    max-width: 82%;

    padding: 10px 12px;

    background: var(--ai-white);
    border: 1px solid var(--ai-border);
    border-radius: 4px 10px 10px 10px;

    color: var(--ai-text);

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

.bs-ai-message--user .bs-ai-message__bubble {
    background: var(--ai-steel);
    border-color: var(--ai-steel);
    border-radius: 10px 4px 10px 10px;

    color: var(--ai-white);
}

.bs-ai-message__bubble p {
    margin: 0 0 7px;
}

.bs-ai-message__bubble p:last-child {
    margin-bottom: 0;
}

.bs-ai-message__link {
    min-height: 35px;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    margin-top: 10px;
    padding: 8px 12px;

    background: var(--ai-dark);
    border-radius: 4px;

    color: var(--ai-white);
    text-decoration: none;

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

    transition:
        background-color 150ms ease;
}

@media (hover: hover) {
    .bs-ai-message__link:hover {
        background: var(--ai-dark-hover);
        color: var(--ai-white);
    }
}


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

.bs-ai-loading-dots {
    min-width: 38px;
    min-height: 17px;

    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.bs-ai-loading-dots i {
    width: 6px;
    height: 6px;

    display: block;

    background: var(--ai-steel);
    border-radius: 50%;

    animation:
        bs-ai-dot 1.2s ease-in-out infinite;
}

.bs-ai-loading-dots i:nth-child(2) {
    animation-delay: 0.15s;
}

.bs-ai-loading-dots i:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes bs-ai-dot {
    0%,
    60%,
    100% {
        opacity: 0.35;
        transform: translateY(0);
    }

    30% {
        opacity: 1;
        transform: translateY(-4px);
    }
}


/* ============================================================
   QUICK ACTIONS
   ============================================================ */

.bs-ai-quick-actions {
    display: flex;
    gap: 6px;

    overflow-x: auto;

    padding: 9px 12px;

    background: var(--ai-white);
    border-top: 1px solid var(--ai-border);

    scrollbar-width: none;
}

.bs-ai-quick-actions::-webkit-scrollbar {
    display: none;
}

.bs-ai-quick-actions[hidden] {
    display: none;
}

.bs-ai-quick-actions button {
    flex: 0 0 auto;

    min-height: 30px;

    padding: 6px 10px;

    background: var(--ai-white);
    border: 1px solid var(--ai-border);
    border-radius: 15px;

    color: var(--ai-steel);

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

    cursor: pointer;
}

@media (hover: hover) {
    .bs-ai-quick-actions button:hover {
        background: var(--ai-steel-light);
        border-color: var(--ai-steel);
    }
}


/* ============================================================
   FORM
   ============================================================ */

.bs-ai-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 42px;
    align-items: end;
    gap: 8px;

    padding: 10px 12px;

    background: var(--ai-white);
    border-top: 1px solid var(--ai-border);
}

.bs-ai-input {
    width: 100%;
    min-height: 40px;
    max-height: 110px;

    padding: 10px 11px;

    resize: none;

    background: var(--ai-paper);
    border: 1px solid var(--ai-border);
    border-radius: 5px;

    color: var(--ai-text);

    font: inherit;
    font-size: 12px;
    line-height: 1.4;

    outline: 0;

    transition:
        border-color 150ms ease,
        box-shadow 150ms ease;
}

.bs-ai-input:focus {
    border-color: var(--ai-steel);

    box-shadow:
        0 0 0 3px rgba(83, 105, 121, 0.1);
}

.bs-ai-input::placeholder {
    color: #929ba1;
}

.bs-ai-send {
    width: 40px;
    height: 40px;

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

    padding: 0;

    background: var(--ai-dark);
    border: 0;
    border-radius: 5px;

    color: var(--ai-white);

    cursor: pointer;

    transition:
        background-color 150ms ease;
}

.bs-ai-send svg {
    width: 19px;
    height: 19px;
}

.bs-ai-send:disabled {
    opacity: 0.55;
    cursor: wait;
}

@media (hover: hover) {
    .bs-ai-send:hover:not(:disabled) {
        background: var(--ai-dark-hover);
    }
}


/* ============================================================
   FOOTER
   ============================================================ */

.bs-ai-footer {
    padding: 7px 12px 8px;

    background: var(--ai-white);
    border-top: 1px solid var(--ai-border);

    color: #929ba1;

    font-size: 8px;
    line-height: 1.35;
    text-align: center;
}


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

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

    .bs-ai-widget {
        left: 12px;
        bottom: calc(
            82px +
            env(safe-area-inset-bottom, 0px)
        );
    }

    .bs-ai-trigger {
        width: 56px;
        min-width: 56px;
        height: 56px;

        padding: 0;

        border-radius: 50%;
    }

    .bs-ai-trigger__label {
        display: none;
    }

    .bs-ai-panel {
        position: fixed;
        inset: 0;
        z-index: 10000;

        width: 100vw;
        height: 100dvh;

        border: 0;
        border-radius: 0;

        box-shadow: none;
    }

    .bs-ai-header {
        padding-top:
            calc(
                12px +
                env(
                    safe-area-inset-top,
                    0px
                )
            );
    }

    .bs-ai-footer {
        padding-bottom:
            calc(
                8px +
                env(
                    safe-area-inset-bottom,
                    0px
                )
            );
    }
}


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

@media (prefers-reduced-motion: reduce) {
    .bs-ai-trigger::before,
    .bs-ai-loading-dots i {
        animation: none !important;
    }

    .bs-ai-trigger,
    .bs-ai-message__link,
    .bs-ai-send {
        transition: none !important;
    }
}