/* AJAX Live Search Specific Styling */
.wegreen-header-search-result {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%; /* This ensures it matches the width of the input bar */
    background-color: #fff;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.15);
    z-index: 1000;
    max-height: 70vh;
    overflow-y: auto;
    margin-top: 5px;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    display: none;
    scrollbar-width: thin;
    scrollbar-color: #ccc #f5f5f5;
    padding: 5px 0;
}

/* Show search results when they have content */
.wegreen-header-search-result.with-result {
    display: block !important;
}

/* Custom scrollbar for search results */
.wegreen-header-search-result::-webkit-scrollbar {
    width: 6px;
    background: #f5f5f5;
    border-radius: 4px;
}

.wegreen-header-search-result::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 4px;
}

/* Search input styling */
.wegreen-header-search-wrapper {
    position: relative;
    width: 400px;
    max-width: 100%;
    margin: 0 24px 0 0;
    z-index: 100;
    margin: 0 10px;
    flex-grow: 1;
    max-width: 400px;
    min-width: 300px;
}

/* Ensure columns with search have proper alignment - moved from header.php */
.wegreen-header-column:has(.wegreen-header-search-wrapper) {
    flex: 2 1 auto;
}

/* Search form field color styling - moved from header.php */
.search-form .search-field,
.search-form .search-submit {
    color: var(--wegreen-header-row-text);
}

.wegreen-header-search-form {
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    padding: 0;
    width: 100%;
    position: relative;
}

.wegreen-header-search-form:focus-within {
    background: rgba(255, 255, 255, 0.2);
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.2);
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: rgba(255, 255, 255, 0.7);
    font-size: 18px;
    z-index: 2;
    pointer-events: none;
}

.wegreen-header-search-input {
    flex: 1 1 auto;
    background: transparent;
    color: #ffffff;
    border: none;
    padding: 10px 10px 10px 40px;
    font-size: 1rem;
    outline: none;
    height: 46px;
    width: 100%;
}

.wegreen-header-search-input::placeholder {
    color: rgba(255, 255, 255, 0.75);
    opacity: 1;
}

/* Search result wrapper */
.search-result-wrapper {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    overflow: visible;
    max-height: 450px; /* Increased height to show more results */
    overflow-y: auto;
}

.search-result-wrapper li {
    border-bottom: 1px solid #eee;
    margin: 0;
    padding: 0;
}

.search-result-wrapper li:last-child {
    border-bottom: none;
}

.search-result-wrapper li a {
    display: flex;
    align-items: center;
    text-decoration: none;
    color: inherit;
    transition: background-color 0.2s, transform 0.1s;
    color: #333;
    font-size: 1rem;
    position: relative;
    padding: 8px 12px;
}

.search-result-wrapper li:last-child a {
    border-bottom: none;
}

.search-result-wrapper li a:hover,
.search-result-wrapper li a:focus,
.search-result-wrapper li a.search-result-active {
    background-color: rgba(9, 112, 86, 0.08);
}

.search-result-wrapper li a:hover .result-title,
.search-result-wrapper li a.search-result-active .result-title {
    color: #097056;
}

/* Result thumb styles */
.result-thumb,
.search-result-wrapper .result-thumb {
    width: 50px;
    height: 70px;
    object-fit: cover;
    margin-right: 12px;
    border-radius: 3px;
    background-color: #f0f0f0;
    flex-shrink: 0;
    overflow: hidden;
}

.wegreen-header-search-result .result-thumb {
    width: 50px;
    height: 70px;
    object-fit: cover;
    margin-right: 12px;
    border-radius: 3px;
    overflow: hidden;
}

.search-result-wrapper .person-thumb {
    border-radius: 50%;
    width: 50px;
    height: 50px;
    border: 2px solid white;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

.search-result-wrapper .result-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s;
}

.search-result-wrapper li a:hover .result-thumb img {
    transform: scale(1.05);
}

.search-result-thumb {
    width: 50px;
    height: 70px;
    object-fit: cover;
    border-radius: 4px;
    background: #f5f5f5;
    flex-shrink: 0;
    display: block;
    overflow: hidden;
}

.search-result-thumb.placeholder {
    background: #eee;
    width: 50px;
    height: 70px;
    display: inline-block;
}

/* Result info styles */
.result-info,
.search-result-wrapper .result-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
    flex: 1;
}

.result-title {
    font-weight: 500;
    font-size: 14px;
    margin-bottom: 3px;
    color: #333;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.search-result-title {
    font-weight: 500;
    color: #333;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    max-height: 2.6em;
    word-break: normal;
}

.result-meta {
    font-size: 12px;
    color: #666;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
}

.search-result-meta {
    font-size: 0.9em;
    color: #666;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* View all results link */
.view-all-results {
    display: block;
    text-align: center;
    padding: 12px;
    background-color: #f9f9f9;
    color: #097056;
    text-decoration: none;
    font-weight: 500;
    border-top: 1px solid #eee;
    transition: background-color 0.2s;
    border-radius: 0 0 8px 8px;
    font-size: 14px;
}

.view-all-results:hover {
    background-color: #f0f0f0;
    color: #065d47;
}

/* No results and loading states */
.search-noresult,
.search-error {
    padding: 20px;
    text-align: center;
    color: #666;
    font-size: 14px;
}

.search-loading {
    padding: 20px;
    text-align: center;
    color: #666;
    font-size: 14px;
    position: relative;
}

.search-loading:after {
    content: "";
    display: inline-block;
    width: 1em;
    height: 1em;
    border: 2px solid rgba(0, 0, 0, 0.2);
    border-top-color: #097056;
    border-radius: 50%;
    margin-left: 8px;
    vertical-align: middle;
    animation: search-spin 0.8s linear infinite;
}

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

/* No thumb placeholder */
.no-thumb {
    width: 50px;
    height: 70px;
    background: #f0f0f0;
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 12px;
    flex-shrink: 0;
}

.no-thumb .result-icon {
    font-size: 20px;
    opacity: 0.6;
}

/* No results styling */
.no-results {
    padding: 20px;
    text-align: center;
    border: none !important;
}

.no-results-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.no-results-icon {
    font-size: 24px;
    opacity: 0.5;
}

.no-results-text {
    color: #666;
    font-size: 14px;
}

/* View all results link styling */
.view-all-results {
    border-top: 1px solid #eee;
    background-color: #f9f9f9;
    border: none !important;
}

.view-all-link {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px;
    color: #097056 !important;
    font-weight: 500;
    text-decoration: none;
    transition: background-color 0.2s;
}

.view-all-link:hover {
    background-color: #f0f0f0;
    color: #065d47 !important;
}

.view-all-text {
    font-size: 14px;
}

.view-all-arrow {
    font-size: 16px;
    transition: transform 0.2s;
}

.view-all-link:hover .view-all-arrow {
    transform: translateX(2px);
}

/* Blog badges styling */
.wegreen-header-search-result .blog-badge {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    background-color: #097056;
    color: white;
    margin-left: 6px;
    letter-spacing: 0.5px;
    line-height: 1.2;
}

/* Blog 1 specific styling */
.search-result-wrapper li[data-blog="1"] a {
    border-left: 3px solid #097056;
}

/* Blog 3 specific styling */
.search-result-wrapper li[data-blog="3"] a {
    border-left: 3px solid #ff6b6b;
}

/* Entertainment content type styling */
.result-meta .content-type-person {
    color: #8e44ad;
    font-weight: 500;
}

.result-meta .content-type-movie,
.result-meta .content-type-drama {
    color: #e74c3c;
    font-weight: 500;
}

.result-meta .content-type-news {
    color: #097056;
    font-weight: 500;
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    .search-form {
        width: 100%;
        margin: 0;
    }
    
    .search-input {
        width: 100%;
        padding: 8px 10px;
        font-size: 14px;
    }
    
    .search-result-thumb {
        width: 40px;
        height: 60px;
    }
    
    .search-result-title {
        font-size: 13px;
    }
    
    .search-result-meta {
        font-size: 11px;
    }
}

@media (max-width: 600px) {
    .wegreen-header-search-wrapper {
        min-width: auto;
        margin: 0 10px;
        width: 100%;
        max-width: none;
    }
    
    .wegreen-header-search-input {
        font-size: 14px;
        height: 40px;
    }
    
    .search-icon {
        font-size: 16px;
    }
    
    .wegreen-header-search-result {
        max-height: 60vh;
        margin-top: 2px;
    }
}

/* Error state styling */
.search-error {
    color: #e74c3c;
    background-color: rgba(231, 76, 60, 0.1);
    border-radius: 4px;
    padding: 15px;
    margin: 10px;
    text-align: center;
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .wegreen-header-search-result {
        background-color: #222;
        border-color: rgba(255, 255, 255, 0.1);
    }
    
    .search-result-wrapper li {
        border-color: rgba(255, 255, 255, 0.1);
    }
    
    .search-result-wrapper li a {
        color: #eee;
    }
    
    .result-title,
    .search-result-title {
        color: #eee;
    }
    
    .result-meta,
    .search-result-meta {
        color: #aaa;
    }
    
    .search-result-wrapper li a:hover,
    .search-result-wrapper li a:focus,
    .search-result-wrapper li a.search-result-active {
        background-color: rgba(9, 112, 86, 0.2);
    }
    
    .view-all-results {
        background-color: #333;
        color: #4CAF50;
        border-color: rgba(255, 255, 255, 0.1);
    }
    
    .view-all-results:hover {
        background-color: #444;
    }
    
    .search-noresult,
    .search-loading {
        color: #aaa;
    }
}

/* AJAX Search Styling for WeGreen Theme */

/* Search Container Styles - Match width of input field */
.jeg_search_result {
    width: 100%;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15);
    border-radius: 0 0 6px 6px;
    overflow: hidden;
    background: #fff;
    max-height: calc(100vh - 150px);
    overflow-y: auto;
}

/* Search Result Wrapper */
.search-result-wrapper {
    margin: 0;
    padding: 8px;
    list-style: none;
}

/* Individual Result Item */
.search-result-wrapper li {
    margin-bottom: 1px;
}

.search-result-wrapper li a {
    display: flex;
    align-items: center;
    padding: 8px;
    text-decoration: none;
    border-radius: 4px;
    transition: background-color 0.2s ease;
}

.search-result-wrapper li a:hover {
    background-color: #f5f5f5;
}

/* Result Thumbnail */
.search-result-wrapper .result-thumb {
    width: 45px;
    height: 45px;
    border-radius: 5px;
    overflow: hidden;
    position: relative;
    margin-right: 12px;
    flex-shrink: 0;
    background-color: #f0f0f0;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Person thumbnail special styling */
.search-result-wrapper .result-thumb.person-thumb {
    border-radius: 50%;
    position: relative;
}

.search-result-wrapper .result-thumb.person-thumb img {
    border-radius: 50%;
    object-fit: cover;
    height: 100%;
    width: 100%;
}

.search-result-wrapper .result-thumb.person-thumb::after {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: linear-gradient(to bottom, rgba(0,0,0,0.1) 0%, rgba(0,0,0,0.3) 100%);
    z-index: 1;
}

.search-result-wrapper .result-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Result Information */
.search-result-wrapper .result-info {
    flex-grow: 1;
    min-width: 0;
}

.search-result-wrapper .result-title {
    display: block;
    font-size: 0.95em;
    font-weight: 500;
    color: #222;
    margin-bottom: 3px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.search-result-wrapper .result-meta {
    display: block;
    font-size: 0.8em;
    color: #666;
}

/* Blog badge for multisite search */
.search-result-wrapper .blog-badge {
    background: #eef6ff;
    color: #427cd4;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.75em;
    margin-left: 5px;
    font-weight: 500;
}

/* View All Link */
.view-all-results {
    display: block;
    text-align: center;
    padding: 10px;
    background: #f8f8f8;
    color: #333;
    font-weight: 500;
    border-top: 1px solid #eaeaea;
    text-decoration: none;
    transition: background 0.2s ease;
}

.view-all-results:hover {
    background: #f0f0f0;
    color: #000;
}

/* No Results Message */
.search-noresult {
    padding: 15px;
    text-align: center;
    color: #666;
    font-style: italic;
}

/* Error Message */
.search-error {
    padding: 15px;
    text-align: center;
    color: #d9534f;
}