/*
Task: MVC Chat Widget Integration
Description: Keeps chatbot widget styles isolated in a dedicated stylesheet to simplify frontend deliverables and reuse.
Date: 27-Apr-2026
*/
/*
Task: Web forms style isolation
Description: Adds a scoped reset and typography baseline so host-site global CSS does not override widget layout and controls.
Date: 27-Apr-2026
*/
#chat-widget,
#chat-widget * ,
#chat-widget *::before,
#chat-widget *::after {
    box-sizing: border-box;
}

#chat-widget {
    font-family: Arial, sans-serif;
    line-height: 1.2;
    text-size-adjust: 100%;
}

#chat-widget button,
#chat-widget input {
    font: inherit;
    letter-spacing: normal;
}

#chat-widget img {
    max-width: none;
    height: auto;
}

/*
Task: Unique selector hardening
Description: Prefixes widget styles with #chat-widget so host project CSS has lower chance to override widget presentation.
Date: 27-Apr-2026
*/
#chat-widget.chat-widget {
    position: fixed;
    right: 1rem;
    bottom: 4.5rem;
    z-index: 1090;
}

#chat-widget .chat-widget-toggle {
    width: 56px;
    height: 56px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 50%;
    background: linear-gradient(135deg, #6a1bb1, #4a17c7);
    color: #fff;
    font-size: 1.3rem;
    box-shadow: 0 8px 22px rgba(72, 13, 121, 0.35);
    cursor: pointer;
}

#chat-widget .chat-widget-toggle-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

#chat-widget .chat-widget-toggle-logo {
    width: 26px;
    height: 26px;
    display: block;
    margin: 0;
}

#chat-widget .chat-widget-window {
    position: fixed;
    right: 0;
    bottom: 86px;
    width: min(400px, calc(100vw - 1rem));
    border-radius: 16px;
    overflow: hidden;
    background: #f4f4f6;
    box-shadow: 0 14px 40px rgba(10, 10, 20, 0.28);
    margin-right: 16px;
}

#chat-widget .chat-widget-header {
    background: linear-gradient(135deg, #6720a8, #5318cb);
    color: #fff;
    padding: 1rem 1.1rem;
}

#chat-widget .chat-widget-header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
}

#chat-widget .chat-widget-brand {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

#chat-widget .chat-widget-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.14);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

#chat-widget .chat-widget-logo {
    width: 28px;
    height: 28px;
    display: block;
}

#chat-widget .chat-widget-title {
    font-size: 1.55rem;
    font-weight: 700;
    line-height: 1.1;
}

#chat-widget .chat-widget-status {
    margin-top: 0.08rem;
    font-size: 0.78rem;
    opacity: 0.94;
}

#chat-widget .chat-widget-status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 0.25rem;
    background-color: #0de454;
}

    #chat-widget .chat-widget-reset-btn {
        width: 34px;
        height: 34px;
        border: 0;
        border-radius: 50%;
        background: rgba(255, 255, 255, 0.2);
        color: #fff;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
        font-style: normal;
        font-size: 1.4rem;
        cursor: pointer;
    }

/* Fallback glyph for reset icon when external icon fonts are unavailable */
#chat-widget .chat-widget-reset-btn .ri-reset-left-fill::before {
    content: "\21BA";
    font-style: normal;
    font-size: 1.4rem;
    line-height: 1;
}

#chat-widget .chat-widget-body {
    padding: 0.9rem 0.95rem;
    overflow-y: auto;
    min-height: 360px;
    max-height: 56vh;
    background-color: #efeff2;
}

#chat-widget .chat-widget-message {
    max-width: 86%;
    margin-bottom: 0.8rem;
}

#chat-widget .chat-widget-bubble-wrap {
    display: flex;
    align-items: flex-end;
    gap: 0.45rem;
}

#chat-widget .chat-widget-user {
    margin-left: auto;
}

#chat-widget .chat-widget-assistant {
    margin-right: auto;
}

#chat-widget .chat-widget-system {
    margin-right: auto;
}

#chat-widget .chat-widget-msg-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    font-size: 0.95rem;
    flex-shrink: 0;
}

#chat-widget .chat-widget-msg-logo {
    width: 22px;
    height: 22px;
    display: block;
}

#chat-widget .chat-widget-user .chat-widget-msg-avatar {
    order: 2;
}

#chat-widget .chat-widget-assistant .chat-widget-msg-avatar,
#chat-widget .chat-widget-system .chat-widget-msg-avatar {
    background: linear-gradient(135deg, #6a1bb1, #4a17c7);
}

#chat-widget .chat-widget-bubble {
    border-radius: 13px;
    padding: 0.85rem 1rem;
    position: relative;
    box-shadow: 0 1px 2px rgba(30, 40, 80, 0.06);
}

#chat-widget .chat-widget-assistant .chat-widget-bubble,
#chat-widget .chat-widget-system .chat-widget-bubble {
    background: #d7dbe2;
    color: #40444f;
}

#chat-widget .chat-widget-user .chat-widget-bubble {
    background: linear-gradient(135deg, #5f30e8, #4a26c6);
    color: #fff;
    border-top-right-radius: 10px;
}

#chat-widget .chat-widget-user .chat-widget-bubble-wrap {
    justify-content: flex-end;
}

#chat-widget .chat-widget-assistant .chat-widget-bubble::after,
#chat-widget .chat-widget-system .chat-widget-bubble::after {
    content: "";
    position: absolute;
    left: -7px;
    bottom: 8px;
    border-width: 7px 8px 7px 0;
    border-style: solid;
    border-color: transparent #d7dbe2 transparent transparent;
}

#chat-widget .chat-widget-user .chat-widget-bubble::after {
    content: "";
    position: absolute;
    right: -7px;
    bottom: 8px;
    border-width: 7px 0 7px 8px;
    border-style: solid;
    border-color: transparent transparent transparent #4a26c6;
}

#chat-widget .chat-widget-text {
    white-space: pre-wrap;
    font-size: 1.05rem;
    line-height: 1.22;
}

#chat-widget .chat-widget-meta {
    margin-top: 0.2rem;
    font-size: 0.72rem;
    color: #6c757d;
}

#chat-widget .chat-widget-user .chat-widget-meta {
    text-align: right;
    padding-right: 2.35rem;
}

#chat-widget .chat-widget-check {
    color: #7c45f8;
    margin-left: 0.25rem;
}

#chat-widget .chat-widget-typing {
    padding: 0.2rem 1rem 0.55rem;
    min-height: 32px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.35rem;
    background: #efeff2;
    color: #6f7582;
    border-top: 0;
}

/*
Task: Bootstrap-independent widget styles
Description: Implements a native typing spinner and label classes so the widget no longer depends on Bootstrap utility/spinner CSS.
Date: 27-Apr-2026
*/
#chat-widget .chat-widget-spinner {
    width: 0.95rem;
    height: 0.95rem;
    border: 0.14rem solid rgba(122, 127, 140, 0.25);
    border-top-color: #7a7f8c;
    border-radius: 50%;
    animation: chat-widget-spin 0.8s linear infinite;
}

#chat-widget .chat-widget-typing-text {
    color: #6f7582;
    font-size: 0.92rem;
    margin: 0;
}

@keyframes chat-widget-spin {
    to {
        transform: rotate(360deg);
    }
}

#chat-widget .chat-widget-quick-actions {
    display: flex;
    gap: 0.45rem;
    padding: 0.7rem 0.9rem 0.45rem;
    background: #efeff2;
    overflow-x: auto;
}

#chat-widget .chat-widget-chip {
    border: 1px solid #e2e4ea;
    border-radius: 13px;
    background: #e8eaee;
    color: #4b4f5a;
    font-weight: 600;
    font-size: 0.85rem;
    padding: 0.38rem 0.62rem;
    white-space: nowrap;
    flex-shrink: 0;
    cursor: pointer;
}

#chat-widget .chat-widget-footer {
    background: #efeff2;
    padding: 0.3rem 0.9rem 0.95rem;
}

#chat-widget .chat-widget-input-wrap {
    border-radius: 16px;
    background: #dfe2e8;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.28rem 0.45rem 0.28rem 0.85rem;
}

#chat-widget .chat-widget-input {
    flex: 1;
    border: 0;
    background: transparent;
    outline: none;
    font-size: 1.05rem;
    color: #4d4f56;
}

#chat-widget .chat-widget-input::placeholder {
    color: #5f636d;
}

#chat-widget .chat-widget-send {
    border: 0;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    background: transparent;
    color: #4f57ff;
    font-size: 1.4rem;
    cursor: pointer;
}

#chat-widget .chat-widget-error {
    color: #dc3545;
    margin-top: 0.35rem;
    font-size: 0.75rem;
}

#chat-widget .chat-widget-close {
    position: fixed;
    right: 0.85rem;
    bottom: 1rem;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    border: 0;
    background: #5a1cb3;
    color: #fff;
    font-size: 1.8rem;
    line-height: 0;
    box-shadow: 0 10px 20px rgba(55, 15, 109, 0.34);
    cursor: pointer;
}

/*
Task: Cross-project HTML widget support
Description: Adds framework-agnostic utility classes so the widget behaves correctly on pages without Bootstrap CSS.
Date: 27-Apr-2026
*/
/* Hide elements without relying on external CSS frameworks */
#chat-widget .d-none {
    display: none !important;
}

/* Provide local fallback for muted text utility */
#chat-widget .text-muted {
    color: #6f7582 !important;
}

/* Keep typing hint compact when bootstrap spacing utilities are unavailable */
#chat-widget .small {
    font-size: 0.92rem;
}

@media (max-width: 575.98px) {
    #chat-widget.chat-widget {
        right: 0.35rem;
        bottom: 0.35rem;
    }

    #chat-widget .chat-widget-window {
        width: 100%;
        margin-right: 0;
    }

    #chat-widget .chat-widget-title {
        font-size: 1.4rem;
    }

    #chat-widget .chat-widget-input {
        font-size: 1rem;
    }
}
