/**
 * ===================================================
 * Potential-Matcher - Such-Styles
 * ===================================================
 * 
 * CSS für die Suchfunktionalität
 * 
 * @copyright (c) 2025 Potential-Matcher
 * @license   Proprietär - Alle Rechte vorbehalten
 * 
 * Diese Software ist urheberrechtlich geschützt.
 * Die Nutzung ist nur mit ausdrücklicher schriftlicher
 * Erlaubnis des Autors gestattet.
 * ===================================================
 */

/* Suchcontainer */
.search-container {
    position: relative;
}

/* Autocomplete Vorschläge */
.autocomplete-suggestions {
    border: 1px solid #dee2e6;
    border-top: none;
    border-radius: 0 0 0.375rem 0.375rem;
    max-height: 250px;
    overflow-y: auto;
    z-index: 1050;
}

.autocomplete-item {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid #f8f9fa;
    cursor: pointer;
    transition: background-color 0.15s ease-in-out;
}

.autocomplete-item:last-child {
    border-bottom: none;
}

.autocomplete-item:hover {
    background-color: #f8f9fa;
}

.autocomplete-item:active {
    background-color: #e9ecef;
}

/* Such-Highlighting */
.search-highlight {
    background-color: #fff3cd;
    padding: 0.1rem 0.2rem;
    border-radius: 0.25rem;
    font-weight: 500;
}

/* Erweiterte Suche */
#advancedSearch .card-body {
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
}

#advancedSearch .form-label {
    font-weight: 500;
    color: #495057;
    font-size: 0.875rem;
}

/* Such-Statistiken */
.search-stats {
    background-color: #e7f1ff;
    border: 1px solid #b6d7ff;
    border-radius: 0.375rem;
    padding: 0.75rem;
    margin-bottom: 1rem;
}

.search-stats .stat-item {
    display: inline-block;
    margin-right: 1rem;
    font-size: 0.875rem;
}

.search-stats .stat-number {
    font-weight: 600;
    color: #0056b3;
}

/* Such-Ergebnisse */
.search-results-info {
    background-color: #d1ecf1;
    border: 1px solid #bee5eb;
    border-radius: 0.375rem;
    padding: 0.5rem 0.75rem;
    margin-bottom: 1rem;
    font-size: 0.875rem;
}

.search-results-info .search-term {
    font-weight: 600;
    color: #0c5460;
}

/* Dashboard-spezifische Anpassungen */
.dashboard-wrapper .search-container {
    margin-bottom: 1.5rem;
}

.dashboard-wrapper .search-container .input-group {
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
}

.dashboard-wrapper .search-container .form-control:focus {
    border-color: #86b7fe;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

/* Mobile Anpassungen */
@media (max-width: 768px) {
    .autocomplete-suggestions {
        max-height: 200px;
    }
    
    .search-container .input-group {
        flex-direction: column;
    }
    
    .search-container .input-group .btn {
        border-radius: 0.375rem !important;
        margin-top: 0.5rem;
    }
    
    #advancedSearch .row .col-md-4 {
        margin-bottom: 0.75rem;
    }
}

/* Animation für erweiterte Suche */
#advancedSearch {
    transition: all 0.3s ease-in-out;
}

.btn[data-bs-target="#advancedSearch"] i {
    transition: transform 0.2s ease-in-out;
}

.btn[data-bs-target="#advancedSearch"][aria-expanded="true"] i {
    transform: rotate(180deg);
}

/* Ladeanimation für Autocomplete */
.autocomplete-loading {
    padding: 0.5rem 0.75rem;
    text-align: center;
    color: #6c757d;
    font-style: italic;
}

.autocomplete-loading::after {
    content: "...";
    animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {
    0%, 20% {
        color: rgba(0,0,0,0);
        text-shadow:
            .25em 0 0 rgba(0,0,0,0),
            .5em 0 0 rgba(0,0,0,0);
    }
    40% {
        color: #6c757d;
        text-shadow:
            .25em 0 0 rgba(0,0,0,0),
            .5em 0 0 rgba(0,0,0,0);
    }
    60% {
        text-shadow:
            .25em 0 0 #6c757d,
            .5em 0 0 rgba(0,0,0,0);
    }
    80%, 100% {
        text-shadow:
            .25em 0 0 #6c757d,
            .5em 0 0 #6c757d;
    }
}

/* Erweiterte Suche Toggle */
.advanced-search-toggle {
    color: #0d6efd;
    text-decoration: none;
    font-size: 0.9em;
    cursor: pointer;
    border: none;
    background: none;
    padding: 0;
    transition: text-decoration 0.2s ease;
}

.advanced-search-toggle:hover {
    text-decoration: underline;
    color: #0a58ca;
}

.advanced-search-toggle:focus {
    outline: none;
    text-decoration: underline;
}

.advanced-search-panel {
    margin-top: 1rem;
    padding: 1rem;
    background-color: #f8f9fa;
    border-radius: 0.375rem;
    border: 1px solid #dee2e6;
}

/* Runde Action-Buttons für Potentiale-Multiselect */
.potentials-action-buttons {
    display: flex !important;
    flex-direction: row !important;
    gap: 0.25rem;
    align-items: center;
    justify-content: flex-end;
}

.potentials-action-buttons.d-flex {
    display: flex !important;
}

.potentials-confirm-btn,
.potentials-reset-btn {
    width: 32px !important;
    height: 32px !important;
    padding: 0 !important;
    display: flex !important;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    border: none;
    font-size: 0.875rem;
    flex-shrink: 0;
    margin: 0 !important;
}

.potentials-confirm-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 2px 8px rgba(25, 135, 84, 0.3);
}

.potentials-reset-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 2px 8px rgba(220, 53, 69, 0.3);
}

.potentials-confirm-btn i,
.potentials-reset-btn i {
    margin: 0;
    font-size: 1rem;
    font-weight: bold;
}

/* Multiselect Container */
.search-layout-potentials {
    position: relative;
}

/* Multi-Select Styling für Dashboard Search */
.search-potentials {
    min-height: 96px;    /* 20% höher: 80px * 1.2 = 96px */
    max-height: 240px;   /* 20% höher: 200px * 1.2 = 240px */
    overflow-y: auto;
    border: 1px solid #ddd;
    border-radius: 4px;
    background-color: #fff;
}

.search-potentials option {
    padding: 0.5rem !important;
    border: none;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    background-color: #fff !important; /* Weißer Hintergrund für alle */
}

/* JavaScript wird die Textfarben aus data-color setzen */
.search-potentials .potential-option {
    background-color: #fff !important;
    font-weight: normal;
}

.search-potentials .potential-option[data-weight="bold"] {
    font-weight: bold !important;
}

/* "Alle Potentialbereiche" Option mit grauem Text */
.search-potentials .all-potentials-option {
    background-color: #f8f9fa !important;
    color: #6c757d !important;
    font-weight: bold !important;
    border-bottom: 2px solid #dee2e6 !important;
}

/* Hover-Effekte - GELB für bessere Benutzerführung - SEHR SPEZIFISCH */
.search-potentials option:hover,
.search-potentials .potential-option:hover,
.search-potentials option.potential-option:hover {
    background-color: #ffc107 !important;
    color: #000 !important;
    background: #ffc107 !important;
}

/* Hover für ausgewählte Elemente - soll weiterhin gelb werden */
.search-potentials .force-selected:hover,
.search-potentials option:checked:hover,
.search-potentials option[selected]:hover {
    background-color: #ffc107 !important;
    color: #000 !important;
    background: #ffc107 !important;
}

/* CRITICAL: Styling für ausgewählte Optionen - MUSS SICHTBAR SEIN */
/* Verwende nur die force-selected Klasse für die visuelle Darstellung */
.search-potentials .force-selected {
    background-color: #0d6efd !important;
    color: #ffffff !important;
    font-weight: bold !important;
}

/* Alternative für WebKit-Browser (Chrome, Safari) */
.search-potentials .force-selected {
    background: linear-gradient(#0d6efd, #0d6efd) !important;
    background-color: #0d6efd !important;
    color: #ffffff !important;
}

/* Stelle sicher, dass nicht-ausgewählte Optionen weiß bleiben */
.search-potentials option:not(.force-selected) {
    background-color: #fff !important;
    background: #fff !important;
}

/* Spezifische Regel für potential-options die nicht force-selected sind */
.search-potentials .potential-option:not(.force-selected) {
    background-color: #fff !important;
    background: #fff !important;
}

/* Focus-Styling für bessere Zugänglichkeit */
.search-potentials option:focus {
    outline: 2px solid #0d6efd !important;
    outline-offset: -2px !important;
}

/* ========================================
   LAYOUT-ANPASSUNGEN FÜR ERWEITERTE SUCHE
   ======================================== */

/* Spezielle Spaltenbreiten für Jahrgänge (schmaler) und Potentiale (breiter) */
.search-layout-grades {
    flex: 0 0 35%;  /* Jahrgänge-Spalte schmaler (35% statt 50%) */
    max-width: 35%;
}

.search-layout-potentials {
    flex: 0 0 65%;  /* Potentiale-Spalte breiter (65% statt 50%) */
    max-width: 65%;
}

/* Responsive Anpassungen für kleinere Bildschirme */
@media (max-width: 768px) {
    .search-layout-grades,
    .search-layout-potentials {
        flex: 0 0 100%;
        max-width: 100%;
    }
}

/* ========================================
   ERWEITERTE SUCHE BUTTONS
   ======================================== */

/* Erweiterte Suche Toggle Link - Dashboard-Style */
.search-advanced-toggle {
    font-weight: normal !important;
    text-decoration: none !important;
    color: #000 !important;
    display: inline-block;
}

.search-advanced-toggle:hover {
    color: #0d6efd !important;
    text-decoration: none !important;
    box-shadow: 0 2px 0 #0d6efd !important;
}

.search-advanced-toggle:focus {
    outline: 2px solid #0d6efd !important;
    outline-offset: 2px !important;
}

/* Reset-Link - Dashboard-Style */
.search-reset-link {
    font-weight: 500 !important;
    text-decoration: none !important;
    color: #000 !important;
}

.search-reset-link:hover {
    color: #0d6efd !important;
    text-decoration: none !important;
    box-shadow: 0 2px 0 #0d6efd !important;
}

/* ========================================
   ERWEITERTE FILTER STYLES
   ======================================== */

/* Jahrgänge Checkbox-Container */
.grades-checkbox-container {
    padding: 0.5rem;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    background-color: #fff;
    min-height: 60px;
}

.grades-checkbox-container .form-check {
    margin-bottom: 0;
    margin-right: 0.5rem;
}

.grades-checkbox-container .form-check:last-child {
    margin-right: 0;
}

/* Potentiale Multi-Select */
.potentials-multiselect {
    min-height: 180px;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
}

.potentials-multiselect:focus {
    border-color: #86b7fe;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

/* Optionen mit Farben stylen */
.potentials-multiselect option {
    padding: 0.5rem;
    margin: 1px 0;
    font-weight: 500;
    border-radius: 3px;
}

.potentials-multiselect option:checked {
    background-color: #ffc107 !important; /* Gelb für ausgewählte */
    color: #000 !important; /* Schwarzer Text für bessere Lesbarkeit */
    font-weight: 600;
    text-shadow: none;
}

.potentials-multiselect option:hover {
    opacity: 0.8;
}

/* "Alle Potentialbereiche" Option speziell stylen */
.potentials-multiselect option[value=""] {
    border-bottom: 2px solid #dee2e6;
    margin-bottom: 4px;
}

/* Checkbox Styling für erweiterte Suche */
.advanced-search-panel .form-check-input {
    margin-top: 0.125rem;
}

.advanced-search-panel .form-check-label {
    font-size: 0.9rem;
    color: #495057;
}

/* Multi-Select Hilfetext */
.multiselect-help {
    font-size: 0.8rem;
    color: #6c757d;
    margin-top: 0.25rem;
}

/* Responsive Anpassungen für erweiterte Suche */
@media (max-width: 768px) {
    /* Mobile Suchfeld-Optimierung - Icon ausblenden, Input volle Breite */
    .search-container .input-group-text {
        display: none !important;
    }
    
    .search-container .input-group {
        display: block !important;
    }
    
    .search-container .form-control {
        font-size: 16px !important; /* Verhindert iOS Safari Zoom */
        border-radius: 0.375rem !important;
        width: 100% !important;
        margin-bottom: 0.5rem !important;
    }
    
    .search-container .btn {
        width: 100% !important;
        margin-bottom: 0.25rem !important;
    }
    
    /* Jahrgänge-Checkboxen linksbündig statt justify-content: space-between */
    .grades-checkbox-container {
        min-height: 80px;
    }
    
    .grades-checkbox-container .d-flex {
        justify-content: flex-start !important;
        gap: 1rem;
    }
    
    .potentials-multiselect {
        min-height: 150px;
    }
    
    .advanced-search-panel .row {
        margin-bottom: 0.5rem;
    }
    
}
