/**
 * Message Threading Styles
 * Support for threaded replies and conversations
 */

/* Thread Reply Button */
.thread-reply-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--bg-secondary, #f8fafc);
    border: 1px solid var(--border-primary, #e2e8f0);
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary, #64748b);
    cursor: pointer;
    transition: all 0.2s;
    margin-left: 8px;
}

.thread-reply-btn:hover {
    background: var(--bg-tertiary, #f6f8fa);
    border-color: var(--accent-primary, #C41E3A);
    color: var(--accent-primary, #C41E3A);
}

.thread-reply-btn i {
    font-size: 11px;
}

/* Reply Preview (shown above input when replying) */
.thread-reply-preview {
    position: relative;
    background: var(--bg-secondary, #f8fafc);
    border: 1px solid var(--border-primary, #e2e8f0);
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.reply-preview-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary, #64748b);
}

.reply-preview-header i {
    color: var(--accent-primary, #C41E3A);
}

.reply-preview-close {
    margin-left: auto;
    width: 24px;
    height: 24px;
    border: none;
    background: transparent;
    color: var(--text-secondary, #64748b);
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.reply-preview-close:hover {
    background: var(--bg-tertiary, #f6f8fa);
    color: var(--text-primary, #1a202c);
}

.reply-preview-content {
    font-size: 13px;
    color: var(--text-primary, #1a202c);
    padding: 8px 12px;
    background: var(--bg-primary, #ffffff);
    border-left: 3px solid var(--accent-primary, #C41E3A);
    border-radius: 4px;
    max-height: 60px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Thread Count Badge */
.thread-count-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: linear-gradient(135deg, var(--accent-primary, #C41E3A) 0%, #a01829 100%);
    color: white;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    margin-left: 8px;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 4px rgba(196, 30, 58, 0.2);
}

.thread-count-badge:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(196, 30, 58, 0.3);
}

.thread-count-badge i {
    font-size: 10px;
}

/* Thread Replies Container */
.thread-replies-container {
    margin-top: 16px;
    margin-left: 32px;
    padding: 16px;
    background: var(--bg-secondary, #f8fafc);
    border-left: 3px solid var(--accent-primary, #C41E3A);
    border-radius: 8px;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.03);
}

.thread-empty {
    padding: 24px;
    text-align: center;
    color: var(--text-secondary, #64748b);
    font-size: 13px;
    font-style: italic;
}

/* Individual Thread Reply */
.thread-reply {
    background: var(--bg-primary, #ffffff);
    border: 1px solid var(--border-primary, #e2e8f0);
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 12px;
    transition: all 0.2s;
}

.thread-reply:last-child {
    margin-bottom: 0;
}

.thread-reply:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    border-color: var(--accent-primary, #C41E3A);
}

/* Thread Reply Header */
.thread-reply-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-primary, #e2e8f0);
}

.thread-reply-role {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-primary, #1a202c);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.thread-reply-user .thread-reply-role {
    color: var(--accent-primary, #C41E3A);
}

.thread-reply-assistant .thread-reply-role {
    color: #1e40af;
}

.thread-reply-time {
    font-size: 11px;
    color: var(--text-secondary, #64748b);
}

/* Thread Reply Content */
.thread-reply-content {
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-primary, #1a202c);
    margin-bottom: 8px;
    word-wrap: break-word;
}

/* Thread Reply Actions */
.thread-reply-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.thread-reply-btn-small {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: transparent;
    border: 1px solid var(--border-primary, #e2e8f0);
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-secondary, #64748b);
    cursor: pointer;
    transition: all 0.2s;
}

.thread-reply-btn-small:hover {
    background: var(--bg-secondary, #f8fafc);
    border-color: var(--accent-primary, #C41E3A);
    color: var(--accent-primary, #C41E3A);
}

.thread-reply-btn-small i {
    font-size: 10px;
}

/* User vs Assistant Reply Styling */
.thread-reply-user {
    border-left: 3px solid var(--accent-primary, #C41E3A);
}

.thread-reply-assistant {
    border-left: 3px solid #1e40af;
}

/* Dark Mode */
html.dark-mode .thread-reply-btn {
    background: #374151;
    border-color: #4b5563;
    color: #d1d5db;
}

html.dark-mode .thread-reply-btn:hover {
    background: #4b5563;
    border-color: var(--accent-primary, #C41E3A);
    color: var(--accent-primary, #C41E3A);
}

html.dark-mode .thread-reply-preview {
    background: #1f2937;
    border-color: #374151;
}

html.dark-mode .reply-preview-header {
    color: #d1d5db;
}

html.dark-mode .reply-preview-content {
    background: #111827;
    color: #f9fafb;
}

html.dark-mode .reply-preview-close {
    color: #9ca3af;
}

html.dark-mode .reply-preview-close:hover {
    background: #374151;
    color: #f9fafb;
}

html.dark-mode .thread-replies-container {
    background: #1f2937;
    border-left-color: var(--accent-primary, #C41E3A);
}

html.dark-mode .thread-reply {
    background: #111827;
    border-color: #374151;
}

html.dark-mode .thread-reply:hover {
    border-color: var(--accent-primary, #C41E3A);
}

html.dark-mode .thread-reply-header {
    border-bottom-color: #374151;
}

html.dark-mode .thread-reply-role {
    color: #f9fafb;
}

html.dark-mode .thread-reply-content {
    color: #e5e7eb;
}

html.dark-mode .thread-reply-btn-small {
    border-color: #4b5563;
    color: #9ca3af;
}

html.dark-mode .thread-reply-btn-small:hover {
    background: #374151;
    border-color: var(--accent-primary, #C41E3A);
    color: var(--accent-primary, #C41E3A);
}

/* Responsive */
@media (max-width: 768px) {
    .thread-replies-container {
        margin-left: 16px;
        padding: 12px;
    }

    .thread-reply {
        padding: 10px 12px;
    }

    .thread-reply-content {
        font-size: 13px;
    }
}

/* Animation */
@keyframes fadeInThread {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.thread-reply {
    animation: fadeInThread 0.3s ease-out;
}

.thread-replies-container {
    animation: fadeInThread 0.4s ease-out;
}
