/* Citation Processor Styles */

/* Simple Reference Links - using answer-content styling */
.reference-link {
    color: #8b5cf6;
    text-decoration: underline;
    text-decoration-color: #c4b5fd;
    transition: color 0.2s ease;
}

.reference-link:hover {
    color: #7c3aed;
    text-decoration-color: #8b5cf6;
}


/* Citation Icons - Base styles */
.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;
}

/* Citation Icon Variants */

/* Default: Circular Link Icon */
.citation-icon.circular-link {
    border-radius: 50%;
    background: #f3f4f6;
    border: 1px solid #d1d5db;
}

/* Square Number Badge */
.citation-icon.square-number {
    border-radius: 2px;
    background: #8b5cf6;
    border: 1px solid #7c3aed;
    color: white;
    font-weight: 600;
    font-size: 9px;
}

.citation-icon.square-number:hover {
    background: #7c3aed;
    border-color: #6d28d9;
}

/* Minimal Superscript */
.citation-icon.minimal-superscript {
    width: auto;
    height: auto;
    background: none;
    border: none;
    border-radius: 0;
    color: #8b5cf6;
    font-size: 10px;
    font-weight: 600;
    vertical-align: super;
    margin-left: 2px;
    padding: 0 2px;
    display: inline-block;
    white-space: nowrap;
    min-width: fit-content;
}

/* Minimal Superscript - Grouped Citations (expand to right) */
.citation-icon.minimal-superscript.citation-grouped {
    width: auto;
    height: auto;
    min-width: fit-content;
    max-width: none;
    margin-left: 2px;
    margin-right: 0;
    padding: 0 4px;
    display: inline-block;
    white-space: nowrap;
    text-align: left;
    position: relative;
    z-index: 1;
}

/* Ensure minimal superscript doesn't break text flow */
.citation-icon.minimal-superscript {
    position: relative;
    z-index: 1;
    line-height: 1;
}

.citation-icon.minimal-superscript:hover {
    color: #7c3aed;
    background: rgba(139, 92, 246, 0.1);
    border-radius: 2px;
}

/* Plain Superscript - Most Minimal Style */
.citation-icon.plain-superscript {
    width: auto !important;
    height: auto !important;
    background: none !important;
    border: none !important;
    border-radius: 0 !important;
    color: var(--tab-active-text, #592b8b) !important; /* Use existing CSS custom property */
    font-size: 11px !important;
    font-weight: 600 !important;
    vertical-align: super !important;
    margin-left: 1px !important;
    margin-right: 0 !important;
    padding: 0 !important;
    display: inline !important;
    white-space: nowrap !important;
    min-width: fit-content !important;
    position: relative !important;
    z-index: 1 !important;
    line-height: 1 !important;
    top: -0.3em !important;
}


/* Plain Superscript - Grouped Citations (space separated) */
.citation-icon.plain-superscript.citation-grouped {
    width: auto !important;
    height: auto !important;
    min-width: fit-content !important;
    max-width: none !important;
    margin-left: 1px !important;
    margin-right: 0 !important;
    padding: 0 !important;
    display: inline !important;
    white-space: nowrap !important;
    text-align: left !important;
    position: relative !important;
    z-index: 1 !important;
    top: -0.3em !important;
}

.citation-icon.plain-superscript:hover {
    color: var(--tab-active-text, #592b8b) !important;
    opacity: 0.8 !important;
    background: rgba(89, 43, 139, 0.1) !important;
    border-radius: 2px !important;
}

/* Grouped Citation Icons - slightly larger for multiple references */
.citation-icon.citation-grouped {
    width: 18px;
    height: 18px;
    font-size: 11px;
}

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

/* Citation Icons - Functional State (after linking) */
.citation-icon[data-linked="true"] {
    background: #f3f4f6;
    border-color: #d1d5db;
    color: #374151;
}

/* Citation Icons - Hover State (subtle background change only) */
.citation-icon:hover {
    background: #e5e7eb;
    border-color: #9ca3af;
}

.citation-icon[data-linked="true"]:hover {
    background: #e5e7eb;
    border-color: #9ca3af;
}



/* 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: auto;
    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;
}

/* Immediate tooltips (before references are available) */
.citation-tooltip-immediate {
    background: #374151;
    border: 1px solid #4b5563;
    font-size: 10px;
    padding: 4px 8px;
}

.citation-tooltip-immediate::after {
    border-top-color: #374151;
}

/* Grouped Citation Tooltip */
.citation-tooltip-grouped {
    padding: 8px 12px;
    max-width: 400px;
}

.tooltip-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.tooltip-reference {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    line-height: 1.4;
}

.tooltip-reference-link {
    color: #60a5fa;
    text-decoration: none;
    cursor: pointer;
    display: block;
    padding: 2px 0;
    border-radius: 2px;
    flex: 1;
}

.tooltip-reference-link:hover {
    color: #93c5fd;
    text-decoration: underline;
}

.tooltip-reference strong {
    color: #fbbf24;
    font-weight: 600;
    min-width: 24px;
    flex-shrink: 0;
}

/* Reference List Base Styles */
.reference-list {
    margin-top: 1.5rem;
}

.reference-list-title {
    font-size: 16px;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #8b5cf6;
}

/* Modern cards specific title styling */
.reference-list.modern-cards .reference-list-title {
    font-size: 16px;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 0.75rem;
    padding-bottom: 0;
    border-bottom: none;
}

.reference-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0.5rem 0;
    margin: 0.25rem 0;
}

.reference-number {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    color: white;
    font-size: 10px;
    font-weight: 600;
    border-radius: 50%;
    flex-shrink: 0;
}

.reference-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    color: #64748b;
    font-size: 12px;
    flex-shrink: 0;
}

.reference-title {
    color: #2c3e50;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s ease;
}

.reference-title:hover {
    color: #8b5cf6;
}

/* Reference List Style Variants */

/* Modern Cards (Default) - Simple List Style */
.reference-list.modern-cards {
    /* Uses base styles above */
}

.reference-list.modern-cards .reference-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 0.75rem 1rem;
    margin: 0.5rem 0;
    background: rgb(248, 249, 250);
    border: none;
    box-shadow: none;
    border-radius: 4px;
    transition: transform 0.2s ease;
    cursor: pointer;
    width: 100%;
}

.reference-list.modern-cards .reference-item:hover {
    transform: translateX(4px);
    background: rgb(243, 244, 245);
}

.reference-list.modern-cards .reference-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    margin-top: 2px;
    font-size: 14px;
    order: 1;
}

.reference-list.modern-cards .reference-number {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    color: inherit;
    vertical-align: super;
    line-height: 1;
    margin: 0 4px;
    position: relative;
    top: -0.3em;
    order: 2;
}

.reference-list.modern-cards .reference-title {
    order: 3;
}

/* PDF icon styling - red color */
.reference-list.modern-cards .reference-icon .fa-file-pdf {
    color: #dc2626; /* red-600 */
}

/* Link icon styling - square with arrow (gray) */
.reference-list.modern-cards .reference-icon .fa-link,
.reference-list.modern-cards .reference-icon .fa-square-arrow-up-right,
.reference-list.modern-cards .reference-icon .fa-external-link {
    color: #374151; /* gray-700 */
}

.reference-list.modern-cards .reference-title {
    color: #1f2937; /* gray-800 */
    text-decoration: none;
    font-weight: 400;
    font-size: 14px;
    line-height: 1.5;
    flex: 1;
}

.reference-list.modern-cards .reference-title:hover {
    color: #1f2937;
    text-decoration: none;
}

/* Compact List */
.reference-list.compact-list {
    margin-top: 1rem;
}

.reference-list.compact-list .reference-list-title {
    font-size: 14px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 0.75rem;
    padding-bottom: 0.25rem;
    border-bottom: 1px solid #d1d5db;
}

.reference-list.compact-list .reference-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0.25rem 0;
    margin: 0.125rem 0;
    font-size: 13px;
}

.reference-list.compact-list .reference-number {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    background: #6b7280;
    color: white;
    font-size: 9px;
    font-weight: 600;
    border-radius: 3px;
    flex-shrink: 0;
}

.reference-list.compact-list .reference-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 12px;
    height: 12px;
    color: #9ca3af;
    font-size: 10px;
    flex-shrink: 0;
}

.reference-list.compact-list .reference-title {
    color: #374151;
    text-decoration: none;
    font-weight: 400;
    font-size: 13px;
}

.reference-list.compact-list .reference-title:hover {
    color: #6b7280;
}

/* Academic Style */
.reference-list.academic-style {
    margin-top: 1.5rem;
    font-family: 'Times New Roman', serif;
}

.reference-list.academic-style .reference-list-title {
    font-size: 16px;
    font-weight: bold;
    color: #000;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #000;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.reference-list.academic-style .reference-item {
    display: block;
    padding: 0.5rem 0;
    margin: 0.5rem 0;
    text-indent: -1.5rem;
    padding-left: 1.5rem;
    line-height: 1.4;
}

.reference-list.academic-style .reference-number {
    display: inline;
    font-weight: bold;
    color: #000;
    margin-right: 0.5rem;
}

.reference-list.academic-style .reference-icon {
    display: none; /* Hide icons in academic style */
}

.reference-list.academic-style .reference-title {
    color: #000;
    text-decoration: none;
    font-weight: normal;
    font-style: italic;
}

.reference-list.academic-style .reference-title:hover {
    color: #333;
    text-decoration: underline;
}

/* Cards Style - Matching Pinned Documents Design */
.reference-list.cards {
    margin-top: 1.5rem;
    position: relative;
}

.reference-list.cards .reference-list-title {
    font-size: 16px;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #e5e7eb;
}

.reference-list.cards .reference-list-container {
    display: flex;
    gap: 12px;
    overflow-x: hidden;
    padding: 8px 0;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    position: relative;
    max-width: 100%;
    width: 100%;
}

.reference-list.cards .carousel-arrow {
    position: absolute !important;
    top: calc(50% + 24px) !important;
    transform: translateY(-50%) !important;
    z-index: 20 !important;
    width: 32px !important;
    height: 32px !important;
    background: rgba(255, 255, 255, 0.9) !important;
    border: 1px solid #e5e7eb !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1) !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

.reference-list.cards .carousel-arrow:hover {
    background: white !important;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15) !important;
    transform: translateY(-50%) scale(1.05) !important;
}

.reference-list.cards .carousel-arrow.visible {
    opacity: 1 !important;
    pointer-events: auto !important;
}

.reference-list.cards .carousel-arrow.left {
    left: 8px !important;
}

.reference-list.cards .carousel-arrow.right {
    right: 8px !important;
}


.reference-list.cards .carousel-arrow svg {
    width: 16px !important;
    height: 16px !important;
    color: #6b7280 !important;
}

.reference-list.cards .carousel-arrow:hover svg {
    color: #374151 !important;
}


.reference-list.cards .reference-item {
    flex-shrink: 0;
    width: 210px;
    background: rgba(249, 250, 251, 0.5); /* bg-gray-50/50 */
    border: 1px solid #e5e7eb; /* border-gray-200 */
    border-radius: 8px; /* rounded-lg */
    padding: 16px; /* p-4 */
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05); /* shadow-sm */
    transition: all 0.2s ease;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    justify-content: center; /* Center content vertically */
    text-decoration: none;
    color: inherit;
    position: relative;
    min-height: fit-content; /* Allow natural height but ensure content is centered */
}

.reference-list.cards .reference-item:hover {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06); /* hover:shadow-md */
    background: #f9fafb; /* hover:bg-gray-50 */
}

.reference-list.cards .reference-item-content {
    display: grid;
    grid-template-columns: auto auto 1fr;
    align-items: center;
    gap: 2px; /* Further reduced gap */
}

.reference-list.cards .reference-icon-container {
    width: 40px; /* w-10 */
    height: 40px; /* h-10 */
    border-radius: 6px; /* rounded-md */
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--pdf-icon-bg, #dbeafe); /* Use custom color or fallback */
}

.reference-list.cards .reference-icon {
    width: 24px; /* w-6 */
    height: 24px; /* h-6 */
    color: var(--pdf-icon-color, #2563eb); /* Use custom color or fallback */
    fill: currentColor;
}

.reference-list.cards .reference-content {
    flex: 1;
    min-width: 0; /* min-w-0 */
}

.reference-list.cards .reference-title {
    color: #1f2937; /* text-gray-800 */
    text-decoration: none;
    font-weight: 500; /* font-weight-medium */
    font-size: 14px; /* text-sm */
    line-height: 1.25;
    display: block;
    margin: 0;
    word-wrap: break-word;
    overflow-wrap: break-word;
    transition: color 0.2s ease;
    truncate: true;
}

.reference-list.cards .reference-item:hover .reference-title {
    color: #1f2937; /* Keep same color on hover */
}


.reference-list.cards .reference-number {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    background: none;
    color: var(--tab-active-text, #592b8b);
    font-size: 12px;
    font-weight: 300;
    line-height: 1;
    flex-shrink: 0;
    border: none;
    border-radius: 0;
    width: 20px;
    height: auto;
    padding: 0;
    margin: 0;
    text-align: center;
    position: relative;
    top: -12px;
}

.reference-list.cards .reference-url {
    display: none; /* Hide URL in cards design */
}

/* Responsive Design */
@media (max-width: 640px) {
    .reference-list {
        margin-top: 1.5rem;
        padding: 1rem;
    }
    
    .reference-list-title {
        font-size: 14px;
    }
    
    .reference-item {
        margin: 0.5rem 0;
        font-size: 14px;
        padding: 0.5rem;
    }
    
    .reference-number {
        width: 20px;
        height: 20px;
        font-size: 10px;
    }
    
    .citation-icon {
        width: 14px;
        height: 14px;
        font-size: 9px;
    }
    
    /* Compact list responsive adjustments */
    .reference-list.compact-list .reference-item {
        font-size: 12px;
        padding: 0.25rem 0.5rem;
    }
    
    .reference-list.compact-list .reference-number {
        width: 18px;
        height: 18px;
        font-size: 8px;
    }
    
    /* Academic style responsive adjustments */
    .reference-list.academic-style .reference-item {
        text-indent: -1rem;
        padding-left: 1rem;
        font-size: 13px;
    }
    
    /* Cards responsive adjustments */
    .reference-list.cards .reference-item {
        width: 160px;
        padding: 12px;
    }
    
    .reference-list.cards .reference-icon-container {
        width: 32px;
        height: 32px;
        background-color: var(--pdf-icon-bg, #dbeafe); /* Use custom color or fallback */
    }
    
    .reference-list.cards .reference-icon {
        width: 20px;
        height: 20px;
        color: var(--pdf-icon-color, #2563eb); /* Use custom color or fallback */
    }
    
    .reference-list.cards .reference-title {
        font-size: 13px;
    }
}

/* Print Styles */
@media print {
    .reference-list {
        background: white;
        border: 1px solid #000;
        page-break-inside: avoid;
    }
    
    .reference-link {
        color: #000;
        text-decoration: underline;
    }
    
    .citation-icon {
        background: white;
        border: 1px solid #000;
        color: #000;
    }
}
