/**
 * Search UX Improvements for Romb.bg
 * Sticky search, auto-suggestions, filter chips, recent searches
 */

/* ============================================
   Sticky Search Bar
   ============================================ */

.sticky-search-wrapper {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1030;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 0.75rem 1rem;
    transform: translateY(-100%);
    transition: transform 0.3s ease-in-out;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.sticky-search-wrapper.visible {
    transform: translateY(0);
}

.sticky-search-wrapper .sticky-search-form {
    max-width: 800px;
    margin: 0 auto;
    display: flex;
    gap: 0.5rem;
}

.sticky-search-wrapper .sticky-search-input {
    flex: 1;
    padding: 0.625rem 1rem;
    border: none;
    border-radius: 8px;
    font-size: 0.9375rem;
    background: rgba(255, 255, 255, 0.95);
}

.sticky-search-wrapper .sticky-search-input:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.3);
}

.sticky-search-wrapper .sticky-search-btn {
    padding: 0.625rem 1.5rem;
    background: #FF385C;
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.sticky-search-wrapper .sticky-search-btn:hover {
    background: #E31C5F;
}

/* Hide sticky search on mobile (use filter toggle instead) */
@media (max-width: 767px) {
    .sticky-search-wrapper {
        display: none;
    }
}

/* ============================================
   Auto-Suggestions Dropdown
   ============================================ */

.search-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border-radius: 0 0 12px 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    z-index: 1050;
    max-height: 400px;
    overflow-y: auto;
    display: none;
}

.search-suggestions.active {
    display: block;
}

.suggestion-group {
    padding: 0.75rem 0;
    border-bottom: 1px solid #f0f0f0;
}

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

.suggestion-group-title {
    padding: 0 1rem 0.5rem;
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #767676;
}

.suggestion-item {
    padding: 0.625rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    transition: background 0.15s;
}

.suggestion-item:hover,
.suggestion-item.highlighted {
    background: #f7f7f7;
}

.suggestion-item i {
    width: 20px;
    text-align: center;
    color: #767676;
}

.suggestion-item .suggestion-text {
    flex: 1;
    font-size: 0.9375rem;
    color: #222;
}

.suggestion-item .suggestion-text mark {
    background: rgba(102, 126, 234, 0.15);
    color: #667eea;
    padding: 0 2px;
    border-radius: 2px;
}

.suggestion-item .suggestion-meta {
    font-size: 0.75rem;
    color: #767676;
}

.suggestion-item .suggestion-category {
    font-size: 0.75rem;
    color: #767676;
    background: #f0f0f0;
    padding: 2px 8px;
    border-radius: 4px;
}

/* Recent searches section */
.recent-searches-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 1rem 0.5rem;
}

.clear-recent-btn {
    font-size: 0.75rem;
    color: #FF385C;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
}

.clear-recent-btn:hover {
    text-decoration: underline;
}

/* ============================================
   Active Filter Chips
   ============================================ */

.filter-chips-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 1rem 0;
    margin-bottom: 0.5rem;
}

.filter-chips-container:empty {
    display: none;
}

.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0.75rem;
    background: #f0f0f0;
    border-radius: 20px;
    font-size: 0.8125rem;
    color: #484848;
    cursor: default;
    transition: all 0.2s;
}

.filter-chip:hover {
    background: #e0e0e0;
}

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

.filter-chip .chip-value {
    color: #222;
}

.filter-chip .chip-remove {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.15s;
}

.filter-chip .chip-remove:hover {
    background: #FF385C;
    color: white;
}

.filter-chip .chip-remove i {
    font-size: 0.625rem;
}

.clear-all-filters {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.75rem;
    background: transparent;
    border: 2px solid #FF385C;
    border-radius: 20px;
    font-size: 0.8125rem;
    font-weight: 600;
    color: #FF385C;
    cursor: pointer;
    transition: all 0.2s;
}

.clear-all-filters:hover {
    background: #FF385C;
    color: white;
}

/* ============================================
   Search Results Summary
   ============================================ */

.search-summary {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 0;
    margin-bottom: 1rem;
    border-bottom: 1px solid #f0f0f0;
}

.search-summary .results-count {
    font-size: 0.9375rem;
    color: #484848;
}

.search-summary .results-count strong {
    color: #222;
    font-weight: 700;
}

.search-summary .search-term {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0.75rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 20px;
    font-size: 0.8125rem;
    font-weight: 600;
}

.search-summary .search-term i {
    font-size: 0.75rem;
}

/* ============================================
   Enhanced Search Input
   ============================================ */

.search-input-wrapper {
    position: relative;
}

.search-input-wrapper .search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: #767676;
    pointer-events: none;
}

.search-input-wrapper input {
    padding-left: 2.75rem;
}

.search-input-wrapper .clear-input {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #e0e0e0;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s;
}

.search-input-wrapper input:not(:placeholder-shown) ~ .clear-input,
.search-input-wrapper .clear-input.visible {
    opacity: 1;
    visibility: visible;
}

.search-input-wrapper .clear-input:hover {
    background: #FF385C;
    color: white;
}

/* ============================================
   Search Loading State
   ============================================ */

.search-loading {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1.5rem;
    color: #767676;
}

.search-loading.active {
    display: flex;
}

.search-loading .spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #f0f0f0;
    border-top-color: #667eea;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ============================================
   Voice Search Button
   ============================================ */

.voice-search-btn {
    position: absolute;
    right: 3rem;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: #767676;
    cursor: pointer;
    border-radius: 50%;
    transition: all 0.2s;
}

.voice-search-btn:hover {
    background: #f0f0f0;
    color: #667eea;
}

.voice-search-btn.listening {
    background: #FF385C;
    color: white;
    animation: pulse 1s ease infinite;
}

@keyframes pulse {
    0%, 100% { transform: translateY(-50%) scale(1); }
    50% { transform: translateY(-50%) scale(1.1); }
}

/* Hide if not supported */
.voice-search-btn.hidden {
    display: none;
}

/* ============================================
   Mobile Filter Button Enhancement
   ============================================ */

.filter-toggle-btn {
    width: 100%;
    padding: 0.875rem 1.25rem;
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    color: #484848;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

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

.filter-toggle-btn .filter-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    background: #FF385C;
    color: white;
    border-radius: 11px;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0 6px;
}

/* ============================================
   Responsive Adjustments
   ============================================ */

@media (max-width: 767px) {
    .filter-chips-container {
        padding: 0.75rem 0;
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }

    .filter-chips-container::-webkit-scrollbar {
        display: none;
    }

    .filter-chip {
        flex-shrink: 0;
    }

    .search-suggestions {
        max-height: 60vh;
    }
}
