/* Hide cart icon by default - Divi theme */
.et-cart-info {
    display: none !important;
}

/* Hide Elementor cart widgets by default */
.hfe-site-header-cart,
.hfe-cart-container,
.elementor-menu-cart__toggle,
.elementor-menu-cart__toggle_wrapper,
#hfe-site-header-cart,
#elementor-menu-cart__toggle_button {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    width: 0 !important;
    height: 0 !important;
    overflow: hidden !important;
}

/* Packaging bag icon container - hidden by default */
.cart-bag-icon {
    display: none;
    position: relative;
    opacity: 0;
    transform: scale(0.5);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

/* Show bag icon when cart has items */
.cart-bag-icon.has-items {
    display: inline-flex !important;
    align-items: center;
    opacity: 1 !important;
    visibility: visible !important;
    transform: scale(1);
    width: auto !important;
    height: auto !important;
    overflow: visible !important;
}

/* Packaging bag icon styling */
.cart-bag-icon .bag-icon {
    display: inline-block;
    width: 36px;
    height: 36px;
    position: relative;
    cursor: pointer;
}

/* SVG bag icon */
.cart-bag-icon .bag-icon svg {
    width: 100%;
    height: 100%;
    fill: currentColor;
    transition: transform 0.3s ease;
}

/* Static icon — visible when cart has items and cursor is NOT on the bag */
.cart-bag-icon .cart-bag-static {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: none;
    pointer-events: none;
    z-index: 1;
}

/* GIF — only visible while cursor is on the bag */
.cart-bag-icon .cart-bag-gif {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: none;
    pointer-events: none;
    z-index: 2;
}

.cart-bag-icon.has-items .cart-bag-static {
    display: block;
}

.cart-bag-icon.has-static.has-items .bag-icon svg {
    opacity: 0;
}

/* Hover: hide static, show GIF */
.cart-bag-icon.has-items:hover .cart-bag-static {
    display: none;
}

.cart-bag-icon.has-items:hover .cart-bag-gif {
    display: block;
}

.cart-bag-icon.has-items:hover .bag-icon svg {
    opacity: 0;
}

/* Animation when product is added */
.cart-bag-icon.adding-product .bag-icon svg {
    animation: bagBounce 0.6s ease;
}

@keyframes bagBounce {
    0% {
        transform: scale(1) rotate(0deg);
    }
    25% {
        transform: scale(1.2) rotate(-10deg);
    }
    50% {
        transform: scale(1.1) rotate(10deg);
    }
    75% {
        transform: scale(1.15) rotate(-5deg);
    }
    100% {
        transform: scale(1) rotate(0deg);
    }
}

/* Pulse animation for bag icon */
.cart-bag-icon.pulse .bag-icon svg {
    animation: bagPulse 0.5s ease;
}

@keyframes bagPulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
}

/* Cart count badge on bag */
.cart-bag-icon .bag-count {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #75c32c;
    color: #fff;
    border-radius: 50%;
    min-width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: bold;
    padding: 0 4px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    animation: countPop 0.3s ease;
}

@keyframes countPop {
    0% {
        transform: scale(0);
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
    }
}

/* Position the bag icon in the same location as cart icon */
#et-top-navigation .cart-bag-icon,
#main-header .cart-bag-icon,
header .cart-bag-icon,
.elementor-location-header .cart-bag-icon,
[data-elementor-type="header"] .cart-bag-icon {
    margin-left: 10px;
    vertical-align: middle;
    display: inline-block;
}

/* Elementor specific positioning */
.elementor-widget-hfe-cart + .cart-bag-icon,
.elementor-widget-woocommerce-menu-cart + .cart-bag-icon,
.hfe-site-header-cart + .cart-bag-icon {
    display: inline-block;
    vertical-align: middle;
}

/* Ensure bag icon appears in the right place in navigation */
#et-top-navigation .cart-bag-link {
    display: inline-block;
    line-height: 1;
    text-decoration: none;
    color: inherit;
}

/* Match Divi theme cart styling */
.cart-bag-icon.cart-bag-link {
    display: inline-block;
    vertical-align: middle;
    text-decoration: none;
    color: inherit;
}

.cart-bag-icon.cart-bag-link:hover {
    opacity: 0.8;
}

/* Ensure Elementor cart container can be shown */
.elementor-menu-cart--shown .elementor-menu-cart__container {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

.elementor-menu-cart--shown .elementor-menu-cart__main {
    display: block !important;
    visibility: visible !important;
}

/* When icon is appended to body (e.g. homepage with different header), pin it so it’s always visible */
.cart-bag-icon.cart-bag-fallback {
    position: fixed !important;
    top: 20px !important;
    right: 20px !important;
    z-index: 99999 !important;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .cart-bag-icon .bag-icon {
        width: 30px;
        height: 30px;
    }
    
    .cart-bag-icon .bag-count {
        min-width: 16px;
        height: 16px;
        font-size: 10px;
        top: -6px;
        right: -6px;
    }
}

/* Hide numeric cart badge over GIF icon */
.cart-bag-icon .bag-count {
    display: none !important;
}

/* ——— Header account (My Account) icon ———
   Visible only when logged in. Sits left of the cart bag. */
.account-user-icon {
    display: none;
    position: relative;
    align-items: center;
    justify-content: center;
    vertical-align: middle;
    text-decoration: none !important;
    color: #000 !important;
    opacity: 0;
    transform: scale(0.5);
    transition: opacity 0.3s ease, transform 0.3s ease;
    line-height: 1;
}

.account-user-icon.is-logged-in {
    display: inline-flex !important;
    opacity: 1 !important;
    visibility: visible !important;
    transform: scale(1);
    pointer-events: auto !important;
    z-index: 5;
}

.account-user-icon .account-user-glyph {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
}

.account-user-icon .account-user-glyph svg {
    width: 100%;
    height: 100%;
    stroke: currentColor;
    fill: none;
}

.account-user-icon:hover .account-user-glyph svg {
    stroke: currentColor;
}

.account-user-icon:hover {
    opacity: 0.8 !important;
    color: #00beea !important;
}

/* Shared header icon cluster: account (left) + cart (right) */
.bharathon-header-icons {
    display: inline-flex !important;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
    vertical-align: middle;
    margin-left: 10px;
    line-height: 1;
    position: relative;
    z-index: 5;
}

.bharathon-header-icons .cart-bag-icon,
.bharathon-header-icons .cart-bag-icon.cart-bag-link,
.bharathon-header-icons .account-user-icon {
    margin-left: 0 !important;
    margin-right: 0 !important;
}

/* Keep icons visible inside Elementor desktop + mobile header sections */
.elementor-section.header .bharathon-header-icons,
.elementor-section.mobile-header .bharathon-header-icons,
.elementor-section.header .account-user-icon.is-logged-in,
.elementor-section.mobile-header .account-user-icon.is-logged-in {
    display: inline-flex !important;
    opacity: 1 !important;
    visibility: visible !important;
}

/* Fixed fallback when neither Elementor nor Divi header target exists */
.bharathon-header-icons--fallback,
.account-user-icon.account-icon-fallback {
    position: fixed !important;
    top: 20px !important;
    right: 20px !important;
    z-index: 99999 !important;
    margin-left: 0 !important;
}

/* Account alone (no cart yet) still pinned top-right */
.account-user-icon.account-icon-fallback {
    display: inline-flex !important;
}

@media (max-width: 1024px) {
    .account-user-icon .account-user-glyph {
        width: 36px;
        height: 36px;
    }

    .bharathon-header-icons {
        gap: 2px;
        margin-left: 6px;
    }

    .elementor-section.mobile-header .account-user-icon.is-logged-in,
    .elementor-section.mobile-header .bharathon-header-icons .account-user-icon {
        display: inline-flex !important;
        opacity: 1 !important;
        visibility: visible !important;
        width: auto !important;
        height: auto !important;
        overflow: visible !important;
    }
}

@media (max-width: 768px) {
    .account-user-icon .account-user-glyph {
        width: 30px;
        height: 30px;
    }
}
