/*
 * Beyond School Toolkit — Classroom Estimator frontend styles.
 *
 * Same design language, scoping convention (.bs-classroom-estimator
 * prefix), and accessibility approach as budget-calculator.css —
 * mobile-first, visible focus states, color-independent error
 * styling, 44px minimum touch targets. Not literally shared as one
 * file with Budget Calculator's stylesheet: the markup differs
 * meaningfully (per-category quantity inputs have no equivalent
 * there), so forcing a shared file would mean over-generic selectors
 * fighting two different structures. What's reused is the
 * *mechanism* — Support\Assets's register/enqueue pattern — not the
 * CSS content itself, which is necessarily new per widget.
 */

.bs-classroom-estimator {
	--bs-ce-color-text: #1d2327;
	--bs-ce-color-muted: #50575e;
	--bs-ce-color-border: #c3c4c7;
	--bs-ce-color-primary: #2c5f7c;
	--bs-ce-color-primary-hover: #1f4759;
	--bs-ce-color-error: #a52222;
	--bs-ce-color-error-bg: #fbeaea;
	--bs-ce-color-surface: #ffffff;
	--bs-ce-color-surface-alt: #f6f7f7;
	--bs-ce-radius: 6px;
	--bs-ce-spacing: 1rem;

	box-sizing: border-box;
	max-width: 640px;
	margin: 0 auto;
	color: var( --bs-ce-color-text );
	font-size: 1rem;
	line-height: 1.5;
}

.bs-classroom-estimator *,
.bs-classroom-estimator *::before,
.bs-classroom-estimator *::after {
	box-sizing: inherit;
}

.bs-classroom-estimator__widget-title {
	margin: 0 0 0.5rem;
}

.bs-classroom-estimator__widget-description {
	margin: 0 0 var( --bs-ce-spacing );
	color: var( --bs-ce-color-muted );
}

.bs-classroom-estimator__form {
	display: flex;
	flex-direction: column;
	gap: var( --bs-ce-spacing );
}

.bs-classroom-estimator__field {
	display: flex;
	flex-direction: column;
	gap: 0.4rem;
}

.bs-classroom-estimator__label,
.bs-classroom-estimator__legend {
	font-weight: 600;
}

.bs-classroom-estimator__fieldset {
	margin: 0;
	padding: 0;
	border: 0;
}

.bs-classroom-estimator__select,
.bs-classroom-estimator__input {
	width: 100%;
	min-height: 44px;
	padding: 0.5rem 0.75rem;
	font-size: 1rem;
	color: var( --bs-ce-color-text );
	background-color: var( --bs-ce-color-surface );
	border: 1px solid var( --bs-ce-color-border );
	border-radius: var( --bs-ce-radius );
}

/* One row per category: checkbox + label, then a paired "quantity
   per student" number field. Wraps to two lines on narrow screens
   rather than compressing the quantity input unreadably small. */
.bs-classroom-estimator__category-list {
	display: flex;
	flex-direction: column;
	gap: 0.75rem;
}

.bs-classroom-estimator__category-row {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.5rem 1rem;
	padding: 0.5rem;
	border-radius: var( --bs-ce-radius );
}

.bs-classroom-estimator__category-row:hover {
	background-color: var( --bs-ce-color-surface-alt );
}

.bs-classroom-estimator__category-checkbox {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	min-height: 44px;
	flex: 1 1 160px;
	cursor: pointer;
}

.bs-classroom-estimator__category-checkbox input {
	width: 1.25rem;
	height: 1.25rem;
	flex-shrink: 0;
}

.bs-classroom-estimator__qty-label {
	font-size: 0.9rem;
	color: var( --bs-ce-color-muted );
	white-space: nowrap;
}

.bs-classroom-estimator__qty-input {
	width: 5rem;
	min-height: 44px;
	padding: 0.4rem 0.5rem;
	font-size: 1rem;
	text-align: center;
	color: var( --bs-ce-color-text );
	background-color: var( --bs-ce-color-surface );
	border: 1px solid var( --bs-ce-color-border );
	border-radius: var( --bs-ce-radius );
}

/* A quantity input whose category checkbox isn't selected is still
   focusable and enterable (never disabled — see the JS module's
   docblock for why), but visually de-emphasized so its relevance is
   clear at a glance. */
.bs-classroom-estimator__category-row:not( [data-bs-selected] ) .bs-classroom-estimator__qty-input {
	opacity: 0.55;
}

.bs-classroom-estimator__select:focus-visible,
.bs-classroom-estimator__input:focus-visible,
.bs-classroom-estimator__qty-input:focus-visible,
.bs-classroom-estimator__category-checkbox input:focus-visible,
.bs-classroom-estimator__submit:focus-visible {
	outline: 3px solid var( --bs-ce-color-primary );
	outline-offset: 2px;
}

.bs-classroom-estimator__error {
	margin: 0;
	padding: 0.4rem 0.6rem;
	font-size: 0.9rem;
	font-weight: 600;
	color: var( --bs-ce-color-error );
	background-color: var( --bs-ce-color-error-bg );
	border-left: 4px solid var( --bs-ce-color-error );
	border-radius: 3px;
}

.bs-classroom-estimator__error[hidden] {
	display: none;
}

.bs-classroom-estimator__submit {
	position: relative;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.5rem;
	min-height: 44px;
	padding: 0.75rem 1.5rem;
	font-size: 1rem;
	font-weight: 600;
	color: #ffffff;
	background-color: var( --bs-ce-color-primary );
	border: 0;
	border-radius: var( --bs-ce-radius );
	cursor: pointer;
}

.bs-classroom-estimator__submit:hover {
	background-color: var( --bs-ce-color-primary-hover );
}

.bs-classroom-estimator__submit:disabled {
	cursor: not-allowed;
	opacity: 0.7;
}

.bs-classroom-estimator__spinner {
	width: 1rem;
	height: 1rem;
	border: 2px solid rgba( 255, 255, 255, 0.4 );
	border-top-color: #ffffff;
	border-radius: 50%;
	animation: bs-classroom-estimator-spin 0.8s linear infinite;
}

.bs-classroom-estimator__spinner[hidden] {
	display: none;
}

@keyframes bs-classroom-estimator-spin {
	to {
		transform: rotate( 360deg );
	}
}

@media ( prefers-reduced-motion: reduce ) {
	.bs-classroom-estimator__spinner {
		animation-duration: 2s;
	}
}

.bs-classroom-estimator__status {
	margin-top: 0.75rem;
	font-size: 0.95rem;
	color: var( --bs-ce-color-muted );
}

.bs-classroom-estimator__status:empty {
	margin-top: 0;
}

.bs-classroom-estimator__results {
	margin-top: 2rem;
	padding: var( --bs-ce-spacing );
	background-color: var( --bs-ce-color-surface-alt );
	border-radius: var( --bs-ce-radius );
}

.bs-classroom-estimator__results[hidden] {
	display: none;
}

.bs-classroom-estimator__results-heading {
	margin-top: 0;
}

.bs-classroom-estimator__results-heading:focus {
	outline: none;
}

.bs-classroom-estimator__breakdown {
	width: 100%;
	border-collapse: collapse;
	font-size: 0.9rem;
}

.bs-classroom-estimator__breakdown th,
.bs-classroom-estimator__breakdown td {
	padding: 0.5rem;
	text-align: left;
	border-bottom: 1px solid var( --bs-ce-color-border );
}

.bs-classroom-estimator__breakdown th {
	font-weight: 600;
}

.bs-classroom-estimator__total {
	margin: 1rem 0;
	font-size: 1.15rem;
}

.bs-classroom-estimator__recommendations {
	margin: 0 0 1rem;
}

.bs-classroom-estimator__recommendations:empty {
	margin: 0;
}

.bs-classroom-estimator__recommendation-group {
	margin-bottom: 1rem;
}

.bs-classroom-estimator__recommendation-group h3 {
	margin: 0 0 0.5rem;
	font-size: 0.95rem;
}

.bs-classroom-estimator__recommendation-list {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
	margin: 0;
	padding: 0;
	list-style: none;
}

.bs-classroom-estimator__recommendation-item a {
	display: inline-flex;
	align-items: center;
	gap: 0.4rem;
	padding: 0.4rem 0.6rem;
	min-height: 44px;
	color: var( --bs-ce-color-primary );
	background-color: var( --bs-ce-color-surface );
	border: 1px solid var( --bs-ce-color-border );
	border-radius: var( --bs-ce-radius );
	text-decoration: none;
}

.bs-classroom-estimator__recommendation-item a:hover,
.bs-classroom-estimator__recommendation-item a:focus-visible {
	text-decoration: underline;
}

.bs-classroom-estimator__recommendation-item img {
	width: 24px;
	height: 24px;
	object-fit: cover;
	border-radius: 3px;
}

.bs-classroom-estimator__disclaimer {
	margin: 0;
	padding-top: 0.75rem;
	border-top: 1px solid var( --bs-ce-color-border );
	color: var( --bs-ce-color-muted );
	font-size: 0.85rem;
}

.bs-classroom-estimator__visually-hidden {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect( 0, 0, 0, 0 );
	white-space: nowrap;
	border: 0;
}

@media ( min-width: 640px ) {
	.bs-classroom-estimator__form {
		display: grid;
		grid-template-columns: 1fr 1fr;
		column-gap: var( --bs-ce-spacing );
		row-gap: var( --bs-ce-spacing );
	}

	.bs-classroom-estimator__fieldset,
	.bs-classroom-estimator__submit {
		grid-column: 1 / -1;
	}

	.bs-classroom-estimator__submit {
		justify-self: start;
	}
}
