/* Citation Panel Styles */

/* Citation Links in Response */
.citation-link {
    color: #3b82f6;
    text-decoration: none;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    padding: 0 2px;
    border-radius: 3px;
}

.citation-link:hover {
    background-color: rgba(59, 130, 246, 0.1);
    color: #2563eb;
}

.citation-link.highlighted {
    background-color: rgba(59, 130, 246, 0.2);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.3);
}

/* Dark mode citation links */
.dark .citation-link {
    color: #60a5fa;
}

.dark .citation-link:hover {
    background-color: rgba(96, 165, 250, 0.1);
    color: #93bbfc;
}

.dark .citation-link.highlighted {
    background-color: rgba(96, 165, 250, 0.2);
    box-shadow: 0 0 0 2px rgba(96, 165, 250, 0.3);
}

/* Citation Panel */
#citationPanel {
    transition: transform 0.3s ease, opacity 0.3s ease;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

#citationPanel.panel-hidden {
    transform: translateX(100%);
    opacity: 0;
}

/* Ensure citation list doesn't overflow */
#citationList {
    flex: 1 1 auto;
    overflow-y: auto;
    min-height: 0; /* Important for flexbox overflow */
}

/* Fix main content area layout */
main > .flex-1.flex {
    min-height: 0; /* Allow flexbox children to shrink */
}

#chatMessages {
    min-width: 0; /* Allow chat messages to shrink */
}

/* Citation Cards */
.citation-card {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 12px;
    transition: all 0.2s ease;
    cursor: pointer;
    position: relative;
}

.citation-card:hover {
    border-color: #3b82f6;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.citation-card.active {
    border-color: #3b82f6;
    background-color: #eff6ff;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.15);
}

.citation-card-unverified {
    border-color: #fbbf24;
    background-color: #fffbeb;
}

.dark .citation-card {
    background: #1f2937;
    border-color: #374151;
}

.dark .citation-card:hover {
    border-color: #60a5fa;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.dark .citation-card.active {
    border-color: #60a5fa;
    background-color: #1e293b;
    box-shadow: 0 4px 12px rgba(96, 165, 250, 0.15);
}

/* Citation Number Badge */
.citation-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background: #3b82f6;
    color: white;
    font-size: 12px;
    font-weight: 600;
    border-radius: 50%;
    flex-shrink: 0;
}

.dark .citation-number {
    background: #60a5fa;
    color: #1f2937;
}

/* Citation Text */
.citation-text {
    font-size: 14px;
    line-height: 1.5;
    color: #374151;
    margin: 8px 0;
    font-style: italic;
    border-left: 3px solid #d1d5db;
    padding-left: 12px;
}

.dark .citation-text {
    color: #d1d5db;
    border-left-color: #4b5563;
}

/* Citation Source */
.citation-source {
    font-size: 12px;
    color: #6b7280;
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 8px;
}

.dark .citation-source {
    color: #9ca3af;
}

.citation-source-title {
    font-weight: 600;
    color: #4b5563;
}

.dark .citation-source-title {
    color: #d1d5db;
}

/* Citation Confidence Score */
.citation-confidence {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 12px;
    background: #f3f4f6;
    color: #6b7280;
}

.dark .citation-confidence {
    background: #374151;
    color: #9ca3af;
}

.citation-confidence.high {
    background: #dcfce7;
    color: #16a34a;
}

.citation-confidence.medium {
    background: #fef3c7;
    color: #d97706;
}

.citation-confidence.low {
    background: #fee2e2;
    color: #dc2626;
}

.dark .citation-confidence.high {
    background: rgba(34, 197, 94, 0.1);
    color: #4ade80;
}

.dark .citation-confidence.medium {
    background: rgba(251, 191, 36, 0.1);
    color: #fbbf24;
}

.dark .citation-confidence.low {
    background: rgba(239, 68, 68, 0.1);
    color: #f87171;
}

/* Mobile Citation Drawer */
#mobileCitationDrawer {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#mobileCitationDrawer.open {
    transform: translateY(0);
}

/* Mobile Citation Button */
.mobile-citation-btn {
    position: fixed;
    bottom: 80px;
    right: 20px;
    width: 56px;
    height: 56px;
    background: #3b82f6;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 40;
}

.mobile-citation-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.mobile-citation-btn.has-citations {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.7);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(59, 130, 246, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(59, 130, 246, 0);
    }
}

/* Citation Badge Count */
.citation-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #ef4444;
    color: white;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 20px;
    text-align: center;
}

/* Export Menu */
.export-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 4px;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    z-index: 100;
    min-width: 180px;
    opacity: 0;
    transform: translateY(-10px);
    transition: all 0.2s ease;
    pointer-events: none;
}

.export-menu.show {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.dark .export-menu {
    background: #1f2937;
    border-color: #374151;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.export-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    cursor: pointer;
    transition: background 0.2s ease;
    color: #374151;
    font-size: 14px;
}

.export-option:hover {
    background: #f3f4f6;
}

.export-option:first-child {
    border-radius: 8px 8px 0 0;
}

.export-option:last-child {
    border-radius: 0 0 8px 8px;
}

.dark .export-option {
    color: #d1d5db;
}

.dark .export-option:hover {
    background: #374151;
}

/* Citation Hover Tooltip */
.citation-tooltip {
    position: absolute;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 12px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    max-width: 400px;
    opacity: 0;
    transform: translateY(-10px);
    transition: all 0.2s ease;
    pointer-events: none;
}

.citation-tooltip.show {
    opacity: 1;
    transform: translateY(0);
}

.dark .citation-tooltip {
    background: #1f2937;
    border-color: #374151;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

/* Citation Stats */
#citationStats {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

.stat-value {
    font-weight: 600;
    color: #111827;
}

.dark .stat-value {
    color: #f3f4f6;
}

/* Responsive Adjustments */
@media (max-width: 1024px) {
    #citationPanel {
        position: fixed;
        right: 0;
        top: 0;
        bottom: 0;
        width: 80%;
        max-width: 400px;
        z-index: 45;
        box-shadow: -4px 0 16px rgba(0, 0, 0, 0.1);
    }
    
    .citation-panel-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 44;
        opacity: 0;
        transition: opacity 0.3s ease;
        pointer-events: none;
    }
    
    .citation-panel-overlay.show {
        opacity: 1;
        pointer-events: auto;
    }
}

@media (max-width: 640px) {
    .citation-card {
        padding: 10px;
    }
    
    .citation-text {
        font-size: 13px;
        padding-left: 8px;
    }
    
    .citation-source {
        font-size: 11px;
    }
}

/* Loading State */
.citation-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    color: #6b7280;
}

.citation-loading-spinner {
    animation: spin 1s linear infinite;
    margin-right: 8px;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* Empty State */
.citation-empty {
    text-align: center;
    padding: 32px 16px;
    color: #9ca3af;
}

.citation-empty-icon {
    width: 48px;
    height: 48px;
    margin: 0 auto 12px;
    opacity: 0.5;
}

/* Theme Transitions */
* {
    transition: background-color 0.2s ease, border-color 0.2s ease;
}
