/**
 * Device Hub – Bundle Package Selector (Frontend)
 *
 * All selectors are namespaced under .dh-pkg-* to avoid collisions with any
 * theme.  CSS custom properties provide a simple theming API — override them
 * in your theme stylesheet:
 *
 *   .dh-pkg-selector {
 *     --dh-border-selected: #e91e63;
 *     --dh-bg-selected:     #fce4ec;
 *   }
 *
 * @package DeviceHub\BundlePackage
 */

/* ==========================================================================
   Custom properties (defaults)
   ========================================================================== */

.dh-pkg-selector {
	--dh-border:          #ddd;
	--dh-border-selected: #0073aa;
	--dh-bg:              #fff;
	--dh-bg-hover:        #fafafa;
	--dh-bg-selected:     #f0f7fb;
	--dh-text:            #1e1e1e;
	--dh-text-muted:      #666;
	--dh-price-color:     #0073aa;
	--dh-error-color:     #d63638;
	--dh-error-bg:        #fff2f2;
	--dh-radius:          6px;
	--dh-transition:      0.14s ease;
}

/* ==========================================================================
   Box-sizing reset (scoped — never touches the theme)
   ========================================================================== */

.dh-pkg-selector,
.dh-pkg-selector *,
.dh-pkg-selector *::before,
.dh-pkg-selector *::after {
	box-sizing: border-box;
}

/* ==========================================================================
   Wrapper
   ========================================================================== */

.dh-pkg-selector {
	margin: 1.25em 0 1.5em;
	font-size: 1em; /* inherit theme font-size */
}

/* ==========================================================================
   Heading
   ========================================================================== */

.dh-pkg-selector__title {
	margin: 0 0 0.4em;
	padding: 0;
	font-size: 1em;
	font-weight: 700;
	color: var(--dh-text);
	line-height: 1.3;
}

/* ==========================================================================
   Help / descriptive text
   ========================================================================== */

.dh-pkg-selector__help {
	margin: 0 0 0.8em;
	padding: 0;
	font-size: 0.875em;
	color: var(--dh-text-muted);
	line-height: 1.5;
}

/* ==========================================================================
   Options list
   ========================================================================== */

.dh-pkg-selector__options {
	display: flex;
	flex-direction: column;
	gap: 8px;
	margin: 0;
	padding: 0;
	list-style: none;
}

/* ==========================================================================
   Option card
   ========================================================================== */

.dh-pkg-option {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 12px 14px;
	border: 1px solid var(--dh-border);
	border-radius: var(--dh-radius);
	background: var(--dh-bg);
	cursor: pointer;
	transition:
		border-color var(--dh-transition),
		background   var(--dh-transition),
		box-shadow   var(--dh-transition);
	/* Reset any link/button styles a theme might apply to <label> */
	text-decoration: none;
	color: inherit;
}

.dh-pkg-option:hover {
	border-color: var(--dh-border-selected);
	background:   var(--dh-bg-hover);
}

.dh-pkg-option:focus-within {
	outline: 2px solid var(--dh-border-selected);
	outline-offset: 2px;
}

.dh-pkg-option--selected {
	border-color: var(--dh-border-selected);
	background:   var(--dh-bg-selected);
	box-shadow:   0 0 0 1px var(--dh-border-selected) inset;
}

/* ==========================================================================
   Radio input
   ========================================================================== */

.dh-pkg-option__radio {
	flex-shrink: 0;
	width:  18px;
	height: 18px;
	margin: 0;
	cursor: pointer;
	accent-color: var(--dh-border-selected);
}

/* ==========================================================================
   Content area (name + description)
   ========================================================================== */

.dh-pkg-option__content {
	flex: 1;
	min-width: 0;
	display: flex;
	flex-direction: column;
	gap: 3px;
}

.dh-pkg-option__name {
	display: block;
	font-size: 0.95em;
	font-weight: 600;
	color: var(--dh-text);
	line-height: 1.2;
	/* Prevent very long names from breaking the layout */
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.dh-pkg-option__desc {
	display: block;
	font-size: 0.8em;
	color: var(--dh-text-muted);
	line-height: 1.4;
	/* Allow descriptions to wrap */
	white-space: normal;
}

/* ==========================================================================
   Price column
   ========================================================================== */

.dh-pkg-option__price {
	flex-shrink: 0;
	text-align: right;
	display: flex;
	flex-direction: column;
	align-items: flex-end;
	gap: 2px;
}

.dh-pkg-option__price-amount {
	display: block;
	font-size: 1em;
	font-weight: 700;
	color: var(--dh-price-color);
	white-space: nowrap;
	line-height: 1.2;
}

.dh-pkg-option__billing {
	display: block;
	font-size: 0.75em;
	color: var(--dh-text-muted);
	white-space: nowrap;
	line-height: 1.2;
}

/* ==========================================================================
   "No package" option variant
   ========================================================================== */

.dh-pkg-option--no-pkg .dh-pkg-option__name {
	font-weight: 400;
	font-style: italic;
	color: var(--dh-text-muted);
}

.dh-pkg-option--no-pkg .dh-pkg-option__price-amount {
	color: var(--dh-text-muted);
	font-weight: 400;
}

/* ==========================================================================
   Inline validation error
   ========================================================================== */

.dh-pkg-selector__error {
	display: none; /* JS shows/hides this */
	margin: 10px 0 0;
	padding: 9px 13px;
	border-left: 3px solid var(--dh-error-color);
	border-radius: 0 var(--dh-radius) var(--dh-radius) 0;
	background: var(--dh-error-bg);
	color: var(--dh-error-color);
	font-size: 0.875em;
	font-weight: 500;
	line-height: 1.4;
}

.dh-pkg-selector--error .dh-pkg-selector__options {
	border-radius: var(--dh-radius);
	outline: 2px solid var(--dh-error-color);
	outline-offset: 2px;
}

/* ==========================================================================
   Responsive — stack price below content on small screens
   ========================================================================== */

@media (max-width: 480px) {
	.dh-pkg-option {
		flex-wrap: wrap;
		gap: 8px;
	}

	.dh-pkg-option__price {
		/* Align with the name text: skip radio width + gap */
		padding-left: 30px;
		flex-basis: 100%;
		align-items: flex-start;
	}

	.dh-pkg-option__name {
		white-space: normal; /* allow wrapping on very small screens */
	}
}
