/**
 * Enhanced Search Experience Styles for Chiholog
 * Provides styling for advanced search suggestions, history, date picker, and result display improvements
 */

/* Advanced Search Suggestions */
.advanced-search-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 1050;
    background: white;
    border: 1px solid #dee2e6;
    border-top: none;
    border-radius: 0 0 0.375rem 0.375rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    max-height: 400px;
    overflow-y: auto;
    display: none;
}

.suggestions-header {
    padding: 8px 12px;
    background: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
    font-weight: 600;
    font-size: 0.875rem;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.advanced-suggestion {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    border-bottom: 1px solid #f8f9fa;
}

.advanced-suggestion:hover,
.advanced-suggestion.active {
    background: #e3f2fd;
    color: #1565c0;
}

.advanced-suggestion:last-child {
    border-bottom: none;
}

.suggestion-content {
    display: flex;
    align-items: center;
    flex: 1;
}

.suggestion-content i {
    margin-right: 8px;
    width: 16px;
    opacity: 0.7;
}

.suggestion-text {
    font-weight: 500;
}

.suggestion-type {
    font-size: 0.75rem;
    padding: 2px 6px;
    border-radius: 0.25rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.suggestion-type {
    background: #e9ecef;
    color: #6c757d;
}

.suggestion-type.popular {
    background: #fff3cd;
    color: #856404;
}

.suggestion-type.combo {
    background: #d1ecf1;
    color: #0c5460;
}

/* Search History */
.search-history-btn {
    border-left: none !important;
    border-radius: 0 0.375rem 0.375rem 0 !important;
}

.search-history-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 1050;
    background: white;
    border: 1px solid #dee2e6;
    border-top: none;
    border-radius: 0 0 0.375rem 0.375rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    max-height: 350px;
    overflow-y: auto;
    display: none;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
    font-weight: 600;
    font-size: 0.875rem;
}

.history-item {
    padding: 10px 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    border-bottom: 1px solid #f8f9fa;
}

.history-item:hover {
    background: #f8f9fa;
}

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

.history-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.history-term {
    font-weight: 500;
    color: #495057;
}

.history-time {
    font-size: 0.75rem;
    color: #6c757d;
}

/* Enhanced Date Picker */
.date-picker-btn {
    border-left: none !important;
    border-radius: 0 0.375rem 0.375rem 0 !important;
}

.date-range-shortcuts {
    margin-top: 10px;
    padding: 10px 0;
    border-top: 1px solid #dee2e6;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.shortcut-label {
    font-weight: 600;
    font-size: 0.875rem;
    color: #6c757d;
    margin-right: 8px;
}

.shortcut-btn {
    margin: 2px;
    padding: 4px 12px;
    font-size: 0.8rem;
}

.date-range-feedback {
    display: block;
    width: 100%;
    margin-top: 0.25rem;
    font-size: 0.875rem;
}

/* Enhanced Search Results */
.search-result-item {
    position: relative;
    border: 1px solid #dee2e6;
    border-radius: 0.5rem;
    padding: 20px;
    margin-bottom: 20px;
    background: white;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
}

.search-result-item:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.result-number {
    position: absolute;
    top: -8px;
    left: -8px;
    background: #007bff;
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.75rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.result-actions {
    float: right;
    margin-left: 10px;
}

.result-actions .btn {
    margin-left: 4px;
    padding: 4px 8px;
}

.reading-time {
    font-size: 0.75rem;
    color: #6c757d;
    background: #f8f9fa;
    padding: 2px 6px;
    border-radius: 0.25rem;
}

.read-more-btn {
    padding: 0;
    margin-top: 8px;
    font-size: 0.875rem;
    text-decoration: none !important;
}

.read-more-btn:hover {
    text-decoration: underline !important;
}

/* Enhanced Highlighting */
.search-highlight {
    background: linear-gradient(120deg, #fff3cd 0%, #ffeaa7 100%);
    padding: 1px 2px;
    border-radius: 2px;
    font-weight: 600;
    border: 1px solid #ffc107;
    box-shadow: 0 1px 2px rgba(255, 193, 7, 0.3);
}

.highlight-legend {
    background: #e3f2fd;
    border: 1px solid #bbdefb;
    border-radius: 0.375rem;
    padding: 10px 15px;
    margin-bottom: 20px;
    text-align: center;
}

.highlight-legend mark {
    margin: 0 4px;
}

/* Search Summary Enhancement */
.search-summary-enhanced {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border: 1px solid #dee2e6;
    border-radius: 0.5rem;
    padding: 15px 20px;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.summary-stats {
    display: flex;
    gap: 20px;
    align-items: center;
    flex-wrap: wrap;
}

.stat-item {
    font-size: 0.9rem;
    color: #495057;
}

.stat-item strong {
    color: #007bff;
    font-weight: 600;
}

.summary-actions {
    display: flex;
    gap: 8px;
}

.summary-actions .btn {
    padding: 6px 12px;
    font-size: 0.8rem;
}

/* Input Group Enhancements */
.input-group .form-control:focus {
    z-index: 3;
}

.input-group .btn:focus {
    z-index: 4;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .advanced-search-suggestions,
    .search-history-dropdown {
        left: -15px;
        right: -15px;
        max-height: 300px;
    }
    
    .search-result-item {
        padding: 15px;
        margin-bottom: 15px;
    }
    
    .result-actions {
        float: none;
        margin: 10px 0 0 0;
        display: flex;
        gap: 8px;
    }
    
    .search-summary-enhanced {
        padding: 12px 15px;
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }
    
    .summary-stats {
        flex-direction: column;
        gap: 8px;
        align-items: stretch;
    }
    
    .summary-actions {
        justify-content: center;
    }
    
    .date-range-shortcuts {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }
    
    .shortcut-label {
        margin: 0 0 8px 0;
        text-align: center;
    }
    
    .shortcut-btn {
        margin: 2px 0;
        width: 100%;
    }
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    .advanced-search-suggestions,
    .search-history-dropdown {
        border-width: 2px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    }
    
    .search-highlight {
        background: #ffff00;
        color: #000000;
        border: 2px solid #000000;
    }
    
    .search-result-item {
        border-width: 2px;
    }
    
    .search-result-item:hover {
        border-color: #007bff;
        box-shadow: 0 0 0 2px #007bff;
    }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    .advanced-suggestion,
    .history-item,
    .search-result-item,
    .result-actions .btn {
        transition: none;
    }
    
    .search-result-item:hover {
        transform: none;
    }
}

/* Print Styles */
@media print {
    .advanced-search-suggestions,
    .search-history-dropdown,
    .result-actions,
    .summary-actions {
        display: none !important;
    }
    
    .search-result-item {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #000;
        margin-bottom: 10px;
    }
    
    .search-highlight {
        background: transparent;
        border: 1px solid #000;
        font-weight: bold;
    }
}

/* Focus Management */
.advanced-suggestion:focus,
.history-item:focus {
    outline: 2px solid #007bff;
    outline-offset: -2px;
}

/* Animation for loading states */
@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.advanced-search-suggestions.show,
.search-history-dropdown.show {
    animation: fadeInDown 0.2s ease-out;
}

/* Custom scrollbar for suggestion lists */
.advanced-search-suggestions::-webkit-scrollbar,
.search-history-dropdown::-webkit-scrollbar {
    width: 6px;
}

.advanced-search-suggestions::-webkit-scrollbar-track,
.search-history-dropdown::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.advanced-search-suggestions::-webkit-scrollbar-thumb,
.search-history-dropdown::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.advanced-search-suggestions::-webkit-scrollbar-thumb:hover,
.search-history-dropdown::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}