/**
 * Custom Autocomplete Global Search Styles for Allure Theme
 */

/* Make search box container relative for absolute positioning */
.search-box,
.store-search-box {
    position: relative;
}

.custom-autocomplete-panel {
    position: absolute;
    top: 100%;
    left: 0;
    width: 500px !important;
    min-width: 400px !important;
    max-width: 600px !important;
    background: #fff;
    border: 1px solid #ddd;
    border-top: none;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    max-height: 700px;
    overflow-y: auto;
    z-index: 9999;
    margin-top: 0;
}

/* On smaller screens, make it responsive */
@media (max-width: 768px) {
    .custom-autocomplete-panel {
        width: 100% !important;
        min-width: 100% !important;
        max-width: 100% !important;
        left: 0 !important;
        right: 0 !important;
    }
}

.custom-autocomplete-results {
    padding: 0;
}

.autocomplete-content {
    padding: 0;
}

.autocomplete-section {
    border-bottom: 1px solid #eee;
    padding: 0;
}

.autocomplete-section:last-child {
    border-bottom: none;
}

/* Use very specific selectors to avoid theme conflicts with .product-list .product-item */
.custom-autocomplete-panel .category-list,
.custom-autocomplete-panel .manufacturer-list,
.custom-autocomplete-panel #autocomplete-product-list {
    list-style: none;
    margin: 0;
    padding: 0;
    width: 100% !important;
}

.custom-autocomplete-panel .category-item,
.custom-autocomplete-panel .manufacturer-item {
    padding: 8px 0;
    border-bottom: 1px solid #f5f5f5;
}

.custom-autocomplete-panel .category-item:last-child,
.custom-autocomplete-panel .manufacturer-item:last-child {
    border-bottom: none;
}

.custom-autocomplete-panel .category-link,
.custom-autocomplete-panel .manufacturer-link {
    color: #333;
    text-decoration: none;
    display: block;
    padding: 5px 0;
    transition: color 0.2s;
}

.custom-autocomplete-panel .category-link:hover,
.custom-autocomplete-panel .manufacturer-link:hover {
    text-decoration: underline;
}

.custom-autocomplete-panel #autocomplete-product-list {
    max-height: 400px;
    overflow-y: auto;
    padding: 0;
    width: 100% !important;
}

/* Very specific selector to override theme .product-list .product-item */
.custom-autocomplete-panel #autocomplete-product-list .product-item {
    padding: 8px 12px !important;
    border-bottom: 1px solid #eee;
    transition: background-color 0.2s;
    width: 100% !important;
    box-sizing: border-box !important;
    min-height: auto !important;
    height: auto !important;
}

.custom-autocomplete-panel #autocomplete-product-list .product-item:last-child {
    border-bottom: none;
}

.custom-autocomplete-panel #autocomplete-product-list .product-item:hover {
    background-color: #f9f9f9;
}

.custom-autocomplete-panel .product-row {
    display: flex;
    gap: 10px;
    align-items: center;
    width: 100%;
}

.custom-autocomplete-panel .product-image {
    flex-shrink: 0;
    width: 50px;
    height: 50px;
}

.custom-autocomplete-panel .product-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border: 1px solid #eee;
}

.custom-autocomplete-panel .product-details {
    flex: 1;
    min-width: 0;
    width: 100%;
}

.custom-autocomplete-panel .product-name {
    font-weight: 600;
    margin-bottom: 2px;
}

.custom-autocomplete-panel .product-name a {
    color: #333;
    text-decoration: none;
    font-size: 13px;
    line-height: 1.3;
}

.custom-autocomplete-panel .product-name a:hover {
    text-decoration: underline;
}

.custom-autocomplete-panel .product-sku {
    font-size: 11px;
    color: #666;
    margin-bottom: 2px;
    line-height: 1.2;
}

.custom-autocomplete-panel .product-description {
    font-size: 11px;
    color: #666;
    margin-bottom: 4px;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
}

.custom-autocomplete-panel .product-pricing {
    margin-bottom: 4px;
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.custom-autocomplete-panel .product-pricing .price-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.custom-autocomplete-panel .product-pricing .price-label {
    font-size: 10px;
    color: #999;
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.custom-autocomplete-panel .product-pricing .price {
    display: inline-block;
    font-weight: 600;
    color: #333;
    font-size: 13px;
}

.custom-autocomplete-panel .product-pricing .each-price {
    color: #4a90e2;
    font-weight: 700;
}

.custom-autocomplete-panel .product-pricing .case-price {
    font-weight: 700;
}

.custom-autocomplete-panel .product-quantity-inputs {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 4px;
}

.custom-autocomplete-panel .quantity-group {
    display: flex;
    align-items: center;
    gap: 5px;
}

.custom-autocomplete-panel .quantity-group label {
    font-size: 11px;
    color: #666;
    font-weight: 500;
    white-space: nowrap;
}

.custom-autocomplete-panel .quantity-input {
    width: 60px;
    padding: 3px 6px;
    border: 1px solid #ddd;
    border-radius: 3px;
    font-size: 12px;
}

.custom-autocomplete-panel .quantity-input:focus {
    outline: none;
}

.custom-autocomplete-panel .stock-availability {
    font-size: 11px;
    font-weight: 500;
    white-space: nowrap;
    color: #4caf50;
}

.custom-autocomplete-panel .stock-availability:empty {
    display: none;
}

.custom-autocomplete-panel .autocomplete-footer {
    position: sticky;
    bottom: 0;
    padding: 8px 12px;
    border-top: 1px solid #eee;
    background-color: #fff;
    text-align: center;
    display: flex;
    gap: 8px;
    justify-content: center;
    align-items: center;
    box-shadow: 0 -2px 4px rgba(0, 0, 0, 0.1);
    z-index: 10;
}

/* Use theme button-1 class - match add-to-cart button design exactly */
.custom-autocomplete-panel .autocomplete-footer .button-1,
.custom-autocomplete-panel .autocomplete-footer .load-more-btn,
.custom-autocomplete-panel .autocomplete-footer .bulk-add-to-cart-btn {
    margin: 0 !important;
    flex: 0 0 auto;
    text-transform: uppercase;
    font-size: 14px;
    padding: 8px 11px !important;
    border: 2px solid #fff !important;
    color: #fff !important;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.3) !important;
    -webkit-transition: all .15s ease-in-out;
    transition: all .15s ease-in-out;
    cursor: pointer;
    font-weight: normal;
    border-radius: 0;
    text-decoration: none;
    display: inline-block;
}

.custom-autocomplete-panel .autocomplete-footer .button-1:hover,
.custom-autocomplete-panel .autocomplete-footer .load-more-btn:hover,
.custom-autocomplete-panel .autocomplete-footer .bulk-add-to-cart-btn:hover {
    border: 2px solid currentColor !important;
    background: #fff !important;
    color: currentColor !important;
}

.custom-autocomplete-panel .autocomplete-footer .button-1:disabled,
.custom-autocomplete-panel .autocomplete-footer .load-more-btn:disabled,
.custom-autocomplete-panel .autocomplete-footer .bulk-add-to-cart-btn:disabled {
    background: #ccc !important;
    border-color: #ccc !important;
    color: #666 !important;
    cursor: not-allowed;
    opacity: 0.6;
}

.custom-autocomplete-panel .autocomplete-loading {
    padding: 12px;
    text-align: center;
    color: #666;
    font-size: 13px;
}

.custom-autocomplete-panel .autocomplete-empty {
    padding: 20px 12px;
    text-align: center;
    color: #666;
}

.custom-autocomplete-panel .autocomplete-error {
    padding: 20px;
    text-align: center;
    color: #dc3545;
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 4px;
    margin: 10px;
}

/* Responsive styles */
@media (max-width: 768px) {
    .custom-autocomplete-panel {
        max-height: 400px;
    }

    .custom-autocomplete-panel .product-row {
        flex-direction: column;
    }

    .custom-autocomplete-panel .product-image {
        width: 100%;
        height: auto;
        max-width: 150px;
        margin: 0 auto;
    }

    .custom-autocomplete-panel .product-quantity-inputs {
        flex-direction: column;
        gap: 10px;
    }

    .custom-autocomplete-panel .quantity-group {
        width: 100%;
    }

    .custom-autocomplete-panel .quantity-input {
        width: 100%;
    }

    .custom-autocomplete-panel .autocomplete-footer {
        flex-direction: column;
    }

    .custom-autocomplete-panel .autocomplete-footer .button-1,
    .custom-autocomplete-panel .autocomplete-footer .load-more-btn,
    .custom-autocomplete-panel .autocomplete-footer .bulk-add-to-cart-btn {
        width: 100%;
        margin-bottom: 8px;
    }
    
    .custom-autocomplete-panel .autocomplete-footer .button-1:last-child,
    .custom-autocomplete-panel .autocomplete-footer .load-more-btn:last-child,
    .custom-autocomplete-panel .autocomplete-footer .bulk-add-to-cart-btn:last-child {
        margin-bottom: 0;
    }
}
