/**
 * Mention Dropdown Styles
 *
 * Scoped to #inputContainer AND #freshChatInputWrapper — the chat page swaps
 * between these two hosts depending on whether the session has any messages
 * (the fresh-chat textarea lives inside #freshChatInputWrapper until the
 * first message is sent).
 */

/* ── Input highlighter ───────────────────────────────────────────────────── */

#inputContainer .mention-input-shell,
#freshChatInputWrapper .mention-input-shell {
    position: relative;
    display: grid;
    flex: 1 1 auto;
    width: 100%;
}

#inputContainer .mention-input-shell > textarea,
#inputContainer .mention-input-shell > .mention-input-highlight,
#freshChatInputWrapper .mention-input-shell > textarea,
#freshChatInputWrapper .mention-input-shell > .mention-input-highlight {
    grid-area: 1 / 1;
}

#inputContainer .mention-input-highlight,
#freshChatInputWrapper .mention-input-highlight {
    pointer-events: none;
    overflow: hidden;
    white-space: pre-wrap;
    word-break: break-word;
    color: transparent;
    z-index: 2;
}

/* The fresh-chat textarea has heavy intrinsic padding (~20px 96px 20px 25px)
   and a font-size that differs from the regular #userInput. The highlight
   layer must match those exactly so the colored mention text overlays the
   raw text in the textarea instead of floating above the input box. */
#freshChatInputWrapper .mention-input-highlight {
    border-radius: 10px;
    box-sizing: border-box;
    padding: 20px 96px 20px 25px;
    min-height: 100px;
    font-size: 0.9rem;
    line-height: 1.45;
    font-family: monospace;
}

#inputContainer .mention-input-shell > textarea,
#freshChatInputWrapper .mention-input-shell > textarea {
    position: relative;
    z-index: 1;
    color: var(--text-color, #1f2937);
    -webkit-text-fill-color: currentColor;
    caret-color: var(--text-color, #1f2937);
}

#inputContainer .mention-input-shell > textarea::placeholder,
#freshChatInputWrapper .mention-input-shell > textarea::placeholder {
    -webkit-text-fill-color: initial;
}

#inputContainer .mention-input-highlight__mention,
#freshChatInputWrapper .mention-input-highlight__mention {
    color: #2563eb;
}

/* ── Dropdown container ──────────────────────────────────────────────────── */

#inputContainer .mention-dropdown,
#freshChatInputWrapper .mention-dropdown,
.mention-input-shell > .mention-dropdown {
    display: none;
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    max-height: 220px;
    overflow-y: auto;
    background: var(--bg-secondary, #ffffff);
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 10px;
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.1);
    /* Welcome container in fresh-chat mode has its own stacking context — push
       the dropdown well above it so the suggestions don't show through. */
    z-index: 1000;
    padding: 4px 0;
    margin-bottom: 8px;
}

/* ── Individual item ─────────────────────────────────────────────────────── */

#inputContainer .mention-dropdown__item,
#freshChatInputWrapper .mention-dropdown__item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    cursor: pointer;
    transition: background-color 0.1s ease;
    font-size: 13px;
    line-height: 1.4;
}

#inputContainer .mention-dropdown__item:hover,
#inputContainer .mention-dropdown__item--active,
#freshChatInputWrapper .mention-dropdown__item:hover,
#freshChatInputWrapper .mention-dropdown__item--active {
    background: var(--bg-hover, #f1f5f9);
}

/* ── Name ────────────────────────────────────────────────────────────────── */

#inputContainer .mention-dropdown__name,
#freshChatInputWrapper .mention-dropdown__name {
    font-weight: 600;
    color: var(--text-primary, #1e293b);
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Secondary @username hint shown when display name differs from username */
#inputContainer .mention-dropdown__handle,
#freshChatInputWrapper .mention-dropdown__handle {
    font-weight: 400;
    font-size: 11px;
    color: var(--text-secondary, #94a3b8);
}

/* ── Role badge ──────────────────────────────────────────────────────────── */

#inputContainer .mention-dropdown__badge,
#freshChatInputWrapper .mention-dropdown__badge {
    font-size: 11px;
    font-weight: 500;
    padding: 1px 6px;
    border-radius: 4px;
    background: var(--bg-tertiary, #e2e8f0);
    color: var(--text-secondary, #64748b);
    white-space: nowrap;
}

#inputContainer .mention-dropdown__badge--everyone,
#freshChatInputWrapper .mention-dropdown__badge--everyone {
    background: #fef3c7;
    color: #92400e;
}

/* ── Dark mode ───────────────────────────────────────────────────────────── */

[data-theme="dark"] #inputContainer .mention-dropdown,
[data-theme="dark"] #freshChatInputWrapper .mention-dropdown {
    background: var(--bg-secondary, #1e293b);
    border-color: var(--border-color, #334155);
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] #inputContainer .mention-input-highlight,
[data-theme="dark"] #freshChatInputWrapper .mention-input-highlight {
    color: transparent;
}

[data-theme="dark"] #inputContainer .mention-input-highlight__mention,
[data-theme="dark"] #freshChatInputWrapper .mention-input-highlight__mention {
    color: #60a5fa;
}

[data-theme="dark"] #inputContainer .mention-dropdown__item:hover,
[data-theme="dark"] #inputContainer .mention-dropdown__item--active,
[data-theme="dark"] #freshChatInputWrapper .mention-dropdown__item:hover,
[data-theme="dark"] #freshChatInputWrapper .mention-dropdown__item--active {
    background: var(--bg-hover, #334155);
}

[data-theme="dark"] #inputContainer .mention-dropdown__name,
[data-theme="dark"] #freshChatInputWrapper .mention-dropdown__name {
    color: var(--text-primary, #f1f5f9);
}

[data-theme="dark"] #inputContainer .mention-dropdown__handle,
[data-theme="dark"] #freshChatInputWrapper .mention-dropdown__handle {
    color: var(--text-secondary, #64748b);
}

[data-theme="dark"] #inputContainer .mention-dropdown__badge,
[data-theme="dark"] #freshChatInputWrapper .mention-dropdown__badge {
    background: var(--bg-tertiary, #334155);
    color: var(--text-secondary, #94a3b8);
}

[data-theme="dark"] #inputContainer .mention-dropdown__badge--everyone,
[data-theme="dark"] #freshChatInputWrapper .mention-dropdown__badge--everyone {
    background: #451a03;
    color: #fbbf24;
}

/* ── Scrollbar ───────────────────────────────────────────────────────────── */

#inputContainer .mention-dropdown::-webkit-scrollbar,
#freshChatInputWrapper .mention-dropdown::-webkit-scrollbar {
    width: 4px;
}

#inputContainer .mention-dropdown::-webkit-scrollbar-thumb,
#freshChatInputWrapper .mention-dropdown::-webkit-scrollbar-thumb {
    background: var(--border-color, #cbd5e1);
    border-radius: 2px;
}
