/**
 * HTR Search Styles
 *
 * Styles for displaying HTR search results with highlighted text regions
 * on manuscript images. Uses regular search-result classes for consistency.
 */

/* Results List Container */
.htr-search-results-list {
    /* Inherits from .search-results-list */
}

/* Individual Result - extends regular search-result */
.htr-search-result {
    margin-bottom: 2rem;
}

.htr-search-result-count {
    margin: 0.5rem 0;
    color: #0066cc;
    font-size: 0.9rem;
    font-weight: 500;
}

/* Match Display */
.htr-search-result-matches {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.htr-search-result-match {
    border-top: 1px solid #eee;
    padding-top: 1rem;
}


/* Match Toggle Button */
.htr-search-result-match-toggle {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    width: 100%;
    padding: 0.5rem 0.75rem;
    background: #f8f8f8;
    border: 1px solid #e0e0e0;
    border-left: 3px solid #ffeb3b;
    border-radius: 2px;
    cursor: pointer;
    text-align: left;
    font-family: 'Georgia', serif;
    line-height: 1.6;
}

.htr-search-result-match-toggle:hover {
    background: #f0f0f0;
}

.htr-match-toggle-icon {
    display: inline-block;
    font-size: 0.85rem;
    color: #555;
    transition: transform 0.15s ease;
    flex-shrink: 0;
}

.htr-match-toggle-icon.expanded {
    transform: rotate(180deg);
}

.htr-search-result-snippet-inline em {
    background: #ffeb3b;
    font-style: normal;
    font-weight: 600;
    padding: 0 2px;
}

.htr-search-result-page-inline {
    margin-left: auto;
    color: #888;
    font-size: 0.85rem;
    white-space: nowrap;
    font-family: sans-serif;
}

.htr-search-result-image {
    margin: 0.75rem 0 0.5rem;
}

.htr-search-result-page {
    margin: 0;
    color: #888;
    font-size: 0.85rem;
}

/* Region Display */
.htr-region-display {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    border-radius: 2px;
    overflow: hidden;
}

.htr-region-display img {
    display: block;
}

.htr-region-display-error {
    padding: 2rem;
    text-align: center;
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 4px;
    color: #856404;
}

.htr-region-display-loading {
    padding: 2rem;
    text-align: center;
    background: #f8f8f8;
    color: #666;
}

/* Highlight Overlay */
.htr-highlight-overlay {
    /* Styles applied inline for dynamic positioning */
    box-sizing: border-box;
}

.htr-highlight-overlay:hover {
    background-color: rgba(255, 255, 0, 0.5) !important;
}

/* Empty and Loading States */
.htr-search-results-empty,
.htr-search-results-loading,
.htr-search-results-error {
    padding: 3rem 2rem;
    text-align: center;
    background: #f8f8f8;
    border-radius: 4px;
    margin: 2rem 0;
}

.htr-search-results-empty p {
    margin: 0 0 0.5rem 0;
    font-size: 1.1rem;
    color: #666;
}

.htr-search-results-empty-hint {
    color: #999;
    font-size: 0.9rem;
}

.htr-search-results-loading p {
    margin: 0;
    color: #666;
    font-size: 1.1rem;
}

.htr-search-results-error {
    background: #fff3cd;
    border: 1px solid #ffc107;
    color: #856404;
}

.htr-search-results-error p {
    margin: 0;
}

/* Responsive Styles */
@media (max-width: 768px) {
    .htr-search-result {
        padding: 1rem;
    }

    .htr-search-result-header {
        flex-direction: column;
    }

    .htr-search-result-thumb img {
        width: 100%;
        max-width: 200px;
    }

    .htr-search-result-snippet {
        font-size: 0.9rem;
    }

    .htr-region-display {
        max-width: 100%;
    }
}
