/* General mobile-friendly base styles */
* {
	box-sizing: border-box;
}

html {
	overflow-y: scroll;
	overflow-x: hidden;
	height: 100%;
}

body {
	min-height: 100%;
	position: relative;
}

.question-container {
    margin-bottom: 20px;
    max-width: 100%;
    overflow-wrap: break-word;
    word-wrap: break-word;
}

.question{
	font-weight: 600;
	margin-bottom: 20px;
	word-wrap: break-word;
	overflow-wrap: break-word;
}

.feedback {
	border-radius: 4px;
}

.hidden{
	display: none;
}

.letter {
	text-transform: capitalize;
	font-weight: bold;
  	margin-right: 0.3em;
}

/* Superscript styling for mathematical powers */
sup {
	font-size: 0.75em;
	position: relative;
	top: -0.4em;
	line-height: 0;
}

.fill-blank-container {
	display: flex;
	align-items: center;
	gap: 10px;
	margin: 15px 0;
}

.fill-blank-input {
	max-width: 200px;
	display: inline-block;
	font-size: 1.1em;
	font-weight: 600;
}

.fill-blank-input.text-success {
	border-color: #28a745;
	background-color: #d4edda;
}

.fill-blank-input.text-danger {
	border-color: #dc3545;
	background-color: #f8d7da;
}

.unit-label {
	font-weight: 600;
	color: #666;
	font-size: 1em;
}

.matrix-container {
	margin: 15px 0;
	width: 100%;
	max-width: 100%;
}

.matrix-row {
	display: flex;
	align-items: flex-start;
	gap: 15px;
	margin-bottom: 15px;
	width: 100%;
}

.matrix-row-label {
	font-weight: 600;
	flex: 1;
	min-width: 0;
	line-height: 1.5;
	padding-right: 10px;
	word-wrap: break-word;
	overflow-wrap: break-word;
}

.matrix-select {
	flex: 0 0 250px;
	width: 250px;
	min-width: 250px;
	max-width: 250px;
}

.matrix-select.is-valid {
	border-color: #28a745;
	background-color: #d4edda;
}

.matrix-select.is-invalid {
	border-color: #dc3545;
	background-color: #f8d7da;
}

.matrix-correct-answers {
	margin-top: 10px;
}

.matrix-correct-answers div {
	padding: 3px 0;
	line-height: 1.5;
}

@media (max-width: 768px) {
	.matrix-row {
		flex-direction: column;
		gap: 8px;
	}
	
	.matrix-row-label {
		padding-right: 0;
	}
	
	.matrix-select {
		flex: 1 1 auto;
		width: 100%;
		max-width: 100%;
		min-width: 0;
	}
}

.ordered-container {
	margin: 15px 0;
	width: 100%;
	min-height: 100px;
}

.ordered-item {
	display: flex;
	align-items: flex-start;
	gap: 10px;
	padding: 12px;
	margin-bottom: 8px;
	border: 2px solid #dee2e6;
	border-radius: 6px;
	background-color: #fff;
	transition: all 0.2s;
	cursor: move;
	cursor: grab;
	user-select: none;
	-webkit-user-select: none;
	-moz-user-select: none;
	-ms-user-select: none;
}

.ordered-item:hover {
	background-color: #f8f9fa;
	box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.ordered-item.dragging {
	opacity: 0.5;
	cursor: grabbing;
	box-shadow: 0 4px 8px rgba(0,0,0,0.2);
	transform: scale(1.02);
}

.ordered-item.no-drag {
	cursor: default;
	opacity: 1;
}

.drag-handle {
	font-size: 1.2em;
	color: #6c757d;
	cursor: grab;
	flex-shrink: 0;
	padding: 0 4px;
	user-select: none;
}

.drag-handle:active {
	cursor: grabbing;
}

.ordered-number {
	font-weight: bold;
	font-size: 1.1em;
	min-width: 25px;
	text-align: center;
	flex-shrink: 0;
	color: #495057;
}

.ordered-text {
	flex: 1;
	line-height: 1.5;
	word-wrap: break-word;
	overflow-wrap: break-word;
	min-width: 0;
}

.ordered-item.ordered-correct {
	border-color: #28a745;
	background-color: #d4edda;
}

.ordered-item.ordered-incorrect {
	border-color: #dc3545;
	background-color: #f8d7da;
}

.ordered-correct-answer {
	margin-top: 10px;
}

.ordered-correct-answer div {
	padding: 3px 0;
}

.cloze-container {
	margin: 15px 0;
}

.cloze-header {
	display: flex;
	align-items: center;
	gap: 10px;
	margin-bottom: 15px;
}

.cloze-number {
	font-weight: 600;
	font-size: 1em;
	color: #212529;
}

.cloze-content {
	line-height: 2;
	font-size: 1.05em;
	word-wrap: break-word;
	overflow-wrap: break-word;
	max-width: 100%;
}

.cloze-dropdown {
	display: inline-block;
	min-width: 150px;
	max-width: 300px;
	padding: 4px 8px;
	margin: 0 4px;
	border: 2px solid #ced4da;
	border-radius: 4px;
	background-color: #fff;
	font-size: 0.95em;
	vertical-align: middle;
	cursor: pointer;
	transition: all 0.2s;
	box-sizing: border-box;
}

.cloze-dropdown:hover:not(:disabled) {
	border-color: #80bdff;
	box-shadow: 0 0 0 0.2rem rgba(0,123,255,.25);
}

.cloze-dropdown:focus {
	outline: none;
	border-color: #80bdff;
	box-shadow: 0 0 0 0.2rem rgba(0,123,255,.25);
}

.cloze-dropdown:disabled {
	cursor: default;
	background-color: #e9ecef;
}

.cloze-dropdown.is-valid {
	border-color: #28a745;
	background-color: #d4edda;
}

.cloze-dropdown.is-invalid {
	border-color: #dc3545;
	background-color: #f8d7da;
}

.cloze-correct-answers {
	margin-top: 10px;
}

.cloze-correct-answers div {
	padding: 3px 0;
	line-height: 1.5;
}

/* Bowtie question styles */
.bowtie-container {
	display: flex;
	gap: 20px;
	margin: 20px 0;
	width: 100%;
}

.bowtie-column {
	flex: 1;
	padding: 15px;
	border: 2px solid #dee2e6;
	border-radius: 8px;
	background-color: #f8f9fa;
	min-width: 0;
}

.bowtie-column-title {
	font-weight: bold;
	font-size: 1em;
	margin-bottom: 15px;
	padding-bottom: 10px;
	border-bottom: 2px solid #dee2e6;
	color: #495057;
	text-align: center;
}

.bowtie-item {
	display: flex;
	align-items: flex-start;
	gap: 8px;
	margin-bottom: 12px;
	padding: 8px;
	background-color: #fff;
	border-radius: 4px;
	transition: background-color 0.2s;
	word-wrap: break-word;
	overflow-wrap: break-word;
}

.bowtie-item:hover {
	background-color: #e9ecef;
}

.bowtie-item input {
	margin-top: 0.3em;
	flex-shrink: 0;
}

.bowtie-left {
	background-color: #fff3cd;
	border-color: #ffc107;
}

.bowtie-left .bowtie-column-title {
	color: #856404;
	border-bottom-color: #ffc107;
}

.bowtie-center {
	background-color: #d1ecf1;
	border-color: #17a2b8;
}

.bowtie-center .bowtie-column-title {
	color: #0c5460;
	border-bottom-color: #17a2b8;
}

.bowtie-right {
	background-color: #d4edda;
	border-color: #28a745;
}

.bowtie-right .bowtie-column-title {
	color: #155724;
	border-bottom-color: #28a745;
}

.bowtie-correct-answers {
	margin-top: 10px;
}

.bowtie-correct-column {
	padding: 8px 0;
	line-height: 1.6;
}

.bowtie-correct-column strong {
	display: block;
	margin-bottom: 4px;
	color: #495057;
}

@media (max-width: 992px) {
	.bowtie-container {
		flex-direction: column;
		gap: 15px;
	}
	
	.bowtie-column {
		width: 100%;
	}
}

.no-padding-bottom {
	padding-bottom: 0 !important;
}

.red {
	color: red;
}

#fixed-box {
	position: fixed;
	z-index: 1000;
	top: 0;
	left: 0;
	right: 0;
}

#test-container {
	position: relative;
	min-height: 100vh;
}

#settings-container {
	position: relative;
	min-height: 100vh;
}

.fixed-box-container {
	width: 100%;
}

.fixed-box-card {
	min-height: 140px;
	padding-top: 0;
	padding-bottom: 0 !important;
}

.fixed-box-btn {
	width: auto;
	margin-bottom: 10px;
}

.fixed-box-title {
	display: block;
}

#results-wrap, #countdown-wrap {
	margin-bottom: 5px;
	width: 50%;
}

.fixed-box-top {
	display: flex;
	margin-top: 15px;
	margin-bottom: 0;
}

.form-check-label {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 1rem;
  word-wrap: break-word;
  overflow-wrap: break-word;
  max-width: 100%;
}

.form-check-input {
  margin-top: 0.3em; /* aligns with first line of text */
  flex-shrink: 0;
}

.answers {
  display: flex;
  flex-direction: column;
  max-width: 100%;
  width: 100%;
}

#quiz {
	width: 100%;
	max-width: 100%;
	overflow-x: hidden;
}

/* Mobile-specific improvements */
@media (max-width: 768px) {
	/* Prevent horizontal scroll */
	body {
		overflow-x: hidden;
	}
	
	html, body {
		max-width: 100%;
		overflow-x: hidden;
	}
	
	/* Fix container padding on mobile */
	.container {
		padding-left: 15px !important;
		padding-right: 15px !important;
		max-width: 100%;
	}
	
	/* Fix card padding */
	.card-body {
		padding: 15px !important;
	}
	
	/* Question container adjustments */
	.question-container {
		padding: 0;
		margin-left: 0;
		margin-right: 0;
	}
	
	.question {
		font-size: 0.95em;
		line-height: 1.5;
		padding-right: 0;
	}
	
	/* Form labels */
	.form-check-label {
		font-size: 0.9em;
		line-height: 1.4;
		padding-right: 0;
	}
	
	/* Buttons - prevent overflow */
	.btn {
		white-space: normal;
		word-wrap: break-word;
		max-width: 100%;
	}
	
	.fixed-box-btn {
		font-size: 0.9em;
		padding-left: 10px !important;
		padding-right: 10px !important;
	}
	
	/* All select elements on mobile - use native behavior */
	select,
	.cloze-dropdown,
	.matrix-select {
		font-size: 16px !important; /* Prevents zoom on iOS */
		min-height: 44px; /* iOS touch target size */
		padding: 10px;
		border: 1px solid #ced4da;
		border-radius: 4px;
		background-color: #fff;
		width: 100%;
		max-width: 100%;
	}
	
	.cloze-dropdown {
		min-width: auto;
		display: inline-block;
		width: auto;
		max-width: calc(100vw - 40px);
	}
	
	.cloze-content {
		line-height: 1.6;
		font-size: 1em;
	}
	
	.cloze-container,
	.matrix-container,
	.question-container,
	.answers {
		overflow: visible !important;
	}
	
	body {
		overflow-x: hidden;
		overflow-y: auto;
	}
	
	/* Fill blank input */
	.fill-blank-input {
		max-width: 120px;
		font-size: 0.95em;
	}
	
	.fill-blank-container {
		flex-wrap: wrap;
	}
	
	/* Ordered items */
	.ordered-item {
		padding: 8px;
		gap: 6px;
	}
	
	.ordered-text {
		font-size: 0.9em;
		word-break: break-word;
	}
	
	.ordered-number {
		min-width: 20px;
		font-size: 1em;
	}
	
	/* Bowtie columns */
	.bowtie-column {
		padding: 8px;
	}
	
	.bowtie-column-title {
		font-size: 0.85em;
		word-wrap: break-word;
	}
	
	.bowtie-item {
		font-size: 0.85em;
		padding: 6px;
		word-wrap: break-word;
	}
	
	/* Matrix */
	.matrix-row-label {
		font-size: 0.9em;
	}
	
	/* Badges */
	.badge {
		font-size: 0.65em !important;
		white-space: normal;
		word-wrap: break-word;
	}
	
	/* Results and feedback */
	.feedback {
		padding-left: 10px !important;
		padding-right: 10px !important;
		font-size: 0.9em;
	}
	
	.hint {
		font-size: 0.9em;
		line-height: 1.4;
	}
	
	/* Fixed box adjustments */
	#fixed-box {
		left: 0;
		right: 0;
		width: 100%;
		padding: 0 10px;
	}
	
	.fixed-box-card {
		padding: 10px !important;
	}
	
	/* Answers container */
	.answers {
		padding-left: 0 !important;
		padding-right: 0 !important;
	}
}

@media (min-width: 1150px) {

	#fixed-box {
		top: 50% !important;
		right: 0 !important;
		transform: translateY(-50%) !important;
	}

	.fixed-box-container {
		width: 250px;
		margin-right: 1.5rem;
	}

	.fixed-box-title {
		display: none;
	}

	.fixed-box-btn {
		width: 100%;
		margin-bottom: 15px;
	}

	#results-wrap, #countdown-wrap {
		margin-top: -5px;
		margin-bottom: 5px;
		width: 100%;
	}

	.fixed-box-top {
		display: block;
		margin-top: 3px;
		margin-bottom: 3px;
	}

}

@media (min-width: 992px) {

	.fixed-box-card {
		min-height: 120px;
		padding-top: 0;
		padding-bottom: 0 !important;
	}

}