.custom-header {
	font-family: Arial, sans-serif;
	color: var(--brand-dark);
}

.custom-header .header-topbar {
	background: var(--brand-primary);
	color: #000000;
	text-align: center;
	font-size: 12px;
	font-weight: 700;
	letter-spacing: 2px;
	padding: 8px 12px;
}

.custom-header .header-topbar .header-inner {
	justify-content: center;
}

.custom-header .header-topbar-text {
	display: block;
	width: 100%;
	text-align: center;
	color: #FFF;
}

.custom-header .header-inner {
	max-width: 1200px;
	margin: 0 auto;
	padding: 0 16px;
	display: flex;
	align-items: center;
}

.custom-header .header-menu-toggle {
	display: none;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	border: none;
	background: transparent;
	padding: 0;
	cursor: pointer;
	color: var(--brand-dark);
}

.custom-header .header-menu-toggle-icon,
.custom-header .header-menu-toggle-icon::before,
.custom-header .header-menu-toggle-icon::after {
	content: '';
	display: block;
	width: 22px;
	height: 2px;
	background: currentColor;
	border-radius: 2px;
	transition: transform 0.2s ease, opacity 0.2s ease;
}

.custom-header .header-menu-toggle-icon::before,
.custom-header .header-menu-toggle-icon::after {
	position: relative;
}

.custom-header .header-menu-toggle-icon::before {
	top: -6px;
}

.custom-header .header-menu-toggle-icon::after {
	top: 4px;
}

.custom-header .header-main {
	background: var(--brand-light);
	border-bottom: 1px solid #f0f0f0;
}

.custom-header .header-logo {
	display: flex;
	align-items: center;
	min-height: 64px;
}

.custom-header .header-logo img {
	max-height: 42px;
	width: auto;
}

.custom-header .header-nav {
	flex: 2;
	display: flex;
	justify-content: center;
}

.custom-header .header-menu {
	list-style: none;
	display: flex;
	gap: 28px;
	margin: 0;
	padding: 0;
	font-weight: 700;
	text-transform: uppercase;
	font-size: 12px;
}

.custom-header .header-menu a {
	color: var(--brand-dark);
	text-decoration: none;
}

.custom-header .header-menu .current-menu-item > a,
.custom-header .header-menu a:hover {
	color: var(--brand-primary);
}

.custom-header .header-cart {
	flex: 0 0 auto;
	display: flex;
	justify-content: flex-end;
	align-items: center;
	min-height: 64px;
	position: relative;
}

.custom-header .header-cart-link {
	display: flex;
	align-items: center;
	gap: 12px;
	text-decoration: none;
	color: var(--brand-dark);
	font-weight: 700;
	position: relative;
	padding: 0 15px;
    height: 100%;
}

.custom-header .header-cart-link:hover {
	color: var(--brand-primary);
}

.custom-header .header-cart-icon {
	width: 28px !important;
	height: 28px !important;
    display: block;
    flex-shrink: 0;
}

.custom-header .header-cart-count {
	position: absolute;
	top: -5px;
	right: 6px;
	background: var(--brand-primary);
	color: var(--brand-dark);
	font-size: 11px;
	font-weight: 700;
	border-radius: 50%;
	width: 18px;
	height: 18px;
	display: flex;
	align-items: center;
	justify-content: center;
}

.custom-header .header-drawer,
.custom-header .header-drawer-overlay {
	display: none;
}

@media (max-width: 1024px) {
	.custom-header .header-inner {
		gap: 12px;
	}

	.custom-header .header-nav {
		display: none;
	}

	.custom-header .header-menu-toggle {
		display: inline-flex;
		flex: 0 0 40px;
	}

	.custom-header .header-logo {
		flex: 1;
		justify-content: center;
	}

	.custom-header .header-cart {
		flex: 0 0 auto;
	}

	.custom-header .header-cart-link {
		width: auto;
        min-width: 44px;
        height: 44px;
        padding: 0 10px;
		justify-content: center;
	}

    .custom-header .header-cart-icon {
        width: 28px !important;
        height: 28px !important;
        flex-shrink: 0;
    }

	.custom-header .header-cart-total {
		display: none;
	}

	.custom-header .header-cart-count {
		top: 4px;
		right: 4px;
	}

	.custom-header .header-drawer {
		display: block;
		position: fixed;
		inset: 0;
		pointer-events: none;
		z-index: 9999;
	}

	.custom-header .header-drawer-panel {
		width: 78vw;
		max-width: 320px;
		height: 100%;
		background: var(--brand-primary);
		padding: 24px 20px;
		transform: translateX(-100%);
		transition: transform 0.25s ease;
		box-shadow: 10px 0 30px rgba(0, 0, 0, 0.15);
		color: var(--brand-dark);
	}

	.custom-header .header-drawer-close {
		border: none;
		background: transparent;
		color: var(--brand-dark);
		font-size: 28px;
		line-height: 1;
		cursor: pointer;
		margin-bottom: 24px;
	}

	.custom-header .header-drawer-nav .header-menu {
		flex-direction: column;
		align-items: flex-start;
		gap: 16px;
		font-size: 14px;
	}

	.custom-header .header-drawer-nav a {
		color: #ffffff;
	}

	.custom-header .header-drawer-nav .header-menu .current-menu-item > a,
	.custom-header .header-drawer-nav .header-menu a:hover {
		color: var(--brand-dark);
	}

	.custom-header .header-drawer-overlay {
		display: block;
		position: fixed;
		inset: 0;
		background: rgba(0, 0, 0, 0.4);
		opacity: 0;
		pointer-events: none;
		transition: opacity 0.25s ease;
		z-index: 9998;
	}

	body.drawer-open .custom-header .header-drawer {
		pointer-events: auto;
	}

	body.drawer-open .custom-header .header-drawer-panel {
		transform: translateX(0);
	}

	body.drawer-open .custom-header .header-drawer-overlay {
		opacity: 1;
		pointer-events: auto;
	}
}

@media (max-width: 900px) {
	.custom-header .header-inner {
		flex-wrap: nowrap;
	}
}
/* Cart Dropdown/Drawer Styles */
.header-cart-drawer {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    z-index: 10000 !important;
    pointer-events: none !important;
    display: none;
}

body.cart-drawer-open .header-cart-drawer {
    display: block !important;
}

.header-cart-drawer-panel {
    position: absolute !important;
    background: #ffffff !important;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15) !important;
    display: flex !important;
    flex-direction: column !important;
    pointer-events: auto !important;
    color: #333 !important;
    z-index: 10001 !important;
    border-radius: 8px !important;
}

/* Desktop: Popover Style */
@media (min-width: 1025px) {
    /* Better visibility logic for Desktop */
    .custom-header .header-cart-drawer {
        position: absolute !important;
        top: 100% !important;
        left: auto !important;
        right: -10px !important;
        width: 380px !important;
        height: auto !important;
        padding-top: 15px !important;
        pointer-events: none !important;
        display: none !important;
    }

    body.cart-drawer-open .custom-header .header-cart-drawer {
        display: flex !important;
        pointer-events: auto !important;
    }

    /* Solid bridge to prevent mouse leaving */
    .header-cart-drawer::before {
        content: "";
        position: absolute;
        top: -20px;
        left: 0;
        right: 0;
        height: 30px;
        background: transparent;
        z-index: 10;
    }

    .header-cart-drawer-panel {
        position: relative !important;
        width: 100% !important;
        max-width: none !important;
        height: 600px !important; /* Increased to fit 3 products comfortably */
        transform: translateY(10px);
        opacity: 0;
        transition: transform 0.25s ease, opacity 0.25s ease !important;
        display: flex !important;
        flex-direction: column !important;
        overflow: hidden !important;
        background: #ffffff !important;
        box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15) !important;
        border-radius: 8px !important;
    }

    body.cart-drawer-open .header-cart-drawer-panel {
        transform: translateY(0) !important;
        opacity: 1 !important;
    }
    .header-cart-drawer-content {
        height: 100% !important;
        display: flex !important;
        flex-direction: column !important;
        padding: 0 !important; /* Managing padding internally */
    }

    .header-cart-drawer-header {
        padding: 15px 20px !important;
    }

    /* Target the product list specifically for scroll on desktop */
    .header-cart-drawer .widget_shopping_cart_content {
        display: flex !important;
        flex-direction: column !important;
        flex: 1 !important;
        overflow: hidden !important;
    }

    .header-cart-drawer .woocommerce-mini-cart {
        flex: 1 !important;
        overflow-y: auto !important;
        padding: 0 20px !important;
        max-height: none !important; /* Let flex handle it */
    }

    .header-cart-drawer .woocommerce-mini-cart__total,
    .header-cart-drawer .woocommerce-mini-cart__buttons {
        padding-left: 20px !important;
        padding-right: 20px !important;
        flex-shrink: 0 !important;
    }
}

/* Image resize in cart */
.header-cart-drawer .woocommerce-mini-cart li img {
    width: 64px !important;
    height: 64px !important;
    min-width: 64px !important;
    max-width: 64px !important;
    object-fit: contain !important;
    margin: 0 !important;
}

.header-cart-drawer .woocommerce-mini-cart li {
    display: flex !important;
    align-items: center !important;
    padding: 10px 0 !important;
    border-bottom: 1px solid #eee !important;
    position: relative !important;
}

/* Fix for remove button in mini cart */
.header-cart-drawer .woocommerce-mini-cart li .remove {
    order: 3 !important;
    margin-left: auto !important;
    position: relative !important;
    inset: auto !important;
}

.header-cart-drawer .woocommerce-mini-cart li a:not(.remove) {
    display: flex !important;
    align-items: center !important;
    gap: 15px !important;
    text-decoration: none !important;
    color: #333 !important;
    font-size: 14px !important;
    flex: 1 !important;
}

.header-cart-drawer .woocommerce-mini-cart__total {
    padding: 15px 20px !important;
    border-top: 2px solid #eee !important;
    margin-top: auto !important;
}

.header-cart-drawer .woocommerce-mini-cart__buttons {
    padding: 0 20px 20px !important;
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 10px !important;
}

.header-cart-drawer .woocommerce-mini-cart__buttons a {
    margin: 0 !important;
    text-align: center !important;
    padding: 12px 5px !important;
    font-size: 13px !important;
    border-radius: 4px !important;
}

.header-cart-drawer .woocommerce-mini-cart__buttons a.checkout {
    background: var(--brand-primary) !important;
    color: var(--brand-dark) !important;
}

/* Hide WooCommerce default "View Cart" link after AJAX add */
.product-card .added_to_cart {
    display: none !important;
}

/* Mobile: Drawer Style */
@media (max-width: 1024px) {
    .header-cart-drawer {
        position: fixed !important;
        inset: 0 !important;
    }

    .header-cart-drawer-panel {
        top: 0 !important;
        right: 0 !important;
        width: 78vw !important;
        max-width: 320px !important;
        height: 100% !important;
        border-radius: 0 !important;
        transform: translateX(100%);
        transition: transform 0.3s ease !important;
    }

    body.cart-drawer-open .header-cart-drawer-panel {
        transform: translateX(0) !important;
    }

    .header-cart-drawer-overlay {
        display: block !important;
        position: fixed !important;
        inset: 0 !important;
        background: rgba(0,0,0,0.4) !important;
        opacity: 0;
        transition: opacity 0.3s ease !important;
        z-index: 9999 !important;
        pointer-events: none !important;
    }

    body.cart-drawer-open .header-cart-drawer-overlay {
        opacity: 1 !important;
        pointer-events: auto !important;
    }
}

.header-cart-drawer-content {
    display: flex !important;
    flex-direction: column !important;
    height: 100% !important;
    padding: 20px !important;
}

.header-cart-drawer-header {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    margin-bottom: 20px !important;
    padding-bottom: 15px !important;
    border-bottom: 1px solid #eee !important;
}

.header-cart-drawer-header h3 {
    margin: 0 !important;
    font-size: 1.1rem !important;
    color: #333 !important;
    font-weight: 700 !important;
}

.header-cart-drawer-close {
    border: none !important;
    background: transparent !important;
    font-size: 28px !important;
    cursor: pointer !important;
    color: #999 !important;
    padding: 0 !important;
    line-height: 1 !important;
}

/* Mini Cart Overrides for Drawer */
.header-cart-drawer .widget_shopping_cart_content {
    flex: 1 !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
}

.header-cart-drawer .woocommerce-mini-cart {
    list-style: none !important;
    margin: 0 !important;
    padding: 0 !important;
    flex: 1 !important;
    overflow-y: auto !important;
}

.header-cart-drawer .woocommerce-mini-cart li {
    display: flex !important;
    gap: 12px !important;
    padding: 12px 0 !important;
    border-bottom: 1px solid #f5f5f5 !important;
    position: relative !important;
    align-items: center !important;
}

.header-cart-drawer .woocommerce-mini-cart li a:not(.remove) {
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    text-decoration: none !important;
    color: #333 !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    line-height: 1.2 !important;
}

.header-cart-drawer .woocommerce-mini-cart li img {
    width: 60px !important;
    height: 60px !important;
    min-width: 60px !important;
    max-width: 60px !important;
    object-fit: contain !important;
    background: #f9f9f9 !important;
    padding: 4px !important;
    border-radius: 4px !important;
    margin: 0 !important;
}

.header-cart-drawer .woocommerce-mini-cart li .remove {
    position: absolute !important;
    top: 12px !important;
    right: 0 !important;
    color: #ccc !important;
    font-size: 18px !important;
    width: 20px !important;
    height: 20px !important;
    text-align: center !important;
}

.header-cart-drawer .woocommerce-mini-cart__total {
    padding: 15px 0 !important;
    border-top: 1px solid #eee !important;
    font-weight: 700 !important;
    font-size: 0.95rem !important;
    display: flex !important;
    justify-content: space-between !important;
}

.header-cart-drawer .woocommerce-mini-cart__buttons {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 8px !important;
    padding-top: 10px !important;
}

.header-cart-drawer .woocommerce-mini-cart__buttons a {
    display: block !important;
    width: 100% !important;
    text-align: center !important;
    padding: 10px !important;
    border-radius: 4px !important;
    font-weight: 700 !important;
    text-transform: uppercase !important;
    font-size: 12px !important;
}

.header-cart-drawer .woocommerce-mini-cart__buttons a.button.wc-forward:not(.checkout) {
    background: #f5f5f5 !important;
    color: #333 !important;
    order: 2 !important;
}

.header-cart-drawer .woocommerce-mini-cart__buttons a.button.checkout {
    background: #FF5F14 !important;
    color: #fff !important;
    order: 1 !important;
}
