/* ============================================================================
   AI chat component (<ai-chat>) — shared styles
   Used by #/experts/ai-search and #/knowledge-base/query.
   Class prefix: .ai-chat-*
   ========================================================================= */

/* The <ai-chat> element itself must fill the remaining height of the
   .ai-chat-page flex column (below the page's tab navigation row). */
ai-chat {
    display: flex;
    flex: 1;
    min-width: 0;
    min-height: 0;
}

/* Make the host page fill the viewport height */
.ai-chat-page {
    height: calc(100vh - 50px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.ai-chat-layout {
    display: flex;
    flex: 1;
    min-height: 0;
    gap: 0;
}

.ai-chat-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

/* Sidebar */
.ai-chat-sidebar {
    width: 280px;
    min-width: 280px;
    background: #fff;
    border-left: 1px solid #ddd;
    display: flex;
    flex-direction: column;
    transition: width 0.25s ease, min-width 0.25s ease, opacity 0.2s ease;
    overflow: hidden;
}

.ai-chat-sidebar.collapsed {
    width: 0;
    min-width: 0;
    border-left: none;
    opacity: 0;
    pointer-events: none;
}

.ai-chat-sidebar-header {
    padding: 12px 14px;
    border-bottom: 1px solid #eee;
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex-shrink: 0;
}

.ai-chat-sidebar-header .sidebar-top-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ai-chat-sidebar-header .sidebar-top-row h5 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: #333;
}

.ai-chat-sidebar-header .sidebar-top-row .ai-chat-sidebar-toggle-inside {
    background: none;
    border: none;
    color: #999;
    cursor: pointer;
    font-size: 13px;
    padding: 2px 4px;
    margin-left: auto;
    transition: color 0.15s;
}

.ai-chat-sidebar-header .sidebar-top-row .ai-chat-sidebar-toggle-inside:hover {
    color: #007bff;
}

.ai-chat-sidebar-list {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

.ai-chat-sidebar-group-label {
    padding: 10px 14px 4px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    color: #999;
    letter-spacing: 0.5px;
}

.ai-chat-sidebar-item {
    padding: 10px 14px;
    cursor: pointer;
    border-bottom: 1px solid #f5f5f5;
    transition: background 0.15s;
}

.ai-chat-sidebar-item:hover {
    background: #f0f4ff;
}

.ai-chat-sidebar-item.active {
    background: #e8f0fe;
    border-left: 3px solid #007bff;
    padding-left: 11px;
}

.ai-chat-sidebar-item .session-row {
    display: flex;
    align-items: flex-start;
    gap: 6px;
}

.ai-chat-sidebar-item .session-info {
    flex: 1;
    min-width: 0;
}

.ai-chat-sidebar-item .session-title {
    font-size: 13px;
    font-weight: 500;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
}

.ai-chat-sidebar-item .session-time {
    font-size: 11px;
    color: #999;
}

.ai-chat-sidebar-item .session-status-indicator {
    flex-shrink: 0;
    font-size: 11px;
    color: #007bff;
    animation: ai-chat-pulsate 1.5s ease-in-out infinite;
}

.ai-chat-sidebar-item .session-delete {
    flex-shrink: 0;
    background: none;
    border: none;
    color: #ccc;
    padding: 0 2px;
    font-size: 13px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s, color 0.15s;
    line-height: 1;
}

.ai-chat-sidebar-item:hover .session-delete {
    opacity: 1;
}

.ai-chat-sidebar-item .session-delete:hover {
    color: #dc3545;
}

.ai-chat-sidebar-empty {
    padding: 20px 14px;
    text-align: center;
    color: #999;
    font-size: 13px;
}

.ai-chat-sidebar-toggle-collapsed-wrapper {
    position: absolute;
    right: 10px;
    top: 10px;
    z-index: 10;
}

.ai-chat-sidebar-toggle-collapsed {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 6px 10px;
    cursor: pointer;
    color: #666;
    font-size: 14px;
    line-height: 1;
    transition: color 0.15s, background 0.15s, border-color 0.15s;
}

.ai-chat-sidebar-toggle-collapsed:hover {
    background: #f0f4ff;
    color: #007bff;
    border-color: #cce0ff;
}

.ai-chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
}

.ai-chat-initial-state {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    border-radius: 8px;
}

.ai-chat-initial-container {
    max-width: 800px;
    width: 100%;
    text-align: center;
    padding: 40px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.ai-chat-initial-container h3 {
    color: #007bff;
    margin-bottom: 10px;
}

.ai-chat-initial-container p {
    margin-bottom: 25px;
}

/* Hero variant of the composer card (first message): borderless
   auto-growing textarea with the reasoning chip and the round send
   button in a footer row inside the card. It overrides the base
   composer's right padding because its button is not floating. */
.ai-chat-composer.ai-chat-composer-initial {
    display: flex;
    flex-direction: column;
    gap: 6px;
    text-align: left;
    padding: 16px 18px 12px 18px;
    border-radius: 20px;
}

.ai-chat-composer.ai-chat-composer-initial .ai-chat-composer-input {
    min-height: 84px;
    max-height: 240px;
    font-size: 15px;
}

.ai-chat-composer-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.ai-chat-composer-footer .ai-chat-reasoning-picker {
    margin: 0;
}

.ai-chat-composer-footer .ai-chat-reasoning-picker select {
    border: 1px solid #dfe3e8;
    border-radius: 8px;
    box-shadow: none;
    background: #fff;
    padding: 2px 20px 2px 8px;
    height: auto;
    font-size: 12px;
    color: #555;
}

.ai-chat-composer-footer .ai-chat-send-btn {
    margin-left: auto;
}

.ai-chat-conversation {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: #f8f9fa;
    border-radius: 8px;
}

.ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px 8px 0 0;
}

.ai-chat-message {
    margin-bottom: 20px;
}

.ai-chat-user-bubble {
    margin-left: 20%;
    background: linear-gradient(135deg, #007bff, #0056b3);
    color: white;
    padding: 12px 18px;
    border-radius: 18px 18px 4px 18px;
    box-shadow: 0 2px 4px rgba(0, 123, 255, 0.3);
}

.ai-chat-user-bubble .msg-header {
    margin-bottom: 5px;
    opacity: 0.9;
    font-size: 12px;
}

.ai-chat-user-bubble .msg-text {
    font-size: 14px;
    line-height: 1.5;
    white-space: pre-wrap;
}

/* Assistant answers carry no box and no header (DeepSeek Harness style):
   the text flows directly on the conversation background. */
.ai-chat-assistant-bubble {
    color: #333;
}

.ai-chat-assistant-bubble .msg-content {
    font-size: 14px;
    line-height: 1.6;
    color: #333;
}

.ai-chat-assistant-bubble .msg-content p { margin-bottom: 8px; }
.ai-chat-assistant-bubble .msg-content h1,
.ai-chat-assistant-bubble .msg-content h2,
.ai-chat-assistant-bubble .msg-content h3 { margin-top: 12px; margin-bottom: 8px; }
.ai-chat-assistant-bubble .msg-content ul,
.ai-chat-assistant-bubble .msg-content ol { margin-bottom: 8px; padding-left: 20px; }
.ai-chat-assistant-bubble .msg-content code {
    background: #e9ecef;
    padding: 1px 4px;
    border-radius: 3px;
    font-size: 13px;
}
.ai-chat-assistant-bubble .msg-content pre {
    background: #2d2d2d;
    color: #f8f8f2;
    padding: 12px;
    border-radius: 6px;
    overflow-x: auto;
    font-size: 13px;
}
.ai-chat-assistant-bubble .msg-content pre code {
    background: none;
    padding: 0;
    color: inherit;
}
.ai-chat-assistant-bubble .msg-content table {
    border-collapse: collapse;
    margin-bottom: 8px;
}
.ai-chat-assistant-bubble .msg-content table th,
.ai-chat-assistant-bubble .msg-content table td {
    border: 1px solid #ddd;
    padding: 4px 8px;
}

.ai-chat-assistant-bubble .msg-content a {
    color: #1aa1e0;
    transition: all 300ms;
}

.ai-chat-assistant-bubble .msg-content a:hover {
    color: #116992;
}

/* Errors keep a visible marker now that answers have no box: a red left
   rule and tinted text instead of a bordered card. */
.ai-chat-assistant-bubble.error-msg {
    border-left: 3px solid #dc3545;
    padding-left: 12px;
    color: #a94442;
}

/* Tool call styles */
.ai-chat-tool-call {
    background: #f8fff9;
    border: 1px solid #d4edda;
    border-left: 4px solid #28a745;
    border-radius: 6px;
    padding: 10px 14px;
    margin-bottom: 8px;
}

.ai-chat-tool-call .tool-header {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ai-chat-tool-call .tool-header .tool-icon {
    color: #28a745;
    font-size: 14px;
}

.ai-chat-tool-call .tool-header .tool-name {
    font-weight: 600;
    color: #28a745;
    font-size: 13px;
}

.ai-chat-tool-call .tool-header .tool-chevron {
    margin-left: 6px;
    font-size: 11px;
    color: #28a745;
    transition: transform 0.2s ease;
}

.ai-chat-tool-call .tool-header .tool-chevron.expanded {
    transform: rotate(90deg);
}

.ai-chat-tool-call .tool-header.clickable {
    cursor: pointer;
}

.ai-chat-tool-call .tool-header.clickable:hover .tool-name,
.ai-chat-tool-call .tool-header.clickable:hover .tool-chevron {
    color: #1e7e34;
}

@keyframes ai-chat-pulsate {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.ai-chat-tool-call .tool-name.ongoing {
    animation: ai-chat-pulsate 1.5s ease-in-out infinite;
}

/* Context checkpoint: the line a compaction leaves in the conversation, where
   the head of the history was folded into a summary so the turn would fit the
   model's window. Quieter than a tool call on purpose — it is not something the
   assistant did to the data, it is the assistant noticing its own memory. What
   it replaced stays readable above it, so this is a footnote, never a warning. */
.ai-chat-compaction {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin: 4px 0 10px;
    padding: 6px 12px;
    border: 1px dashed #cfd6dd;
    border-radius: 6px;
    background: #fbfcfd;
    color: #6b7683;
    font-size: 12px;
}

.ai-chat-compaction.expandable {
    cursor: pointer;
}

.ai-chat-compaction .compaction-icon {
    font-size: 12px;
    color: #8a95a1;
}

.ai-chat-compaction .compaction-label {
    font-weight: 600;
}

.ai-chat-compaction .compaction-chevron {
    font-size: 10px;
    transition: transform 0.2s ease;
}

.ai-chat-compaction .compaction-chevron.expanded {
    transform: rotate(90deg);
}

/* The summarizer is a model call of its own: the pause is real, so the line
   says it is happening rather than appearing after the fact. */
.ai-chat-compaction.pending .compaction-label {
    animation: ai-chat-pulsate 1.5s ease-in-out infinite;
}

/* Nothing was folded (the summary saved nothing, or the host refused). The
   conversation carried on whole, so this is informational, not an error. */
.ai-chat-compaction.failed {
    border-color: #e8d9a8;
    background: #fdfcf6;
    color: #8a7a3e;
}

.ai-chat-compaction.failed .compaction-icon {
    color: #b39b4e;
}

.ai-chat-compaction .compaction-body {
    flex-basis: 100%;
    margin-top: 4px;
    padding-top: 6px;
    border-top: 1px dashed #e3e8ee;
    color: #4d5660;
    font-size: 12px;
    max-height: 340px;
    overflow-y: auto;
}

.ai-chat-compaction .compaction-body h2 {
    font-size: 12px;
    font-weight: 700;
    margin: 8px 0 2px;
    color: #3d4650;
}

.ai-chat-compaction .compaction-body ul,
.ai-chat-compaction .compaction-body p {
    margin: 0 0 4px;
}

/* Reasoning ("thinking") styles: a single line where the text flows — the end
   of the thinking stays visible while its beginning runs off the left edge —
   and which expands on click. */
.ai-chat-reasoning {
    background: #f8f9fa;
    border: 1px solid #e2e5e9;
    border-left: 4px solid #6c757d;
    border-radius: 6px;
    padding: 7px 14px;
    margin-bottom: 8px;
    cursor: pointer;
}

.ai-chat-reasoning:hover {
    background: #f1f3f5;
}

.ai-chat-reasoning .reasoning-line {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.ai-chat-reasoning .reasoning-icon {
    color: #6c757d;
    font-size: 13px;
    flex: 0 0 auto;
}

.ai-chat-reasoning .reasoning-label {
    font-weight: 600;
    color: #6c757d;
    font-size: 12px;
    white-space: nowrap;
    flex: 0 0 auto;
}

.ai-chat-reasoning .reasoning-label.ongoing {
    animation: ai-chat-pulsate 1.5s ease-in-out infinite;
}

/* The flowing tail: the span is anchored to the right edge of the line and
   shifted back by its own width, so the end of the thinking stays in view as
   it grows — its beginning going out of the line on the left. */
.ai-chat-reasoning .reasoning-ticker {
    position: relative;
    flex: 1 1 auto;
    min-width: 0;
    height: 17px;
    overflow: hidden;
}

.ai-chat-reasoning .reasoning-ticker span {
    position: absolute;
    left: 100%;
    top: 0;
    transform: translateX(-100%);
    white-space: nowrap;
    font-size: 12px;
    font-style: italic;
    color: #6c757d;
    line-height: 17px;
}

/* Until the thinking is long enough to overflow the line, keep it flush left */
.ai-chat-reasoning .reasoning-ticker.from-left span {
    left: 0;
    transform: none;
}

.ai-chat-reasoning .reasoning-chevron {
    margin-left: auto;
    font-size: 11px;
    color: #6c757d;
    transition: transform 0.2s ease;
    flex: 0 0 auto;
}

.ai-chat-reasoning .reasoning-chevron.expanded {
    transform: rotate(90deg);
}

.ai-chat-reasoning .reasoning-body {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #e2e5e9;
    max-height: 320px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 12.5px;
    line-height: 1.5;
    color: #495057;
}

/* Folded turn steps (DeepSeek Harness style): one subdued summary line
   ("7 tool calls - 2 messages ›") standing in for a finished turn's tool
   calls, thinking and mid-turn texts; clicking it expands them back. */
.ai-chat-turn-steps {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f8f9fa;
    border: 1px solid #e2e5e9;
    border-radius: 6px;
    padding: 7px 14px;
    margin-bottom: 8px;
    cursor: pointer;
    user-select: none;
}

.ai-chat-turn-steps:hover {
    background: #f1f3f5;
}

.ai-chat-turn-steps .steps-icon {
    color: #6c757d;
    font-size: 13px;
    flex: 0 0 auto;
}

.ai-chat-turn-steps .steps-label {
    font-weight: 600;
    color: #6c757d;
    font-size: 12px;
}

.ai-chat-turn-steps .steps-chevron {
    margin-left: auto;
    font-size: 11px;
    color: #6c757d;
    transition: transform 0.2s ease;
    flex: 0 0 auto;
}

.ai-chat-turn-steps .steps-chevron.expanded {
    transform: rotate(90deg);
}

.ai-chat-tool-call .tool-details {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #d4edda;
}

.ai-chat-tool-call .tool-details .detail-label {
    font-size: 11px;
    font-weight: 600;
    color: #6c757d;
    text-transform: uppercase;
    margin-bottom: 4px;
}

.ai-chat-tool-call .tool-details pre {
    background: #f1f3f4;
    border: 1px solid #d4edda;
    border-radius: 4px;
    padding: 8px;
    font-size: 12px;
    margin: 4px 0 10px 0;
    max-height: 200px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-word;
}

/* Input area — holds the composer card (restyled DeepSeek Harness style) */
.ai-chat-input-area {
    background: transparent;
    border-radius: 0 0 8px 8px;
    padding: 10px 15px 15px 15px;
}

/* Composer card: one rounded container, borderless auto-growing textarea
   inside (see autoGrowComposer in the component), round action button
   floating in the bottom-right corner. */
.ai-chat-composer {
    position: relative;
    display: block;
    background: #fff;
    border: 1px solid #dfe3e8;
    border-radius: 18px;
    padding: 12px 56px 12px 16px;
    box-shadow: 0 1px 3px rgba(16, 24, 40, 0.05);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.ai-chat-composer:focus-within {
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.14);
}

.ai-chat-composer .ai-chat-composer-input {
    display: block;
    width: 100%;
    min-height: 34px;
    max-height: 176px;
    overflow-y: auto;
    border: none;
    outline: none;
    box-shadow: none;
    background: transparent;
    resize: none;
    padding: 6px 0;
    margin: 0;
    font-size: 14px;
    line-height: 1.4;
    color: #333;
}

.ai-chat-composer .ai-chat-composer-input:focus {
    border: none;
    box-shadow: none;
}

.ai-chat-composer .ai-chat-composer-input::placeholder {
    color: #9aa4b0;
}

.ai-chat-composer .ai-chat-composer-input:disabled {
    background: transparent;
    opacity: 0.6;
}

.ai-chat-composer-actions {
    position: absolute;
    right: 10px;
    bottom: 10px;
}

.ai-chat-send-btn {
    width: 38px;
    height: 38px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: #007bff;
    color: #fff;
    font-size: 15px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.15s ease, opacity 0.15s ease, transform 0.1s ease;
}

.ai-chat-send-btn:hover {
    background: #0069d9;
    color: #fff;
}

.ai-chat-send-btn:active {
    transform: scale(0.94);
}

.ai-chat-send-btn[disabled] {
    background: #c3d4e8;
    cursor: default;
    transform: none;
}

.ai-chat-send-btn.ai-chat-stop-btn {
    background: #d9534f;
}

.ai-chat-send-btn.ai-chat-stop-btn:hover {
    background: #c9302c;
}

.ai-chat-send-btn.ai-chat-stop-btn[disabled] {
    background: #eba9a7;
}

/* Streaming indicator */
.ai-chat-streaming-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 0;
    color: #6c757d;
    font-size: 13px;
}

.ai-chat-streaming-indicator .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #007bff;
    animation: ai-chat-dot-pulse 1.2s ease-in-out infinite;
}

.ai-chat-streaming-indicator .dot:nth-child(2) { animation-delay: 0.2s; }
.ai-chat-streaming-indicator .dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes ai-chat-dot-pulse {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

/* Entity action menus (injected into rendered markdown by aiChatEnhancements directive) */
.ai-chat-entity-wrapper {
    display: inline;
    position: relative;
}

.ai-chat-entity-action-btn {
    display: inline-block;
    background: none;
    border: 1px solid #ddd;
    border-radius: 3px;
    color: #999;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    line-height: 1;
    padding: 0 2px 0 3px;
    margin-left: 1px;
    vertical-align: baseline;
    letter-spacing: 1px;
    transition: color 0.15s, background 0.15s, border-color 0.15s;
}

.ai-chat-entity-action-btn:hover {
    color: #007bff;
    background: #f0f4ff;
    border-color: #cce0ff;
}

.ai-chat-entity-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 1050;
    min-width: 180px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    padding: 4px 0;
    margin-top: 2px;
    white-space: nowrap;
}

.ai-chat-entity-dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 14px;
    font-size: 13px;
    color: #333;
    cursor: pointer;
    transition: background 0.12s;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
}

.ai-chat-entity-dropdown-item:hover {
    background: #f0f4ff;
    color: #007bff;
}

.ai-chat-entity-dropdown-item.loading {
    color: #999;
    pointer-events: none;
}

.ai-chat-entity-dropdown-item i {
    width: 16px;
    text-align: center;
    font-size: 13px;
}

/* Leading icon inside entity links (XC expert X, LinkedIn "in"), injected by
   the aiChatEnhancements directive — part of the clickable link, left of the
   link text. Assets: /images/icons/xc-icon.svg, /images/icons/linkedin-icon.png */
.ai-chat-link-icon {
    display: inline-block;
    width: 1.05em;
    height: 1.05em;
    margin-right: 4px;
    vertical-align: -0.15em;
}

/* Action buttons below the last assistant message of a turn: plain row
   under the text, no separator rule (the answers have no box anymore). */
.ai-chat-copy-footer {
    display: flex;
    justify-content: flex-start;
    margin-top: 8px;
    gap: 8px;
}

.ai-chat-copy-btn,
.ai-chat-regenerate-btn {
    background: none;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 4px 10px;
    font-size: 12px;
    color: #6c757d;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: color 0.15s, background 0.15s, border-color 0.15s;
}

.ai-chat-copy-btn:hover,
.ai-chat-regenerate-btn:hover {
    color: #007bff;
    background: #f0f4ff;
    border-color: #cce0ff;
}

.ai-chat-copy-btn.copied {
    color: #28a745;
    border-color: #c3e6cb;
    background: #f0fff4;
}

.ai-chat-regenerate-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* Reasoning level of a session: chosen once, when the session is created */
.ai-chat-reasoning-picker {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.ai-chat-reasoning-picker label {
    margin: 0;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: #6c757d;
    white-space: nowrap;
}

.ai-chat-reasoning-picker select {
    width: auto;
    max-width: 220px;
    font-size: 13px;
}

.ai-chat-reasoning-picker .ai-chat-reasoning-note {
    font-size: 12px;
    color: #999;
}

/* The same level, read-only once the session exists */
.ai-chat-reasoning-badge {
    display: flex;
    align-items: baseline;
    gap: 6px;
    margin-bottom: 6px;
    font-size: 12px;
    color: #6c757d;
}

.ai-chat-reasoning-badge .reasoning-value {
    font-weight: 600;
    color: #495057;
}

.ai-chat-reasoning-badge .reasoning-fallback {
    color: #c0392b;
}

/* Responsive */
@media (max-width: 768px) {
    .ai-chat-user-bubble { margin-left: 5%; }
    .ai-chat-initial-container { margin: 20px; padding: 30px 20px; }
    .ai-chat-page { height: calc(100vh - 100px); }
    .ai-chat-reasoning-picker { flex-wrap: wrap; }
}

/* --------------------------------------------------------------------------
   "Ask questions" card (ask_user_question tool) — replaces the composer
   while the agent waits for an answer. See the "Ask questions" block in
   scripts/common/aiChat.component.js.
   -------------------------------------------------------------------------- */
.ai-chat-question-card {
    background: #fff;
    border: 1px solid #007bff;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
    overflow: hidden;
}

.ai-chat-question-card .q-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px 10px 18px;
}

.ai-chat-question-card .q-heading {
    min-width: 0;
}

.ai-chat-question-card .q-eyebrow {
    color: #6c757d;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-bottom: 3px;
}

.ai-chat-question-card .q-title {
    font-size: 15px;
    font-weight: 600;
    line-height: 21px;
}

.ai-chat-question-card .q-header-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.ai-chat-question-card .q-icon-btn {
    width: 26px;
    height: 26px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: none;
    color: #868e96;
    line-height: 1;
}

.ai-chat-question-card .q-icon-btn:hover:not(:disabled) {
    background: #f0f4ff;
    color: #343a40;
}

.ai-chat-question-card .q-icon-btn:disabled {
    opacity: 0.5;
    cursor: default;
}

.ai-chat-question-card .q-body {
    border-top: 1px solid #f0f0f0;
    padding: 6px 8px 10px;
}

.ai-chat-question-card .q-options {
    display: flex;
    flex-direction: column;
}

.ai-chat-question-card .q-option,
.ai-chat-question-card .q-custom-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    width: 100%;
    min-height: 40px;
    padding: 8px 10px;
    margin-top: 2px;
    border: 1px solid transparent;
    border-radius: 8px;
    background: none;
    color: inherit;
    text-align: left;
    font: inherit;
    transition: background 0.12s, border-color 0.12s;
}

.ai-chat-question-card button.q-option {
    cursor: pointer;
}

.ai-chat-question-card .q-option:hover:not(:disabled),
.ai-chat-question-card .q-option.selected,
.ai-chat-question-card .q-custom-row:hover,
.ai-chat-question-card .q-custom-row.active,
.ai-chat-question-card .q-custom-row:focus-within {
    background: #f0f4ff;
    border-color: #cce0ff;
}

.ai-chat-question-card .q-option:disabled {
    cursor: default;
    opacity: 0.7;
}

.ai-chat-question-card .q-number,
.ai-chat-question-card .q-checkbox {
    flex: 0 0 20px;
    width: 20px;
    height: 20px;
    margin-top: 1px;
    display: grid;
    place-items: center;
    color: #6c757d;
    font-size: 12px;
    font-weight: 600;
}

.ai-chat-question-card .q-number {
    background: #f1f3f5;
    border-radius: 5px;
}

.ai-chat-question-card .q-checkbox .fa {
    font-size: 16px;
    color: #007bff;
}

.ai-chat-question-card .q-option-copy {
    flex: 1;
    min-width: 0;
}

.ai-chat-question-card .q-option-line {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 2px 8px;
}

.ai-chat-question-card .q-option-label {
    font-size: 14px;
    font-weight: 500;
    line-height: 20px;
}

.ai-chat-question-card .q-badge {
    background: #007bff;
    color: #fff;
    border-radius: 4px;
    padding: 0 5px;
    font-size: 10px;
    font-weight: 600;
    line-height: 16px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.ai-chat-question-card .q-description {
    display: block;
    color: #6c757d;
    font-size: 13px;
    line-height: 18px;
    margin-top: 1px;
}

.ai-chat-question-card .q-custom-field {
    flex: 1;
    min-height: 0;
    border: none;
    background: none;
    padding: 1px 0;
    font-size: 14px;
    line-height: 20px;
    resize: none;
    overflow-y: hidden;
}

.ai-chat-question-card .q-custom-field:focus {
    outline: none;
    box-shadow: none;
}

.ai-chat-question-card .q-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 10px;
    padding: 0 8px;
}

.ai-chat-question-card .q-pager {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.ai-chat-question-card .q-pager button {
    width: 26px;
    height: 26px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: none;
    color: #868e96;
    line-height: 1;
}

.ai-chat-question-card .q-pager button:hover:not(:disabled) {
    background: #f0f4ff;
    color: #343a40;
}

.ai-chat-question-card .q-pager button:disabled {
    opacity: 0.4;
    cursor: default;
}

.ai-chat-question-card .q-progress {
    font-size: 13px;
    font-weight: 600;
    color: #495057;
    padding: 0 4px;
    white-space: nowrap;
}

.ai-chat-question-card .q-error {
    flex: 1;
    min-height: 16px;
    color: #a94442;
    font-size: 12px;
    line-height: 16px;
    text-align: right;
}

.ai-chat-question-card .q-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

/* Collapsed card: keep the pending question visible without eating the
   conversation area (the answer buttons hide with the body). */
.ai-chat-question-card.minimized .q-header {
    padding-bottom: 14px;
}

@media (max-width: 720px) {
    .ai-chat-question-card .q-footer {
        flex-wrap: wrap;
    }
    .ai-chat-question-card .q-actions {
        margin-left: auto;
    }
}

/* ---------------------------------------------------------------------------
   Stopped turn (tool calls left dangling by a dead request): banner at the
   end of the conversation offering to resume it (see resumeTurn() in
   scripts/common/aiChat.component.js).
   --------------------------------------------------------------------------- */
.ai-chat-interrupted {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 12px 0 4px;
    padding: 10px 14px;
    border: 1px solid #e6d9a8;
    border-left: 4px solid #d9a520;
    border-radius: 6px;
    background: #fdf8e7;
    color: #7a6014;
    font-size: 13px;
}

.ai-chat-interrupted .fa-exclamation-triangle {
    color: #d9a520;
}

.ai-chat-interrupted .interrupted-text {
    flex: 1 1 auto;
}

.ai-chat-interrupted .interrupted-resume-btn {
    flex-shrink: 0;
    background: #d9a520;
    border: 1px solid #c2920f;
    color: #fff;
    border-radius: 4px;
    padding: 5px 12px;
    font-size: 12px;
    line-height: 1.4;
    cursor: pointer;
}

.ai-chat-interrupted .interrupted-resume-btn:hover {
    background: #c2920f;
}

.ai-chat-interrupted .interrupted-resume-btn .fa {
    margin-right: 4px;
}

/* --- Browser notifications (chatNotifications service + aiChat hooks) --- */

/* Soft-ask strip shown above the composer when a turn starts. Same warm
   accent as the question-card note palette; deliberately low height. */
.ai-chat-notif-ask {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 8px 0;
    padding: 7px 12px;
    border: 1px solid #e6d9a8;
    border-radius: 8px;
    background: #fdf9ec;
    color: #6b5d1f;
    font-size: 12.5px;
    line-height: 1.35;
}

.ai-chat-notif-ask .fa {
    color: #b59b2f;
}

.ai-chat-notif-ask-btn {
    border: none;
    border-radius: 12px;
    background: #007bff;
    color: #fff;
    font-size: 12px;
    padding: 3px 10px;
    cursor: pointer;
    white-space: nowrap;
}

.ai-chat-notif-ask-btn:hover {
    background: #0069d9;
    color: #fff;
}

.ai-chat-notif-dismiss {
    border: none;
    background: none;
    color: #8a8a8a;
    font-size: 12px;
    padding: 3px 6px;
    cursor: pointer;
    text-decoration: underline;
    white-space: nowrap;
}

/* Bell toggle beside the send/stop button: quiet ghost circle, blue when
   notifications are actually on. */
.ai-chat-notif-bell {
    width: 38px;
    height: 38px;
    padding: 0;
    border: 1px solid #d5d9de;
    border-radius: 50%;
    background: transparent;
    color: #9aa2ab;
    font-size: 14px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: color 0.15s ease, border-color 0.15s ease;
}

.ai-chat-notif-bell:hover {
    color: #007bff;
    border-color: #007bff;
}

.ai-chat-notif-bell.on {
    color: #007bff;
    border-color: #9cc3f5;
}
