/**
 * Advanced Search Styles
 *
 * @package ComplySpec_Accessible
 * @since 1.5.0
 */

/* ========================================
   SEARCH FORM
   ======================================== */

.cs-search-form {
    position: relative;
    max-width: 600px;
    margin: 0 auto;
}

.cs-search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.cs-search-input {
    width: 100%;
    padding: 1rem 3rem 1rem 1.25rem;
    font-size: 1rem;
    border: 2px solid #e9ecef;
    border-radius: 50px;
    transition: all 0.3s ease;
    background: #fff;
}

.cs-search-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
}

.cs-search-icon {
    position: absolute;
    right: 1.25rem;
    color: #6c757d;
    pointer-events: none;
}

.cs-search-loading {
    position: absolute;
    right: 1.25rem;
    display: none;
}

.cs-search-loading.active {
    display: block;
}

.cs-search-loading i {
    color: #667eea;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ========================================
   SEARCH RESULTS DROPDOWN
   ======================================== */

.cs-search-results {
    position: absolute;
    top: calc(100% + 10px);
    left: 0;
    right: 0;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.15);
    max-height: 500px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
}

.cs-search-results.active {
    display: block;
}

.cs-search-results-list {
    list-style: none;
    margin: 0;
    padding: 0.5rem 0;
}

.cs-search-result-item {
    border-bottom: 1px solid #f8f9fa;
}

.cs-search-result-item:last-child {
    border-bottom: none;
}

.cs-search-result-link {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 1rem;
    text-decoration: none;
    color: #333;
    transition: background 0.2s ease;
}

.cs-search-result-link:hover,
.cs-search-result-link:focus {
    background: #f8f9fa;
    outline: none;
}

.cs-search-result-link:focus-visible {
    outline: 2px solid #667eea;
    outline-offset: -2px;
}

.cs-search-result-thumbnail {
    width: 60px;
    height: 60px;
    flex-shrink: 0;
    border-radius: 6px;
    overflow: hidden;
    background: #e9ecef;
}

.cs-search-result-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.cs-search-result-content {
    flex: 1;
    min-width: 0;
}

.cs-search-result-title {
    font-size: 1rem;
    font-weight: 600;
    margin: 0 0 0.25rem;
    color: #333;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.cs-search-result-link:hover .cs-search-result-title {
    color: #667eea;
}

.cs-search-result-excerpt {
    font-size: 0.875rem;
    color: #6c757d;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.cs-search-result-meta {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 0.5rem;
    font-size: 0.75rem;
    color: #6c757d;
}

.cs-search-result-type {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.5rem;
    background: #e9ecef;
    border-radius: 12px;
    text-transform: capitalize;
}

.cs-search-no-results {
    padding: 2rem;
    text-align: center;
    color: #6c757d;
}

.cs-search-no-results i {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.3;
}

.cs-search-no-results p {
    margin: 0;
    font-size: 1rem;
}

.cs-search-view-all {
    padding: 1rem;
    text-align: center;
    border-top: 1px solid #e9ecef;
}

.cs-search-view-all-link {
    display: inline-block;
    padding: 0.5rem 1.5rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    text-decoration: none;
    border-radius: 6px;
    font-weight: 600;
    transition: all 0.3s ease;
}

.cs-search-view-all-link:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.3);
}

/* ========================================
   POPULAR SEARCHES
   ======================================== */

.cs-popular-searches {
    padding: 1rem;
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
}

.cs-popular-searches-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: #6c757d;
    margin: 0 0 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.cs-popular-searches-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    list-style: none;
    margin: 0;
    padding: 0;
}

.cs-popular-search-item {
    display: inline-block;
}

.cs-popular-search-link {
    display: inline-block;
    padding: 0.5rem 1rem;
    background: #fff;
    color: #667eea;
    text-decoration: none;
    border-radius: 20px;
    font-size: 0.875rem;
    transition: all 0.2s ease;
    border: 1px solid #e9ecef;
}

.cs-popular-search-link:hover {
    background: #667eea;
    color: #fff;
    border-color: #667eea;
    transform: translateY(-1px);
}

/* ========================================
   SEARCH OVERLAY (for mobile)
   ======================================== */

.cs-search-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 999;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.cs-search-overlay.active {
    display: block;
    opacity: 1;
}

/* ========================================
   MOBILE RESPONSIVENESS
   ======================================== */

@media (max-width: 768px) {
    .cs-search-form {
        max-width: 100%;
    }

    .cs-search-results {
        max-height: 400px;
        border-radius: 8px;
    }

    .cs-search-result-link {
        padding: 0.75rem;
    }

    .cs-search-result-thumbnail {
        width: 50px;
        height: 50px;
    }

    .cs-search-result-title {
        font-size: 0.9375rem;
    }

    .cs-popular-searches {
        padding: 0.75rem;
    }
}

/* ========================================
   ACCESSIBILITY
   ======================================== */

.cs-search-results[role="listbox"] {
    /* Ensure proper ARIA roles */
}

.cs-search-result-item[role="option"] {
    /* Option styling */
}

@media (prefers-reduced-motion: reduce) {
    .cs-search-input,
    .cs-search-result-link,
    .cs-popular-search-link {
        transition-duration: 0.01ms !important;
    }
}

/* Screen reader only text */
.cs-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* ========================================
   HIGHLIGHT MATCHED TEXT
   ======================================== */

.cs-search-highlight {
    background: rgba(255, 235, 59, 0.3);
    font-weight: 600;
    padding: 0 2px;
    border-radius: 2px;
}

/* ========================================
   SEARCH STATISTICS (Admin)
   ======================================== */

.cs-search-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.cs-search-stat-card {
    background: #fff;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.cs-search-stat-value {
    font-size: 2rem;
    font-weight: 800;
    color: #667eea;
    margin: 0;
}

.cs-search-stat-label {
    font-size: 0.875rem;
    color: #6c757d;
    margin: 0.25rem 0 0;
}
