html {
  font-size: 14px;
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

html {
  position: relative;
  min-height: 100%;
}

body {
  margin-bottom: 60px;
}

.ai-answer {
    white-space: pre-wrap;
    line-height: 1.6;
    overflow-wrap: anywhere;
}

.conversation-panel {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.ai-assistant-message {
    align-self: flex-start;
    background: #f1f3f5;
}

.ai-page {
    max-width: 1000px;
    margin: 0 auto;
    padding: 24px 16px 48px;
}

.ai-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
    margin-bottom: 24px;
}

.ai-title {
    margin-bottom: 6px;
    font-size: 2rem;
    font-weight: 700;
}

.ai-subtitle {
    margin: 0;
    color: #6c757d;
}

.conversation-panel {
    min-height: 420px;
    max-height: 620px;
    overflow-y: auto;
    padding: 24px;
    border: 1px solid #dee2e6;
    border-radius: 14px;
    background-color: #ffffff;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
}

.empty-conversation {
    min-height: 360px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: #6c757d;
    text-align: center;
}

    .empty-conversation h4 {
        color: #343a40;
        margin-bottom: 8px;
    }

.message-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.prompt-container {
    margin-top: 28px;
    padding: 20px;
    border: 1px solid #dee2e6;
    border-radius: 14px;
    background-color: #ffffff;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.05);
}

.prompt-label {
    font-weight: 600;
}

.prompt-textarea {
    resize: vertical;
    min-height: 90px;
}

.prompt-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 14px;
}

.ai-loading {
    font-size: 0.95rem;
    color: #6c757d;
}

.diagnostics-panel {
    margin-top: 32px;
    border: 1px solid #dee2e6;
    border-radius: 12px;
    background-color: #f8f9fa;
    overflow: hidden;
}

.diagnostics-header {
    padding: 12px 16px;
    font-weight: 600;
    border-bottom: 1px solid #dee2e6;
    background-color: #f1f3f5;
}

.diagnostics-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 16px;
    padding: 16px;
}

.diagnostic-item-wide {
    grid-column: span 4;
}

.diagnostic-item-outcome {
    grid-column: span 1;
}

.diagnostic-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.diagnostic-label {
    font-size: 0.8rem;
    color: #6c757d;
}

.diagnostic-value {
    font-weight: 600;
    color: #212529;
}

.ai-chat-message {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    width: 100%;
}

.ai-message-avatar {
    flex: 0 0 40px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 0.8rem;
    font-weight: 700;
}

.ai-message-bubble {
    width: auto;
    max-width: 78%;
    min-height: 0;
    padding: 12px 16px;
    border-radius: 16px;
}

.ai-thinking-bubble {
    min-width: 170px;
}

.ai-thinking-content {
    display: flex;
    align-items: center;
    gap: 9px;
    color: #6c757d;
}

.ai-thinking-dots {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

    .ai-thinking-dots span {
        width: 6px;
        height: 6px;
        border-radius: 50%;
        background-color: currentColor;
        animation: ai-thinking-pulse 1.2s infinite ease-in-out;
    }

        .ai-thinking-dots span:nth-child(1) {
            animation-delay: 0s;
        }

        .ai-thinking-dots span:nth-child(2) {
            animation-delay: 0.15s;
        }

        .ai-thinking-dots span:nth-child(3) {
            animation-delay: 0.3s;
        }

@keyframes ai-thinking-pulse {
    0%, 60%, 100% {
        opacity: 0.35;
        transform: translateY(0);
    }

    30% {
        opacity: 1;
        transform: translateY(-3px);
    }
}

.ai-message-sender {
    margin-bottom: 5px;
    font-size: 0.8rem;
    font-weight: 700;
}

/*.ai-message-text {
    margin: 0;
    line-height: 1.6;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}*/

.ai-message-text {
    line-height: 1.6;
    overflow-wrap: anywhere;
}

/* User message */
.ai-user-message .ai-message-text {
    white-space: pre-wrap;
}

.ai-user-message {
    flex-direction: row-reverse;
}

    .ai-user-message .ai-message-bubble {
        background-color: #dbeafe;
        color: #212529;
        border-bottom-right-radius: 4px;
    }

    .ai-user-message .ai-message-avatar {
        background-color: #0d6efd;
        .ai-user-message .ai-message-text color: #ffffff;
    }

    .ai-user-message .ai-message-sender {
        text-align: right;
        color: #495057;
    }

/* AI message */

.ai-assistant-message {
    flex-direction: row;
}

    .ai-assistant-message .ai-message-bubble {
        background-color: #f1f3f5;
        color: #212529;
        border-bottom-left-radius: 4px;
    }

    .ai-assistant-message .ai-message-avatar {
        background-color: #212529;
        color: #ffffff;
    }

    .ai-assistant-message .ai-message-sender {
        color: #6c757d;
    }

@media (max-width: 768px) {
    .ai-message-bubble {
        max-width: 85%;
    }

    .ai-message-avatar {
        flex-basis: 34px;
        width: 34px;
        height: 34px;
        font-size: 0.7rem;
    }
}

.diagnostics-panel {
    margin-top: 32px;
    border: 1px solid #dee2e6;
    border-radius: 12px;
    background-color: #f8f9fa;
    overflow: hidden;
}

.diagnostics-toggle {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 13px 16px;
    border: none;
    background-color: #f1f3f5;
    font-weight: 600;
    color: #212529;
    text-align: left;
    cursor: pointer;
}

    .diagnostics-toggle:hover {
        background-color: #e9ecef;
    }

    .diagnostics-toggle:focus-visible {
        outline: 3px solid rgba(13, 110, 253, 0.25);
        outline-offset: -3px;
    }

.diagnostics-chevron {
    display: inline-block;
    transition: transform 0.2s ease;
}

.diagnostics-toggle[aria-expanded="true"]
.diagnostics-chevron {
    transform: rotate(180deg);
}

.diagnostics-content {
    border-top: 1px solid #dee2e6;
}

.diagnostic-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.diagnostic-label {
    font-size: 0.8rem;
    color: #6c757d;
}

.diagnostic-value {
    font-weight: 600;
    color: #212529;
}

@media (max-width: 768px) {
    .diagnostics-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

.ai-message-text > :first-child {
    margin-top: 0;
}

.ai-message-text > :last-child {
    margin-bottom: 0;
}

.ai-message-text p {
    margin-bottom: 0.85rem;
}

.ai-message-text h1,
.ai-message-text h2,
.ai-message-text h3,
.ai-message-text h4 {
    margin-top: 1.2rem;
    margin-bottom: 0.7rem;
    line-height: 1.3;
}

.ai-message-text h1 {
    font-size: 1.5rem;
}

.ai-message-text h2 {
    font-size: 1.3rem;
}

.ai-message-text h3 {
    font-size: 1.15rem;
}

.ai-message-text ul,
.ai-message-text ol {
    margin-bottom: 1rem;
    padding-left: 1.5rem;
}

.ai-message-text li {
    margin-bottom: 0.35rem;
}

.ai-message-text blockquote {
    margin: 1rem 0;
    padding: 0.75rem 1rem;
    border-left: 4px solid #adb5bd;
    background-color: rgba(0, 0, 0, 0.03);
    color: #495057;
}

.ai-message-text code {
    padding: 0.15rem 0.35rem;
    border-radius: 4px;
    background-color: #e9ecef;
    font-family: Consolas, Monaco, "Courier New", monospace;
    font-size: 0.9em;
}

.ai-message-text pre {
    margin: 1rem 0;
    padding: 1rem;
    overflow-x: auto;
    border-radius: 8px;
    background-color: #212529;
    color: #f8f9fa;
}

    .ai-message-text pre code {
        padding: 0;
        background-color: transparent;
        color: inherit;
        font-size: 0.9rem;
    }

.ai-message-text table {
    width: 100%;
    margin: 1rem 0;
    border-collapse: collapse;
}

.ai-message-text th,
.ai-message-text td {
    padding: 0.65rem;
    border: 1px solid #dee2e6;
    text-align: left;
}

.ai-message-text th {
    background-color: #e9ecef;
}

.agent-trace-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.agent-trace-step {
    display: flex;
    gap: 1rem;
    padding: 1rem 0;
    border-bottom: 1px solid #e5e7eb;
}

    .agent-trace-step:last-child {
        border-bottom: none;
    }

.agent-trace-marker {
    width: 2rem;
    height: 2rem;
    flex: 0 0 2rem;
    border-radius: 50%;
    border: 1px solid #ced4da;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

.agent-trace-body {
    flex: 1;
    min-width: 0;
}

.agent-trace-title {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.agent-trace-title {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.agent-trace-reason {
    font-size: 0.9rem;
    color: #6c757d;
}

.agent-trace-observation {
    margin-top: 0.75rem;
    padding: 0.75rem;
    background: #f8f9fa;
    border-radius: 0.375rem;
}

.agent-trace-observation-type {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    margin-bottom: 0.25rem;
}

.agent-trace-observation-summary {
    font-size: 0.9rem;
}

.agent-trace-planner {
    background: #eef6ff;
    border-left: 4px solid #0d6efd;
    padding: 10px;
    border-radius: 6px;
    font-weight: 600;
}

.agent-trace-observation {
    background: #f3fff5;
    border-left: 4px solid #198754;
}

.agent-trace-tool {
    background: #f8f3ff;
    border-left: 4px solid #6f42c1;
}

.agent-trace-step {
    position: relative;
    padding-left: 60px;
}

.agent-trace-step::before {
    content: "";
    position: absolute;
    left: 18px;
    top: 40px;
    bottom: -20px;
    width: 2px;
    background: #d9d9d9;
}

.agent-trace-step:last-child::before {
    display: none;
}

.conversation-history-card {
    max-height: 75vh;
    overflow: hidden;
}

#conversationList {
    max-height: 68vh;
    overflow-y: auto;
}

.conversation-history-item {
    text-align: left;
}

.conversation-history-title {
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conversation-history-meta {
    margin-top: 0.25rem;
    font-size: 0.8rem;
    color: #6c757d;
}

.conversation-history-item.active
.conversation-history-meta {
    color: rgba(255, 255, 255, 0.8);
}

.conversation-history-empty {
    padding: 1rem;
    font-size: 0.9rem;
    color: #6c757d;
}

.conversation-history-main {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.conversation-open-button {
    flex: 1;
    min-width: 0;
    border: 0;
    background: transparent;
    text-align: left;
    padding: 0;
}

.conversation-history-actions {
    display: flex;
    align-items: center;
    gap: 0.15rem;
}

.conversation-history-actions .btn {
    padding: 0.15rem 0.3rem;
    text-decoration: none;
}

.conversation-history-item.active {
    background-color: #0d6efd;
    color: #fff;
}

.conversation-history-item.active
.conversation-open-button {
    color: #fff;
}

.conversation-history-item.active
.conversation-history-meta {
    color: rgba(255, 255, 255, 0.8);
}

.report-artifact {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-top: 16px;
    padding: 12px 14px;
    border: 1px solid #dee2e6;
    border-radius: 8px;
}

.report-artifact-info {
    min-width: 0;
}

.report-artifact-title {
    font-weight: 600;
    margin-bottom: 2px;
}

.report-artifact-file {
    font-size: 0.875rem;
    color: #6c757d;
    overflow-wrap: anywhere;
}

.report-artifact .btn {
    flex-shrink: 0;
}