/**
 * Header Live Search Styles (v2.1)
 * Enhanced for visibility and performance
 */
.header-search {
    position: relative;
    /* Ensure the wrapper doesn't clip the dropdown */
}

.novateplica-search-results {
    position: absolute;
    top: calc(100% + 5px);
    left: 0;
    right: 0;
    background: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    box-shadow: 0 15px 45px rgba(0, 0, 0, 0.15);
    z-index: 999999;
    display: none;
    max-height: 500px;
    overflow-y: auto;
    width: 100%;
    min-width: 300px;
}

.novateplica-search-results.active {
    display: block;
}

.novateplica-search-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    z-index: 90;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
}

.novateplica-search-overlay.is-active {
    opacity: 1;
    visibility: visible;
}

/* Dark Mode Optimization */
[data-theme="dark"] .novateplica-search-results {
    background: #1f2937;
    border-color: #374151;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

[data-theme="dark"] .live-search-results-list li {
    border-bottom-color: #2d3748;
}

[data-theme="dark"] .live-search-results-list li a {
    color: #e5e7eb;
}

[data-theme="dark"] .live-search-results-list .result-title {
    color: #f3f4f6;
}

[data-theme="dark"] .live-search-results-list .result-image {
    background: #111827;
    border-color: #374151;
}

[data-theme="dark"] .live-search-results-list li:hover {
    background-color: #2d3748;
}

[data-theme="dark"] .live-search-footer {
    background: #1a202c;
    border-top-color: #2d3748;
}

[data-theme="dark"] .live-search-footer a {
    color: var(--primary-color);
}

[data-theme="dark"] .novateplica-search-results::-webkit-scrollbar-track {
    background: #111827;
}

[data-theme="dark"] .novateplica-search-results::-webkit-scrollbar-thumb {
    background: #374151;
}

/* Custom Scrollbar */
.novateplica-search-results::-webkit-scrollbar {
    width: 8px;
}

.novateplica-search-results::-webkit-scrollbar-track {
    background: #f8f8f8;
}

.novateplica-search-results::-webkit-scrollbar-thumb {
    background: #ddd;
    border-radius: 10px;
}

.novateplica-search-results::-webkit-scrollbar-thumb:hover {
    background: #ccc;
}

.novateplica-search-results.loading {
    min-height: 120px;
    display: block !important;
}

/* Loading Overlay */
.novateplica-search-results.loading::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.8);
    z-index: 50;
    backdrop-filter: blur(2px);
    border-radius: 8px;
}

[data-theme="dark"] .novateplica-search-results.loading::before {
    background: rgba(31, 41, 55, 0.8);
}

.novateplica-search-results.loading::after {
    content: "";
    width: 35px;
    height: 35px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid var(--primary-color, #FFDE00);
    border-radius: 50%;
    animation: spin-search 0.8s linear infinite;
    position: absolute;
    top: 50%;
    left: 50%;
    margin-top: -17.5px;
    margin-left: -17.5px;
    z-index: 51;
}

@keyframes spin-search {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.live-search-results-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.live-search-results-list li {
    border-bottom: 1px solid #f2f2f2;
    transition: all 0.2s ease;
}

.live-search-results-list li:last-child {
    border-bottom: none;
}

.live-search-results-list li a {
    display: flex;
    align-items: center;
    padding: 12px 18px;
    text-decoration: none;
    color: #333;
}

.live-search-results-list li:hover,
.live-search-results-list li.active {
    background-color: #f7f9fc;
}

.live-search-results-list .result-image {
    width: 55px;
    height: 55px;
    flex-shrink: 0;
    margin-right: 15px;
    border: 1px solid #f0f0f0;
    border-radius: 6px;
    overflow: hidden;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
}

.live-search-results-list .result-image img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.live-search-results-list .result-info {
    flex-grow: 1;
    overflow: hidden;
}

.live-search-results-list .result-title {
    display: block;
    font-size: 14.5px;
    line-height: 1.4;
    font-weight: 500;
    color: #222;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 3px;
}

.live-search-results-list .result-title mark {
    background: #fff4a3;
    /* Softer highlight */
    color: #000;
    padding: 0 2px;
    border-radius: 3px;
    font-weight: 600;
}

.live-search-results-list .result-price {
    display: block;
    font-size: 15px;
    font-weight: 700;
    color: #d32f2f;
    /* Standard price color */
}

.live-search-footer {
    position: sticky;
    bottom: 0;
    z-index: 10;
    padding: 14px;
    background: #ffffff;
    text-align: center;
    border-top: 1px solid #eee;
    box-shadow: 0 -5px 15px rgba(0, 0, 0, 0.05);
}

.live-search-footer a {
    font-size: 13.5px;
    font-weight: 600;
    color: #0071bc;
    text-decoration: none;
}

.live-search-footer a:hover {
    text-decoration: underline;
}

.live-search-footer a i {
    margin-left: 6px;
    font-size: 11px;
}

.no-results-found {
    padding: 40px 20px;
    text-align: center;
    color: #888;
}

.no-results-found i {
    display: block;
    font-size: 32px;
    margin-bottom: 15px;
    color: #ccc;
}

.no-results-found span {
    font-size: 15px;
}

/* Mobile Adjustments */
@media (max-width: 991px) {
    .novateplica-search-results {
        max-height: 380px;
        position: fixed;
        /* Better for mobile keyboards */
        top: 60px;
        left: 10px;
        right: 10px;
        width: auto;
        min-width: 0;
    }
}