/* MUAST site chatbot widget */
.muast-chatbot {
    --chat-blue: #13357b;
    --chat-blue-dark: #0c2859;
    --chat-green: #3ba94a;
    --chat-gold: #c4a35a;
    --chat-surface: #ffffff;
    --chat-muted: #64748b;
    --chat-border: #e2e8f0;
    --chat-shadow: 0 12px 40px rgba(15, 23, 42, 0.18);
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 1080;
    font-family: "Roboto", "Segoe UI", system-ui, sans-serif;
}

.muast-chat-launcher {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 50%;
    background: linear-gradient(145deg, #1a448f 0%, #0c2859 100%);
    color: #fff;
    cursor: pointer;
    box-shadow: 0 8px 28px rgba(12, 40, 89, 0.38);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.muast-chat-launcher:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 32px rgba(12, 40, 89, 0.45);
}

.muast-chat-launcher:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 3px;
}

.muast-chat-launcher-icon {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 1.2rem;
}

.muast-chat-icon-close {
    display: none;
}

.muast-chat-launcher.is-open .muast-chat-icon-open {
    display: none;
}

.muast-chat-launcher.is-open .muast-chat-icon-close {
    display: block;
    font-size: 1.15rem;
}

.muast-chat-panel {
    position: absolute;
    right: 0;
    bottom: calc(100% + 14px);
    width: min(380px, calc(100vw - 32px));
    height: min(560px, calc(100vh - 120px));
    background: var(--chat-surface);
    border-radius: 18px;
    border: 1px solid var(--chat-border);
    box-shadow: var(--chat-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: muastChatIn 0.22s ease;
}

@keyframes muastChatIn {
    from { opacity: 0; transform: translateY(12px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.muast-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 16px 14px;
    background: linear-gradient(135deg, var(--chat-blue), var(--chat-blue-dark));
    color: #fff;
}

.muast-chat-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.muast-chat-avatar {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.muast-chat-header h2 {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.2;
}

.muast-chat-header p {
    margin: 2px 0 0;
    font-size: 0.78rem;
    opacity: 0.88;
}

.muast-chat-close {
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    cursor: pointer;
    flex-shrink: 0;
}

.muast-chat-role {
    padding: 10px 14px;
    border-bottom: 1px solid var(--chat-border);
    background: #f8fafc;
}

.muast-chat-role-label {
    display: block;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--chat-muted);
    margin-bottom: 6px;
}

.muast-chat-role-btns {
    display: flex;
    gap: 6px;
}

.muast-role-btn {
    flex: 1;
    padding: 6px 8px;
    border: 1px solid var(--chat-border);
    border-radius: 999px;
    background: #fff;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--chat-blue);
    cursor: pointer;
}

.muast-role-btn.is-active {
    background: var(--chat-blue);
    border-color: var(--chat-blue);
    color: #fff;
}

.muast-chat-messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #f8fafc;
}

.muast-chat-msg {
    max-width: 88%;
    padding: 10px 12px;
    border-radius: 14px;
    font-size: 0.88rem;
    line-height: 1.5;
    word-wrap: break-word;
}

.muast-chat-msg.bot {
    align-self: flex-start;
    background: #fff;
    border: 1px solid var(--chat-border);
    border-bottom-left-radius: 4px;
    color: #1e293b;
}

.muast-chat-msg.user {
    align-self: flex-end;
    background: var(--chat-blue);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.muast-chat-msg a {
    color: var(--chat-blue);
    font-weight: 600;
    text-decoration: underline;
}

.muast-chat-msg.user a { color: #dbeafe; }

.muast-chat-msg ul {
    margin: 8px 0 0;
    padding-left: 18px;
}

.muast-chat-msg li { margin-bottom: 4px; }

.muast-chat-typing {
    align-self: flex-start;
    padding: 10px 14px;
    background: #fff;
    border: 1px solid var(--chat-border);
    border-radius: 14px;
    font-size: 0.82rem;
    color: var(--chat-muted);
    display: flex;
    align-items: center;
    gap: 8px;
}

.muast-typing-dots {
    display: inline-flex;
    gap: 3px;
}

.muast-typing-dots span {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--chat-blue);
    animation: muastDot 1.2s infinite ease-in-out;
}

.muast-typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.muast-typing-dots span:nth-child(3) { animation-delay: 0.3s; }

@keyframes muastDot {
    0%, 80%, 100% { opacity: 0.3; transform: translateY(0); }
    40% { opacity: 1; transform: translateY(-3px); }
}

.muast-chat-quick {
    display: flex;
    gap: 6px;
    padding: 8px 12px 0;
    overflow-x: auto;
    flex-wrap: nowrap;
    scrollbar-width: thin;
}

.muast-chat-quick:empty { display: none; padding: 0; }

.muast-quick-chip {
    flex-shrink: 0;
    padding: 6px 12px;
    border: 1px solid var(--chat-border);
    border-radius: 999px;
    background: #fff;
    font-size: 0.76rem;
    font-weight: 600;
    color: var(--chat-blue);
    cursor: pointer;
    white-space: nowrap;
}

.muast-quick-chip:hover {
    background: #eef3fb;
    border-color: var(--chat-blue);
}

.muast-chat-form {
    display: flex;
    gap: 8px;
    padding: 12px;
    border-top: 1px solid var(--chat-border);
    background: #fff;
}

.muast-chat-form input {
    flex: 1;
    min-width: 0;
    padding: 10px 14px;
    border: 1px solid var(--chat-border);
    border-radius: 999px;
    font-size: 0.88rem;
    outline: none;
}

.muast-chat-form input:focus {
    border-color: var(--chat-blue);
    box-shadow: 0 0 0 3px rgba(19, 53, 123, 0.12);
}

.muast-chat-form button {
    width: 42px;
    height: 42px;
    border: none;
    border-radius: 50%;
    background: var(--chat-green);
    color: #fff;
    cursor: pointer;
    flex-shrink: 0;
}

.muast-chat-form button:hover { background: #2d8a3a; }

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

@media (max-width: 480px) {
    .muast-chatbot {
        right: 12px;
        bottom: 12px;
        left: auto;
        width: auto;
        display: flex;
        flex-direction: column;
        align-items: flex-end;
        gap: 12px;
    }

    .muast-chat-panel {
        position: fixed;
        left: 12px;
        right: 12px;
        bottom: 76px;
        top: auto;
        width: auto;
        height: min(68dvh, calc(100dvh - 100px));
        max-height: calc(100dvh - 100px);
        z-index: 1081;
    }

    .muast-chat-launcher {
        position: relative;
        z-index: 1082;
        width: 52px;
        height: 52px;
        flex-shrink: 0;
        display: inline-flex !important;
        visibility: visible !important;
        opacity: 1 !important;
    }

    .muast-chat-launcher-icon {
        font-size: 1.15rem;
    }

    .muast-chat-header,
    .muast-chat-messages,
    .muast-chat-quick,
    .muast-chat-form {
        flex-shrink: 0;
    }

    .muast-chat-messages {
        flex: 1 1 auto;
        min-height: 120px;
    }
}