/* Common CSS styles for the application */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f8f9fa;
}

/* Headers use Merriweather font */
h1, h2, h3, h4, h5, h6,
.navbar-brand,
.display-1, .display-2, .display-3, .display-4, .display-5, .display-6 {
    font-family: 'Merriweather', serif;
}

/* Card adjustments */
.card {
    border-radius: 0.5rem;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    margin-bottom: 1.5rem;
}

.card-header {
    border-top-left-radius: 0.5rem !important;
    border-top-right-radius: 0.5rem !important;
}

/* Button styles */
.btn {
    border-radius: 0.3rem;
}

/* Custom colors */
.bg-primary {
    background-color: #1976d2 !important;
}

.text-primary {
    color: #1976d2 !important;
}

.btn-primary {
    background-color: #1976d2;
    border-color: #1976d2;
}

.btn-primary:hover {
    background-color: #1565c0;
    border-color: #1565c0;
}

/* Progress bar */
.progress {
    height: 1.5rem;
    font-size: 0.8rem;
    font-weight: bold;
    border-radius: 0.3rem;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
}
.back-link {
    margin-bottom: 15px;
    display: block;
}
.section {
    margin-bottom: 30px;
    background: #f9f9f9;
    border-radius: 5px;
    padding: 15px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.meta-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-top: 15px;
}
.meta-item {
    background: white;
    border-radius: 5px;
    padding: 15px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.meta-label {
    font-weight: bold;
    margin-bottom: 5px;
}
.status {
    text-align: center;
    font-weight: bold;
    padding: 5px 10px;
    border-radius: 4px;
    display: inline-block;
    min-width: 60px;
    cursor: help;
    position: relative;
}
.pass {
    background-color: #DFF2BF;
    color: #4F8A10;
}
.fail {
    background-color: #FFBABA;
    color: #D8000C;
}
.truncate {
    max-width: 300px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.error-details {
    font-size: 14px;
    color: #D8000C;
}
pre {
    background: #f5f5f5;
    padding: 15px;
    border-radius: 4px;
    overflow-x: auto;
    white-space: pre-wrap;
}

/* Table styling */
table {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
    font-size: 14px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    border-radius: 6px;
    overflow: hidden;
}

thead {
    background-color: #f0f0f0;
}

th {
    text-align: left;
    padding: 12px 15px;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 13px;
    letter-spacing: 0.03em;
    border-bottom: 2px solid #ddd;
}

td {
    padding: 12px 15px;
    border-bottom: 1px solid #eee;
    vertical-align: middle;
}

td a {
    color: #2196F3;
    text-decoration: none;
    font-weight: 500;
}

td a:hover {
    text-decoration: underline;
}

tbody tr:hover {
    background-color: #f9f9f9;
}

tbody tr:last-child td {
    border-bottom: none;
}

/* Column specific widths for evaluation results table */
.table:not(.client-settings-table) th:nth-child(1), 
.table:not(.client-settings-table) td:nth-child(1) { width: 20%; } /* Title */
.table:not(.client-settings-table) th:nth-child(2), 
.table:not(.client-settings-table) td:nth-child(2) { width: 25%; } /* Utterance */
.table:not(.client-settings-table) th:nth-child(3), 
.table:not(.client-settings-table) td:nth-child(3) { width: 40%; } /* Response */
.table:not(.client-settings-table) th:nth-child(4), 
.table:not(.client-settings-table) td:nth-child(4) { width: 15%; text-align: center; } /* Status */

/* Column widths for client settings table */
.client-settings-table th:nth-child(1), 
.client-settings-table td:nth-child(1) { width: 25%; } /* Device ID */
.client-settings-table th:nth-child(2), 
.client-settings-table td:nth-child(2) { width: 15%; } /* Feature Level */
.client-settings-table th:nth-child(3), 
.client-settings-table td:nth-child(3) { width: 15%; } /* Agent Implementation */
.client-settings-table th:nth-child(4), 
.client-settings-table td:nth-child(4) { width: 15%; } /* Media Search Type */
.client-settings-table th:nth-child(5), 
.client-settings-table td:nth-child(5) { width: 20%; } /* Last Modified */
.client-settings-table th:nth-child(6), 
.client-settings-table td:nth-child(6) { width: 10%; text-align: center; } /* Actions */
.trace-container {
    margin-top: 15px;
}
/* Success and error indicators */
.success {
    border-left: 4px solid #4CAF50;
}
.error {
    border-left: 4px solid #F44336;
}

/* Tool calls */
.tool-call {
    background: white;
    border-radius: 8px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    overflow: hidden;
}

/* RAG results */
.rag-result {
    background: white;
    border-radius: 8px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    overflow: hidden;
    padding: 15px;
}

/* LLM requests */
.llm-request {
    background: white;
    border-radius: 8px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    overflow: hidden;
}

.llm-request-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #f8f9fa;
    padding: 12px 15px;
    border-bottom: 1px solid #eee;
}

/* Function calls (in message tool calls) */
.function-call {
    background: #f9f9f9;
    border-radius: 6px;
    padding: 12px;
    margin: 10px 0;
    border-left: 3px solid #FF9800;
}

/* Tool definitions */
.tool-definition {
    background: white;
    border-radius: 8px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    overflow: hidden;
    padding: 15px;
    border-left: 4px solid #2196F3;
}
.tool-call-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #f8f9fa;
    padding: 12px 15px;
    border-bottom: 1px solid #eee;
}
.tool-name {
    font-weight: 600;
    font-size: 16px;
    color: #333;
}

/* LLM Request Header */
.llm-request-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 10px;
}

.request-title {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

/* LLM Role Badge */
.llm-role-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75em;
    font-weight: 500;
    background-color: #e9ecef;
    color: #495057;
    white-space: nowrap;
}

/* Special styling for common roles */
.llm-role-badge[title*="command"] {
    background-color: #e6f3ff;
    color: #0056b3;
}

.llm-role-badge[title*="butler"] {
    background-color: #e6f7e6;
    color: #1e7e34;
}

.llm-role-badge[title*="commentary"] {
    background-color: #fff3cd;
    color: #856404;
}

.llm-request {
    background: white;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.request-content {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.request-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
}

.request-meta > div {
    display: flex;
    align-items: center;
    gap: 5px;
}
.tool-metadata {
    display: flex;
    gap: 15px;
    font-size: 13px;
    color: #666;
    flex-wrap: wrap;
}

/* Tool classification and source badges */
.tool-classification {
    font-size: 0.8em;
    padding: 3px 8px;
    border-radius: 12px;
    font-weight: bold;
    margin-right: 10px;
    text-transform: uppercase;
    border: 1px solid;
}

.tool-source {
    font-size: 0.75em;
    padding: 2px 6px;
    border-radius: 10px;
    font-weight: 600;
    text-transform: uppercase;
    color: white;
    background-color: #6c757d;
}

.tool-source.source-spice {
    background-color: #28a745;
}

.tool-source.source-local_feature {
    background-color: #007bff;
}

.tool-source.source-client_tool {
    background-color: #ffc107;
    color: #212529;
}

.tool-source-details {
    font-size: 0.75em;
    padding: 2px 6px;
    border-radius: 10px;
    background-color: #e9ecef;
    color: #495057;
    font-weight: 500;
}

.classification-query {
    background-color: #e0f2f7;
    color: #007bff;
    border-color: #007bff;
}

.classification-action {
    background-color: #fff0e1;
    color: #fd7e14;
    border-color: #fd7e14;
}

.classification-n\/a {
    background-color: #e9ecef;
    color: #6c757d;
    border-color: #6c757d;
}
.tool-call-content {
    padding: 15px;
}
.tool-section {
    margin-bottom: 15px;
}
.section-title {
    font-weight: 600;
    margin-bottom: 10px;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #555;
}
.tool-args-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 10px;
    margin-bottom: 15px;
}
.tool-param {
    background-color: #f5f5f5;
    padding: 12px;
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.param-name {
    font-weight: 600;
    font-size: 13px;
    color: #555;
}
.param-value {
    font-family: monospace;
    word-break: break-all;
    background-color: #fff;
    padding: 8px;
    border-radius: 4px;
    border: 1px solid #eee;
}
.no-args {
    color: #999;
    font-style: italic;
}
.tool-result {
    margin: 0;
    background-color: #f5f5f5;
    padding: 12px;
    border-radius: 6px;
    overflow-y: auto;
}

/* Tool results in trace displays have specific positioning */
.tool-call .tool-result {
    margin-left: 20px;
    padding: 10px;
    border-radius: 4px;
}

/* Apply pre-wrap only to JSON content inside tool results */
.tool-result pre,
.tool-result .tool-result-json {
    white-space: pre-wrap;
}
details {
    margin: 10px 0;
    border-radius: 4px;
    border: 1px solid #eee;
}
details summary {
    padding: 8px 12px;
    background-color: #f8f9fa;
    cursor: pointer;
    border-radius: 4px;
}
details pre {
    margin: 0;
    padding: 12px;
    border-top: 1px solid #eee;
    max-height: 500px;
    overflow-y: auto;
}
.button {
    display: inline-block;
    padding: 6px 12px;
    background-color: #f8f9fa;
    border: 1px solid #ddd;
    border-radius: 4px;
    text-decoration: none;
    color: #333;
    transition: background-color 0.2s;
}
.button:hover {
    background-color: #e9ecef;
    text-decoration: none;
}
.message-summary {
    margin: 10px 0;
    padding: 10px;
    border-radius: 4px;
}
.user-message {
    background-color: #e3f2fd;
    border-left: 4px solid #2196F3;
}
.assistant-message {
    background-color: #e8f5e9;
    border-left: 4px solid #4CAF50;
}
.tool-message {
    background-color: #fff3e0;
    border-left: 4px solid #FF9800;
}
.warning {
    background-color: #ffebee;
    border-left: 4px solid #F44336;
}
.request-content {
    margin-top: 10px;
}

.request-summary {
    padding: 15px;
}
.tool-params-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}
.param-pill {
    display: inline-flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.7);
    border-radius: 20px;
    overflow: hidden;
    border: 1px solid #eee;
    font-size: 12px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.param-name {
    background-color: #f8f9fa;
    padding: 4px 8px;
    font-weight: 600;
    color: #555;
    border-right: 1px solid #eee;
}
.param-value {
    padding: 4px 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #333;
}
.error-code {
    color: #F44336;
    font-weight: bold;
}
.success-code {
    color: #4CAF50;
    font-weight: bold;
}
.code-block {
    font-family: monospace;
    background-color: #f8f9fa;
    padding: 12px;
    border-radius: 4px;
    border-left: 4px solid #4CAF50;
    margin: 10px 0;
    overflow-x: auto;
}
.message-content {
    margin-top: 5px;
}

/* Apply pre-wrap only to specific content that needs whitespace preservation */
.message-content pre,
.message-content .tool-result-json,
.tool-result pre,
.tool-result .tool-result-json {
    white-space: pre-wrap;
}

/* Apply pre-wrap to actual text content in expandable elements */
.expandable[open] > .expandable-content {
    white-space: pre-wrap;
}

/* Apply pre-wrap to direct text content only */
.message-text-content {
    white-space: pre-wrap;
}

/* Assertion checks styling */
.assertion-checks {
    margin-top: 15px;
    background-color: #f7f7f7;
    padding: 15px;
    border-radius: 5px;
}

.checks-list {
    list-style-type: none;
    margin-top: 5px;
    padding-left: 0;
}

.checks-list li {
    margin-bottom: 8px;
    padding: 10px;
    border-radius: 4px;
    font-size: 14px;
    background-color: #f9f9f9;
    position: relative;
    overflow: hidden;
    border-left: 3px solid transparent;
}

.check-success {
    color: #1e8e3e;
    border-left-color: #1e8e3e !important;
    background-color: #f0fff4 !important;
}

.check-failure {
    color: #d93025;
    border-left-color: #d93025 !important;
    background-color: #fff0f0 !important;
    font-weight: 500;
    box-shadow: 0 2px 4px rgba(217, 48, 37, 0.15);
}

.check-neutral {
    color: #555;
    border-left-color: #888 !important;
    background-color: #f9f9f9 !important;
}

.assertion-details-collapsible {
    margin-top: 15px;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
}

.details-summary {
    padding: 10px 15px;
    background-color: #f5f5f5;
    cursor: pointer;
    font-weight: 500;
    color: #555;
}

.assertion-details-json, 
.assertion-details-text {
    padding: 15px;
    background-color: #f9f9f9;
    margin: 0;
    font-size: 0.9em;
    overflow-x: auto;
    white-space: pre-wrap;
    font-family: monospace;
}

/* Styling for the details when expanded */
details[open] .details-summary {
    border-bottom: 1px solid #e0e0e0;
}

/* Failure banner styling */
.assertion-failure-banner {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    margin-bottom: 15px;
    background-color: #fff0f0;
    border-left: 4px solid #d93025;
    border-radius: 4px;
    font-weight: 500;
    box-shadow: 0 2px 4px rgba(217, 48, 37, 0.15);
}

.failure-icon {
    margin-right: 12px;
    font-size: 20px;
    color: #d93025;
}

.failure-message {
    color: #d93025;
    flex: 1;
    font-size: 15px;
}

/* Assertion card styling */
.assertion-card {
    background: white;
    border-radius: 8px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    overflow: hidden;
}

.assertion-card.assertion-pass {
    border-left: 4px solid #4CAF50;
}

.assertion-card.assertion-fail {
    border-left: 4px solid #F44336;
}

.assertion-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #f8f9fa;
    padding: 12px 15px;
    border-bottom: 1px solid #eee;
}

.assertion-type {
    font-weight: 600;
    font-size: 16px;
    color: #333;
}

/* Two-column assertion content layout */
.assertion-content {
    padding: 15px;
}

.assertion-expected, 
.assertion-details {
    background-color: #f9f9f9;
    border-radius: 6px;
    padding: 15px;
}

.assertion-label {
    font-weight: 600;
    margin-bottom: 10px;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #555;
}

/* Improved tool parameter display */
.tool-params-improved {
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tool-param-item {
    background-color: #f8f9fa;
    border-radius: 6px;
    padding: 10px;
    border: 1px solid #e9ecef;
}

.param-name-header {
    font-weight: 600;
    font-size: 12px;
    color: #495057;
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Enhanced tool result display */
.tool-result-structured {
    background-color: #f8f9fa;
    border-radius: 6px;
    padding: 12px;
    border: 1px solid #e9ecef;
}

/* Expandable content styling */
.expand-text {
    color: #007bff;
    font-size: 0.9em;
    font-weight: 500;
}

/* Universal expandable styling */
.expandable {
    border: none;
    margin: 0;
}

.expandable > summary {
    cursor: pointer;
    list-style: none;
    font-family: inherit;
    word-break: break-word;
}

.expandable > summary::-webkit-details-marker {
    display: none;
}

.expandable[open] > summary {
    display: none;
}

.expandable > .expandable-content {
    display: none;
}

.expandable[open] > .expandable-content {
    display: block;
    white-space: pre-wrap;
    word-break: break-word;
    margin: 0;
}

/* Default expandable styling - white background with border */
.expandable > summary {
    background-color: white;
    padding: 10px;
    border-radius: 4px;
    border: 1px solid #dee2e6;
    white-space: pre-wrap;
}

.expandable > summary:hover {
    background-color: #f8f9fa;
}

.expandable[open] > .expandable-content {
    background-color: white;
    padding: 10px;
    border-radius: 4px;
    border: 1px solid #dee2e6;
}

/* Other fields expandable styling */
.other-summary {
    font-size: 13px;
    color: #6c757d;
    cursor: pointer;
    padding: 8px 12px;
    background-color: #f8f9fa;
    border-radius: 4px;
}

.other-summary:hover {
    background-color: #e9ecef;
}

/* Content expandable styling for user/response content */
.content-expandable {
    border: none;
    margin: 0;
}

.content-expandable > summary {
    background-color: transparent;
    padding: 0;
    border: none;
    white-space: pre-wrap;
    word-break: break-word;
    cursor: pointer;
    font-family: inherit;
    list-style: none;
    color: inherit;
}

.content-expandable > summary:hover {
    background-color: rgba(0, 0, 0, 0.05);
    border-radius: 4px;
    padding: 4px;
    margin: -4px;
}

.content-expandable > summary::-webkit-details-marker {
    display: none;
}

/* Hide summary content when expanded, show full content */
.content-expandable[open] > summary {
    display: none;
}

.content-expandable > .content-expandable-content {
    display: none;
}

.content-expandable[open] > .content-expandable-content {
    display: block;
    word-break: break-word;
    margin: 0;
    color: inherit;
    background-color: transparent;
    padding: 0;
    border: none;
}

/* Apply pre-wrap specifically to user and assistant message content */
.user-message .content-expandable[open] > .content-expandable-content,
.assistant-message .content-expandable[open] > .content-expandable-content {
    white-space: pre-wrap;
}

/* JSON expandable styling */
.json-expandable {
    border: none;
    margin: 0;
}

.json-summary {
    cursor: pointer;
    padding: 10px;
    background-color: #f8f9fa;
    border-radius: 4px;
    list-style: none;
}

.json-summary:hover {
    background-color: #e9ecef;
}

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

.json-summary pre {
    margin: 0;
    display: inline;
    background: none;
    padding: 0;
    border: none;
}

/* Hide summary content when expanded, show full content */
.json-expandable[open] .json-summary {
    display: none;
}

.json-expandable .tool-result-json:not(.json-summary .tool-result-json) {
    display: none;
}

.json-expandable[open] .tool-result-json:not(.json-summary .tool-result-json) {
    display: block;
    margin: 0;
}

.tool-result-status {
    font-weight: 600;
    padding: 6px 10px;
    border-radius: 4px;
    margin-bottom: 10px;
    display: inline-block;
    font-size: 14px;
}

.tool-result-success {
    background-color: #d1edff;
    color: #0056b3;
    border: 1px solid #bee5eb;
}

.tool-result-error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.tool-result-response {
    margin-top: 10px;
}

.tool-result-error-msg {
    background-color: white;
    padding: 10px;
    border-radius: 4px;
    border: 1px solid #f5c6cb;
    color: #721c24;
    margin-top: 10px;
    white-space: pre-wrap;
    word-break: break-word;
}

.tool-result-other {
    margin-top: 10px;
}

.tool-result-other summary {
    font-size: 13px;
    color: #6c757d;
    cursor: pointer;
    padding: 3px 0;
}

.tool-result-json {
    background-color: white;
    padding: 10px;
    border-radius: 4px;
    border: 1px solid #dee2e6;
    margin: 0;
    max-height: 300px;
    overflow-y: auto;
    font-size: 13px;
}

.tool-result-text {
    background-color: white;
    padding: 10px;
    border-radius: 4px;
    border: 1px solid #dee2e6;
    white-space: pre-wrap;
    word-break: break-word;
    color: #495057;
}

/* Additional tool result styles for tool_formatter.py */
.tool-result-empty {
    color: #6c757d;
    font-style: italic;
    padding: 10px;
    background-color: #f8f9fa;
    border-radius: 4px;
}

.tool-result-json-container {
    background-color: #f8f9fa;
    border-radius: 6px;
    padding: 10px;
    border: 1px solid #e9ecef;
}

/* Field display styles for status pattern */
.tool-result-field {
    margin: 8px 0;
    padding: 8px 10px;
    background-color: white;
    border-radius: 4px;
    border: 1px solid #e9ecef;
}

.field-name {
    font-weight: 600;
    font-size: 12px;
    color: #495057;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.field-value {
    font-family: monospace;
    color: #495057;
    font-size: 13px;
    word-break: break-word;
}

/* Breadcrumb navigation styling */
.breadcrumb-custom {
    background: none;
    padding: 0;
    margin-bottom: 1rem;
}

.breadcrumb-custom .breadcrumb-item + .breadcrumb-item::before {
    content: "›";
    color: #6c757d;
}

.breadcrumb-custom a {
    color: #0d6efd;
    text-decoration: none;
}

.breadcrumb-custom a:hover {
    text-decoration: underline;
}
