/**
 * Global Search Styling
 *
 * Custom styles for the global search functionality including
 * search input, results dropdown, and result items.
 */

/* Search Input Enhancements */
#globalSearch {
    transition: all 0.2s ease-in-out;
    font-size: 0.95rem;
}

#globalSearch:focus {
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.15);
    border-color: #86b7fe !important;
}

#globalSearch::placeholder {
    color: #adb5bd;
    font-size: 0.9rem;
}

/* Clear Button Styling */
#clearSearch {
    opacity: 0.6;
    transition: opacity 0.2s ease-in-out;
}

#clearSearch:hover {
    opacity: 1;
}

/* Results Dropdown Container */
#searchResults {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 0.5rem;
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: 0.375rem;
    z-index: 1050;
    min-width: 350px;
}

/* Result Groups */
.result-group {
    margin: 0;
}

.result-group:last-child {
    border-bottom: none !important;
}

.result-group-header {
    position: sticky;
    top: 0;
    z-index: 1;
    background-color: #f8f9fa !important;
    border-bottom: 1px solid #dee2e6;
}

.result-group-header small {
    font-size: 0.75rem;
    letter-spacing: 0.05em;
}

/* Result Items */
.result-item {
    border: none;
    border-bottom: 1px solid #f1f3f5;
    transition: all 0.15s ease-in-out;
    text-decoration: none;
    color: inherit;
}

.result-item:last-child {
    border-bottom: none;
}

.result-item:hover,
.result-item.active {
    background-color: #f8f9fa;
    cursor: pointer;
}

.result-item.active {
    background-color: #e7f1ff;
    border-left: 3px solid #0d6efd;
}

/* Result Item Content */
.result-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.25rem;
    background-color: #f8f9fa;
}

.result-icon i {
    font-size: 1.1rem;
}

.result-title {
    font-size: 0.95rem;
    line-height: 1.4;
    color: #212529;
}

.result-subtitle {
    font-size: 0.85rem;
    line-height: 1.3;
    color: #6c757d;
    margin-top: 0.125rem;
}

.result-metadata {
    font-size: 0.8rem;
    white-space: nowrap;
}

/* Search Highlight */
.result-item mark {
    padding: 0.1em 0.2em;
    border-radius: 0.2em;
}

/* Result Footer */
.result-footer {
    position: sticky;
    bottom: 0;
    background-color: #f8f9fa !important;
    border-top: 1px solid #dee2e6 !important;
}

.result-footer small {
    font-size: 0.8rem;
}

/* Loading State */
.result-item.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* Empty State */
.empty-state {
    padding: 3rem 1.5rem;
    text-align: center;
}

.empty-state i {
    opacity: 0.3;
}

.empty-state div {
    margin-top: 1rem;
    font-size: 0.95rem;
}

/* Keyboard Shortcut Badge (in placeholder) */
.search-shortcut-badge {
    display: inline-block;
    padding: 0.15em 0.4em;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1;
    color: #6c757d;
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 0.25rem;
    margin-left: 0.5rem;
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    #searchResults {
        position: fixed;
        top: 60px;
        left: 0;
        right: 0;
        margin: 0;
        border-radius: 0;
        max-height: calc(100vh - 60px);
        overflow-y: auto;
    }

    .result-group-header {
        position: sticky;
        top: 0;
    }

    .result-metadata {
        display: none;
    }
}

@media (max-width: 576px) {
    #globalSearch {
        font-size: 0.9rem;
    }

    #globalSearch::placeholder {
        font-size: 0.85rem;
    }

    .result-title {
        font-size: 0.9rem;
    }

    .result-subtitle {
        font-size: 0.8rem;
    }
}

/* Animation for dropdown appearance */
@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

#searchResults[style*="display: block"] {
    animation: slideDown 0.2s ease-out;
}

/* Focus visible for accessibility */
.result-item:focus-visible {
    outline: 2px solid #0d6efd;
    outline-offset: -2px;
    z-index: 1;
}

/* Print styles - hide search in print */
@media print {
    #globalSearchForm,
    #searchResults {
        display: none !important;
    }
}
