/**
 * Flora Search Styles
 * Version: 3.3.5
 * Based on working snippet
 */

/* Основной контейнер результатов */
#flora-autocomplete-results {
    position: fixed;
    background: #fff;
    border: 1px solid #e0e0e0;
    max-height: 400px;
    overflow-y: auto;
    width: 550px;
    max-width: calc(100vw - 40px);
    z-index: 99999;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    border-radius: 8px;
    margin-top: 4px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    display: none;
    -webkit-overflow-scrolling: touch;
}

/* Элемент результата */
.flora-autocomplete-item {
    padding: 14px 16px;
    cursor: pointer;
    border-bottom: 1px solid #f5f5f5;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 14px;
    position: relative;
}

.flora-autocomplete-item:last-child {
    border-bottom: none;
}

.flora-autocomplete-item:hover,
.flora-autocomplete-item.keyboard-active {
    background: #f8f9fa;
    transform: translateX(2px);
}

/* 🌿 Стили для растений с картинками */
.flora-plant-item {
    background: linear-gradient(135deg, #e8f5e9 0%, #f1f8e9 100%);
    border-left: 4px solid #4caf50;
    color: #1b5e20;
    font-weight: 500;
    padding: 16px;
}

.flora-plant-item:hover {
    background: linear-gradient(135deg, #dcedc8 0%, #e8f5e9 100%);
    transform: translateX(3px);
}

.flora-plant-thumbnail {
    width: 56px;
    height: 56px;
    object-fit: cover;
    border-radius: 8px;
    border: 3px solid #4caf50;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.3);
    transition: transform 0.2s ease;
}

.flora-plant-item:hover .flora-plant-thumbnail {
    transform: scale(1.05);
}

.flora-plant-content {
    flex: 1;
    min-width: 0;
}

.flora-plant-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 6px;
    color: #1b5e20;
    display: flex;
    align-items: center;
    gap: 8px;
}

.flora-plant-subtitle {
    font-size: 13px;
    color: #2e7d32;
    margin-bottom: 6px;
}

.flora-plant-stats {
    display: flex;
    gap: 8px;
    font-size: 12px;
    flex-wrap: wrap;
}

.flora-plant-stat.stock {
    background: #e8f5e9;
    color: #2e7d32;
    padding: 3px 10px;
    border-radius: 12px;
    border: 1px solid #4caf50;
    font-weight: 500;
    white-space: nowrap;
}

.flora-plant-stat.preorder {
    background: #fff3e0;
    color: #e65100;
    padding: 3px 10px;
    border-radius: 12px;
    border: 1px solid #ff9800;
    font-weight: 500;
    white-space: nowrap;
}

/* 🛒 Стили для товаров */
.flora-product-item {
    color: #333;
}

.flora-product-item.instock::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 4px;
    background: #4caf50;
}

.flora-product-item.onbackorder::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 4px;
    background: #ff9800;
}

.flora-item-thumbnail {
    width: 56px;
    height: 56px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid #e8e8e8;
    flex-shrink: 0;
    transition: transform 0.2s ease;
}

.flora-autocomplete-item:hover .flora-item-thumbnail {
    transform: scale(1.05);
}

.flora-item-content {
    flex: 1;
    min-width: 0;
}

.flora-item-title {
    font-size: 15px;
    font-weight: 500;
    margin-bottom: 4px;
    color: #222;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.flora-item-meta {
    display: flex;
    gap: 8px;
    font-size: 12px;
    flex-wrap: wrap;
    align-items: center;
}

.flora-item-sku {
    background: #f0f0f0;
    padding: 2px 8px;
    border-radius: 10px;
    color: #666;
}

.flora-stock-indicator {
    font-size: 11px;
    font-weight: 500;
    padding: 2px 8px;
    border-radius: 10px;
}

.flora-stock-indicator.instock {
    color: #2e7d32;
    background: #e8f5e9;
}

.flora-stock-indicator.onbackorder {
    color: #e65100;
    background: #fff3e0;
}

.flora-price-block {
    text-align: right;
    min-width: 80px;
}

.flora-item-price {
    font-size: 16px;
    color: #2e7d32;
    font-weight: 600;
    white-space: nowrap;
}

.flora-item-price.on-sale {
    color: #d32f2f;
}

.flora-regular-price {
    font-size: 13px;
    color: #999;
    text-decoration: line-through;
    margin-bottom: 2px;
}

/* Сообщение о поиске по Enter */
.flora-search-hint {
    padding: 12px 16px;
    background: #e3f2fd;
    color: #1565c0;
    font-size: 13px;
    text-align: center;
    border-top: 1px solid #bbdefb;
    margin-top: 8px;
}

.flora-search-hint kbd {
    background: #1976d2;
    color: white;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 600;
    display: inline-block;
    margin: 0 2px;
}

/* Состояния */
.flora-loading {
    padding: 20px;
    text-align: center;
    color: #666;
    font-size: 14px;
}

.flora-loading-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #4caf50;
    border-radius: 50%;
    animation: flora-spin 1s linear infinite;
    margin-right: 8px;
    vertical-align: middle;
}

@keyframes flora-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.flora-no-results {
    padding: 24px;
    color: #666;
    text-align: center;
    font-size: 14px;
}

.flora-no-results-icon {
    font-size: 32px;
    margin-bottom: 8px;
    opacity: 0.5;
}

/* Мобильная адаптация */
@media(max-width: 768px) {
    #flora-autocomplete-results {
        width: calc(100vw - 20px) !important;
        left: 10px !important;
        right: 10px !important;
        max-height: 60vh !important;
    }
    
    .flora-autocomplete-item {
        padding: 16px 14px;
        min-height: 70px;
    }
    
    .flora-plant-item {
        padding: 18px 14px;
        min-height: 80px;
    }
    
    .flora-plant-thumbnail {
        width: 50px;
        height: 50px;
    }
    
    .flora-item-thumbnail {
        width: 48px;
        height: 48px;
    }
    
    .flora-plant-stats {
        font-size: 11px;
        gap: 6px;
    }
    
    .flora-item-title {
        font-size: 14px;
        -webkit-line-clamp: 1;
    }
    
    .flora-plant-title {
        font-size: 15px;
    }
    
    .flora-search-hint {
        font-size: 12px;
        padding: 10px 14px;
    }
}

/* Скроллбар */
#flora-autocomplete-results::-webkit-scrollbar {
    width: 6px;
}

#flora-autocomplete-results::-webkit-scrollbar-track {
    background: #f5f5f5;
}

#flora-autocomplete-results::-webkit-scrollbar-thumb {
    background: #ddd;
    border-radius: 3px;
}

#flora-autocomplete-results::-webkit-scrollbar-thumb:hover {
    background: #ccc;
}

/* Подсветка совпадений */
.flora-autocomplete-item .highlight {
    background: #ffeb3b;
    padding: 0 2px;
    border-radius: 2px;
    font-weight: 600;
}

/* Z-index фикс для популярных тем */
.storefront-handheld-footer-bar #flora-autocomplete-results,
.mobile-menu #flora-autocomplete-results {
    z-index: 999999 !important;
}

/* Фикс для WooCommerce форм */
.woocommerce-product-search {
    position: relative;
}

/* Улучшение доступности */
.flora-autocomplete-item:focus {
    outline: 2px solid #4caf50;
    outline-offset: -2px;
}

/* Скрываем от screen readers элементы оформления */
.flora-loading-spinner,
.flora-no-results-icon {
    aria-hidden: true;
}

/* Планшеты */
@media (min-width: 769px) and (max-width: 1024px) {
    #flora-autocomplete-results {
        max-width: 500px;
    }
}

/* Темная тема (если поддерживается) */
@media (prefers-color-scheme: dark) {
    #flora-autocomplete-results {
        background: #1e1e1e;
        border-color: #333;
        color: #e0e0e0;
    }
    
    .flora-autocomplete-item {
        border-bottom-color: #333;
    }
    
    .flora-autocomplete-item:hover,
    .flora-autocomplete-item.keyboard-active {
        background: #2d2d2d;
    }
    
    .flora-plant-item {
        background: #1a2e1a;
    }
    
    .flora-plant-item:hover,
    .flora-plant-item.keyboard-active {
        background: #234423;
    }
    
    .flora-item-title {
        color: #e0e0e0;
    }
    
    .flora-plant-title {
        color: #81c784;
    }
    
    .flora-item-meta,
    .flora-plant-subtitle {
        color: #999;
    }
    
    .flora-search-hint {
        background: #2d2d2d;
        border-top-color: #444;
        color: #999;
    }
    
    .flora-search-hint kbd {
        background: #1e1e1e;
        border-color: #444;
        box-shadow: 0 2px 0 #333;
    }
}

/* Анимации появления */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

#flora-autocomplete-results.show {
    animation: fadeIn 0.2s ease-out;
}
