/* Live Search Styles */
.lhk-live-search-container {
    position: relative;
    width: 100%;
    max-width: 400px;
}

.lhk-search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.lhk-search-input {
    width: 100%;
    padding: 0.75rem 2.5rem 0.75rem 2.5rem;
    border: 2px solid #e5e7eb;
    border-radius: 0.5rem;
    font-size: 1rem;
    transition: all 0.2s ease;
    background: #ffffff;
    color: #374151;
}

.lhk-search-input:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.lhk-search-icon {
    position: absolute;
    left: 0.75rem;
    width: 1.25rem;
    height: 1.25rem;
    color: #6b7280;
    pointer-events: none;
}

.lhk-search-spinner {
    position: absolute;
    right: 0.75rem;
    width: 1.25rem;
    height: 1.25rem;
    color: #2563eb;
    animation: spin 1s linear infinite;
}

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

/* Results Container */
.lhk-search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 1000;
    margin-top: 0.5rem;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    max-height: 80vh;
    overflow-y: auto;
}

.lhk-search-results-inner {
    padding: 0.5rem 0;
}

/* Group Headers */
.lhk-search-group {
    margin-bottom: 1rem;
}

.lhk-search-group:last-child {
    margin-bottom: 0;
}

.lhk-search-group-header {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid #f3f4f6;
    background: #f9fafb;
}

/* Search Items */
.lhk-search-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    text-decoration: none;
    color: inherit;
    transition: all 0.15s ease;
    border-bottom: 1px solid #f3f4f6;
    cursor: pointer;
}

.lhk-search-item:hover,
.lhk-search-item:focus,
.lhk-search-item.focused {
    background: #f3f4f6;
    text-decoration: none;
    outline: none;
}

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

/* Item Thumbnail/Icon */
.lhk-search-item-thumb {
    flex-shrink: 0;
    width: 3rem;
    height: 3rem;
    border-radius: 0.375rem;
    overflow: hidden;
    background: #f3f4f6;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.lhk-search-item-icon {
    width: 1.5rem;
    height: 1.5rem;
    color: #6b7280;
}

/* Item Content */
.lhk-search-item-content {
    flex: 1;
    min-width: 0;
}

.lhk-search-item-title {
    font-weight: 600;
    color: #111827;
    margin: 0 0 0.25rem 0;
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.lhk-search-item-excerpt {
    font-size: 0.875rem;
    color: #6b7280;
    margin: 0;
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.lhk-search-item-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.25rem;
    font-size: 0.75rem;
    color: #9ca3af;
}

.lhk-search-item-type {
    background: #e5e7eb;
    color: #374151;
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
    font-weight: 500;
}

/* States */
.lhk-search-empty,
.lhk-search-error,
.lhk-search-loading {
    padding: 2rem 1rem;
    text-align: center;
    color: #6b7280;
}

.lhk-search-error {
    color: #dc2626;
}

.lhk-search-empty-icon,
.lhk-search-error-icon {
    width: 3rem;
    height: 3rem;
    margin: 0 auto 1rem auto;
    opacity: 0.5;
}

/* View All Link */
.lhk-search-view-all {
    display: block;
    padding: 0.75rem 1rem;
    text-align: center;
    background: #f9fafb;
    border-top: 1px solid #e5e7eb;
    color: #2563eb;
    text-decoration: none;
    font-weight: 500;
    transition: all 0.15s ease;
}

.lhk-search-view-all:hover {
    background: #f3f4f6;
    text-decoration: none;
}

/* Modal/Fullscreen Styles */
.lhk-live-search-container[data-style="modal"] .lhk-search-results,
.lhk-live-search-container[data-style="fullscreen"] .lhk-search-results {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999;
    margin: 0;
    border-radius: 0;
    max-height: none;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.lhk-live-search-container[data-style="modal"] .lhk-search-results-inner {
    max-width: 600px;
    margin: 2rem auto;
    background: white;
    border-radius: 0.5rem;
    max-height: calc(100vh - 4rem);
    overflow-y: auto;
}

.lhk-live-search-container[data-style="fullscreen"] .lhk-search-results-inner {
    background: white;
    height: 100vh;
    overflow-y: auto;
}

/* Close Button for Modal/Fullscreen */
.lhk-search-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 2rem;
    height: 2rem;
    border: none;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
}

.lhk-search-close:hover {
    background: rgba(0, 0, 0, 0.2);
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .lhk-search-input {
        background: #1f2937;
        border-color: #374151;
        color: #f9fafb;
    }
    
    .lhk-search-input:focus {
        border-color: #3b82f6;
        box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
    }
    
    .lhk-search-results {
        background: #1f2937;
        border-color: #374151;
    }
    
    .lhk-search-group-header {
        background: #111827;
        color: #9ca3af;
        border-color: #374151;
    }
    
    .lhk-search-item {
        border-color: #374151;
    }
    
    .lhk-search-item:hover,
    .lhk-search-item:focus,
    .lhk-search-item.focused {
        background: #374151;
    }
    
    .lhk-search-item-title {
        color: #f9fafb;
    }
    
    .lhk-search-item-excerpt {
        color: #d1d5db;
    }
    
    .lhk-search-view-all {
        background: #111827;
        border-color: #374151;
        color: #3b82f6;
    }
    
    .lhk-search-view-all:hover {
        background: #374151;
    }
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .lhk-live-search-container {
        max-width: none;
    }
    
    .lhk-search-input {
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    .lhk-search-results {
        max-height: 70vh;
    }
    
    .lhk-live-search-container[data-style="modal"] .lhk-search-results-inner {
        margin: 1rem;
        max-height: calc(100vh - 2rem);
    }
    
    .lhk-search-item-thumb {
        width: 2.5rem;
        height: 2.5rem;
    }
    
    .lhk-search-item {
        padding: 0.5rem 1rem;
        gap: 0.5rem;
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .lhk-search-input {
        border-width: 2px;
    }
    
    .lhk-search-item:focus,
    .lhk-search-item.focused {
        outline: 2px solid #2563eb;
        outline-offset: -2px;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    .lhk-search-input,
    .lhk-search-item,
    .lhk-search-view-all {
        transition: none;
    }
    
    .lhk-search-spinner {
        animation: none;
    }
}

/* Focus Styles for Accessibility */
.lhk-search-input:focus-visible {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
}

.lhk-search-item:focus-visible {
    outline: 2px solid #2563eb;
    outline-offset: -2px;
}

/* Screen Reader Only Text */
.lhk-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}