/* Streaming Answer Display Styles */
.streaming-answer {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-start;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 0;
    margin: 0;
    box-shadow: none;
    position: relative;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
}

/* Answer content container */
.answer-content {
    width: 100%;
    line-height: 1.6;
    color: #2c3e50;
    font-size: 16px;
    overflow-x: hidden;
    word-wrap: break-word;
    padding: 0;
}

/* Mobile: No padding for answer content */
@media (max-width: 639px) {
    .answer-content {
        padding: 0;
    }
}

/* Desktop: Add padding for answer content (no top padding) */
@media (min-width: 640px) {
    .answer-content {
        padding: 0 1rem 1rem 1rem;
    }
}

/* Typography styles for answer content */
.answer-content h1 {
    font-size: 20px;
    font-weight: 600;
    color: #2c3e50;
    margin: 0 0 1rem 0;
    line-height: 1.4;
}

.answer-content h2 {
    font-size: 18px;
    font-weight: 600;
    color: #2c3e50;
    margin: 1.5rem 0 0.75rem 0;
    line-height: 1.4;
}

.answer-content h3 {
    font-size: 16px;
    font-weight: 600;
    color: #2c3e50;
    margin: 1.25rem 0 0.5rem 0;
    line-height: 1.4;
}

.answer-content p {
    margin: 0 0 1rem 0;
    color: #2c3e50;
    line-height: 1.6;
}

.answer-content ul, .answer-content ol {
    margin: 0 0 1rem 0;
    padding-left: 1.5rem;
    color: #2c3e50;
}

.answer-content li {
    margin: 0.25rem 0;
    line-height: 1.5;
}

.answer-content ul li {
    list-style-type: disc;
}

.answer-content ol li {
    list-style-type: decimal;
}

/* Nested lists */
.answer-content ul ul, .answer-content ol ol, .answer-content ul ol, .answer-content ol ul {
    margin: 0.25rem 0;
    padding-left: 1.25rem;
}

/* Strong and emphasis */
.answer-content strong {
    font-weight: 600;
    color: #2c3e50;
}

.answer-content em {
    font-style: italic;
    color: #4b5563;
}

/* Code and preformatted text */
.answer-content code {
    background: #f1f5f9;
    padding: 0.125rem 0.25rem;
    border-radius: 4px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 13px;
    color: #7c3aed;
}

.answer-content pre {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 1rem;
    margin: 1rem 0;
    overflow-x: auto;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 13px;
    line-height: 1.4;
}

.answer-content pre code {
    background: none;
    padding: 0;
    border-radius: 0;
    color: #374151;
}

/* Blockquotes */
.answer-content blockquote {
    border-left: 4px solid #8b5cf6;
    padding-left: 1rem;
    margin: 1rem 0;
    color: #4b5563;
    font-style: italic;
    background: #faf5ff;
    padding: 0.75rem 1rem;
    border-radius: 0 8px 8px 0;
}

/* Tables */
.answer-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
    font-size: 13px;
}

.answer-content th, .answer-content td {
    border: 1px solid #e2e8f0;
    padding: 0.5rem 0.75rem;
    text-align: left;
}

.answer-content th {
    background: #f8fafc;
    font-weight: 600;
    color: #374151;
}

.answer-content td {
    color: #4b5563;
}

/* Links */
.answer-content a {
    color: #8b5cf6;
    text-decoration: underline;
    text-decoration-color: #c4b5fd;
    transition: color 0.2s ease;
}

.answer-content a:hover {
    color: #7c3aed;
    text-decoration-color: #8b5cf6;
}

/* Horizontal rules */
.answer-content hr {
    border: none;
    height: 1px;
    background: linear-gradient(90deg, transparent 0%, #e2e8f0 20%, #e2e8f0 80%, transparent 100%);
    margin: 1.5rem 0;
}

/* Streaming cursor animation */
.streaming-cursor {
    display: inline-block;
    width: 2px;
    height: 1.2em;
    background: #8b5cf6;
    margin-left: 2px;
    animation: blink 1s infinite;
    vertical-align: text-bottom;
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

/* Fade in animation for the entire answer */
.streaming-answer {
    animation: fadeIn 0.4s ease-out;
}

@keyframes fadeIn {
    from { 
        opacity: 0; 
        transform: translateY(10px); 
    }
    to { 
        opacity: 1; 
        transform: translateY(0); 
    }
}



/* Responsive design */
@media (max-width: 640px) {
    .answer-content {
        font-size: 13px;
    }
    
    .answer-content h1 {
        font-size: 18px;
    }
    
    .answer-content h2 {
        font-size: 16px;
    }
    
    .answer-content h3 {
        font-size: 15px;
    }
}

/* Loading state for streaming */
.streaming-answer.loading .answer-content {
    opacity: 0.7;
}

/* Completed state */
.streaming-answer.completed .streaming-cursor {
    display: none;
}

/* Citation icons - FontAwesome Link Icon with Background */
.citation-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    margin-left: 4px;
    background: #f3f4f6;
    border: 1px solid #d1d5db;
    border-radius: 50%;

    color: #374151;
    cursor: pointer;
    font-size: 10px;
    vertical-align: middle;
    text-decoration: none;
    transition: all 0.2s ease;
    position: relative;
}

/* Group highlighting effect */
.citation-group {
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
    border-radius: 6px;
    padding: 2px 4px;
    margin: -2px 0;
    box-sizing: border-box;
    position: relative;
}

.citation-group.highlighted {
    background: #fef3c7 !important;
    box-shadow: 0 0 0 1px rgba(251, 191, 36, 0.3);
    animation: highlightFadeIn 0.3s ease-out;
}

@keyframes highlightFadeIn {
    from {
        background: transparent;
        box-shadow: none;
    }
    to {
        background: #fef3c7;
        box-shadow: 0 0 0 1px rgba(251, 191, 36, 0.3);
    }
}

/* Ensure highlighting works even with nested elements */
.citation-group.highlighted * {
    position: relative;
    z-index: 1;
}

.citation-icon:hover {
    background: #e5e7eb;
    border-color: #9ca3af;
    color: #1f2937;
}

.citation-icon i {
    font-size: inherit;
}

/* Ensure citations stay inline and don't wrap */
.answer-content p .citation-icon,
.answer-content li .citation-icon {
    margin-left: 4px;
    margin-right: 0;
    display: inline-flex;
    vertical-align: middle;
}

/* Citation tooltip */
.citation-tooltip {
    position: fixed;
    bottom: auto;
    left: auto;
    transform: none;
    margin: 0;
    padding: 6px 10px;
    background: #1f2937;
    color: white;
    font-size: 11px;
    font-weight: 500;
    border-radius: 4px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    z-index: 9999;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    pointer-events: none;
    max-width: 300px;
    word-wrap: break-word;
    white-space: normal;
}

.citation-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 3px solid transparent;
    border-top-color: #1f2937;
}

.citation-icon:hover .citation-tooltip {
    opacity: 1;
    visibility: visible;
}

/* Answer Action Buttons */
.answer-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 0;
    margin-bottom: 1.5rem;
    padding-top: 0;
    width: 100%;
}

@media (max-width: 639px) {
    .answer-actions {
        padding-left: 0;
        padding-right: 0;
    }
}

@media (min-width: 640px) {
    .answer-actions {
        padding-left: 1rem;
        padding-right: 1rem;
    }
}

.action-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 4px;
    color: #64748b;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.action-button:hover {
    background: #f8fafc;
    color: #475569;
}

.action-button:active {
    transform: scale(0.95);
}

.action-button svg {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
}

/* Copy button specific styles */
.copy-button.copied {
    background: #dcfce7;
    color: #166534;
}

.copy-button.copied:hover {
    background: #bbf7d0;
}

/* Like button active state */
.like-button.active {
    background: #dcfce7;
    color: #166534;
}

.like-button.active svg {
    stroke: #166534;
}

.like-button.active:hover {
    background: #bbf7d0;
}

/* Dislike button active state */
.dislike-button.active {
    background: #fef2f2;
    color: #dc2626;
}

.dislike-button.active svg {
    stroke: #dc2626;
}

.dislike-button.active:hover {
    background: #fee2e2;
}

/* Follow-up Questions */
.follow-up-questions {
    margin-top: 2rem;
    width: 100%;
}

@media (max-width: 639px) {
    .follow-up-questions {
        padding-left: 0;
        padding-right: 0;
    }
}

@media (min-width: 640px) {
    .follow-up-questions {
        padding-left: 0;
        padding-right: 1rem;
    }
}

.follow-up-title {
    font-size: 14px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 0.75rem;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.follow-up-questions-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.follow-up-question {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    color: #475569;
    font-size: 14px;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    width: 100%;
}

.follow-up-question:hover {
    background: #f8fafc;
    border-color: #8b5cf6;
    color: #8b5cf6;
    transform: translateX(4px);
}

.follow-up-question:active {
    transform: translateX(2px) scale(0.98);
}

/* Mobile responsive adjustments */
@media (max-width: 640px) {
    .action-button {
        width: 28px;
        height: 28px;
    }

    .action-button svg {
        width: 16px;
        height: 16px;
    }

    .follow-up-question {
        font-size: 13px;
        padding: 0.625rem 0.875rem;
    }
}
