/* ==========================================================================
   AlienTech Sync — [at_protocol_addons] Protocol Chooser Shortcode
   ========================================================================== */

/* --------------------------------------------------------------------------
   Root container
   -------------------------------------------------------------------------- */

.at-proto-chooser {
	font-size: 1rem;
	line-height: 1.5;
	font-family: inherit;
	color: #0f172a;
	margin: 1rem 0;
}

/* --------------------------------------------------------------------------
   Device selector — logged-in users pick which serial to apply protocols to
   -------------------------------------------------------------------------- */

.at-proto-device-selector {
	display: flex;
	align-items: center;
	gap: 0.6rem;
	margin-bottom: 1rem;
	flex-wrap: wrap;
}

.at-proto-device-selector__label {
	font-size: 0.72rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	color: #5a6070;
	white-space: nowrap;
	flex-shrink: 0;
}

.at-proto-device-selector__select {
	flex: 1 1 auto;
	min-width: 0;
	font-size: 0.82rem;
	color: #0f172a;
	background: #fff;
	border: 1px solid #e2e7ed;
	border-radius: 6px;
	padding: 0.35rem 0.6rem;
	cursor: pointer;
	appearance: auto;
	max-width: 100%;
}

.at-proto-device-selector__select:focus {
	outline: 2px solid #ffee00;
	outline-offset: 1px;
	border-color: #d4b800;
}

/* --------------------------------------------------------------------------
   Group block
   -------------------------------------------------------------------------- */

.at-proto-chooser__group {
	margin-bottom: 0.5rem;
}

/* Group header — clickable accordion toggle */
.at-proto-chooser__group-header {
	display: flex;
	align-items: center;
	gap: 0.4rem;
	padding: 0.25rem 0.4rem;
	margin: 0 0 0.2rem;
	border-radius: 4px;
	cursor: pointer;
	user-select: none;
	transition: background 0.12s;
}

.at-proto-chooser__group-header:hover {
	background: #f1f5f9;
}

/* Title */
.at-proto-chooser__group-title {
	margin: 0;
	padding: 0;
	font-size: 0.7rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	color: #5a6070;
	line-height: 1;
	border: none;
	background: none;
}

/* Item count badge */
.at-proto-chooser__group-count {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 1.1rem;
	height: 1.1rem;
	padding: 0 0.3rem;
	font-size: 0.6rem;
	font-weight: 700;
	line-height: 1;
	color: #5a6070;
	background: #ffffff;
	border: 1px solid #e2e7ed;
	border-radius: 999px;
}

/* Chevron — injected by JS, rotates when collapsed */
.at-proto-chooser__group-chevron {
	margin-left: auto;
	font-size: 0.6rem;
	color: #475569;
	line-height: 1;
	transition: transform 0.18s ease;
	flex-shrink: 0;
}

.at-proto-chooser__group--collapsed .at-proto-chooser__group-chevron {
	transform: rotate(-90deg);
}

/* Hint text */
.at-proto-chooser__group-hint {
	margin: 0 0 0.25rem 0.4rem;
	padding: 0;
	font-size: 0.75rem;
	font-weight: 400;
	line-height: 1.4;
	color: #475569;
	font-style: italic;
}

/* Hide sub-grid and hint when collapsed */
.at-proto-chooser__group--collapsed .at-proto-chooser__sub-grid,
.at-proto-chooser__group--collapsed .at-proto-chooser__group-hint {
	display: none;
}

/* --------------------------------------------------------------------------
   Items grid — 2 columns
   -------------------------------------------------------------------------- */

.at-proto-chooser__sub-grid {
	display: grid;
	grid-template-columns: repeat(2, 1fr);
	gap: 0.2rem;
	list-style: none;
	margin: 0;
	padding: 0;
}

/* Individual row */
.at-proto-chooser__sub-row {
	display: block;
	background: #ffffff;
	border: 1px solid #e2e7ed;
	border-radius: 5px;
	transition: border-color 0.12s ease, background 0.12s ease;
}

/* Bundle pill badge */
.at-proto-chooser__bundle-pill {
	display: inline-block;
	font-size: 0.6em;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.05em;
	color: #000;
	background: #ffee00;
	padding: 1px 6px;
	border-radius: 4px;
	margin-left: 4px;
	vertical-align: middle;
	line-height: 1.4;
}

/* Label wraps the whole row */
.at-proto-chooser__option-label {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	padding: 0.35rem 0.5rem;
	cursor: pointer;
	margin: 0;
	width: 100%;
	box-sizing: border-box;
}

/* Hover */
.at-proto-chooser__sub-row:hover {
	border-color: #475569;
	background: #f8fafc;
}

/* Checked */
.at-proto-chooser__sub-row:has(.at-proto-chooser__checkbox:checked) {
	border-color: #ffee00;
	background: #fffbeb;
}

/* Bundle checked — same as regular checked, no special border */

/* Native checkbox — hidden, kept for accessibility / form behaviour */
.at-proto-chooser__checkbox {
	position: absolute;
	opacity: 0;
	pointer-events: none;
	width: 0;
	height: 0;
	margin: 0;
}

/* Custom visual checkbox */
.at-proto-chooser__check-visual {
	flex-shrink: 0;
	align-self: flex-start;
	margin-top: 0.18rem;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 0.95rem;
	height: 0.95rem;
	border: 1.5px solid #cbd5e1;
	border-radius: 3px;
	background: #fff;
	transition: background 0.12s, border-color 0.12s;
}

.at-proto-chooser__sub-row:hover .at-proto-chooser__check-visual {
	border-color: #475569;
}

/* Checked — yellow tick */
.at-proto-chooser__sub-row:has(.at-proto-chooser__checkbox:checked) .at-proto-chooser__check-visual {
	background: #ffee00 !important;
	border-color: #d4b800 !important;
}

.at-proto-chooser__sub-row:has(.at-proto-chooser__checkbox:checked) .at-proto-chooser__check-visual::after {
	content: '';
	display: block;
	width: 0.25rem;
	height: 0.45rem;
	border: 1.5px solid #0f172a;
	border-top: none;
	border-left: none;
	transform: rotate(45deg) translate(-1px, -1px);
}

/* Included — green tick */
.at-proto-chooser__sub-row--included .at-proto-chooser__check-visual {
	background: #f0fdf4 !important;
	border-color: #16a34a !important;
}

.at-proto-chooser__sub-row--included .at-proto-chooser__check-visual::after {
	content: '';
	display: block;
	width: 0.25rem;
	height: 0.45rem;
	border: 1.5px solid #16a34a;
	border-top: none;
	border-left: none;
	transform: rotate(45deg) translate(-1px, -1px);
}

/* Body */
.at-proto-chooser__sub-body {
	flex: 1;
	min-width: 0;
}

/* Prefix — "OBD Slave Activation" */
.at-proto-chooser__sub-prefix {
	display: block;
	font-size: 0.65rem;
	font-weight: 400;
	color: #475569;
	line-height: 1.3;
	letter-spacing: 0;
}

/* Name — "Marine & PWC" */
.at-proto-chooser__sub-name {
	display: block;
	font-size: 0.8rem;
	font-weight: 700;
	color: #0f172a;
	line-height: 1.25;
	word-break: break-word;
}

.at-proto-chooser__sub-row:has(.at-proto-chooser__checkbox:checked) .at-proto-chooser__sub-name {
	color: #0f172a;
}

/* Price */
.at-proto-chooser__sub-price {
	flex-shrink: 0;
	text-align: right;
	font-size: 0.78rem;
	font-weight: 600;
	color: #0f172a;
	white-space: nowrap;
	padding-left: 0.35rem;
}

.at-proto-chooser__sub-row:has(.at-proto-chooser__checkbox:checked) .at-proto-chooser__sub-price {
	color: #0f172a;
}

/* Strike-through original price when on sale */
.at-proto-chooser__price-was {
	display: block;
	font-size: 0.7rem;
	font-weight: 400;
	color: #475569;
	text-decoration: line-through;
	margin-bottom: 1px;
}

.at-proto-chooser__price-was .woocommerce-Price-amount,
.at-proto-chooser__price-was bdi {
	text-decoration: inherit;
	font-size: inherit;
	font-weight: inherit;
	color: inherit;
}

/* WC price span sizing normalisation */
.at-proto-chooser__sub-price .woocommerce-Price-amount,
.at-proto-chooser__sub-price bdi {
	font-size: inherit;
	font-weight: inherit;
	color: inherit;
}

/* --------------------------------------------------------------------------
   "Included" state — when a full-group product is selected, other items in
   the same group get this class to show they're covered without being added
   separately to the cart.
   -------------------------------------------------------------------------- */

.at-proto-chooser__sub-row--included {
	opacity: 0.65;
	background: #f0fdf4 !important;
	border-color: #86efac !important;
	cursor: default;
	pointer-events: none;
}

.at-proto-chooser__sub-row--included .at-proto-chooser__option-label {
	cursor: default;
}

/* Strike through price — item is covered by the full product */
.at-proto-chooser__sub-row--included .at-proto-chooser__sub-price {
	color: #86efac;
	text-decoration: line-through;
}

/* --------------------------------------------------------------------------
   Footer: total
   -------------------------------------------------------------------------- */

.at-proto-chooser__footer {
	margin-top: 0.5rem;
	padding: 0.5rem 0.75rem;
	background: #f8fafc;
	border: 1px solid #e2e7ed;
	border-radius: 6px;
}

.at-proto-chooser__total {
	display: flex;
	align-items: baseline;
	gap: 0.5rem;
}

.at-proto-chooser__total-label {
	font-size: 0.8rem;
	color: #475569;
}

.at-proto-chooser__total-value {
	font-size: 1rem;
	font-weight: 700;
	color: #0f172a;
}

.at-proto-chooser__total-value .woocommerce-Price-amount,
.at-proto-chooser__total-value bdi {
	font-size: inherit;
	font-weight: inherit;
	color: inherit;
}

/* --------------------------------------------------------------------------
   Add-to-cart button — disabled until ≥ 1 protocol selected
   -------------------------------------------------------------------------- */

/* Hide quantity on single product page */
.at-sp-layout__form .quantity {
	display: none !important;
}

/* Add-to-cart button — default: yellow + rounded */
.at-sp-layout__form .single_add_to_cart_button {
	background-color: #ffee00 !important;
	background-image: none !important;
	color: #0f172a !important;
	border: 1px solid #ffee00 !important;
	border-radius: 50px !important;
	box-shadow: none !important;
	text-shadow: none !important;
	opacity: 1 !important;
	transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease !important;
}

/* Hover / focus: black background, white text */
.at-sp-layout__form .single_add_to_cart_button:hover,
.at-sp-layout__form .single_add_to_cart_button:focus,
.at-sp-layout__form .single_add_to_cart_button:active {
	background-color: #000 !important;
	border-color: #000 !important;
	color: #fff !important;
}

/* Disabled */
.at-sp-layout__form .single_add_to_cart_button.disabled,
.at-sp-layout__form .single_add_to_cart_button:disabled {
	opacity: 0.35 !important;
	cursor: not-allowed !important;
	pointer-events: none !important;
	background-color: #e2e7ed !important;
	border-color: #e2e7ed !important;
	color: #475569 !important;
}

.at-proto-chooser__btn-hint {
	margin: 0 0 0.35rem;
	padding: 0;
	font-size: 0.75rem;
	font-weight: 400;
	color: #475569;
	text-align: center;
	font-style: italic;
}

/* --------------------------------------------------------------------------
   Validation / status message
   -------------------------------------------------------------------------- */

.at-proto-chooser__msg {
	display: none;
	margin: 0.4rem 0 0;
	padding: 0.4rem 0.7rem;
	font-size: 0.8rem;
	line-height: 1.4;
	border-radius: 5px;
}

.at-proto-chooser__msg--error {
	color: #991b1b;
	background: #fef2f2;
	border: 1px solid #fecaca;
}

.at-proto-chooser__msg--success {
	color: #166534;
	background: #f0fdf4;
	border: 1px solid #bbf7d0;
}

/* --------------------------------------------------------------------------
   Responsive breakpoints
   Desktop default: 2 columns (set in .at-proto-chooser__sub-grid above)
   ≤ 991px : 1 column  (tablet-portrait / small laptop)
   ≤ 768px : 2 columns (tablet-landscape sidebar or narrow tablet)
   ≤ 500px : 1 column  (mobile — full width)
   -------------------------------------------------------------------------- */

@media ( max-width: 991px ) {
	.at-proto-chooser__sub-grid {
		grid-template-columns: 1fr;
	}
}

@media ( max-width: 768px ) {
	.at-proto-chooser__sub-grid {
		grid-template-columns: repeat(2, 1fr);
	}
}

@media ( max-width: 500px ) {
	.at-proto-chooser__sub-grid {
		grid-template-columns: 1fr;
	}

	.at-proto-chooser__option-label {
		flex-wrap: wrap;
	}

	.at-proto-chooser__sub-price {
		padding-left: calc( 0.875rem + 0.5rem );
		text-align: left;
		flex-basis: 100%;
	}
}

/* --------------------------------------------------------------------------
   Fallback for Firefox < 121 (no :has() support)
   -------------------------------------------------------------------------- */

@supports not selector( :has(a) ) {
	.at-proto-chooser__sub-row {
		/* checked highlight skipped, hover still works */
	}
}
