/* Help Assistant widget. Uses MudBlazor CSS palette variables so it follows the
   active Light/Dark theme automatically. All classes are prefixed "helpbot-". */

.helpbot-root {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 1400; /* above content, below MudBlazor dialogs/snackbars */
}

.helpbot-fab {
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.28);
}

.helpbot-panel {
    display: flex;
    flex-direction: column;
    width: 400px;
    max-width: calc(100vw - 32px);
    height: 600px;
    max-height: calc(100vh - 48px);
    border-radius: 16px;
    overflow: hidden;
    background-color: var(--mud-palette-surface);
    color: var(--mud-palette-text-primary);
}

.helpbot-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 8px 10px 16px;
    background-color: var(--mud-palette-primary);
    color: var(--mud-palette-primary-text);
}

.helpbot-header-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 1rem;
}

.helpbot-header-actions .mud-icon-button {
    color: var(--mud-palette-primary-text);
}

.helpbot-scopes {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--mud-palette-divider);
}

.helpbot-messages {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
}

.helpbot-empty {
    margin: auto;
    text-align: center;
    padding: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.helpbot-suggestions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
    max-width: 320px;
}

.helpbot-suggestion {
    justify-content: flex-start;
    text-align: left;
    text-transform: none;
}

/* Messages */
.helpbot-msg {
    display: flex;
    gap: 8px;
    max-width: 100%;
}

.helpbot-msg-user {
    justify-content: flex-end;
}

.helpbot-msg-assistant {
    justify-content: flex-start;
}

.helpbot-avatar {
    flex: 0 0 auto;
    margin-top: 2px;
}

.helpbot-assistant-body {
    display: flex;
    flex-direction: column;
    max-width: 85%;
}

.helpbot-bubble {
    padding: 8px 12px;
    border-radius: 12px;
    line-height: 1.45;
    word-wrap: break-word;
    overflow-wrap: anywhere;
    font-size: 0.9rem;
}

.helpbot-bubble-user {
    background-color: var(--mud-palette-primary);
    color: var(--mud-palette-primary-text);
    border-bottom-right-radius: 4px;
    max-width: 85%;
}

.helpbot-bubble-assistant {
    background-color: var(--mud-palette-background-grey, var(--mud-palette-background));
    color: var(--mud-palette-text-primary);
    border: 1px solid var(--mud-palette-divider);
    border-bottom-left-radius: 4px;
}

/* Tighten Markdown spacing inside assistant bubbles */
.helpbot-bubble-assistant p { margin: 0 0 8px 0; }
.helpbot-bubble-assistant p:last-child { margin-bottom: 0; }
.helpbot-bubble-assistant ul,
.helpbot-bubble-assistant ol { margin: 4px 0 8px 0; padding-left: 20px; }
.helpbot-bubble-assistant li { margin-bottom: 2px; }
.helpbot-bubble-assistant pre {
    background-color: var(--mud-palette-surface);
    border: 1px solid var(--mud-palette-divider);
    border-radius: 6px;
    padding: 8px;
    overflow-x: auto;
}
.helpbot-bubble-assistant code { font-size: 0.85em; }
.helpbot-bubble-assistant a { color: var(--mud-palette-primary); }
.helpbot-bubble-assistant table { border-collapse: collapse; font-size: 0.85em; }
.helpbot-bubble-assistant th,
.helpbot-bubble-assistant td { border: 1px solid var(--mud-palette-divider); padding: 4px 8px; }

.helpbot-feedback {
    display: flex;
    gap: 2px;
    margin-top: 2px;
    opacity: 0.75;
}

/* Typing indicator */
.helpbot-typing {
    display: inline-flex;
    gap: 4px;
    align-items: center;
    height: 1.2em;
}
.helpbot-typing span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: var(--mud-palette-text-secondary);
    animation: helpbot-bounce 1.2s infinite ease-in-out both;
}
.helpbot-typing span:nth-child(1) { animation-delay: -0.24s; }
.helpbot-typing span:nth-child(2) { animation-delay: -0.12s; }

@keyframes helpbot-bounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

/* Input */
.helpbot-input {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    padding: 8px 12px 4px 12px;
    border-top: 1px solid var(--mud-palette-divider);
}
.helpbot-textfield { flex: 1 1 auto; }

.helpbot-disclaimer {
    padding: 0 12px 8px 12px;
    text-align: center;
}

/* Mobile: full-screen sheet */
@media (max-width: 600px) {
    .helpbot-root {
        right: 12px;
        bottom: 12px;
    }
    .helpbot-panel {
        position: fixed;
        inset: 0;
        width: 100vw;
        height: 100vh;
        max-width: 100vw;
        max-height: 100vh;
        border-radius: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    .helpbot-messages { scroll-behavior: auto; }
    .helpbot-typing span { animation: none; }
}
