/**
 * Public styles for Multi Location Inventory Rental
 */

.multiloc-location-selector,
.multiloc-shop-location-filter {
	margin: 20px 0;
	padding: 15px;
	background: #f9f9f9;
	border: 1px solid #ddd;
	border-radius: 4px;
}

/* Hide duplicate filters if both shortcode and automatic filter exist */
body.woocommerce-shop .multiloc-location-selector:not(:first-of-type),
body.woocommerce-shop .multiloc-shop-location-filter:not(:first-of-type),
body.woocommerce.archive .multiloc-location-selector:not(:first-of-type),
body.woocommerce.archive .multiloc-shop-location-filter:not(:first-of-type) {
	display: none !important;
}

.multiloc-location-selector label {
	font-weight: 600;
	margin-right: 10px;
}

.multiloc-location-selector select {
	margin-right: 10px;
	padding: 8px;
	min-width: 200px;
}

.multiloc-filter-btn {
	margin-left: 10px;
}

.multiloc-product-availability {
	margin: 15px 0;
	padding: 10px;
	border-left: 4px solid #2271b1;
	background: #f0f6fc;
}

.multiloc-product-availability.out-of-stock {
	border-left-color: #d63638;
	background: #fcf0f1;
}

.multiloc-product-availability.low-stock {
	border-left-color: #dba617;
	background: #fcf9e8;
}

.multiloc-booking-form {
	margin: 30px 0;
	padding: 20px;
	background: #f9f9f9;
	border: 1px solid #ddd;
	border-radius: 4px;
}

.multiloc-booking-form h3 {
	margin-top: 0;
}

/* Ensure Calculate Price button has same styling */
.multiloc-calculate-price {
	display: inline-flex !important;
	align-items: center !important;
	justify-content: center !important;
	height: 44px !important;
	min-height: 44px !important;
	max-height: 44px !important;
	padding: 12px 20px !important;
	margin: 0 !important;
	line-height: 1 !important;
	vertical-align: baseline !important;
	box-sizing: border-box !important;
}

.multiloc-booking-form-fields .form-row {
	margin-bottom: 15px;
}

.multiloc-booking-form-fields label {
	display: block;
	margin-bottom: 5px;
	font-weight: 600;
}

.multiloc-booking-form-fields input[type="date"],
.multiloc-booking-form-fields input[type="number"],
.multiloc-booking-form-fields select {
	width: 100%;
	padding: 8px;
	border: 1px solid #ddd;
	border-radius: 4px;
}

.multiloc-price-calculation {
	margin: 20px 0;
	padding: 15px;
	background: #fff;
	border: 1px solid #ddd;
	border-radius: 4px;
}

.multiloc-price-breakdown {
	margin-top: 10px;
}

.multiloc-price-breakdown > div {
	display: flex;
	justify-content: space-between;
	padding: 5px 0;
	border-bottom: 1px solid #eee;
}

.multiloc-price-breakdown > div:last-child {
	border-bottom: none;
	border-top: 2px solid #2271b1;
	padding-top: 10px;
	margin-top: 10px;
}

.multiloc-availability-check {
	margin: 15px 0;
	padding: 10px;
	border-radius: 4px;
}

.multiloc-available {
	color: #155724;
	background: #d4edda;
	padding: 10px;
	border-radius: 4px;
}

.multiloc-unavailable {
	color: #721c24;
	background: #f8d7da;
	padding: 10px;
	border-radius: 4px;
}

/* Hide Add to Cart buttons on shop/archive pages */
.woocommerce ul.products li.product .button.add_to_cart_button,
.woocommerce ul.products li.product .button.product_type_simple,
.woocommerce ul.products li.product .button.product_type_variable,
.woocommerce ul.products li.product .button.product_type_grouped,
.woocommerce ul.products li.product .button.product_type_external,
.woocommerce ul.products li.product a.add_to_cart_button,
.woocommerce-page ul.products li.product .button.add_to_cart_button,
.woocommerce-page ul.products li.product .button.product_type_simple,
.woocommerce-page ul.products li.product .button.product_type_variable,
.woocommerce-page ul.products li.product .button.product_type_grouped,
.woocommerce-page ul.products li.product .button.product_type_external,
.woocommerce-page ul.products li.product a.add_to_cart_button,
.woocommerce ul.products li.product a.button.add_to_cart_button,
.woocommerce-page ul.products li.product a.button.add_to_cart_button {
	display: none !important;
	visibility: hidden !important;
	opacity: 0 !important;
	height: 0 !important;
	width: 0 !important;
	padding: 0 !important;
	margin: 0 !important;
	overflow: hidden !important;
}

/* Style the View Product button */
.multiloc-view-product {
	display: inline-block !important;
	padding: 10px 20px;
	background-color: #2271b1;
	color: #fff !important;
	text-decoration: none;
	border-radius: 4px;
	font-weight: 600;
	transition: background-color 0.3s ease;
	border: none;
	cursor: pointer;
	text-align: center;
	line-height: 1.5;
}

.multiloc-view-product:hover,
.multiloc-view-product:focus {
	background-color: #135e96;
	color: #fff !important;
	text-decoration: none;
	outline: none;
}

.multiloc-view-product:active {
	background-color: #0a4b78;
}

/* Ensure View Product button appears in product loops */
.woocommerce ul.products li.product .multiloc-view-product,
.woocommerce-page ul.products li.product .multiloc-view-product {
	display: inline-block !important;
	margin-top: 10px;
	width: auto;
}

/* Hide add to cart in widgets and other locations */
.woocommerce .widget .button.add_to_cart_button,
.woocommerce .widget a.add_to_cart_button,
.woocommerce-page .widget .button.add_to_cart_button,
.woocommerce-page .widget a.add_to_cart_button,
.widget_shopping_cart .button.add_to_cart_button,
.widget_shopping_cart a.add_to_cart_button {
	display: none !important;
}

/* Hide add to cart in related products */
.woocommerce .related .button.add_to_cart_button,
.woocommerce .related a.add_to_cart_button,
.woocommerce .upsells .button.add_to_cart_button,
.woocommerce .upsells a.add_to_cart_button,
.woocommerce-page .related .button.add_to_cart_button,
.woocommerce-page .related a.add_to_cart_button,
.woocommerce-page .upsells .button.add_to_cart_button,
.woocommerce-page .upsells a.add_to_cart_button {
	display: none !important;
}

/* Shop page location filter */
.multiloc-shop-location-filter {
	margin: 20px 0;
	padding: 20px;
	background: #f9f9f9;
	border: 1px solid #ddd;
	border-radius: 4px;
}

.multiloc-shop-location-filter label {
	font-weight: 600;
	margin-right: 10px;
}

.multiloc-shop-location-filter select {
	padding: 8px;
	min-width: 200px;
	margin-right: 10px;
}

.multiloc-shop-filter-btn {
	margin-left: 0;
}

/* Booking form buttons container */
.multiloc-booking-form-buttons {
	display: flex;
	gap: 10px;
	align-items: baseline;
	margin-top: 15px;
	flex-wrap: wrap;
}

/* Ensure buttons are aligned properly - force same baseline */
.multiloc-booking-form-buttons .button,
.multiloc-booking-form-buttons button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	vertical-align: baseline;
	line-height: 1;
	padding: 12px 20px;
	margin: 0;
	height: 44px;
	min-height: 44px;
	max-height: 44px;
	box-sizing: border-box;
	border: none;
	cursor: pointer;
}

/* Show add to cart button on booking form */
.multiloc-add-to-cart {
	margin-top: 0;
}

/* Override when shown via JavaScript */
.multiloc-add-to-cart.show,
#multiloc-add-to-cart.show {
	display: inline-block !important;
	visibility: visible !important;
	opacity: 1 !important;
	height: auto !important;
	width: auto !important;
	padding: 10px 20px !important;
	margin: 15px 0 0 0 !important;
	overflow: visible !important;
	position: relative !important;
	left: auto !important;
}

/* Hide single product add to cart button (but not in booking form) */
.woocommerce div.product form.cart:not(.multiloc-booking-form-fields) .single_add_to_cart_button,
.woocommerce div.product form.cart:not(.multiloc-booking-form-fields) button.single_add_to_cart_button,
.woocommerce div.product form.cart:not(.multiloc-booking-form-fields) button[type="submit"].single_add_to_cart_button,
.woocommerce-page div.product form.cart:not(.multiloc-booking-form-fields) .single_add_to_cart_button,
.woocommerce-page div.product form.cart:not(.multiloc-booking-form-fields) button.single_add_to_cart_button,
.woocommerce-page div.product form.cart:not(.multiloc-booking-form-fields) button[type="submit"].single_add_to_cart_button,
.woocommerce div.product .single_add_to_cart_button:not(.multiloc-add-to-cart),
.woocommerce-page div.product .single_add_to_cart_button:not(.multiloc-add-to-cart) {
	display: none !important;
	visibility: hidden !important;
	opacity: 0 !important;
	height: 0 !important;
	width: 0 !important;
	padding: 0 !important;
	margin: 0 !important;
	overflow: hidden !important;
	position: absolute !important;
	left: -9999px !important;
}

/* Ensure View Cart and Continue Shopping buttons are visible */
.woocommerce-message .button.wc-forward,
.woocommerce-message .multiloc-view-cart,
.woocommerce-message a.button.wc-forward,
.woocommerce-message .multiloc-continue-shopping {
	display: inline-block !important;
	visibility: visible !important;
	opacity: 1 !important;
	margin-left: 10px;
	vertical-align: middle;
}

.woocommerce-message {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 10px;
}

/* Cart page continue shopping button */
.multiloc-cart-continue-shopping {
	margin: 20px 0;
	text-align: left;
}

/* Floating cart/checkout buttons */
.multiloc-floating-cart-buttons {
	position: fixed;
	bottom: 20px;
	right: 20px;
	background: #fff;
	border: 2px solid #2271b1;
	border-radius: 8px;
	padding: 15px 20px;
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
	z-index: 9999;
	min-width: 250px;
	display: flex;
	flex-direction: column;
	gap: 10px;
}

.multiloc-floating-cart-buttons .multiloc-cart-info {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding-bottom: 10px;
	border-bottom: 1px solid #ddd;
	margin-bottom: 10px;
}

.multiloc-floating-cart-buttons .multiloc-cart-count {
	font-weight: 600;
	color: #333;
}

.multiloc-floating-cart-buttons .multiloc-cart-total {
	font-weight: 700;
	color: #2271b1;
	font-size: 1.1em;
}

.multiloc-floating-cart-buttons .multiloc-cart-actions {
	display: flex;
	gap: 10px;
}

.multiloc-floating-cart-buttons .multiloc-view-cart-btn,
.multiloc-floating-cart-buttons .multiloc-checkout-btn {
	flex: 1;
	text-align: center;
	padding: 10px 15px;
	text-decoration: none;
	border-radius: 4px;
	font-weight: 600;
}

.multiloc-floating-cart-buttons .multiloc-view-cart-btn {
	background-color: #2271b1;
	color: #fff;
}

.multiloc-floating-cart-buttons .multiloc-view-cart-btn:hover {
	background-color: #135e96;
	color: #fff;
}

.multiloc-floating-cart-buttons .multiloc-checkout-btn {
	background-color: #00a32a;
	color: #fff;
}

.multiloc-floating-cart-buttons .multiloc-checkout-btn:hover {
	background-color: #008a20;
	color: #fff;
}

/* Hide on mobile if needed (optional) */
@media (max-width: 768px) {
	.multiloc-floating-cart-buttons {
		bottom: 10px;
		right: 10px;
		left: 10px;
		min-width: auto;
	}
}

/* Ensure floating buttons are visible and styled */
.multiloc-floating-cart-buttons {
	display: block !important;
}

/* Ensure Continue Shopping button is visible in all contexts */
.woocommerce-message .multiloc-continue-shopping,
.woocommerce-info .multiloc-continue-shopping,
.woocommerce-error .multiloc-continue-shopping,
.woocommerce .multiloc-continue-shopping,
.multiloc-continue-shopping {
	display: inline-block !important;
	visibility: visible !important;
	opacity: 1 !important;
	margin-left: 10px;
	padding: 10px 20px;
	text-decoration: none;
}

/* Hide quantity and add to cart form on single product if needed */
.woocommerce div.product form.cart,
.woocommerce-page div.product form.cart {
	/* Keep the form visible for the booking form, but hide the add to cart button */
}

.woocommerce div.product form.cart .quantity,
.woocommerce-page div.product form.cart .quantity {
	/* Hide quantity selector if you want, or keep it for the booking form */
	/* display: none; */
}

/* Ensure product content starts below custom header */
/* This handles fixed/sticky headers that overlap content */

/* Method 1: If header is fixed or sticky, add padding to main content area */
body.single-product header.fixed ~ .site-main,
body.single-product header.sticky ~ .site-main,
body.single-product .site-header.fixed ~ .site-main,
body.single-product .site-header.sticky ~ .site-main,
body.single-product header[class*="fixed"] ~ .site-main,
body.single-product header[class*="sticky"] ~ .site-main,
body.single-product .site-header[class*="fixed"] ~ .site-main,
body.single-product .site-header[class*="sticky"] ~ .site-main {
	padding-top: 120px; /* Default header height - adjust if needed */
}

/* Method 2: Add padding to content area if header is fixed/sticky (for themes that use different structure) */
body.single-product .content-area {
	position: relative;
}

/* Method 3: Direct padding on product container when header is fixed/sticky */
body.single-product .woocommerce div.product {
	position: relative;
	scroll-margin-top: 120px; /* For anchor links */
}

/* Method 4: Add top padding to the first element in main content to push everything down */
body.single-product .site-main > *:first-child {
	margin-top: 0;
}

/* If header is detected as fixed/sticky, add padding to push content down */
body.single-product header.fixed,
body.single-product header.sticky,
body.single-product .site-header.fixed,
body.single-product .site-header.sticky,
body.single-product header[class*="fixed"],
body.single-product header[class*="sticky"],
body.single-product .site-header[class*="fixed"],
body.single-product .site-header[class*="sticky"] {
	/* Header styles - ensure it's positioned correctly */
}

/* Add top padding/margin to product page content to account for header height */
/* This is a fallback that applies padding if header is fixed/sticky */
body.single-product .entry-content,
body.single-product .product {
	position: relative;
}

/* Ensure product summary and content are not hidden by header */
body.single-product .woocommerce div.product .summary,
body.single-product .woocommerce div.product .woocommerce-product-gallery,
body.single-product .woocommerce div.product .entry-summary {
	position: relative;
}

/* Comprehensive solution: Add padding-top to main content wrapper when header is fixed/sticky */
/* This targets common WordPress theme structures */
body.single-product header[style*="position: fixed"],
body.single-product header[style*="position:fixed"],
body.single-product .site-header[style*="position: fixed"],
body.single-product .site-header[style*="position:fixed"],
body.single-product header[style*="position: sticky"],
body.single-product header[style*="position:sticky"],
body.single-product .site-header[style*="position: sticky"],
body.single-product .site-header[style*="position:sticky"] {
	/* Header is fixed/sticky - content below needs padding */
}

/* Add padding to content when header is fixed/sticky (using adjacent sibling selector) */
body.single-product header[style*="position: fixed"] ~ *,
body.single-product header[style*="position:fixed"] ~ *,
body.single-product .site-header[style*="position: fixed"] ~ *,
body.single-product .site-header[style*="position:fixed"] ~ *,
body.single-product header[style*="position: sticky"] ~ *,
body.single-product header[style*="position:sticky"] ~ *,
body.single-product .site-header[style*="position: sticky"] ~ *,
body.single-product .site-header[style*="position:sticky"] ~ * {
	/* This will be handled by JavaScript or more specific selectors */
}

/* Most reliable method: Add padding to main content area on single product pages */
/* This ensures content starts below any fixed/sticky header */
/* Note: JavaScript will dynamically adjust this based on actual header height */
/* This CSS serves as a fallback if JavaScript is disabled */
body.single-product .site-main {
	padding-top: 100px; /* Fallback: Adjust this value based on your header height */
}

/* If the theme uses a different structure, also target content-area */
body.single-product .content-area {
	padding-top: 100px; /* Fallback: Adjust this value based on your header height */
}

/* For WooCommerce product pages specifically */
body.single-product .woocommerce {
	padding-top: 20px; /* Additional spacing if needed */
}

/* Ensure product container itself has proper spacing */
body.single-product .woocommerce div.product {
	margin-top: 0;
	padding-top: 0;
}

/* Add scroll-margin-top for smooth scrolling to anchors */
body.single-product .woocommerce div.product,
body.single-product .woocommerce div.product .summary,
body.single-product .woocommerce div.product .woocommerce-product-gallery,
body.single-product .woocommerce div.product .entry-summary {
	scroll-margin-top: 140px; /* Slightly more than padding-top for better UX */
}

/* Unavailable product overlay on shop loop thumbnails */
.multiloc-thumbnail-with-overlay {
	position: relative;
	display: block;
}

.multiloc-thumbnail-with-overlay .multiloc-unavailable-overlay {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
	pointer-events: none;
}
