/**
 * WooCommerce Ship Booster - Live Search Styles
 * Provides styling for dynamic search dropdown functionality
 * 
 * @since 1.5.0
 */

/* Search wrapper positioning */
.woo-ship-booster-search-wrapper {
    position: relative;
    display: inline-block;
    width: 100%;
}

/* Main results container */
.woo-ship-booster-live-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 9999;
    background: #ffffff;
    border: 1px solid #ddd;
    border-top: none;
    border-radius: 0 0 4px 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    max-height: 400px;
    overflow: hidden;
    font-size: 14px;
    line-height: 1.4;
    pointer-events: auto; /* Ensure the dropdown is interactive */
    user-select: none; /* Prevent text selection issues */
}

/* Results list */
.woo-ship-booster-results-list {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 320px;
    overflow-y: auto;
}

/* Individual result item */
.woo-ship-booster-result-item {
    margin: 0;
    padding: 0;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: background-color 0.2s ease;
    pointer-events: auto; /* Ensure items are clickable */
}

.woo-ship-booster-result-item:last-child {
    border-bottom: none;
}

.woo-ship-booster-result-item:hover {
    background-color: #f8f9fa;
}

.woo-ship-booster-result-item.woo-ship-booster-selected {
    background-color: #e5e7eb;
    color: #1f2937;
}

.woo-ship-booster-result-item.woo-ship-booster-selected .woo-ship-booster-result-title {
    color: #1f2937;
    font-weight: 600;
}

.woo-ship-booster-result-item.woo-ship-booster-selected .woo-ship-booster-result-sku {
    color: #6b7280;
}

.woo-ship-booster-result-item.woo-ship-booster-selected .woo-ship-booster-result-price {
    color: #1f2937;
}

/* Result content layout */
.woo-ship-booster-result-content {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    text-decoration: none;
    color: inherit;
}

/* Product image */
.woo-ship-booster-result-image {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: 4px;
    margin-right: 12px;
    flex-shrink: 0;
    border: 1px solid #e0e0e0;
}

.woo-ship-booster-result-image-placeholder {
    width: 40px;
    height: 40px;
    background-color: #f5f5f5;
    border-radius: 4px;
    margin-right: 12px;
    flex-shrink: 0;
    border: 1px solid #e0e0e0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.woo-ship-booster-result-image-placeholder::before {
    content: "📦";
    font-size: 16px;
    opacity: 0.5;
}

/* Product details */
.woo-ship-booster-result-details {
    flex: 1;
    min-width: 0;
}

.woo-ship-booster-result-title {
    margin: 0 0 4px 0;
    font-size: 14px;
    font-weight: 600;
    color: #333;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.woo-ship-booster-result-sku {
    display: inline-block;
    font-size: 12px;
    color: #666;
    background-color: #f0f0f0;
    padding: 2px 6px;
    border-radius: 2px;
    margin-bottom: 4px;
}

.woo-ship-booster-result-price {
    font-size: 13px;
    color: #2c3e50;
    font-weight: 600;
}

.woo-ship-booster-result-price .amount {
    color: #27ae60;
}

/* Out of stock styling */
.woo-ship-booster-out-of-stock {
    opacity: 0.6;
}

.woo-ship-booster-out-of-stock .woo-ship-booster-result-title {
    color: #666;
}

.woo-ship-booster-out-of-stock .woo-ship-booster-result-price::after {
    content: " (Utsolgt)";
    color: #e74c3c;
    font-weight: normal;
    font-size: 12px;
}

/* Loading state */
.woo-ship-booster-loading {
    padding: 15px;
    text-align: center;
    color: #666;
}

.woo-ship-booster-loading-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.woo-ship-booster-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #0073aa;
    border-radius: 50%;
    animation: woo-ship-booster-spin 1s linear infinite;
}

@keyframes woo-ship-booster-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* No results state */
.woo-ship-booster-no-results {
    padding: 15px;
    text-align: center;
    color: #666;
    font-style: italic;
}

/* Footer with "View All" link */
.woo-ship-booster-search-footer {
    border-top: 1px solid #f0f0f0;
    padding: 10px 15px;
    background-color: #f8f9fa;
    text-align: center;
}

.woo-ship-booster-view-all {
    color: #0073aa;
    text-decoration: none;
    font-weight: 600;
    font-size: 13px;
    display: inline-block;
    padding: 5px 10px;
    border-radius: 3px;
    transition: all 0.2s ease;
}

.woo-ship-booster-view-all:hover {
    background-color: #0073aa;
    color: #ffffff;
    text-decoration: none;
}

/* Responsive design */
@media (max-width: 768px) {
    .woo-ship-booster-live-results {
        position: fixed;
        left: 10px !important;
        right: 10px;
        width: auto !important;
        max-height: 60vh;
    }
    
    .woo-ship-booster-result-content {
        padding: 10px 12px;
    }
    
    .woo-ship-booster-result-image,
    .woo-ship-booster-result-image-placeholder {
        width: 35px;
        height: 35px;
        margin-right: 10px;
    }
    
    .woo-ship-booster-result-title {
        font-size: 13px;
    }
}

/* Dark theme support */
@media (prefers-color-scheme: dark) {
    .woo-ship-booster-live-results {
        background: #2c3e50;
        border-color: #34495e;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    }
    
    .woo-ship-booster-result-item {
        border-bottom-color: #34495e;
    }
    
    .woo-ship-booster-result-item:hover,
    .woo-ship-booster-result-item.woo-ship-booster-selected {
        background-color: #34495e;
    }
    
    .woo-ship-booster-result-title {
        color: #ecf0f1;
    }
    
    .woo-ship-booster-result-sku {
        background-color: #34495e;
        color: #bdc3c7;
    }
    
    .woo-ship-booster-result-price {
        color: #ecf0f1;
    }
    
    .woo-ship-booster-search-footer {
        background-color: #34495e;
        border-top-color: #2c3e50;
    }
    
    .woo-ship-booster-loading,
    .woo-ship-booster-no-results {
        color: #bdc3c7;
    }
    
    .woo-ship-booster-image-placeholder {
        background-color: #34495e;
        border-color: #2c3e50;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .woo-ship-booster-live-results {
        border: 2px solid #000;
    }
    
    .woo-ship-booster-result-item:hover,
    .woo-ship-booster-result-item.woo-ship-booster-selected {
        background-color: #000;
        color: #fff;
    }
    
    .woo-ship-booster-view-all {
        border: 1px solid #0073aa;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .woo-ship-booster-result-item,
    .woo-ship-booster-view-all {
        transition: none;
    }
    
    .woo-ship-booster-spinner {
        animation: none;
    }
    
    .woo-ship-booster-spinner::after {
        content: "⏳";
        display: block;
        width: 16px;
        height: 16px;
        line-height: 16px;
        text-align: center;
    }
}

/* Focus management for accessibility */
.woo-ship-booster-result-item:focus {
    outline: 2px solid #0073aa;
    outline-offset: -2px;
}

/* Ensure proper stacking with popular themes */
.woo-ship-booster-live-results {
    z-index: 999999 !important;
}

/* Theme-specific overrides */

/* Flatsome theme compatibility */
.flatsome-search .woo-ship-booster-live-results {
    position: absolute;
    z-index: 9999;
}

/* Storefront theme compatibility */
.storefront .site-search .woo-ship-booster-live-results {
    border-radius: 0;
}

/* Astra theme compatibility */
.astra-search-box .woo-ship-booster-live-results {
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
}

/* OceanWP theme compatibility */
.oceanwp-mobile-search .woo-ship-booster-live-results {
    position: fixed;
    left: 0;
    right: 0;
    width: 100% !important;
}