/**
 * CSS for source sentence highlighting and truth block mapping
 */

/* Highlighted content container */
.highlighted-content {
    line-height: 1.6;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 0.375rem;
    border: 1px solid #e9ecef;
}

/* Base style for highlighted sentences */
.truth-block-highlight {
    padding: 2px 4px;
    border-radius: 3px;
    margin: 0 1px;
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
}

/* Quality-based colors for truth block highlighting */
.truth-block-highlight.quality-excellent {
    background-color: rgba(39, 174, 96, 0.3); /* var(--color-excellent) with transparency */
    border-left: 4px solid var(--color-excellent);
    color: #1e7e34; /* Darker green for text readability */
}

.truth-block-highlight.quality-good {
    background-color: rgba(46, 204, 113, 0.3); /* var(--color-good) with transparency */
    border-left: 4px solid var(--color-good);
    color: #155724; /* Darker green for text readability */
}

.truth-block-highlight.quality-moderate-high {
    background-color: rgba(243, 156, 18, 0.3); /* var(--color-moderate-high) with transparency */
    border-left: 4px solid var(--color-moderate-high);
    color: #856404; /* Darker orange for text readability */
}

.truth-block-highlight.quality-moderate-low {
    background-color: rgba(230, 126, 34, 0.3); /* var(--color-moderate-low) with transparency */
    border-left: 4px solid var(--color-moderate-low);
    color: #8b4513; /* Darker orange for text readability */
}

.truth-block-highlight.quality-poor {
    background-color: rgba(231, 76, 60, 0.3); /* var(--color-poor) with transparency */
    border-left: 4px solid var(--color-poor);
    color: #721c24; /* Darker red for text readability */
}

.truth-block-highlight.quality-unknown {
    background-color: rgba(149, 165, 166, 0.3); /* var(--color-unknown) with transparency */
    border-left: 4px solid var(--color-unknown);
    color: #495057; /* Darker gray for text readability */
}

/* Fallback colors for specific truth blocks (still needed for backward compatibility) */
.tb-0, .tb-1, .tb-2, .tb-3, .tb-4, .tb-5, .tb-6, .tb-7 {
    /* These will be overridden by quality classes but kept for fallback */
    border-left: 3px solid #6c757d;
}

/* Hover effects */
.truth-block-highlight:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    z-index: 10;
}

/* Active/focused state */
.truth-block-highlight.active {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

/* Enhanced tooltip for quality-based highlighting */
.truth-block-highlight::after {
    content: "Quality: " attr(data-quality-score) " - " attr(data-quality-label) " (Block " attr(data-block-index) ")";
    position: absolute;
    top: -35px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.9);
    color: white;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 0.75rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 20;
    max-width: 250px;
    text-align: center;
}

.truth-block-highlight:hover::after {
    opacity: 1;
}

/* Highlight legend styles */
.highlight-legend {
    background: #e9ecef;
    padding: 0.5rem;
    border-radius: 0.25rem;
    border-left: 4px solid #6c757d;
}

/* Quality legend styles */
.quality-legend {
    border: 1px solid #dee2e6;
}

.quality-legend-item {
    display: inline-flex;
    align-items: center;
    font-size: 0.8rem;
    margin: 0.1rem;
}

.quality-sample {
    display: inline-block;
    width: 16px;
    height: 16px;
    border-radius: 3px;
    margin-right: 0.4rem;
    border: 1px solid rgba(0,0,0,0.1);
}

/* Quality sample colors matching highlight styles */
.quality-sample.quality-excellent {
    background-color: rgba(39, 174, 96, 0.6);
    border-left: 3px solid var(--color-excellent);
}

.quality-sample.quality-good {
    background-color: rgba(46, 204, 113, 0.6);
    border-left: 3px solid var(--color-good);
}

.quality-sample.quality-moderate-high {
    background-color: rgba(243, 156, 18, 0.6);
    border-left: 3px solid var(--color-moderate-high);
}

.quality-sample.quality-moderate-low {
    background-color: rgba(230, 126, 34, 0.6);
    border-left: 3px solid var(--color-moderate-low);
}

.quality-sample.quality-poor {
    background-color: rgba(231, 76, 60, 0.6);
    border-left: 3px solid var(--color-poor);
}

/* Source mapping section styles */
.source-mapping {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 0.375rem;
    padding: 1rem;
}

.source-sentence-item {
    background: white;
    padding: 0.5rem;
    border-left: 3px solid #007bff;
    margin: 0.25rem 0;
    border-radius: 0.25rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* Extraction type badges */
.source-mapping .badge {
    font-size: 0.7rem;
    padding: 0.25rem 0.5rem;
}

/* Truth block content styling */
.truth-block-content {
    position: relative;
}

.truth-block-text {
    font-size: 1.1rem;
    line-height: 1.6;
    margin-bottom: 1rem;
    padding: 1rem;
    background: #fff;
    border-left: 4px solid #007bff;
    border-radius: 0.25rem;
}

/* Enhanced anchor navigation styles */
.truth-block {
    scroll-margin-top: 80px; /* Offset for fixed headers */
    transition: all 0.3s ease;
}

.truth-block:target,
.truth-block.truth-block-highlighted {
    border-left-color: #0056b3 !important;
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.3) !important;
    background: linear-gradient(90deg, rgba(0, 123, 255, 0.05) 0%, transparent 100%) !important;
}

/* Interactive highlighting JavaScript hooks */
.truth-block[data-block-index] {
    transition: all 0.3s ease;
}

.truth-block[data-block-index]:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(0,0,0,0.1);
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .highlighted-content {
        padding: 0.75rem;
        font-size: 0.9rem;
    }

    .truth-block-highlight::after {
        font-size: 0.6rem;
        padding: 2px 6px;
    }

    .source-mapping {
        padding: 0.75rem;
    }
}

/* Truth block link styles for node detail pages */
.truth-block-link {
    text-decoration: none !important;
    display: inline;
    transition: all 0.2s ease;
}

.truth-block-link:hover {
    text-decoration: none !important;
    transform: scale(1.02);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.truth-block-link:hover .truth-block-highlight {
    filter: brightness(1.1);
    border-left-width: 5px;
}

.truth-block-link:focus {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}
