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

.chat-modal {
    background: white;
    border-radius: 8px;
    width: 90%;
    max-width: 500px;
    height: 70vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.chat-header {
    padding: 15px 20px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-header h3 {
    margin: 0;
    font-size: 18px;
}

.close-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
}

.chat-messages {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    background: #f9f9f9;
}

.chat-message {
    margin-bottom: 15px;
    background: white;
    padding: 10px;
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.message-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 5px;
    font-size: 12px;
    color: #666;
}

.message-author {
    font-weight: bold;
}

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

.chat-input {
    padding: 15px;
    border-top: 1px solid #eee;
    display: flex;
    gap: 10px;
}

.chat-input input {
    flex: 1;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.chat-input button {
    padding: 10px 20px;
    background: #007bff;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}

.chat-input button:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.loading, .no-messages, .error {
    text-align: center;
    padding: 20px;
    color: #666;
    font-style: italic;
}

.error {
    color: #d32f2f;
}

/* Thread chat specific styles */
.thread-chat-modal {
    width: 95%;
    max-width: 760px;
    max-height: 90vh;
}

.thread-chat-modal .chat-header {
    border-bottom: 1px solid #e5ebf4;
    padding: 16px 20px;
    gap: 12px;
}

.thread-back-btn {
    background: transparent;
    border: none;
    color: #0d6efd;
    font-weight: 600;
    cursor: pointer;
    padding: 6px 8px;
}

.thread-info-bar {
    padding: 12px 20px;
    background: #f7f9fc;
    border-bottom: 1px solid #e3e9f2;
}

.thread-info-title {
    font-size: 16px;
    font-weight: 600;
    color: #1f2933;
}

.thread-info-meta {
    margin-top: 4px;
    font-size: 12px;
    color: #667185;
}

.thread-messages {
    background: #f2f5fb;
    padding: 16px;
}

.thread-message {
    border: 1px solid #e1e6ef;
    border-radius: 10px;
    padding: 12px 14px;
    margin-bottom: 12px;
    background: #fff;
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.05);
}

.thread-message-meta {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: #5f6b7c;
    margin-bottom: 6px;
}

.thread-message-body {
    font-size: 14px;
    line-height: 1.5;
    color: #1f2933;
}

.thread-passage-btn {
    margin-top: 10px;
    padding: 6px 10px;
    background: transparent;
    border: 1px solid #0d6efd;
    border-radius: 6px;
    color: #0d6efd;
    cursor: pointer;
    font-size: 12px;
}

.thread-chat-modal .chat-input {
    flex-direction: column;
    gap: 8px;
    padding: 16px 20px;
}

.thread-textarea {
    width: 100%;
    min-height: 70px;
    border: 1px solid #d0d7e3;
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 14px;
    resize: vertical;
    font-family: inherit;
}

.thread-input-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    width: 100%;
}
