/* Chat View Styles */

.chat-view-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    background-color: var(--bg-dark);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    color: var(--text-primary);
}

/* Collapsible tool call indicator */
/* Legacy styles kept for compatibility; replaced by .disclosure */

/* New shared Disclosure component using native <details>/<summary> */
.disclosure {
    border-left: 2px solid #888;
    background: rgba(200,200,200,0.05);
    border-radius: 6px;
    margin: 4px 0 12px 12px;
}
.disclosure__summary {
    list-style: none;
    cursor: pointer;
    padding: 6px 8px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
}
.disclosure__summary::-webkit-details-marker { display: none; }
.disclosure[open] .disclosure__summary { background: rgba(200,200,200,0.08); }
.disclosure__summary:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }
.disclosure__content { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .2s ease; }
.disclosure[open] .disclosure__content { grid-template-rows: 1fr; }
.disclosure__content > * { overflow: hidden; padding: 8px; font-family: monospace; font-size: 0.85em; }
.tool-detail-row {
    margin-bottom: 4px;
}
.tool-detail-row pre {
    margin: 4px 0;
    white-space: pre-wrap;
    word-break: break-all;
}
.output-row {
    position: relative;
}
.show-more {
    color: var(--color-primary);
    cursor: pointer;
    font-size: 0.8em;
    position: absolute;
    bottom: 4px;
    right: 8px;
}
.copy-btn {
    font-size: 0.8em;
    margin-left: 8px;
    cursor: pointer;
}

/* Header styles */
.chat-header {
    display: flex;
    align-items: center;
    padding: 15px;
    background-color: var(--bg-darker);
    border-bottom: 1px solid var(--border-color);
    height: 70px;
    margin-top: 70px;
}

.back-button {
    font-size: 24px;
    cursor: pointer;
    margin-right: 20px;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s;
    color: var(--text-primary);
    background-color: rgba(255, 255, 255, 0.1);
}

.back-button:hover {
    background-color: var(--bg-hover);
}

.agent-info {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.agent-name {
    font-size: 16px;
    font-weight: 500;
    color: var(--text-secondary);
}

.thread-title-label {
    font-size: 16px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-top: 4px;
}

.thread-title-text {
    font-size: 18px;
    font-weight: 600;
    margin-top: 4px;
    padding: 2px 4px;
    color: var(--text-primary);
}

/* Body styles */
.chat-body {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Sidebar styles */
.thread-sidebar {
    width: 300px;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    background-color: var(--bg-darker);
}

.sidebar-header {
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.new-thread-btn {
    background-color: var(--color-primary);
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.2s;
}

.new-thread-btn:hover {
    background-color: #0069d9;
}

.thread-list {
    flex: 1;
    overflow-y: auto;
}

.thread-item {
    padding: 15px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background-color 0.2s;
    position: relative;
}

.thread-item:hover {
    background-color: var(--bg-hover);
}

.thread-item.selected {
    background-color: var(--bg-hover);
}

.thread-item-title {
    font-weight: 600;
    margin-bottom: 5px;
    font-size: 14px;
    color: var(--text-primary);
}

.thread-edit-button {
    position: absolute;
    top: 15px;
    right: 15px;
    font-size: 14px;
    color: var(--text-secondary);
    opacity: 0;
    transition: opacity 0.2s;
    cursor: pointer;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.thread-item:hover .thread-edit-button {
    opacity: 1;
}

.thread-edit-button:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

.thread-item-time {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 5px;
}

.thread-item-preview {
    font-size: 13px;
    color: var(--text-secondary);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Conversation area styles */
.conversation-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background-color: var(--bg-dark);
}

.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    padding-bottom: 20px; /* Normal padding */
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Chat row container - properly aligns avatar with message */
.chat-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    width: 100%;
    margin-bottom: 4px;
}

/* User messages - avatar on right */
.chat-row:has(.user-message) {
    flex-direction: row-reverse;
}

/* Avatar styling in chat */
.chat-row .avatar-badge {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    font-size: 14px;
    margin-bottom: 2px;
}

.chat-row .avatar-badge.small {
    width: 32px;
    height: 32px;
}

.message {
    max-width: 70%;
    padding: 12px 16px;
    border-radius: 18px;
    position: relative;
    word-wrap: break-word;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
    transition: box-shadow 0.2s ease;
}

.message:hover {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.12);
}

/* User message styling */
.user-message {
    background-color: var(--color-primary);
    color: rgb(8, 2, 2);
    border-bottom-right-radius: 4px;
    margin-left: auto;
}

/* Message tail for user messages */
.user-message::after {
    content: '';
    position: absolute;
    bottom: 0;
    right: -6px;
    width: 0;
    height: 0;
    border-left: 6px solid #E0E0E0; /* Match new background */
    border-right: 6px solid transparent;
    border-bottom: 6px solid transparent;
}

/* Assistant message styling */
.assistant-message {
    background-color: var(--bg-button);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
    margin-right: auto;
}

/* Message tail for assistant messages */
.assistant-message::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: -6px;
    width: 0;
    height: 0;
    border-right: 6px solid var(--bg-button);
    border-left: 6px solid transparent;
    border-bottom: 6px solid transparent;
}

/* Pending message style */
.message.pending {
    opacity: 0.7;
}

/* Pulsing animation for pending messages */
@keyframes pulse {
    0% { opacity: 0.7; }
    50% { opacity: 0.9; }
    100% { opacity: 0.7; }
}

.message.pending {
    animation: pulse 1.5s infinite ease-in-out;
}

/* Pending indicator */
.message.pending .message-time::before {
    content: "• ";
    color: var(--color-primary);
}

.message-content {
    font-size: 14px;
    line-height: 1.5;
}

.message-time {
    font-size: 11px;
    opacity: 0.7;
    margin-top: 6px;
    text-align: right;
}

.user-message .message-time {
    text-align: left;
}

/* Input area styles */
.chat-input-area {
    display: flex;
    padding: 15px;
    border-top: 1px solid var(--border-color);
    background-color: var(--bg-darker);
    position: relative;
    z-index: 5;
    gap: 10px;
    margin-bottom: 30px; /* Account for the fixed status bar at bottom */
}

.chat-input {
    flex: 1;
    padding: 12px 20px;
    border: 1px solid var(--border-color);
    border-radius: 24px;
    font-size: 14px;
    outline: none;
    transition: all 0.2s;
    background-color: var(--bg-dark);
    color: var(--text-primary);
}

.chat-input:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

.chat-input:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.send-button {
    min-width: 64px;
    height: 44px;
    border-radius: 22px;
    background-color: var(--color-primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 20px;
    font-size: 14px;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
}

.send-button:hover:not(:disabled) {
    background-color: #0069d9;
    transform: scale(1.05);
}

.send-button:active:not(:disabled) {
    transform: scale(0.95);
}

.send-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Tool message styling */
.message.tool-message {
    background-color: #f5f5f5;
    border-left: 3px solid #007acc;
    margin-left: 40px;
    margin-right: 80px;
    font-family: monospace;
    padding: 12px 15px;
    color: #333;
}

.tool-header {
    font-weight: bold;
    color: #007acc;
    margin-bottom: 8px;
    font-size: 0.9em;
    padding-bottom: 4px;
    border-bottom: 1px solid rgba(0, 122, 204, 0.2);
}

/* Loading indicator for threads */
.thread-loading {
    padding: 20px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 14px;
}

.thread-list-empty {
    padding: 20px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 14px;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .thread-sidebar {
        position: absolute;
        left: -300px;
        top: 140px;
        bottom: 0;
        z-index: 10;
        transition: left 0.3s ease;
        width: 80%;
        max-width: 300px;
    }
    
    .thread-sidebar.active {
        left: 0;
    }
    
    .back-button {
        display: block;
    }
    
    .chat-input-area {
        padding: 10px;
    }
    
    .status-bar {
        display: none;
    }
    
    .message {
        max-width: 85%;
    }
    
    .messages-container {
        padding: 15px;
    }
}
