/* Flo chat widget.
   Material 3 colour roles and shapes, expressed as custom properties on the
   container so light and dark themes differ only in their tokens. Class names
   are the contract with docs_scripts/chatbot.js. */

/* ==========================================================================
   Tokens
   ========================================================================== */
.chatbot-container,
.chatbot-toggle {
    --flo-primary: #4279f4;
    --flo-on-primary: #ffffff;
    --flo-primary-container: #d6e4ff;
    --flo-on-primary-container: #0028aa;
    --flo-secondary-container: #e0e2f2;
    --flo-on-secondary-container: #171b2c;
    --flo-tertiary-container: #e8eefc;
    --flo-surface: #fbf8ff;
    --flo-surface-container-lowest: #ffffff;
    --flo-surface-container-low: #f5f2fb;
    --flo-surface-container: #efedf5;
    --flo-surface-container-high: #e9e7f0;
    --flo-surface-container-highest: #e3e1ea;
    --flo-on-surface: #1b1b21;
    --flo-on-surface-variant: #45464f;
    --flo-outline: #767680;
    --flo-outline-variant: #c6c5d0;
    --flo-error: #ba1a1a;
    --flo-error-container: #ffdad6;
    --flo-on-error-container: #410002;
    --flo-scrim: rgba(0, 0, 0, 0.32);
    --flo-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 8px 24px rgba(20, 24, 60, 0.14);
    --flo-shadow-high: 0 2px 6px rgba(0, 0, 0, 0.12), 0 24px 56px rgba(20, 24, 60, 0.22);
    --flo-state-hover: rgba(66, 121, 244, 0.08);
    --flo-state-press: rgba(66, 121, 244, 0.12);
    --flo-font: "Open Sans", "Segoe UI", system-ui, sans-serif;
    --flo-font-display: "Open Sans", "Segoe UI", system-ui, sans-serif;
    --flo-mono: "Roboto Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    --flo-ease: cubic-bezier(0.2, 0, 0, 1);
}

.chatbot-container.dark-theme {
    --flo-primary: #a9c7ff;
    --flo-on-primary: #003064;
    --flo-primary-container: #244f9f;
    --flo-on-primary-container: #d6e4ff;
    --flo-secondary-container: #404659;
    --flo-on-secondary-container: #dde1f9;
    --flo-tertiary-container: #30394b;
    --flo-surface: #121318;
    --flo-surface-container-lowest: #0d0e13;
    --flo-surface-container-low: #1b1b21;
    --flo-surface-container: #1f1f25;
    --flo-surface-container-high: #292a2f;
    --flo-surface-container-highest: #34343a;
    --flo-on-surface: #e4e1e9;
    --flo-on-surface-variant: #c6c5d0;
    --flo-outline: #8f909a;
    --flo-outline-variant: #45464f;
    --flo-error: #ffb4ab;
    --flo-error-container: #93000a;
    --flo-on-error-container: #ffdad6;
    --flo-shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.45);
    --flo-shadow-high: 0 2px 6px rgba(0, 0, 0, 0.4), 0 24px 56px rgba(0, 0, 0, 0.55);
    --flo-state-hover: rgba(169, 199, 255, 0.08);
    --flo-state-press: rgba(169, 199, 255, 0.12);
}

/* ==========================================================================
   Container
   ========================================================================== */
.chatbot-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    top: auto;
    left: auto;
    width: 420px;
    min-width: 320px;
    min-height: 420px;
    height: calc(100vh - 120px);
    max-height: 760px;
    background: var(--flo-surface);
    color: var(--flo-on-surface);
    border-radius: 28px;
    box-shadow: var(--flo-shadow-high);
    display: flex;
    flex-direction: column;
    z-index: 10000;
    font-family: var(--flo-font);
    -webkit-font-smoothing: antialiased;
    opacity: 0;
    transform: translateY(16px) scale(0.98);
    transform-origin: bottom right;
    transition: opacity 0.25s var(--flo-ease), transform 0.3s var(--flo-ease), border-radius 0.3s var(--flo-ease);
    pointer-events: none;
    overflow: hidden;
    resize: both;
}

.chatbot-container *,
.chatbot-container *::before,
.chatbot-container *::after {
    box-sizing: border-box;
}

.chatbot-container[style*="flex"] {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* Resize grip hint in the bottom-right corner */
.chatbot-container::after {
    content: '';
    position: absolute;
    bottom: 6px;
    right: 8px;
    width: 10px;
    height: 10px;
    border-right: 2px solid var(--flo-outline-variant);
    border-bottom: 2px solid var(--flo-outline-variant);
    border-bottom-right-radius: 4px;
    pointer-events: none;
    opacity: 0.8;
}

.chatbot-container.expanded {
    resize: none;
}

.chatbot-container.expanded::after {
    display: none;
}

.chatbot-container .main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    min-width: 0;
    min-height: 0;
    background: var(--flo-surface);
}

/* Legacy chat-list sidebar is not used in this layout. */
.sidebar-strip,
.chat-sidebar {
    display: none !important;
}

.chatbot-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    background: var(--flo-scrim, rgba(0, 0, 0, 0.32));
    backdrop-filter: blur(4px);
    z-index: 9999;
}

.chatbot-body {
    display: flex;
    flex-direction: row;
    flex: 1;
    min-height: 0;
    height: 100%;
}

/* ==========================================================================
   Header
   ========================================================================== */
.chatbot-header {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 12px 12px 18px;
    background: var(--flo-surface-container-low);
    color: var(--flo-on-surface);
    border-bottom: 1px solid var(--flo-outline-variant);
}

.chatbot-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.chatbot-brand-avatar {
    position: relative;
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    border-radius: 50%;
    overflow: hidden;
    background: linear-gradient(135deg, var(--flo-primary-container), var(--flo-tertiary-container));
}

.chatbot-brand-avatar img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    transform: scale(2.2);
}

.chatbot-brand-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.chatbot-title {
    margin: 0;
    font-family: var(--flo-font-display);
    font-size: 17px;
    font-weight: 500;
    line-height: 22px;
    letter-spacing: 0;
    color: var(--flo-on-surface);
}

.chatbot-subtitle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    line-height: 16px;
    color: var(--flo-on-surface-variant);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chatbot-subtitle::before {
    content: '';
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #1e9e5a;
    box-shadow: 0 0 0 2px color-mix(in srgb, #1e9e5a 25%, transparent);
    flex-shrink: 0;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 2px;
}

.header-icon-btn {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--flo-on-surface-variant);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s var(--flo-ease), color 0.15s var(--flo-ease);
    pointer-events: auto;
}

.header-icon-btn:hover {
    background: var(--flo-state-hover);
    color: var(--flo-on-surface);
}

.header-icon-btn:active {
    background: var(--flo-state-press);
}

.header-icon-btn:focus-visible {
    outline: 2px solid var(--flo-primary);
    outline-offset: 1px;
}

.header-icon-btn svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

/* Overflow menu */
.options-dropdown {
    display: none;
    position: absolute;
    top: 58px;
    right: 14px;
    min-width: 200px;
    padding: 8px 0;
    background: var(--flo-surface-container);
    border-radius: 12px;
    box-shadow: var(--flo-shadow);
    z-index: 10100;
    animation: floMenuIn 0.18s var(--flo-ease);
}

.options-dropdown.show {
    display: block;
}

.dropdown-item {
    width: 100%;
    height: 44px;
    display: flex !important;
    align-items: center;
    gap: 12px !important;
    padding: 0 16px;
    border: none;
    background: none;
    text-align: left;
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    color: var(--flo-on-surface);
    cursor: pointer;
    transition: background 0.15s var(--flo-ease);
}

.dropdown-item svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    color: var(--flo-on-surface-variant);
}

.dropdown-item:hover {
    background: var(--flo-state-hover);
}

.dropdown-item.danger-item {
    margin-top: 8px;
    border-top: 1px solid var(--flo-outline-variant);
    color: var(--flo-error);
}

.dropdown-item.danger-item svg {
    color: var(--flo-error);
}

/* ==========================================================================
   Messages
   ========================================================================== */
.chat-messages {
    flex: 1;
    width: 100%;
    min-width: 0;
    overflow-y: auto;
    padding: 20px 18px 8px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    background: var(--flo-surface);
    scrollbar-width: thin;
    scrollbar-color: var(--flo-outline-variant) transparent;
}

.message {
    display: flex;
    width: 100%;
    min-width: 0;
    animation: floMessageIn 0.28s var(--flo-ease);
}

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

.bot-message {
    justify-content: flex-start;
    align-items: flex-start;
    gap: 12px;
}

.message-content {
    min-width: 0;
    font-size: 14.5px;
    line-height: 1.6;
    overflow-wrap: anywhere;
    word-wrap: break-word;
}

/* User turns: a tonal bubble on the right. */
.user-message .message-content {
    max-width: 82%;
    padding: 10px 16px;
    background: var(--flo-primary-container);
    color: var(--flo-on-primary-container);
    border-radius: 20px 20px 6px 20px;
}

/* Assistant turns: open text beside the avatar, like a document. */
.bot-message .message-content {
    flex: 1;
    max-width: 100%;
    padding: 4px 0 0;
    color: var(--flo-on-surface);
}

.message-content p {
    margin: 0 0 10px;
}

.message-content p:last-child {
    margin-bottom: 0;
}

.message-content a {
    color: var(--flo-primary);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
}

.message-content ul,
.message-content ol {
    margin: 6px 0 10px;
    padding-left: 22px;
}

.message-content li {
    margin: 3px 0;
}

.message-content strong {
    font-weight: 600;
}

.message-content h1,
.message-content h2,
.message-content h3,
.message-content h4 {
    margin: 14px 0 8px;
    font-weight: 700;
    line-height: 1.35;
    color: var(--flo-on-surface);
}

.message-content h1 { font-size: 1.2em; }
.message-content h2 { font-size: 1.1em; }
.message-content h3 { font-size: 1.05em; }
.message-content h4 { font-size: 1em; }

.message-content table {
    display: block;
    width: 100%;
    max-width: 100%;
    margin: 10px 0;
    border-collapse: collapse;
    overflow-x: auto;
    font-size: 13px;
    line-height: 1.45;
}

.message-content thead {
    background: var(--flo-surface-container-low);
}

.message-content th,
.message-content td {
    padding: 7px 10px;
    border: 1px solid var(--flo-outline-variant);
    text-align: left;
    vertical-align: top;
}

.message-content th {
    font-weight: 600;
    white-space: nowrap;
}

.message-content blockquote {
    margin: 8px 0;
    padding: 6px 12px;
    border-left: 3px solid var(--flo-primary);
    color: var(--flo-on-surface-variant);
    background: var(--flo-surface-container-low);
}

.message-content hr {
    margin: 12px 0;
    border: none;
    border-top: 1px solid var(--flo-outline-variant);
}

.message-content :not(pre) > code {
    font-family: var(--flo-mono);
    font-size: 0.88em;
    padding: 1px 6px;
    border-radius: 6px;
    background: var(--flo-surface-container-high);
    color: var(--flo-on-surface);
}

/* Code blocks. Fenced code renders as <pre><code class="language-x">, so the
   block itself must own its overflow: a single long unbreakable line would
   otherwise stretch the message past the container and be clipped. */
.message-content pre {
    display: block;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    margin: 10px 0;
    padding: 12px 14px;
    overflow-x: auto;
    overflow-y: hidden;
    white-space: pre;
    border-radius: 12px;
    background: var(--flo-surface-container-high) !important;
    border: 1px solid var(--flo-outline-variant);
    font-size: 12.5px;
    line-height: 1.55;
    scrollbar-width: thin;
}

.message-content pre code {
    display: block;
    min-width: max-content;
    font-family: var(--flo-mono);
    background: transparent !important;
    text-shadow: none !important;
}

/* Avatar beside assistant turns */
.flo-avatar-container {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    border-radius: 50%;
    overflow: hidden;
    background: linear-gradient(135deg, var(--flo-primary-container), var(--flo-tertiary-container));
}

.flo-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    transform: scale(2.2);
}

.typing-indicator .message-content {
    padding: 0;
}

.flo-loader-icon {
    width: 56px;
    height: 56px;
    object-fit: contain;
    margin-top: -10px;
}

/* Suggested first questions under the welcome message */
.suggestion-chips {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    margin-top: 14px;
}

.suggestion-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    box-sizing: border-box;
    min-height: 40px;
    padding: 10px 14px 10px 12px;
    border: 1px solid var(--flo-outline-variant);
    border-radius: 8px;
    background: var(--flo-surface-container-lowest, #fff);
    color: var(--flo-on-surface);
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.35;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s var(--flo-ease), border-color 0.15s var(--flo-ease);
}

.suggestion-chip svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    fill: var(--flo-primary);
}

.suggestion-chip:hover {
    background: var(--flo-state-hover);
    border-color: var(--flo-outline);
}

.suggestion-chip:focus-visible {
    outline: 2px solid var(--flo-primary);
    outline-offset: 1px;
}

/* Tool activity ("Searching the docs…") */
.flo-tool-status {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px 6px 10px;
    border-radius: 8px;
    background: var(--flo-secondary-container);
    color: var(--flo-on-secondary-container);
    font-size: 12.5px;
    font-weight: 500;
    animation: floMessageIn 0.2s var(--flo-ease);
}

.flo-tool-status-icon {
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: floPulse 1.6s infinite ease-in-out;
}

.flo-tool-status-icon svg {
    width: 14px;
    height: 14px;
}

.interrupted-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 10px;
    padding: 3px 10px;
    border-radius: 8px;
    background: var(--flo-surface-container-high);
    color: var(--flo-on-surface-variant);
    font-size: 12px;
    font-weight: 500;
    user-select: none;
}

.interrupted-badge svg {
    width: 12px;
    height: 12px;
    fill: currentColor;
}

/* ==========================================================================
   Flo's agents trail — full-width panel (same weight as Sources)
   ========================================================================== */
.flo-research {
    display: block;
    width: 100%;
    box-sizing: border-box;
    margin-top: 12px;
    border: 1px solid var(--flo-outline-variant);
    border-radius: 10px;
    background: var(--flo-surface-container-lowest, #fff);
    overflow: hidden;
    animation: floMessageIn 0.28s var(--flo-ease);
}

.flo-research:not([open]) .flo-research-summary {
    border-bottom: none;
}

.flo-research:not([open]) .flo-research-summary:hover {
    background: var(--flo-state-hover);
}

.flo-research[open] .flo-research-summary,
.flo-research.flo-research-live .flo-research-summary {
    border-bottom: 1px solid var(--flo-outline-variant);
}

.flo-research[open] .flo-research-summary::before,
.flo-research:not([open]) .flo-research-summary::before {
    order: 2;
    margin-left: auto;
}

.flo-research[open] .flo-research-summary::before {
    transform: rotate(-135deg); /* ▴ */
}

.flo-research:not([open]) .flo-research-summary::before {
    transform: rotate(45deg); /* ▾ */
}

.flo-research-summary {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    cursor: pointer;
    user-select: none;
    font-family: var(--flo-font);
    font-size: 13px;
    font-weight: 600;
    line-height: 1.3;
    color: var(--flo-on-surface);
    background: var(--flo-surface-container-low);
    transition: background 0.15s var(--flo-ease);
    outline: none;
}

.flo-research-summary:focus,
.flo-research-summary:focus-visible {
    outline: none;
}

.flo-research-summary-label {
    min-width: 0;
    flex: 0 1 auto;
    margin-right: 2px;
}

.flo-research-summary > .flo-research-scout {
    margin-top: 0;
}

.flo-research-summary::-webkit-details-marker {
    display: none;
}

.flo-research-summary::before {
    content: '';
    width: 5px;
    height: 5px;
    border-right: 1.5px solid currentColor;
    border-bottom: 1.5px solid currentColor;
    transform: rotate(45deg);
    transition: transform 0.18s var(--flo-ease);
    flex-shrink: 0;
    opacity: 0.65;
}

.flo-research-list {
    margin: 0;
    padding: 0;
    list-style: none;
    display: flex;
    flex-direction: column;
}

.flo-research-step {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 0;
    padding: 0;
    border: none;
    border-top: 1px solid var(--flo-outline-variant);
    border-radius: 0;
    background: transparent;
}

.flo-research-step:first-child {
    border-top: none;
}

.flo-research-step-main {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    width: 100%;
    min-width: 0;
    padding: 7px 10px;
}

.flo-research-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--flo-on-surface);
    flex: 1;
    min-width: 0;
    line-height: 1.35;
}

.flo-research-scout {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    white-space: nowrap;
    padding: 1px 5px;
    border-radius: 4px;
    background: var(--flo-primary-container);
    color: var(--flo-on-primary-container);
    flex-shrink: 0;
    margin-top: 1px;
}

.flo-research-scout--docs { background: #d6e4ff; color: #0028aa; }
.flo-research-scout--issues { background: #e8f5e9; color: #1b5e20; }
.flo-research-scout--code { background: #f3e5f5; color: #6a1b9a; }
.flo-research-scout--web { background: #fff3e0; color: #e65100; }
.flo-research-scout--prioritizer,
.flo-research-scout--flo { background: var(--flo-secondary-container); color: var(--flo-on-secondary-container); }

.flo-research-spinner {
    width: 10px;
    height: 10px;
    margin-top: 2px;
    border-radius: 50%;
    border: 2px solid var(--flo-outline-variant);
    border-top-color: var(--flo-primary);
    flex-shrink: 0;
    animation: floScoutSpin 0.8s linear infinite;
}

.flo-research-check {
    width: 10px;
    height: 10px;
    margin-top: 3px;
    border-radius: 50%;
    background: var(--flo-primary);
    flex-shrink: 0;
    opacity: 0.9;
}

.flo-research-check::before {
    content: none;
}

@keyframes floScoutSpin {
    to { transform: rotate(360deg); }
}

.flo-research-step--running .flo-research-title {
    font-style: italic;
    font-weight: 500;
    color: var(--flo-on-surface-variant);
}

.flo-research-step--running {
    background: color-mix(in srgb, var(--flo-primary) 4%, transparent);
}

.flo-research-packet {
    flex: 1 1 100%;
    margin: 0 10px 8px 28px;
    padding: 8px 10px;
    border-left: 2px solid var(--flo-primary);
    border-radius: 0 8px 8px 0;
    background: var(--flo-primary-container);
    font-size: 12px;
    color: var(--flo-on-primary-container);
}

.flo-research-packet > summary {
    cursor: pointer;
    font-weight: 600;
    font-size: 11px;
    color: var(--flo-on-surface);
}

.flo-research-packet-row { margin-top: 3px; line-height: 1.35; }

.flo-research-packet-findings {
    margin: 4px 0 0;
    padding-left: 16px;
    line-height: 1.35;
}

.flo-research-meta {
    font-size: 11px;
    color: var(--flo-on-surface-variant);
    text-align: right;
    line-height: 1.35;
}

/* ==========================================================================
   Sources
   ========================================================================== */
.citations-container {
    margin-top: 14px;
    border-radius: 16px;
    background: var(--flo-surface-container-low);
    border: 1px solid var(--flo-outline-variant);
    overflow: hidden;
    animation: floMessageIn 0.3s var(--flo-ease);
}

.citations-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    cursor: pointer;
    user-select: none;
    transition: background 0.15s var(--flo-ease);
}

.citations-header:hover {
    background: var(--flo-state-hover);
}

.citations-header-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.citations-icon-badge {
    width: 22px;
    height: 22px;
    border-radius: 6px;
    background: var(--flo-primary-container);
    color: var(--flo-on-primary-container);
    display: flex;
    align-items: center;
    justify-content: center;
}

.citations-icon-badge svg {
    width: 13px;
    height: 13px;
}

.citations-title {
    font-size: 13px;
    font-weight: 500;
    color: var(--flo-on-surface);
}

.citations-count-pill {
    min-width: 20px;
    padding: 1px 7px;
    border-radius: 10px;
    background: var(--flo-surface-container-highest);
    color: var(--flo-on-surface-variant);
    font-size: 11px;
    font-weight: 600;
    text-align: center;
}

.citations-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--flo-on-surface-variant);
    transition: transform 0.2s var(--flo-ease);
}

.citations-toggle svg {
    width: 16px;
    height: 16px;
}

.citations-toggle.expanded {
    transform: rotate(180deg);
}

.citations-content {
    display: none;
    padding: 4px 8px 8px;
}

.citations-content.expanded {
    display: block;
    animation: floMessageIn 0.2s var(--flo-ease);
}

.citations-grid {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.citation-pill {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 8px;
    border-radius: 10px;
    text-decoration: none !important;
    color: inherit !important;
    animation: floMessageIn 0.3s var(--flo-ease) both;
    animation-delay: calc(var(--i, 0) * 40ms);
    transition: background 0.15s var(--flo-ease);
}

.citation-pill:hover {
    background: var(--flo-state-hover);
}

.citation-pill-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    flex: 1;
}

.citation-doc-icon {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    border-radius: 8px;
    background: var(--flo-surface-container-highest);
    color: var(--flo-primary);
    display: flex;
    align-items: center;
    justify-content: center;
}

.citation-doc-icon svg {
    width: 14px;
    height: 14px;
}

.citation-pill-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
}

.citation-pill-title {
    font-size: 13px;
    font-weight: 500;
    line-height: 1.3;
    color: var(--flo-on-surface);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.citation-pill-sub {
    margin-top: 1px;
    font-size: 11.5px;
    color: var(--flo-on-surface-variant);
}

/* Corpus badges on citations (KF blue, not purple) */
.citation-corpus { font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; padding: 1px 5px; border-radius: 3px; flex-shrink: 0; vertical-align: middle; margin-right: 4px; }
.citation-corpus--docs { background: #d6e4ff; color: #0028aa; }
.citation-corpus--issues { background: #e8f5e9; color: #1b5e20; }
.citation-corpus--code { background: #f3e5f5; color: #6a1b9a; }
.citation-corpus--web { background: #fff3e0; color: #e65100; }
.citation-corpus--other { background: #eceff1; color: #455a64; }

/* Live research trail */
.flo-research-live .flo-research-summary-label {
    color: var(--flo-on-surface);
}
.flo-research-live-badge {
    margin-left: auto;
    color: var(--flo-primary);
    font-weight: 700;
    font-size: 10px;
    letter-spacing: 0.02em;
    animation: floLivePulse 1.4s ease-in-out infinite;
    flex-shrink: 0;
}
.flo-research-live .flo-research-summary::before {
    display: none; /* LIVE badge sits on the right instead */
}
@keyframes floLivePulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.45; }
}
.flo-research-step--running .flo-research-meta { font-style: italic; }

.citation-external-icon {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    margin-left: 8px;
    color: var(--flo-on-surface-variant);
    transition: transform 0.15s var(--flo-ease), color 0.15s var(--flo-ease);
}

.citation-pill:hover .citation-external-icon {
    color: var(--flo-primary);
    transform: translate(1px, -1px);
}

/* ==========================================================================
   Answer feedback
   ========================================================================== */
.feedback-bar {
    display: flex;
    align-items: center;
    gap: 2px;
    margin-top: 10px;
    font-size: 12px;
    color: var(--flo-on-surface-variant);
}

.feedback-label {
    margin-right: 4px;
}

.feedback-btn {
    width: 32px;
    height: 32px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--flo-on-surface-variant);
    cursor: pointer;
    transition: background 0.15s var(--flo-ease), color 0.15s var(--flo-ease);
}

.feedback-btn svg {
    width: 17px;
    height: 17px;
    fill: currentColor;
}

.feedback-btn:hover {
    background: var(--flo-state-hover);
    color: var(--flo-on-surface);
}

.feedback-btn:focus-visible {
    outline: 2px solid var(--flo-primary);
    outline-offset: 1px;
}

.feedback-btn.selected {
    background: var(--flo-primary-container);
    color: var(--flo-on-primary-container);
}

.feedback-status {
    margin-left: 6px;
}

.feedback-comment {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.feedback-comment input {
    flex: 1;
    min-width: 0;
    height: 36px;
    padding: 0 14px;
    border: 1px solid var(--flo-outline-variant);
    border-radius: 18px;
    background: var(--flo-surface);
    color: var(--flo-on-surface);
    font-family: inherit;
    font-size: 13px;
    outline: none;
}

.feedback-comment input:focus {
    border-color: var(--flo-primary);
    box-shadow: 0 0 0 1px var(--flo-primary);
}

.feedback-comment button {
    height: 36px;
    padding: 0 16px;
    border: none;
    border-radius: 18px;
    background: var(--flo-primary);
    color: var(--flo-on-primary);
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
}

/* ==========================================================================
   Composer
   ========================================================================== */
.chat-input-container {
    display: flex;
    flex-direction: column;
    padding: 8px 14px 12px;
    background: var(--flo-surface);
}

.chatbot-container .input-wrapper.composer {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 10px 12px 8px;
    background: var(--flo-surface-container-lowest, #fff);
    border: 1px solid var(--flo-outline-variant);
    border-radius: 18px;
    box-shadow: none;
    transition: border-color 0.15s var(--flo-ease), background 0.15s var(--flo-ease);
    overflow: hidden;
}

.chatbot-container .input-wrapper.composer:focus-within {
    background: var(--flo-surface-container-lowest, #fff);
    border-color: var(--flo-primary);
    box-shadow: none;
}

.composer-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding-top: 6px;
}

.composer-tools-left {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    flex-wrap: wrap;
}

.composer-tool-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
    margin: 0;
    padding: 5px 10px 5px 8px;
    border: 1px solid var(--flo-outline-variant);
    border-radius: 999px;
    background: transparent;
    color: var(--flo-on-surface-variant);
    font-family: inherit;
    font-size: 12px;
    font-weight: 500;
    line-height: 1;
    cursor: pointer;
    transition: background 0.15s var(--flo-ease), border-color 0.15s var(--flo-ease), color 0.15s var(--flo-ease);
}

.composer-tool-chip svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    color: currentColor;
}

.composer-tool-chip:hover {
    background: var(--flo-state-hover);
    color: var(--flo-on-surface);
    border-color: var(--flo-outline);
}

.composer-tool-chip.active {
    color: var(--flo-on-primary-container);
    background: var(--flo-primary-container);
    border-color: color-mix(in srgb, var(--flo-primary) 40%, var(--flo-outline-variant));
}

.composer-tool-chip#web-toggle.active {
    color: #e65100;
    background: #fff3e0;
    border-color: color-mix(in srgb, #e65100 35%, var(--flo-outline-variant));
}

.composer-tool-chip:focus-visible {
    outline: 2px solid var(--flo-primary);
    outline-offset: 1px;
}

.chat-input {
    flex: 1;
    width: 100%;
    min-height: 24px;
    max-height: 120px;
    padding: 2px 4px 8px;
    border: none;
    outline: none;
    background: none;
    resize: none;
    overflow-y: auto;
    font-family: inherit;
    font-size: 14.5px;
    line-height: 22px;
    color: var(--flo-on-surface);
}

.chat-input::-webkit-resizer {
    display: none;
}

.chat-input::placeholder {
    color: var(--flo-on-surface-variant);
}

.chatbot-container button.send-button,
.chatbot-container .send-button {
    box-sizing: border-box;
    width: 36px !important;
    height: 36px !important;
    min-width: 36px !important;
    max-width: 36px !important;
    min-height: 36px !important;
    max-height: 36px !important;
    flex: 0 0 36px;
    margin: 0 !important;
    border: none !important;
    border-radius: 999px !important;
    overflow: hidden;
    background: var(--flo-primary);
    color: var(--flo-on-primary);
    cursor: pointer;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    padding: 0 !important;
    line-height: 0 !important;
    appearance: none;
    -webkit-appearance: none;
    transition: background 0.2s var(--flo-ease), color 0.2s var(--flo-ease), transform 0.2s var(--flo-ease), box-shadow 0.2s var(--flo-ease);
}

.chatbot-container .send-button:hover {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.chatbot-container .send-button:active {
    transform: scale(0.94);
}

.chatbot-container .send-button svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
    display: block;
    flex-shrink: 0;
}

.chatbot-container .composer:has(.chat-input:placeholder-shown) .send-button:not(.stop-mode) {
    background: transparent;
    color: var(--flo-on-surface-variant);
    box-shadow: none;
}

.chatbot-container .send-button.stop-mode {
    background: var(--flo-on-surface) !important;
    color: var(--flo-surface) !important;
    border-radius: 999px !important;
    box-shadow: none !important;
}

.chatbot-container .send-button.stop-mode svg {
    width: 14px;
    height: 14px;
}

.disclaimer-text {
    margin: 8px 4px 0;
    font-size: 11px;
    line-height: 1.4;
    color: var(--flo-on-surface-variant);
    text-align: center;
}

.disclaimer-text a {
    color: var(--flo-primary);
    text-decoration: none;
}

.disclaimer-text a:hover {
    text-decoration: underline;
}

/* ==========================================================================
   Launcher
   ========================================================================== */
.chatbot-toggle {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 120px;
    height: 120px;
    padding: 0;
    border: none;
    background: transparent;
    cursor: pointer;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.flo-toggle-icon {
    width: 120px;
    height: 120px;
    object-fit: contain;
    cursor: pointer;
    filter: drop-shadow(0 6px 14px rgba(20, 24, 60, 0.22));
    transition: transform 0.25s var(--flo-ease);
}

.chatbot-toggle:hover .flo-toggle-icon {
    transform: scale(1.05) translateY(-2px);
}

.chatbot-speech-bubble {
    position: absolute;
    bottom: 112px;
    right: 18px;
    padding: 8px 14px;
    border-radius: 16px 16px 4px 16px;
    background: var(--flo-primary);
    color: var(--flo-on-primary);
    font-family: var(--flo-font);
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    box-shadow: var(--flo-shadow);
    opacity: 0;
    visibility: hidden;
    transform: translateY(8px);
    transition: opacity 0.2s var(--flo-ease), transform 0.2s var(--flo-ease), visibility 0.2s;
    pointer-events: none;
}

.chatbot-toggle:hover .chatbot-speech-bubble {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* ==========================================================================
   Expanded (dashboard) view with the persona panel
   ========================================================================== */
.chatbot-container.expanded {
    width: 980px;
    /* Centred with left:50% + translate(-50%); cap to the viewport so it never
       overflows both edges and gets clipped. */
    max-width: calc(100vw - 32px);
    height: 84vh;
    max-height: 820px;
    top: 50%;
    left: 50%;
    bottom: auto;
    right: auto;
    transform: translate(-50%, -50%) scale(1) !important;
    transform-origin: center;
    border-radius: 28px;
}

.chatbot-container.expanded[style*="flex"] {
    transform: translate(-50%, -50%) scale(1) !important;
}

.chatbot-container.expanded .chat-messages,
.chatbot-container.expanded .chat-input-container {
    padding-left: max(24px, calc((100% - 760px) / 2));
    padding-right: max(24px, calc((100% - 760px) / 2));
}

.persona-sidebar {
    display: none;
    width: 300px;
    flex-direction: column;
    gap: 12px;
    padding: 16px;
    overflow-y: auto;
    background: var(--flo-surface-container-low);
    border-right: 1px solid var(--flo-outline-variant);
}

.chatbot-container.expanded .persona-sidebar {
    display: flex;
}

.persona-card {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 16px;
    border-radius: 16px;
    background: var(--flo-surface-container-lowest);
}

.persona-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.persona-card-header h4 {
    margin: 0;
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: var(--flo-on-surface-variant);
}

.mascot-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    text-align: center;
}

.persona-video {
    width: 132px;
    height: 132px;
    object-fit: contain;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--flo-primary-container), var(--flo-tertiary-container));
}

.persona-video[data-persona="debug"] {
    object-position: center 10%;
}

.mascot-status-label {
    font-size: 12px;
    line-height: 1.4;
    color: var(--flo-on-surface-variant);
}

.mascot-status-highlight {
    font-weight: 600;
    color: var(--flo-primary);
}

.mascot-persona-label {
    margin-top: 4px;
    text-align: center;
}

.mascot-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 12px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 500;
}

.mascot-badge svg {
    flex-shrink: 0;
}

.docs-badge {
    background: var(--flo-primary-container);
    color: var(--flo-on-primary-container);
}

.debug-badge {
    background: #ffdcc2;
    color: #2e1500;
}

.research-badge {
    background: var(--flo-primary-container, #d6e4ff);
    color: var(--flo-on-primary-container, #0028aa);
}

.chatbot-container.dark-theme .debug-badge {
    background: #6e3900;
    color: #ffdcc2;
}

.selector-content {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.persona-pill {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border: 1px solid transparent;
    border-radius: 12px;
    background: transparent;
    cursor: pointer;
    user-select: none;
    transition: background 0.15s var(--flo-ease), border-color 0.15s var(--flo-ease);
}

.persona-pill:hover {
    background: var(--flo-state-hover);
}

.persona-pill.active {
    background: var(--flo-secondary-container);
}

.persona-pill.disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.persona-pill-icon {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--flo-surface-container-high);
    color: var(--flo-on-surface-variant);
}

.persona-pill.active .persona-pill-icon {
    background: var(--flo-primary);
    color: var(--flo-on-primary);
}

.persona-pill-text {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.persona-pill-name {
    font-size: 13.5px;
    font-weight: 500;
    line-height: 1.2;
    color: var(--flo-on-surface);
}

.persona-pill-sub {
    font-size: 11px;
    color: var(--flo-on-surface-variant);
}

.persona-pill-check {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    color: var(--flo-primary);
    opacity: 0;
    transition: opacity 0.15s;
}

.persona-pill-check.visible {
    opacity: 1;
}


/* ==========================================================================
   Small screens: full-screen sheet
   ========================================================================== */
@media (max-width: 600px) {
    .chatbot-container,
    .chatbot-container.expanded {
        inset: 0;
        width: 100%;
        max-width: 100%;
        height: 100%;
        max-height: none;
        min-width: 0;
        border-radius: 0;
        resize: none;
        transform: translateY(16px) !important;
    }

    .chatbot-container[style*="flex"],
    .chatbot-container.expanded[style*="flex"] {
        transform: none !important;
    }

    .chatbot-container::after,
    .chatbot-container.expanded .persona-sidebar {
        display: none;
    }

    .chatbot-container.expanded .chat-messages,
    .chatbot-container.expanded .chat-input-container {
        padding-left: 16px;
        padding-right: 16px;
    }

    .chatbot-toggle {
        right: 12px;
        bottom: 12px;
        width: 96px;
        height: 96px;
    }

    .flo-toggle-icon {
        width: 96px;
        height: 96px;
    }
}

/* ==========================================================================
   Motion
   ========================================================================== */
@keyframes floMessageIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes floMenuIn {
    from { opacity: 0; transform: translateY(-4px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes floPulse {
    0%, 100% { transform: scale(0.92); opacity: 0.7; }
    50% { transform: scale(1.08); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
    .chatbot-container,
    .chatbot-container *,
    .chatbot-toggle * {
        animation: none !important;
        transition: none !important;
    }
}
