/**
 * WooCommerce Floating Barcode Scanner — frontend styles.
 */

#wbs-scanner-root {
	--wbs-button-bg: #7f54b3;
	--wbs-button-color: #ffffff;
	--wbs-offset-v: 24px;
	--wbs-offset-h: 24px;
}

.wbs-visually-hidden {
	position: absolute !important;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect( 0, 0, 0, 0 );
	white-space: nowrap;
	border: 0;
}

/* -----------------------------------------------------------------------
 * Floating action button
 * ---------------------------------------------------------------------*/

.wbs-fab {
	position: fixed;
	z-index: 99998;
	display: flex;
	align-items: center;
	gap: 8px;
	border: none;
	border-radius: 999px;
	padding: 14px 20px 14px 16px;
	background: var( --wbs-button-bg );
	color: var( --wbs-button-color );
	box-shadow: 0 4px 14px rgba( 0, 0, 0, 0.25 );
	cursor: pointer;
	font-size: 14px;
	font-weight: 600;
	line-height: 1;
	transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.wbs-fab:hover,
.wbs-fab:focus {
	transform: translateY( -2px );
	box-shadow: 0 6px 18px rgba( 0, 0, 0, 0.3 );
	color: var( --wbs-button-color );
}

.wbs-fab-icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
}

.wbs-fab-icon svg {
	display: block;
}

.wbs-position-bottom-right .wbs-fab {
	right: var( --wbs-offset-h );
	bottom: var( --wbs-offset-v );
}

.wbs-position-bottom-left .wbs-fab {
	left: var( --wbs-offset-h );
	bottom: var( --wbs-offset-v );
}

.wbs-position-top-right .wbs-fab {
	right: var( --wbs-offset-h );
	top: var( --wbs-offset-v );
}

.wbs-position-top-left .wbs-fab {
	left: var( --wbs-offset-h );
	top: var( --wbs-offset-v );
}

@media ( max-width: 480px ) {
	.wbs-fab-label {
		display: none;
	}

	.wbs-fab {
		padding: 14px;
	}
}

body.wbs-modal-open {
	overflow: hidden;
}

/* -----------------------------------------------------------------------
 * Modal
 * ---------------------------------------------------------------------*/

.wbs-modal {
	position: fixed;
	inset: 0;
	z-index: 99999;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 16px;
}

.wbs-modal[hidden] {
	display: none;
}

.wbs-modal-overlay {
	position: absolute;
	inset: 0;
	background: rgba( 0, 0, 0, 0.6 );
}

.wbs-modal-panel {
	position: relative;
	width: 100%;
	max-width: 460px;
	max-height: 90vh;
	overflow: hidden;
	background: #fff;
	border-radius: 12px;
	box-shadow: 0 10px 40px rgba( 0, 0, 0, 0.35 );
	display: flex;
	flex-direction: column;
}

.wbs-modal-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 16px 20px;
	border-bottom: 1px solid #eee;
	flex: 0 0 auto;
}

.wbs-modal-header h2 {
	margin: 0;
	font-size: 18px;
}

.wbs-modal-close {
	background: transparent;
	border: none;
	font-size: 26px;
	line-height: 1;
	cursor: pointer;
	color: #555;
	padding: 4px 8px;
}

.wbs-modal-close:hover {
	color: #000;
}

.wbs-modal-body {
	padding: 16px 20px;
	flex: 1 1 auto;
	overflow-y: auto;
	min-height: 0; /* required for a flex child to actually scroll instead of growing the panel */
}

.wbs-instructions {
	margin: 0 0 12px;
	color: #555;
	font-size: 13px;
}

/* -----------------------------------------------------------------------
 * Camera viewport + "added" confirmation overlay
 * ---------------------------------------------------------------------*/

.wbs-camera-wrap {
	position: relative;
}

#wbs-reader {
	width: 100%;
	min-height: 240px;
	background: #000;
	border-radius: 8px;
	overflow: hidden;
}

#wbs-reader video {
	border-radius: 8px;
}

.wbs-scan-overlay {
	position: absolute;
	inset: 0;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 8px;
	background: rgba( 26, 126, 61, 0.55 );
	border-radius: 8px;
	color: #fff;
	text-align: center;
	padding: 16px;
	animation: wbs-overlay-fade-in 0.15s ease;
}

.wbs-scan-overlay[hidden] {
	display: none;
}

.wbs-scan-overlay-icon {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 48px;
	height: 48px;
	border-radius: 50%;
	background: #fff;
	color: #1a7e3d;
	font-size: 26px;
	font-weight: 700;
}

.wbs-scan-overlay-text {
	font-weight: 600;
	font-size: 15px;
	max-width: 90%;
	text-shadow: 0 1px 2px rgba( 0, 0, 0, 0.4 );
}

@keyframes wbs-overlay-fade-in {
	from {
		opacity: 0;
	}
	to {
		opacity: 1;
	}
}

/* -----------------------------------------------------------------------
 * Action row: gallery upload + "Scan Next Item"
 * ---------------------------------------------------------------------*/

.wbs-actions-row {
	display: flex;
	gap: 10px;
	margin-top: 12px;
}

.wbs-btn {
	flex: 1;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 10px 14px;
	border-radius: 6px;
	border: none;
	font-size: 13px;
	font-weight: 600;
	cursor: pointer;
	text-align: center;
	transition: opacity 0.15s ease;
}

.wbs-btn:disabled {
	cursor: not-allowed;
	opacity: 0.6;
}

.wbs-btn-primary {
	background: var( --wbs-button-bg, #7f54b3 );
	color: var( --wbs-button-color, #fff );
}

.wbs-btn-primary:hover:not( :disabled ) {
	opacity: 0.9;
}

.wbs-btn-secondary {
	background: #f2f2f2;
	color: #333;
}

.wbs-btn-secondary:hover {
	background: #e7e7e7;
}

/* -----------------------------------------------------------------------
 * Status line + scan log
 * ---------------------------------------------------------------------*/

.wbs-status {
	margin-top: 12px;
	min-height: 20px;
	font-size: 14px;
	font-weight: 600;
	text-align: center;
}

.wbs-status-success {
	color: #1a7e3d;
}

.wbs-status-error {
	color: #c0392b;
}

.wbs-status-warning {
	color: #b8860b;
}

.wbs-status-info,
.wbs-status-scanning {
	color: #555;
}

.wbs-scan-log {
	list-style: none;
	margin: 14px 0 0;
	padding: 0;
	max-height: 160px;
	overflow-y: auto;
	border-top: 1px solid #eee;
}

.wbs-log-item {
	padding: 8px 4px;
	border-bottom: 1px solid #f2f2f2;
	font-size: 13px;
}

.wbs-log-item.wbs-log-success {
	color: #1a7e3d;
}

.wbs-log-item.wbs-log-error {
	color: #c0392b;
}

.wbs-log-item.wbs-log-warning {
	color: #b8860b;
}

/* -----------------------------------------------------------------------
 * Multi-match product picker
 * ---------------------------------------------------------------------*/

.wbs-multi-match {
	margin-top: 12px;
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.wbs-multi-match[hidden] {
	display: none;
}

.wbs-multi-item {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 8px;
	border: 1px solid #eee;
	border-radius: 8px;
}

.wbs-multi-item-image {
	width: 44px;
	height: 44px;
	object-fit: cover;
	border-radius: 6px;
	flex-shrink: 0;
	background: #f5f5f5;
}

.wbs-multi-item-info {
	display: flex;
	flex-direction: column;
	flex: 1;
	min-width: 0;
}

.wbs-multi-item-name {
	font-size: 13px;
	font-weight: 600;
	color: #222;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.wbs-multi-item-price {
	font-size: 12px;
	color: #666;
}

.wbs-multi-add-btn {
	flex: 0 0 auto;
	padding: 8px 12px;
	font-size: 12px;
}

/* -----------------------------------------------------------------------
 * Footer
 * ---------------------------------------------------------------------*/

.wbs-modal-footer {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 12px 20px;
	border-top: 1px solid #eee;
	font-size: 14px;
	flex: 0 0 auto;
}

.wbs-cart-count-wrap strong {
	margin-left: 4px;
}

.wbs-view-cart-link {
	text-decoration: none;
	font-weight: 600;
	color: var( --wbs-button-bg );
}

.wbs-view-cart-link:hover {
	text-decoration: underline;
}

@media ( max-width: 480px ) {
	.wbs-modal-panel {
		max-width: 100%;
		max-height: 95vh;
	}

	#wbs-reader {
		min-height: 200px;
	}

	.wbs-actions-row {
		flex-direction: column;
	}
}
