/* ----------------------------------------------------------------
    [Table of contents]

    1.  Global & Visibility
    2.  Header Layout & Alignment
    3.  Search Form & Icon Styling (Updated)
    4.  AJAX Search Results
    5.  Action Icons & Cart Counter
    6.  Sticky Header
    7.  Mini Cart Popup & Overlay
    8.  Mini Cart Content & Product List
    9.  Mini Cart Footer & Button
-----------------------------------------------------------------*/

/* 1. Global & Visibility
-----------------------------------------------------------------*/
.elementor-widget-custom-mobile-header {
    display: none;
}

@media (max-width: 1024px) {
    .elementor-widget-custom-mobile-header {
        display: block;
    }
}

.cmh-body-no-scroll {
    overflow: hidden;
}

/* 2. Header Layout & Alignment
-----------------------------------------------------------------*/
.elementor-widget-custom-mobile-header .cmh-header-container {
    display: flex;
    align-items: center;
    width: 100%;
    box-sizing: border-box;
    background-color: #ffffff;
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
    padding: 0 15px;
}

.elementor-widget-custom-mobile-header .cmh-logo,
.elementor-widget-custom-mobile-header .cmh-search-wrapper,
.elementor-widget-custom-mobile-header .cmh-action-icons-wrapper {
    display: flex;
    align-items: center;
}

.elementor-widget-custom-mobile-header .cmh-logo {
    flex-basis: 20%;
    justify-content: flex-start;
}
.elementor-widget-custom-mobile-header .cmh-logo img {
    max-height: 50px;
    width: auto;
    height: auto;
}

.elementor-widget-custom-mobile-header .cmh-search-wrapper {
    flex-grow: 1;
    min-width: 0;
    justify-content: center;
}

.elementor-widget-custom-mobile-header .cmh-action-icons-wrapper {
    flex-basis: 20%;
    justify-content: flex-end;
    gap: 15px;
}

/* 3. Search Form & Icon Styling (Updated)
-----------------------------------------------------------------*/
.elementor-widget-custom-mobile-header .cmh-search-container {
    width: 100%;
    position: relative;
}
.elementor-widget-custom-mobile-header .custom-search-form-container {
    width: 100%;
    max-width: 400px;
    margin: 0;
    position: relative;
}

.elementor-widget-custom-mobile-header .custom-search-input {
    width: 100%;
    height: 40px;
    border-radius: 100px;
    border: 1px solid #ddd;
    background-color: #f5f5f5;
    font-size: 14px;
    box-sizing: border-box;
    -webkit-appearance: none;
}
.elementor-widget-custom-mobile-header .custom-search-input:focus {
    outline: none;
    border-color: #aaa;
}

.elementor-widget-custom-mobile-header .custom-search-button {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    height: 100%;
    width: 45px;
    background: transparent;
    border: none;
    padding: 0;
    margin: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box; /* Ensures padding is included in the size */
}
.elementor-widget-custom-mobile-header .custom-search-button svg {
    width: 16px;
    height: 16px;
    fill: #333;
}

/* Icon Position: Left (Default) */
.elementor-widget-custom-mobile-header.cmh-search-icon-pos-left .custom-search-button {
    left: 0;
}
.elementor-widget-custom-mobile-header.cmh-search-icon-pos-left .custom-search-input {
    padding-left: 45px;
    padding-right: 20px;
}

/* Icon Position: Right */
.elementor-widget-custom-mobile-header.cmh-search-icon-pos-right .custom-search-button {
    right: 0;
    left: auto;
}
.elementor-widget-custom-mobile-header.cmh-search-icon-pos-right .custom-search-input {
    padding-left: 20px;
    padding-right: 45px;
}

/* Icon Background: Yes */
.elementor-widget-custom-mobile-header.cmh-search-icon-bg-yes .custom-search-button {
    background-color: #333; /* Default background color */
    height: calc(100% - 8px);
    width: auto; /* Width will be determined by aspect ratio and padding */
    aspect-ratio: 1 / 1; /* Ensures it's a perfect square before radius */
}
.elementor-widget-custom-mobile-header.cmh-search-icon-bg-yes .custom-search-button svg {
    fill: #fff; /* Make icon white on dark background */
}
.elementor-widget-custom-mobile-header.cmh-search-icon-bg-yes.cmh-search-icon-pos-left .custom-search-button {
    left: 4px;
}
.elementor-widget-custom-mobile-header.cmh-search-icon-bg-yes.cmh-search-icon-pos-right .custom-search-button {
    right: 4px;
}

/* 4. AJAX Search Results
-----------------------------------------------------------------*/
.elementor-widget-custom-mobile-header .cmh-ajax-search-results {
    position: absolute;
    top: calc(100% + 5px);
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    background: #fff;
    border: 1px solid #eee;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    z-index: 999;
    display: none;
    max-height: 70vh;
    overflow-y: auto;
}
.elementor-widget-custom-mobile-header .cmh-ajax-search-results.active { display: block; }
.elementor-widget-custom-mobile-header .cmh-ajax-search-results ul { list-style: none; margin: 0; padding: 5px; }
.elementor-widget-custom-mobile-header .cmh-ajax-search-results li a { display: flex; align-items: center; gap: 10px; padding: 8px; text-decoration: none; color: #333; border-radius: 4px; transition: background-color 0.2s ease; }
.elementor-widget-custom-mobile-header .cmh-ajax-search-results li a:hover { background-color: #f9f9f9; }
.elementor-widget-custom-mobile-header .cmh-result-thumb { width: 45px; height: 45px; object-fit: cover; border-radius: 4px; flex-shrink: 0; }
.elementor-widget-custom-mobile-header .cmh-result-details { display: flex; flex-direction: column; }
.elementor-widget-custom-mobile-header .cmh-result-title { font-size: 14px; font-weight: 500; }
.elementor-widget-custom-mobile-header .cmh-result-price { font-size: 13px; color: #555; }

/* 5. Action Icons & Cart Counter
-----------------------------------------------------------------*/
.elementor-widget-custom-mobile-header .cmh-action-icon {
    position: relative;
    cursor: pointer;
    display: flex;
    align-items: center;
}
.elementor-widget-custom-mobile-header .cmh-action-icon a, 
.elementor-widget-custom-mobile-header .cmh-action-icon > div {
    color: #333;
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}
.elementor-widget-custom-mobile-header .cmh-action-icon .elementor-icon,
.elementor-widget-custom-mobile-header .cmh-action-icon i,
.elementor-widget-custom-mobile-header .cmh-action-icon svg {
    width: 1em;
    height: 1em;
}

.elementor-widget-custom-mobile-header .cmh-cart-count {
    position: absolute;
    top: 0;
    right: 0;
    background-color: red;
    color: white;
    border-radius: 50%;
    height: 18px;
    min-width: 18px;
    font-size: 10px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 18px;
    padding: 0 3px;
    box-sizing: border-box;
    transform: translate(40%, -40%);
}

/* 6. Sticky Header
-----------------------------------------------------------------*/
.elementor-widget-custom-mobile-header .cmh-header-wrapper {
    position: relative;
    z-index: 1000;
}
.elementor-widget-custom-mobile-header .cmh-header-container.is-sticky {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1001;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
    animation: cmhSlideDown 0.3s ease-out;
}
@keyframes cmhSlideDown {
    from { transform: translateY(-100%); }
    to { transform: translateY(0); }
}

/* 7. Mini Cart Popup & Overlay
-----------------------------------------------------------------*/
.elementor-widget-custom-mobile-header .cmh-mini-cart-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    z-index: 1002;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}
.elementor-widget-custom-mobile-header .cmh-mini-cart-overlay.is-visible {
    opacity: 1;
    visibility: visible;
}

.elementor-widget-custom-mobile-header .cmh-mini-cart-popup {
    position: fixed;
    top: 0;
    right: -100%;
    width: 90%;
    max-width: 380px;
    height: 100%;
    background-color: #fff;
    z-index: 1003;
    box-shadow: -5px 0 25px rgba(0,0,0,0.15);
    transition: right 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    display: flex;
    flex-direction: column;
}
.elementor-widget-custom-mobile-header .cmh-mini-cart-popup.is-visible {
    right: 0;
}

.elementor-widget-custom-mobile-header .cmh-mini-cart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid #eee;
    flex-shrink: 0;
}
.elementor-widget-custom-mobile-header .cmh-mini-cart-header h3 { margin: 0; font-size: 18px; }
.elementor-widget-custom-mobile-header .cmh-close-cart-btn { background: none; border: none; font-size: 28px; line-height: 1; cursor: pointer; color: #888; padding: 0; }

/* 8. Mini Cart Content & Product List
-----------------------------------------------------------------*/
.elementor-widget-custom-mobile-header .cmh-mini-cart-content-wrapper {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.elementor-widget-custom-mobile-header .cmh-mini-cart-content {
    flex-grow: 1;
    overflow-y: auto;
    padding: 20px;
}
.elementor-widget-custom-mobile-header .cmh-cart-empty { text-align: center; color: #777; padding-top: 40px; }
.elementor-widget-custom-mobile-header .cmh-product-list { list-style: none; margin: 0; padding: 0; }
.elementor-widget-custom-mobile-header .cmh-product-list li { display: flex; gap: 15px; align-items: center; padding-bottom: 15px; margin-bottom: 15px; border-bottom: 1px solid #f0f0f0; }
.elementor-widget-custom-mobile-header .cmh-product-list li:last-child { border-bottom: none; }
.elementor-widget-custom-mobile-header .cmh-product-image { width: 60px; height: 60px; flex-shrink: 0; }
.elementor-widget-custom-mobile-header .cmh-product-image img { width: 100%; height: 100%; object-fit: cover; border-radius: 4px; }
.elementor-widget-custom-mobile-header .cmh-product-details { display: flex; flex-direction: column; }
.elementor-widget-custom-mobile-header .cmh-product-title { font-weight: 600; color: #333; text-decoration: none; margin-bottom: 5px; }
.elementor-widget-custom-mobile-header .cmh-product-price { color: #666; font-size: 14px; }

/* 9. Mini Cart Footer & Button
-----------------------------------------------------------------*/
.elementor-widget-custom-mobile-header .cmh-mini-cart-footer {
    padding: 20px;
    border-top: 1px solid #eee;
    flex-shrink: 0;
    background: #fff;
}
.elementor-widget-custom-mobile-header .cmh-mini-cart-footer.button-pos-top {
    order: -1;
    border-top: none;
    border-bottom: 1px solid #eee;
}
.elementor-widget-custom-mobile-header .cmh-total { display: flex; justify-content: space-between; font-size: 16px; margin-bottom: 20px; }
.elementor-widget-custom-mobile-header .cmh-total strong { font-weight: 600; }
.elementor-widget-custom-mobile-header .cmh-checkout-btn { display: block; width: 100%; padding: 15px; background-color: #2c3e50; color: #fff; text-align: center; text-decoration: none; border-radius: 5px; font-weight: bold; transition: background-color 0.2s ease; }
.elementor-widget-custom-mobile-header .cmh-checkout-btn:hover { background-color: #34495e; }
