/**
 * Live Search Styling
 * Beautiful, categorized instant search results
 */

/* ============================================
   Search Form Container
   ============================================ */
.rf-live-search-wrapper {
    position: relative;
    display: inline-flex;
    align-items: center;
}

/* Search Toggle Button (Initially Visible) */
.rf-search-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    background: transparent;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 10001;
}

.rf-search-toggle:hover {
    opacity: 0.7;
}

.rf-search-toggle svg {
    width: 22px;
    height: 22px;
    color: currentColor;
}

/* Search Form (Hidden Initially, Slides In) */
.rf-search-form {
    position: absolute;
    top: 50%;
    right: 0;
    transform: translateY(-50%) translateX(20px);
    width: 550px;
    max-width: 90vw;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: all 0.4s cubic-bezier(0.25, 0.1, 0.25, 1);
    z-index: 10000;
}

/* Active State - Form Slides In */
.rf-live-search-wrapper.is-active .rf-search-form {
    transform: translateY(-50%) translateX(0);
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* Hide toggle when active */
.rf-live-search-wrapper.is-active .rf-search-toggle {
    opacity: 0;
    pointer-events: none;
}

/* ============================================
   Search Input
   ============================================ */
.rf-search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    border-radius: 50px;
}
.rf-search-input-wrapper input[type="search"]{
    padding-left: 50px;
}
.rf-search-form-icon {
    position: absolute;
    left: 20px;
    width: 20px;
    height: 20px;
    color: #999999;
    pointer-events: none;
    z-index: 2;
}

.rf-search-input {
    width: 100%;
    padding: 14px 60px 14px 64px;
    font-size: 15px;
    font-family: inherit;
    color: #28333A;
    background: #ffffff;
    border: 2px solid #e0e0e0;
    border-radius: 50px;
    outline: none;
    transition: all 0.3s ease;
}

.rf-search-input:focus {
    border-color: #A69B73;
    box-shadow: 0 0 0 3px rgba(166, 155, 115, 0.1);
}

.rf-search-input::placeholder {
    color: #999999;
}

/* Close Button */
.rf-search-close {
    position: absolute;
    right: 12px;
    width: 36px;
    height: 36px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.05);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
    z-index: 2;
}

.rf-search-close:hover {
    background: rgba(0, 0, 0, 0.1);
    transform: rotate(90deg);
}

.rf-search-close svg {
    width: 16px;
    height: 16px;
    color: #666666;
}

/* ============================================
   Results Dropdown
   ============================================ */
.rf-search-results-dropdown {
    position: absolute;
    top: calc(100% + 12px);
    left: 0;
    right: 0;
    width: 100%;
    min-width: 550px;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    max-height: 600px;
    overflow-y: auto;
    z-index: 9999;
}

/* Loading State */
.rf-search-results-loading {
    padding: 3rem 2rem;
    text-align: center;
    display: none;
}

.rf-search-spinner {
    width: 40px;
    height: 40px;
    margin: 0 auto 1rem;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #A69B73;
    border-radius: 50%;
    animation: rf-spin 0.8s linear infinite;
}

@keyframes rf-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.rf-search-results-loading p {
    color: #666666;
    font-size: 0.9375rem;
    margin: 0;
}

/* Results Content */
.rf-search-results-content {
    padding: 1rem 0;
}

/* ============================================
   Search Sections
   ============================================ */
.rf-search-section {
    padding: 0.5rem 0;
}

.rf-search-section-title {
    padding: 0.75rem 1.5rem;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #A69B73;
    margin: 0;
    background: linear-gradient(to bottom, transparent 0%, #f8f8f8 100%);
}

.rf-search-items {
    display: flex;
    flex-direction: column;
}

/* ============================================
   Search Items
   ============================================ */
.rf-search-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 1.5rem;
    text-decoration: none;
    color: inherit;
    transition: all 0.2s ease;
}

.rf-search-item:hover {
    background: #f8f8f8;
}

.rf-search-item-image {
    flex-shrink: 0;
    width: 50px;
    height: 50px;
    border-radius: 8px;
    overflow: hidden;
    background: linear-gradient(135deg, #f5f5f5 0%, #e8e8e8 100%);
}

.rf-search-item-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.rf-search-item-content {
    flex: 1;
    min-width: 0;
}

.rf-search-item-title {
    font-size: 0.9375rem;
    font-weight: 600;
    color: #28333A;
    margin-bottom: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rf-search-item-meta {
    font-size: 0.8125rem;
    color: #999999;
}

.rf-search-item-excerpt {
    font-size: 0.8125rem;
    color: #666666;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ============================================
   Search Footer
   ============================================ */
.rf-search-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid #e0e0e0;
    background: #f8f8f8;
}

.rf-search-view-all {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 12px 24px;
    font-size: 0.9375rem;
    font-weight: 600;
    color: #A69B73;
    text-decoration: none;
    background: #ffffff;
    border: 2px solid #A69B73;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.rf-search-view-all:hover {
    color: #ffffff;
    background: #A69B73;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(166, 155, 115, 0.3);
}

/* ============================================
   No Results
   ============================================ */
.rf-search-no-results {
    padding: 3rem 2rem;
    text-align: center;
    color: #666666;
    font-size: 0.9375rem;
}

.rf-search-no-results::before {
    content: "🔍";
    display: block;
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.4;
}

/* ============================================
   Elementor Integration
   ============================================ */
.elementor-widget-shortcode .rf-live-search-wrapper {
    margin: 0;
}

/* Make search icon color inherit from Elementor text color */
.elementor-widget-shortcode .rf-search-form-icon {
    color: currentColor;
    opacity: 0.6;
}

/* ============================================
   Responsive Design
   ============================================ */
@media (max-width: 768px) {
    .rf-search-toggle {
        width: 40px;
        height: 40px;
    }
    
    .rf-search-toggle svg {
        width: 20px;
        height: 20px;
    }
    
    .rf-search-form {
        width: 420px;
    }
    
    .rf-search-input {
        font-size: 14px;
        padding: 12px 52px 12px 52px;
    }
    
    .rf-search-form-icon {
        left: 18px;
    }
    
    .rf-search-close {
        right: 10px;
        width: 32px;
        height: 32px;
    }
    
    .rf-search-results-dropdown {
        min-width: 420px;
        max-height: 400px;
    }
    
    .rf-search-section-title {
        padding: 0.5rem 1rem;
        font-size: 0.7rem;
    }
    
    .rf-search-item {
        padding: 10px 1rem;
        gap: 10px;
    }
    
    .rf-search-item-image {
        width: 40px;
        height: 40px;
    }
    
    .rf-search-item-title {
        font-size: 0.875rem;
    }
    
    .rf-search-item-meta,
    .rf-search-item-excerpt {
        font-size: 0.75rem;
    }
}

@media (max-width: 480px) {
    .rf-search-form {
        width: calc(100vw - 60px);
        right: -10px;
    }
    
    .rf-search-input {
        padding: 10px 48px 10px 44px;
        font-size: 13px;
    }
    
    .rf-search-form-icon {
        left: 14px;
        width: 18px;
        height: 18px;
    }
    
    .rf-search-close {
        right: 8px;
        width: 30px;
        height: 30px;
    }
    
    .rf-search-results-dropdown {
        min-width: calc(100vw - 60px);
    }
}
