/**
 * Smart Search 2.0 - Styling
 * Modern AI-powered search interface for behavior journal
 */

/* ===== SMART SEARCH CONTAINER ===== */
.smart-search-container {
    position: relative;
    width: 100%;
}

/* ===== SEARCH INPUT WRAPPER ===== */
.search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    padding: 4px;
    transition: all 0.3s ease;
    margin-bottom: 8px;
}

.search-input-wrapper:focus-within {
    border-color: var(--primary-color, #6366f1);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
    background: rgba(255, 255, 255, 0.15);
}

/* ===== SMART SEARCH INPUT ===== */
.smart-search-input {
    flex: 1;
    background: transparent;
    border: none;
    padding: 12px 16px;
    font-size: 14px;
    color: var(--text-color, #1f2937);
    outline: none;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.smart-search-input::placeholder {
    color: rgba(107, 114, 128, 0.7);
    font-style: italic;
}

.smart-search-input:focus {
    background: rgba(255, 255, 255, 0.05);
}

/* ===== VOICE & ADVANCED SEARCH BUTTONS ===== */
.voice-search-btn,
.advanced-search-btn {
    background: transparent;
    border: none;
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 4px;
}

.voice-search-btn:hover,
.advanced-search-btn:hover {
    background: rgba(99, 102, 241, 0.1);
    transform: scale(1.05);
}

.voice-search-btn:active,
.advanced-search-btn:active {
    transform: scale(0.95);
}

.voice-search-btn.recording {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ===== SEARCH SUGGESTIONS DROPDOWN ===== */
.search-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    margin-top: 4px;
    max-height: 300px;
    overflow-y: auto;
    transition: all 0.3s ease;
}

.search-suggestions.hidden {
    display: none;
}

.suggestions-header {
    padding: 12px 16px 8px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted, #6b7280);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.suggestions-list {
    padding: 8px 0;
}

.suggestion-item {
    padding: 10px 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(0, 0, 0, 0.02);
}

.suggestion-item:hover {
    background: rgba(99, 102, 241, 0.05);
    transform: translateX(2px);
}

.suggestion-item:last-child {
    border-bottom: none;
}

.suggestion-text {
    flex: 1;
    font-size: 14px;
    color: var(--text-color, #1f2937);
}

.suggestion-type {
    font-size: 11px;
    padding: 2px 6px;
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary-color, #6366f1);
    border-radius: 4px;
    text-transform: uppercase;
    font-weight: 500;
    letter-spacing: 0.3px;
}

.suggestion-recent {
    background: rgba(16, 185, 129, 0.1);
    color: #10b981;
}

.suggestion-pattern {
    background: rgba(245, 158, 11, 0.1);
    color: #f59e0b;
}

/* ===== SEARCH EXPLANATION ===== */
.search-explanation {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1), rgba(139, 92, 246, 0.05));
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: 8px;
    padding: 12px;
    margin-top: 8px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    transition: all 0.3s ease;
}

.search-explanation.hidden {
    display: none;
}

.explanation-text {
    flex: 1;
    font-size: 13px;
    color: var(--text-color, #1f2937);
    line-height: 1.5;
}

.explanation-close {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-muted, #6b7280);
    padding: 0;
    margin-left: 12px;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.explanation-close:hover {
    color: var(--text-color, #1f2937);
    transform: scale(1.2);
}

/* ===== LEGACY SEARCH TOGGLE ===== */
.legacy-search.hidden {
    display: none;
}

.legacy-search {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
}

/* ===== LOADING STATES ===== */
.smart-search-input.loading {
    background: linear-gradient(90deg, rgba(99, 102, 241, 0.05) 0%, rgba(99, 102, 241, 0.1) 50%, rgba(99, 102, 241, 0.05) 100%);
    background-size: 200% 100%;
    animation: loading 2s infinite;
}

@keyframes loading {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.search-processing {
    position: absolute;
    right: 60px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 12px;
    color: var(--primary-color, #6366f1);
    opacity: 0.8;
}

.search-processing::after {
    content: '';
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid transparent;
    border-top-color: var(--primary-color, #6366f1);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-left: 8px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 768px) {
    .smart-search-input {
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 14px 16px;
    }
    
    .voice-search-btn,
    .advanced-search-btn {
        padding: 10px;
        font-size: 14px;
    }
    
    .search-suggestions {
        max-height: 250px;
    }
    
    .suggestion-item {
        padding: 12px 16px;
    }
}

@media (max-width: 480px) {
    .search-input-wrapper {
        flex-direction: column;
        align-items: stretch;
    }
    
    .smart-search-input {
        margin-bottom: 8px;
        border-radius: 8px;
    }
    
    .voice-search-btn,
    .advanced-search-btn {
        width: 100%;
        margin-left: 0;
        margin-bottom: 4px;
        justify-content: center;
    }
}

/* ===== ACCESSIBILITY ENHANCEMENTS ===== */
.search-input-wrapper:focus-within .voice-search-btn,
.search-input-wrapper:focus-within .advanced-search-btn {
    outline: 2px solid var(--primary-color, #6366f1);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    .smart-search-input,
    .search-input-wrapper,
    .suggestion-item,
    .voice-search-btn,
    .advanced-search-btn {
        transition: none;
    }
    
    .voice-search-btn.recording {
        animation: none;
        opacity: 0.7;
    }
    
    .smart-search-input.loading {
        animation: none;
        background: rgba(99, 102, 241, 0.1);
    }
}

/* ===== HIGH CONTRAST MODE ===== */
@media (prefers-contrast: high) {
    .search-input-wrapper {
        border: 2px solid var(--text-color, #1f2937);
        background: var(--background-color, white);
    }
    
    .search-suggestions {
        border: 2px solid var(--text-color, #1f2937);
        background: var(--background-color, white);
    }
    
    .suggestion-item:hover {
        background: var(--text-color, #1f2937);
        color: var(--background-color, white);
    }
}