#custom-ajax-search-form {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
    margin-bottom: 10px;
    padding: 0;
    box-sizing: border-box;
}

#custom-ajax-search-input {
    flex-grow: 1;
    height: 42px;
    padding: 8px 12px;
    border: 1px solid #ccc;
    border-right: none;
    border-radius: 4px 0 0 4px;
    font-size: 16px;
}

#custom-ajax-search-button {
    height: 42px;
    padding: 0 16px;
    border: 1px solid #ccc;
    border-left: none;
    border-radius: 0 4px 4px 0;
    background-color: #f1f1f1;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#custom-ajax-search-button svg {
    width: 20px;
    height: 20px;
    display: block;
}

#custom-ajax-clear {
    position: absolute;
    right: 55px;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    font-size: 18px;
    color: #999;
    line-height: 1;
    padding: 2px;
}

#custom-ajax-search-results {
    position: absolute;
    top: 42px;
    left: 0;
    width: 100%;
    max-height: 300px;
    overflow-y: auto;
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 0 0 4px 4px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
    z-index: 9999;
    display: none;
    box-sizing: border-box;
}

ul.cas-product-list {
    list-style: none;
    margin: 0;
    padding: 0;
}
.cas-product-item {
    display: flex;
    align-items: center;
    padding: 8px 10px;
    border-bottom: 1px solid #eee;
    transition: background-color 0.2s;
}
.cas-product-item:last-child {
    border-bottom: none;
}
.cas-product-item:hover {
    background-color: #f9f9f9;
}
.cas-product-link {
    display: flex;
    align-items: center;
    flex: 1;
    min-width: 0;
    text-decoration: none;
    color: #333;
}
.cas-product-thumb img {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 4px;
    margin-right: 8px;
}
.cas-product-title {
    font-size: 14px;
    font-weight: bold;
    margin: 0;
}
.cas-product-brand {
    font-size: 0.75em;
    font-style: italic;
    display: block;
    line-height: 1;
}
.cas-product-variations,
.cas-variation-matches {
    font-family: 'blanket', sans-serif;
    font-size: 0.85em;
    color: #555;
    padding: 2px 0;
}
.cas-product-details {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    margin-right: 8px;
}
.cas-product-price {
    font-weight: bold;
    color: #0073aa;
    font-size: 14px;
}

/* Category/brand section */
.cas-taxonomy-section {
    border-top: 1px solid #ddd;
    padding: 8px 10px;
}
.cas-section-title {
    margin: 0 0 5px;
    font-size: 13px;
    color: #666;
}
.cas-taxonomy-list {
    list-style: none;
    margin: 0;
    padding: 0;
}
.cas-taxonomy-item {
    padding: 4px 0;
}
.cas-taxonomy-link {
    text-decoration: none;
    color: #555;
}
.cas-taxonomy-link:hover {
    text-decoration: underline;
    color: #0073aa;
}
.cas-category-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.cas-category-badge {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #888;
    background: #eee;
    padding: 2px 6px;
    border-radius: 3px;
    flex-shrink: 0;
}
.cas-category-name {
    flex-grow: 1;
}
.cas-cat-count {
    font-size: 0.9em;
    color: #888;
    font-weight: normal;
}
.cas-categories-section {
    padding-top: 6px;
}
/* When categories appear after products, add a separator */
.cas-products-section + .cas-categories-section {
    border-top: 1px solid #ddd;
    padding-top: 8px;
}
#custom-ajax-search-results > .cas-categories-section:first-child {
    border-top: none;
    padding-top: 8px;
}
.cas-categories-section .cas-section-title {
    text-transform: uppercase;
    letter-spacing: 0.02em;
    font-weight: 600;
}

/* Products section - same section title style for consistency */
.cas-products-section {
    border-top: 1px solid #ddd;
    padding: 8px 10px;
}
.cas-products-section .cas-section-title {
    text-transform: uppercase;
    letter-spacing: 0.02em;
    font-weight: 600;
    margin: 0 0 5px;
    font-size: 13px;
    color: #666;
}
#custom-ajax-search-results > .cas-products-section:first-child {
    border-top: none;
    padding-top: 8px;
}

/* "No products found" */
#custom-ajax-search-results p {
    margin: 0;
    padding: 12px;
    text-align: center;
    color: #999;
    font-style: italic;
}

/* highlight */
mark {
    background-color: #ffeb3b;
    padding: 0 2px;
}

.cas-results-list {
    /* This container holds the results.
       Positioning and borders are handled by the parent #custom-ajax-search-results */
    display: block;
    width: 100%;
    max-height: 300px; /* Match parent container */
    overflow-y: auto;
}

.cas-result-item {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    border-bottom: 1px solid #eee;
    text-decoration: none;
    color: #333;
    transition: background-color 0.2s ease;
}

.cas-result-item:hover {
    background-color: #f5f5f5;
}

.cas-result-item:last-child {
    border-bottom: none;
}

.cas-result-image {
    width: 50px;
    height: 50px;
    margin-right: 12px;
    flex-shrink: 0;
}

.cas-result-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.cas-result-details {
    display: flex;
    flex-direction: column;
    justify-content: center;
    flex-grow: 1;
}

.cas-result-title {
    font-weight: 600;
    font-size: 15px;
    margin-bottom: 4px;
}

.cas-result-title .highlight {
    background-color: #fff3a3;
    font-weight: bold;
}

.cas-result-price {
    font-size: 14px;
    color: #555;
}

.cas-no-results {
    padding: 15px;
    text-align: center;
    color: #777;
}

/* Action buttons (heart + quick-add) sit to the right of the product link */
.cas-product-item .cas-product-actions {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: 8px;
}

/* Heart button in search results — override product-loop absolute positioning + shrink emoji */
#custom-ajax-search-results .cas-product-item .eg-heart {
    position: static !important;
    top: auto !important;
    right: auto !important;
    width: 28px !important;
    height: 28px !important;
    min-width: 0 !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 1.5px solid #d4e4de !important;
    border-radius: 6px !important;
    background: #fff !important;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}
#custom-ajax-search-results .cas-product-item .eg-heart:hover {
    border-color: #a5ccbc !important;
    box-shadow: 0 2px 6px rgba(44, 94, 84, 0.18) !important;
}
#custom-ajax-search-results .cas-product-item .eg-heart .eg-heart-emoji {
    font-size: 14px !important;
    line-height: 1 !important;
    margin: 0 !important;
}

/* Quick-add button in search results — high specificity to override theme button defaults */
#custom-ajax-search-results button.cas-quick-add {
    flex-shrink: 0;
    width: 28px !important;
    height: 28px !important;
    padding: 0 !important;
    border: 1.5px solid #2c5e54 !important;
    border-radius: 6px !important;
    background: linear-gradient(135deg, #2c5e54 0%, #3a7a6d 100%) !important;
    color: #fff !important;
    font-size: 18px;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-shadow: 0 2px 6px rgba(44, 94, 84, 0.25);
    min-width: 0;
    min-height: 0;
}
#custom-ajax-search-results button.cas-quick-add:hover {
    box-shadow: 0 4px 10px rgba(44, 94, 84, 0.35) !important;
    background: linear-gradient(135deg, #3a7a6d 0%, #4a8e80 100%) !important;
}
#custom-ajax-search-results button.cas-quick-add.cas-quick-add--loading {
    pointer-events: none;
    opacity: 0.7;
}
#custom-ajax-search-results button.cas-quick-add.cas-quick-add--success {
    background: #a5ccbc !important;
    border-color: #a5ccbc !important;
    color: #fff !important;
}
#custom-ajax-search-results button.cas-quick-add.cas-quick-add--error {
    background: #fee2e2 !important;
    border-color: #ef4444 !important;
    color: #b91c1c !important;
}
#custom-ajax-search-results button.cas-quick-add.cas-quick-add--warning {
    background: #fef3c7 !important;
    border-color: #f59e0b !important;
    color: #92400e !important;
}
.cas-quick-add-icon {
    display: inline-block;
    margin-top: -1px;
}

/* Limit dropdown width on larger screens for cleaner layout */
@media (min-width: 768px) {
    #custom-ajax-search-results {
        max-width: 640px;
    }
}
