html,
body {
    height: 100%;
    margin: 0;
    font-family: sans-serif;
    background-color: #f0f2f5;
}

body {
    padding: 20px;
    box-sizing: border-box;
}

.container {
    max-width: 960px;
    margin: 0 auto 100px auto;
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

h1,
h2 {
    color: #1c1e21;
}

.collapsible-header {
    cursor: pointer;
    user-select: none;
}

.toggle-icon {
    display: inline-block;
    transition: transform 0.2s;
}

.collapsible-header.collapsed .toggle-icon {
    transform: rotate(-90deg);
}

.collapsible-content {
    max-height: 1000px;
    overflow: hidden;
    transition: max-height 0.3s ease-in-out;
}

.collapsible-content.collapsed {
    max-height: 0;
}

#agent-card-section,
#chat-container {
    margin-top: 20px;
    border-top: 1px solid #ddd;
    padding-top: 20px;
}

.url-input-container,
.chat-input-container {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

.connect-btn-container {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 20px;
}

.http-headers-container,
.message-metadata-container {
    margin-bottom: 20px;
}

.http-headers-header,
.message-metadata-header {
    cursor: pointer;
    user-select: none;
    padding: 8px 0;
    font-weight: bold;
    color: #1c1e21;
}

.http-headers-content,
.message-metadata-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-in-out;
    padding: 0;
    margin: 0;
}

.http-headers-content.expanded,
.message-metadata-content.expanded {
    max-height: 500px;
    padding: 10px 0;
}

#headers-list,
#metadata-list {
    margin-bottom: 10px;
}

.header-item,
.metadata-item {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

.header-item input,
.metadata-item input {
    flex: 1;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.remove-header-btn,
.remove-metadata-btn {
    background-color: #dc3545;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 0 10px;
    cursor: pointer;
}

#add-header-btn,
#add-metadata-btn {
    background-color: #1877f2;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 8px 12px;
    cursor: pointer;
}

#agent-card-url,
#chat-input {
    flex-grow: 1;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

#connect-btn,
#send-btn {
    padding: 10px 15px;
    border: none;
    background-color: #1877f2;
    color: white;
    border-radius: 4px;
    cursor: pointer;
}

#chat-input:disabled,
#send-btn:disabled {
    background-color: #e4e6eb;
    cursor: not-allowed;
}

.agent-card-display {
    position: relative;
}

#agent-card-content {
    background-color: #f7f7f7;
    padding: 15px;
    border-radius: 4px;
    white-space: pre-wrap;
    word-wrap: break-word;
    max-height: 400px;
    overflow: auto;
}

#agent-card-content:empty {
    display: none;
}

.message {
    padding: 8px 12px;
    border-radius: 18px;
    margin-bottom: 8px;
    max-width: 75%;
    width: fit-content;
    cursor: pointer;
    transition: background-color 0.2s;
    display: flex;
    /* <-- Fix: Use flexbox for alignment */
    align-items: center;
    /* <-- Fix: Align items vertically */
}

.message a {
    color: #050505;
    font-weight: bold;
    text-decoration: underline;
}

.message:hover {
    filter: brightness(95%);
}

.kind-chip {
    background-color: #dcdfe3;
    border: 1px solid #c8ccd1;
    color: #050505;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.8em;
    font-weight: 500;
    margin-right: 8px;
    display: inline-block;
    vertical-align: middle;
}

.kind-chip-task {
    background-color: #e0f2fe;
    /* light blue */
    border-color: #7dd3fc;
    color: #0c4a6e;
}

.kind-chip-status-update {
    background-color: #fefce8;
    /* light yellow */
    border-color: #fde047;
    color: #713f12;
}

.kind-chip-artifact-update {
    background-color: #dcfce7;
    /* light green */
    border-color: #86efac;
    color: #14532d;
}

.kind-chip-message {
    background-color: #f3e8ff;
    /* light purple */
    border-color: #d8b4fe;
    color: #581c87;
}

.kind-chip-error {
    background-color: #fef2f2;
    /* light red */
    border-color: #fca5a5;
    color: #991b1b;
}

.message.user {
    background-color: #0084ff;
    color: white;
    align-self: flex-end;
}

.message.agent {
    background-color: #e4e6eb;
    color: #050505;
    align-self: flex-start;
}

.message.agent-progress {
    background-color: #f0f0f0;
    color: #65676b;
    font-style: italic;
    font-size: 0.9em;
    align-self: flex-start;
}

.message.agent-error {
    background-color: #fbe3e4;
    color: #d12f2f;
    border: 1px solid #f5c6cb;
    align-self: flex-start;
}

/* <-- Fix: Styles for validation status */
.validation-status {
    margin-left: 8px;
    font-size: 0.8em;
}

.validation-status.valid {
    color: green;
}

.validation-status.invalid {
    color: orange;
}

#debug-console {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 300px;
    background: #2f3640;
    color: #f5f6fa;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.2);
    transform: translateY(0);
    transition: transform 0.3s ease-in-out;
}

#debug-console.hidden {
    transform: translateY(calc(100% - 40px));
}

#debug-handle {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    height: 40px;
    background: #1f2429;
    cursor: ns-resize;
    user-select: none;
}

.debug-controls button {
    background: #4a4a4a;
    border: 1px solid #666;
    color: white;
    padding: 4px 10px;
    border-radius: 4px;
    cursor: pointer;
    margin-left: 10px;
}

#toggle-console-btn {
    background-color: #007bff;
}

#debug-content {
    height: calc(100% - 40px);
    overflow-y: auto;
    padding: 10px;
    font-family: monospace;
    white-space: pre-wrap;
}

.log-entry {
    padding: 8px;
    border-radius: 4px;
    margin-bottom: 5px;
    border-left: 3px solid #ccc;
}

.log-entry strong {
    font-weight: bold;
    margin-right: 10px;
}

.log-timestamp {
    color: #999;
    margin-right: 10px;
    font-size: 0.8em;
}

.log-entry.log-request {
    background-color: rgba(0, 123, 255, 0.1);
    border-left-color: #007bff;
}

.log-entry.log-response {
    background-color: rgba(108, 117, 125, 0.1);
    border-left-color: #6c757d;
}

.log-entry.log-error {
    background-color: rgba(220, 53, 69, 0.1);
    border-left-color: #dc3545;
}

.log-entry.log-validation_error {
    background-color: rgba(255, 193, 7, 0.1);
    border-left-color: #ffc107;
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-overlay.hidden {
    display: none;
}

.modal-content {
    background: #fff;
    color: #1c1e21;
    padding: 20px;
    border-radius: 8px;
    width: 80%;
    max-width: 800px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    position: relative;
}

.modal-close-btn {
    position: absolute;
    top: 10px;
    right: 20px;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    color: #555;
}

#modal-json-content {
    background: #f7f7f7;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 15px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.json-highlight {
    background-color: #ffc107;
    color: #333;
    padding: 0 4px;
    border-radius: 3px;
}

#chat-messages {
    height: 300px;
    overflow-y: auto;
    border: 1px solid #ddd;
    padding: 10px;
    border-radius: 4px;
    margin-bottom: 10px;
    background-color: #f7f7f7;
    display: flex;
    flex-direction: column;
}

.chat-info {
    font-size: 0.9em;
    color: #65676b;
    margin-top: 0;
    text-align: center;
}

.placeholder-text {
    color: #888;
    text-align: center;
    padding: 0;
    margin: 0;
}

#validation-errors {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 20px;
}

#validation-errors .placeholder-text:only-child {
    margin: auto;
    padding: 20px;
}

.loader {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #1877f2;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    animation: spin 1s linear infinite;
    margin: 0;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}
