.ehtsearch-widget {
    position: relative;
    width: 100%;
    max-width: 600px; /* Default width when inactive */
    margin: 0 auto;
    transition: all 0.3s ease;
    z-index: 1002; /* Base z-index */
}

/* --- IMMERSIVE MODE (Active) --- */
.ehtsearch-widget.ehtsearch-active {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    max-width: 100%;
    background: #fff;
    padding: 15px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    box-sizing: border-box;
    height: auto;
    z-index: 99999; /* Force on top of everything */

    /* Animation: Slide Down from Top Center */
    animation: slideDown 0.3s ease-out forwards;
    transform-origin: top center;
}

@keyframes slideDown {
    0% {
        transform: translateY(-100%);
        opacity: 0;
    }
    100% {
        transform: translateY(0);
        opacity: 1;
    }
}

.ehtsearch-widget.ehtsearch-active .ehtsearch-input-group {
    max-width: 1200px; /* Limit width of input in full screen */
    margin: 0 auto;
    border: 1px solid var(--eht-btn-bg, #2fb5d2); /* Highlight border */
    box-shadow: 0 0 0 3px rgba(47, 181, 210, 0.1);
    position: relative;
    z-index: 100000; /* Input above widget background */
    background: #fff;
}
/* ----------------------------- */

.ehtsearch-input-group {
    display: flex;
    align-items: center; /* Vertical centering */
    justify-content: space-between;
    background: #fff;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    padding: 0; /* Remove padding on container */
    border: 1px solid #ddd;
    transition: all 0.3s ease;
    height: 45px; /* Fixed height for consistency */
    overflow: hidden; /* Ensure children don't overflow */
}

.ehtsearch-input {
    flex-grow: 1;
    border: none;
    outline: none;
    padding: 0 15px;
    font-size: 16px;
    background: transparent;
    height: 100%; /* Fill height */
    line-height: normal; /* Reset line-height */
    margin: 0;
}

.ehtsearch-loader {
    border: 2px solid #f3f3f3;
    border-top: 2px solid var(--eht-btn-bg, #2fb5d2);
    border-radius: 50%;
    width: 16px;
    height: 16px;
    animation: spin 1s linear infinite;
    display: none;
    margin-right: 10px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.ehtsearch-button, .ehtsearch-mic {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0 15px;
    color: #333;
    height: 100%; /* Fill height of input group */
    display: flex; /* Use flexbox */
    align-items: center; /* Center vertically */
    justify-content: center; /* Center horizontally */
    margin: 0; /* Remove margins */
    line-height: 1; /* Reset line-height */
}

.ehtsearch-mic {
    color: #777;
    transition: color 0.2s;
    padding-right: 5px; /* Adjust spacing between mic and search */
}

.ehtsearch-mic:hover {
    color: #333;
}

.ehtsearch-mic.listening {
    color: var(--eht-discount, #f44336);
    animation: pulse 1.5s infinite;
}

.ehtsearch-button i, .ehtsearch-mic i {
    display: block;
    font-size: 24px;
    line-height: 1;
    height: 20px;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

.ehtsearch-results {
    position: fixed;
    left: 0;
    right: 0;
    /* Top will be set by JS, but default to something reasonable */
    top: 75px;
    height: calc(100vh - 75px); /* Force full height minus header */
    background: #fff;
    overflow-y: auto;
    z-index: 99998; /* Just below the widget but above overlay */
    padding: 20px 0;
    box-sizing: border-box;
    border-top: 1px solid #eee;
    display: none; /* Hidden by default */
}

.ehtsearch-results-content {
    max-width: 1600px;
    margin: 0 auto;
    padding: 0 20px;
    min-height: 100%; /* Ensure content fills the scrollable area */
}

.ehtsearch-close-btn {
    display: none; /* Hidden by default, shown in active mode via JS logic or CSS */
}

.ehtsearch-widget.ehtsearch-active .ehtsearch-close-btn {
    display: block;
    position: fixed; /* Fixed to viewport */
    right: 20px;
    top: 15px;
    background: none;
    border: none;
    font-size: 32px; /* Larger for better visibility */
    cursor: pointer;
    color: #fff; /* White color */
    z-index: 100002; /* Above everything including input group */
    padding: 0;
    line-height: 1;
    height: 45px;
    width: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-shadow: 0 1px 3px rgba(0,0,0,0.5); /* Shadow for better visibility on light backgrounds if needed */
}

/* History Styles */
.ehtsearch-history {
    padding: 10px 0;
}

.ehtsearch-section-title {
    font-size: 13px;
    text-transform: uppercase;
    color: #999;
    margin: 0 0 15px 0;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.ehtsearch-history-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.ehtsearch-history-list li {
    padding: 10px 15px;
    border-bottom: 1px solid #f5f5f5;
    cursor: pointer;
    display: flex;
    align-items: center;
    font-size: 15px;
    color: #333;
    transition: background 0.2s;
}

.ehtsearch-history-list li:hover {
    background: #f9f9f9;
}

.ehtsearch-history-list li i {
    margin-right: 15px;
    color: #bbb;
    font-size: 20px;
}

/* Suggestions (Categories/Brands) */
.ehtsearch-suggestions-list {
    list-style: none;
    padding: 0;
    margin: 0 0 20px 0;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.ehtsearch-suggestions-list li a {
    display: inline-block;
    padding: 8px 16px;
    background: #f0f2f5;
    border-radius: 20px;
    color: #333;
    text-decoration: none;
    font-size: 14px;
    transition: all 0.2s;
}

.ehtsearch-suggestions-list li a:hover {
    background: #e0e0e0;
    color: #000;
}

/* Results Grid */
.ehtsearch-results-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: 20px;
}

.ehtsearch-result-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 15px;
    border: 1px solid #eee;
    border-radius: 8px;
    transition: all 0.3s ease;
    text-align: center;
    position: relative;
    background: #fff;
    height: 100%;
}

.ehtsearch-result-item:hover, .ehtsearch-result-item.selected {
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    transform: translateY(-2px);
    border-color: var(--eht-btn-bg, #2fb5d2);
}

.ehtsearch-product-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: inherit;
    width: 100%;
    flex-grow: 1;
}

.ehtsearch-product-image {
    position: relative;
    width: 100%;
    height: var(--eht-img-height, 180px); /* Use CSS variable */
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 15px;
    overflow: hidden;
}

.ehtsearch-product-image img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.ehtsearch-discount-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background-color: var(--eht-discount, #f44336);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: bold;
    z-index: 1;
}

.ehtsearch-stock-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: bold;
    z-index: 1;
    color: #fff;
}

.ehtsearch-stock-available { background-color: var(--eht-stock-in, #4cbb6c); }
.ehtsearch-stock-unavailable { background-color: #e0e0e0; color: #888; }
.ehtsearch-stock-last { background-color: var(--eht-stock-last, #ff9800); }

.ehtsearch-highlight {
    background-color: #fff3cd;
    font-weight: bold;
    color: #333;
    padding: 0 2px;
}

.product-name {
    font-weight: 600;
    font-size: 15px;
    margin-bottom: 5px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    height: 42px;
    color: #333;
}

.product-price-and-shipping {
    font-size: 16px;
    color: var(--eht-btn-bg, #2fb5d2);
    margin-top: auto;
    font-weight: bold;
}

.regular-price {
    text-decoration: line-through;
    color: #999;
    font-size: 13px;
    margin-right: 5px;
    font-weight: normal;
}

.ehtsearch-add-to-cart {
    margin-top: 15px;
    width: 100%;
}

.ehtsearch-add-to-cart button, .ehtsearch-add-to-cart a.btn {
    width: 100%;
    padding: 10px;
    font-size: 13px;
    text-transform: uppercase;
    font-weight: 600;
    border-radius: 4px;
    cursor: pointer;
    background-color: var(--eht-btn-bg, #2fb5d2);
    color: var(--eht-btn-text, #ffffff);
    border: none;
    transition: background 0.2s;
    display: block;
    text-align: center;
}

.ehtsearch-add-to-cart button:hover, .ehtsearch-add-to-cart a.btn:hover {
    opacity: 0.9;
    color: var(--eht-btn-text, #ffffff);
}

.ehtsearch-add-to-cart button:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}

.ehtsearch-view-all {
    grid-column: 1 / -1;
    display: flex;
    justify-content: center;
    padding: 20px 0;
    margin-top: 20px;
    border-top: 1px solid #eee;
}

.ehtsearch-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--color-primary, #000); /* Use primary color or black */
    opacity: 0.7; /* Transparency */
    z-index: 99990; /* High z-index but below widget */
    backdrop-filter: blur(3px);
}

/* Modal Styles */
.ehtsearch-modal {
    position: fixed;
    top: 200px;
    left: 0px;
    width: 100%;
    height: 100%;
    /* background: rgba(0, 0, 0, 0.5); */
    z-index: 200000;
    display: none; /* Hidden by default */
    align-items: center;
    justify-content: center;
}

.ehtsearch-modal.active {
    display: flex !important;
}

.ehtsearch-modal-content {
    background: #fff;
    padding: 30px;
    border-radius: 8px;
    width: 90%;
    max-width: 400px;
    position: relative;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    text-align: center;
    margin: auto; /* Ensure centering */
}

.ehtsearch-modal-close {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 24px;
    cursor: pointer;
    color: #999;
}

.ehtsearch-modal-content h3 {
    margin-top: 0;
    color: #333;
}

.ehtsearch-modal-content .form-group {
    margin: 15px 0;
}

.ehtsearch-modal-content .form-control {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.ehtsearch-alert-message {
    padding: 10px;
    border-radius: 4px;
    font-size: 13px;
}

.ehtsearch-alert-message.success {
    background-color: #d4edda;
    color: #155724;
}

.ehtsearch-alert-message.error {
    background-color: #f8d7da;
    color: #721c24;
}

/* Responsive */
@media (max-width: 768px) {
    .ehtsearch-widget.ehtsearch-active {
        padding: 10px;
    }
    .ehtsearch-results-list {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px;
    }
    .ehtsearch-product-image {
        height: var(--eht-img-height-mobile, 120px); /* Use mobile variable */
    }

    /* Mobile Badge Positioning to avoid overlap */
    .ehtsearch-stock-badge {
        top: auto;
        bottom: 5px;
        left: 5px;
        font-size: 10px;
        padding: 2px 6px;
    }
    .ehtsearch-discount-badge {
        font-size: 10px;
        padding: 2px 6px;
        top: 5px;
        right: 5px;
    }
}
