/**
 * search-highlighting.css
 * Styles für die Such- und Filterfunktion im TreeViewer v2.4.0
 * 
 * @author EXPECTATE Consulting GmbH
 * @version 2.4.0
 * 
 * NEU in v2.4.0:
 * - Erweiterte Filterleiste mit Dropdowns
 * - Pfad-Kontext-Darstellung für Elternknoten
 * - Filter-Chips für aktive Filter
 * - Statistik-Anzeige für Filterergebnisse
 */

/* ============================================================================
   SEARCH INPUT STYLING
   ============================================================================ */

.search-input {
    padding: 8px 14px;
    border: 2px solid #e0e0e0;
    border-radius: 20px;
    font-size: 14px;
    width: 220px;
    transition: all 0.2s ease;
    background: white;
}

.search-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15);
    width: 280px;
}

.search-input:not(:placeholder-shown) {
    border-color: #667eea;
}

.search-input::placeholder {
    color: #9e9e9e;
}

/* Such-Button */
#search-button {
    background: #667eea;
    border: none;
    color: white;
    padding: 8px 14px;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
}

#search-button:hover {
    background: #5a6fd6;
    transform: translateY(-1px);
}

#search-button:active {
    transform: translateY(0);
}

/* ============================================================================
   SEARCH RESULTS INFO BAR
   ============================================================================ */

.search-results-info {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 8px;
    font-size: 13px;
    margin: 0 12px;
    animation: slideIn 0.3s ease-out;
}

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

.search-results-info .result-count {
    font-weight: 600;
}

.search-results-info .nav-buttons {
    display: flex;
    gap: 4px;
    margin-left: auto;
}

.search-results-info .nav-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    padding: 4px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s ease;
}

.search-results-info .nav-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.search-results-info .clear-btn {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.search-results-info .clear-btn:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* ============================================================================
   TREE NODE SEARCH HIGHLIGHTS
   ============================================================================ */

/* Alle gefundenen Treffer */
.tree-node.search-match > .tree-node-header {
    background: linear-gradient(135deg, #fff3e0 0%, #ffe0b2 100%) !important;
    border: 2px solid #ff9800 !important;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(255, 152, 0, 0.2);
}

/* Aktuell ausgewählter Treffer */
.tree-node.search-current > .tree-node-header {
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%) !important;
    border: 2px solid #2196f3 !important;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(33, 150, 243, 0.3);
    transform: scale(1.01);
}

/* Flash-Animation für erste Fundstelle */
.tree-node.search-match-flash > .tree-node-header {
    animation: searchFlash 1.5s ease-out;
}

@keyframes searchFlash {
    0% {
        background: #667eea !important;
        transform: scale(1.02);
    }
    15% {
        background: #667eea !important;
    }
    100% {
        background: linear-gradient(135deg, #fff3e0 0%, #ffe0b2 100%) !important;
        transform: scale(1);
    }
}

/* FIM-ID Badge Highlight bei Treffern */
.tree-node.search-match .badge-fim-id,
.tree-node.search-current .badge-fim-id {
    background-color: #fff8e1 !important;
    border-color: #ffb300 !important;
    color: #e65100 !important;
    font-weight: 700;
}

/* Label Highlight bei Treffern */
.tree-node.search-match .tree-label,
.tree-node.search-current .tree-label {
    font-weight: 600;
    color: #37474f;
}

/* ============================================================================
   SEARCH MATCH BADGE (optionaler Treffer-Indikator)
   ============================================================================ */

.tree-node.search-match::before {
    content: '●';
    position: absolute;
    left: -20px;
    top: 50%;
    transform: translateY(-50%);
    color: #ff9800;
    font-size: 10px;
    animation: pulse 2s infinite;
}

.tree-node.search-current::before {
    content: '▶';
    color: #2196f3;
    font-size: 12px;
    animation: none;
}

@keyframes pulse {
    0%, 100% {
        opacity: 0.5;
    }
    50% {
        opacity: 1;
    }
}

/* ============================================================================
   NO RESULTS STATE
   ============================================================================ */

.search-no-results {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: #ffebee;
    color: #c62828;
    border-radius: 8px;
    font-size: 13px;
    margin: 0 12px;
    border-left: 3px solid #ef5350;
}

.search-no-results .no-results-icon {
    font-size: 18px;
}

/* ============================================================================
   SEARCH KEYBOARD HINT
   ============================================================================ */

.search-hint {
    font-size: 11px;
    color: #9e9e9e;
    margin-left: 8px;
}

.search-hint kbd {
    background: #f5f5f5;
    border: 1px solid #e0e0e0;
    border-radius: 3px;
    padding: 1px 4px;
    font-family: monospace;
    font-size: 10px;
}

/* ============================================================================
   RESPONSIVE ADJUSTMENTS
   ============================================================================ */

@media (max-width: 768px) {
    .search-input {
        width: 150px;
    }
    
    .search-input:focus {
        width: 200px;
    }
    
    .search-results-info {
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .search-results-info .nav-buttons {
        width: 100%;
        justify-content: center;
    }
}

/* ============================================================================
   DARK THEME SUPPORT
   ============================================================================ */

[data-theme="dark"] .search-input {
    background: #424242;
    border-color: #616161;
    color: white;
}

[data-theme="dark"] .search-input:focus {
    border-color: #90caf9;
    box-shadow: 0 0 0 3px rgba(144, 202, 249, 0.2);
}

[data-theme="dark"] .tree-node.search-match > .tree-node-header {
    background: linear-gradient(135deg, #4a4a00 0%, #5d5d00 100%) !important;
    border-color: #ffb300 !important;
}

[data-theme="dark"] .tree-node.search-current > .tree-node-header {
    background: linear-gradient(135deg, #1a3a5c 0%, #1e4976 100%) !important;
    border-color: #64b5f6 !important;
}

[data-theme="dark"] .search-no-results {
    background: #5d2323;
    color: #ffcdd2;
}

/* ============================================================================
   FILTER TOOLBAR - v2.4.0
   ============================================================================ */

.filter-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border: 1px solid #dee2e6;
    border-radius: 8px;
    margin: 8px 0;
}

.filter-toolbar-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    color: #495057;
}

.filter-toolbar-label .filter-icon {
    font-size: 16px;
}

.filter-group {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    flex: 1;
}

.filter-select-wrapper {
    position: relative;
    min-width: 160px;
}

.filter-select-wrapper label {
    display: block;
    font-size: 10px;
    font-weight: 600;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.filter-select {
    width: 100%;
    padding: 8px 32px 8px 12px;
    font-size: 13px;
    border: 1px solid #ced4da;
    border-radius: 6px;
    background: white;
    color: #495057;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236c757d' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    transition: all 0.2s ease;
}

.filter-select:hover {
    border-color: #667eea;
}

.filter-select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15);
}

.filter-select.active {
    border-color: #667eea;
    background-color: #f0f4ff;
    font-weight: 500;
}

.filter-actions {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

.filter-btn {
    padding: 8px 14px;
    font-size: 12px;
    font-weight: 500;
    border: 1px solid #ced4da;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.filter-btn-reset {
    background: white;
    color: #6c757d;
}

.filter-btn-reset:hover {
    background: #f8f9fa;
    border-color: #adb5bd;
    color: #495057;
}

.filter-btn-reset:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Filter-Statistik */
.filter-stats {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 20px;
    font-size: 12px;
    color: #495057;
    white-space: nowrap;
}

.filter-stats .stats-icon {
    color: #667eea;
}

.filter-stats .stats-count {
    font-weight: 600;
    color: #667eea;
}

.filter-stats.has-filter {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-color: transparent;
}

.filter-stats.has-filter .stats-icon,
.filter-stats.has-filter .stats-count {
    color: white;
}

/* ============================================================================
   FILTER MATCH STATES - Pfad-Kontext-Darstellung
   ============================================================================ */

/* Element erfüllt Filter direkt = TREFFER */
.tree-node.filter-match > .tree-node-header {
    background: linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 100%) !important;
    border-left: 4px solid #4caf50 !important;
    border-radius: 4px;
}

.tree-node.filter-match > .tree-node-header .tree-label {
    font-weight: 600;
    color: #2e7d32;
}

.tree-node.filter-match > .tree-node-header .badge-fim-id {
    background: #e8f5e9 !important;
    border-color: #4caf50 !important;
    color: #2e7d32 !important;
}

/* Element ist Eltern-Pfad zu einem Treffer = KONTEXT */
.tree-node.filter-path > .tree-node-header {
    background: #fafafa !important;
    opacity: 0.7;
    border-left: 2px dashed #bdbdbd !important;
    border-radius: 4px;
}

.tree-node.filter-path > .tree-node-header .tree-label {
    color: #757575;
    font-weight: 400;
}

.tree-node.filter-path > .tree-node-header .tree-icon {
    opacity: 0.5;
}

.tree-node.filter-path > .tree-node-header .tree-badge {
    opacity: 0.5;
}

/* Pfad-Indikator */
.tree-node.filter-path > .tree-node-header .tree-node-header-right::after {
    content: '⋯';
    margin-left: 8px;
    color: #9e9e9e;
    font-size: 14px;
}

/* Element entspricht NICHT dem Filter und hat keine passenden Kinder = VERSTECKT */
.tree-node.filter-hidden {
    display: none !important;
}

/* Kombinierter Status: Suche + Filter */
.tree-node.filter-match.search-match > .tree-node-header {
    background: linear-gradient(135deg, #fff8e1 0%, #ffecb3 100%) !important;
    border-left: 4px solid #ff9800 !important;
    border: 2px solid #ff9800 !important;
}

.tree-node.filter-match.search-current > .tree-node-header {
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%) !important;
    border: 2px solid #2196f3 !important;
    border-left: 4px solid #2196f3 !important;
}

/* ============================================================================
   FILTER ACTIVE INDICATOR
   ============================================================================ */

.viewer-toolbar.filter-active {
    border-bottom: 2px solid #667eea;
    position: relative;
}

.viewer-toolbar.filter-active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, #667eea, #764ba2, #667eea);
    background-size: 200% 100%;
    animation: filterGradient 2s linear infinite;
}

@keyframes filterGradient {
    0% { background-position: 0% 0%; }
    100% { background-position: 200% 0%; }
}

/* ============================================================================
   FILTER CHIPS (aktive Filter anzeigen)
   ============================================================================ */

.filter-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: #e8eaf6;
    border: 1px solid #c5cae9;
    border-radius: 16px;
    font-size: 11px;
    color: #3949ab;
}

.filter-chip .chip-label {
    font-weight: 600;
}

.filter-chip .chip-value {
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.filter-chip .chip-remove {
    background: none;
    border: none;
    color: #7986cb;
    cursor: pointer;
    padding: 0;
    font-size: 14px;
    line-height: 1;
    transition: color 0.2s;
}

.filter-chip .chip-remove:hover {
    color: #3949ab;
}

/* ============================================================================
   FILTER TOGGLE BUTTON
   ============================================================================ */

.filter-toggle-btn {
    padding: 6px 12px;
    font-size: 13px;
    font-weight: 500;
    background: white;
    color: #667eea;
    border: 1px solid #667eea;
    border-radius: 6px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
}

.filter-toggle-btn:hover {
    background: #f0f4ff;
}

.filter-toggle-btn.active {
    background: #667eea;
    color: white;
}

.filter-toggle-btn .filter-count {
    background: #ff9800;
    color: white;
    padding: 1px 6px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
}

/* ============================================================================
   DARK THEME - Filter Styles
   ============================================================================ */

[data-theme="dark"] .filter-toolbar {
    background: linear-gradient(135deg, #2d2d2d 0%, #1f1f1f 100%);
    border-color: #424242;
}

[data-theme="dark"] .filter-toolbar-label {
    color: #e0e0e0;
}

[data-theme="dark"] .filter-select-wrapper label {
    color: #9e9e9e;
}

[data-theme="dark"] .filter-select {
    background: #424242;
    border-color: #616161;
    color: #e0e0e0;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%239e9e9e' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
}

[data-theme="dark"] .filter-select:hover,
[data-theme="dark"] .filter-select:focus {
    border-color: #90caf9;
}

[data-theme="dark"] .filter-select.active {
    background-color: #1a3a5c;
    border-color: #64b5f6;
}

[data-theme="dark"] .filter-stats {
    background: #424242;
    border-color: #616161;
    color: #e0e0e0;
}

[data-theme="dark"] .tree-node.filter-match > .tree-node-header {
    background: linear-gradient(135deg, #1b3d1f 0%, #2e5033 100%) !important;
}

[data-theme="dark"] .tree-node.filter-match > .tree-node-header .tree-label {
    color: #81c784;
}

[data-theme="dark"] .tree-node.filter-path > .tree-node-header {
    background: #2d2d2d !important;
    opacity: 0.6;
}

[data-theme="dark"] .filter-chip {
    background: #3949ab;
    border-color: #5c6bc0;
    color: #e8eaf6;
}

[data-theme="dark"] .filter-toggle-btn {
    background: #424242;
    border-color: #90caf9;
    color: #90caf9;
}

[data-theme="dark"] .filter-toggle-btn:hover {
    background: #1a3a5c;
}

[data-theme="dark"] .filter-toggle-btn.active {
    background: #667eea;
    color: white;
}

/* ============================================================================
   RESPONSIVE - Filter Toolbar
   ============================================================================ */

@media (max-width: 992px) {
    .filter-toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    
    .filter-group {
        flex-wrap: wrap;
    }
    
    .filter-select-wrapper {
        min-width: 140px;
        flex: 1;
    }
    
    .filter-actions {
        justify-content: space-between;
        margin-top: 8px;
    }
}

@media (max-width: 576px) {
    .filter-select-wrapper {
        min-width: 100%;
    }
    
    .filter-stats {
        width: 100%;
        justify-content: center;
    }
}
