/**
 * Dodo Payments -- gateway settings screen.
 *
 * Scoped entirely to the elements this plugin renders. The stock WooCommerce
 * settings markup is left alone.
 *
 * Lengths are in `rem` so the screen tracks the reader's font size rather than
 * fighting it: a browser set to large text scales this UI with the rest of
 * wp-admin instead of holding it at a fixed pixel size. `rem` rather than `em`
 * throughout, so nothing compounds through the nested panel/row/label markup.
 * Media queries use `em`, which they resolve against the initial font size.
 *
 * Two exceptions stay in pixels on purpose: hairline borders, which should
 * remain one device pixel at any text size, and the focus ring, which should
 * not thin out when text is small.
 */

/* ---------------------------------------------------------------------------
   Collapsible sections
   --------------------------------------------------------------------------- */

.dodo-panel {
	background: #fff;
	border: 1px solid #c3c4c7;
	border-radius: 0.25rem;
	margin: 0 0 0.625rem;
}

.dodo-panel__toggle {
	align-items: center;
	background: none;
	border: 0;
	border-bottom: 1px solid transparent;
	color: #1d2327;
	cursor: pointer;
	display: flex;
	font-size: 0.875rem;
	font-weight: 600;
	gap: 0.5625rem;
	margin: 0;
	padding: 0.75rem 0.875rem;
	text-align: left;
	width: 100%;
}

.dodo-panel__toggle:hover,
.dodo-panel__toggle:focus {
	color: #2271b1;
}

.dodo-panel__toggle:focus-visible {
	box-shadow: inset 0 0 0 2px #2271b1;
	outline: none;
}

.dodo-panel.is-open > .dodo-panel__toggle {
	border-bottom-color: #dcdcde;
}

.dodo-panel__caret {
	color: #787c82;
	flex: none;
	font-size: 1rem;
	line-height: 1;
	transition: transform 0.15s ease;
}

.dodo-panel.is-open .dodo-panel__caret {
	transform: rotate(90deg);
}

.dodo-panel__count {
	background: #f0f0f1;
	border-radius: 0.5625rem;
	color: #646970;
	font-size: 0.6875rem;
	font-variant-numeric: tabular-nums;
	font-weight: 400;
	margin-left: auto;
	padding: 0.0625rem 0.5625rem;
}

.dodo-panel__body {
	padding: 0 0.875rem 0.5rem;
}

.dodo-panel__body > p:first-child {
	color: #646970;
	margin-top: 0.75rem;
	max-width: 70ch;
}

.dodo-panel__body .form-table {
	margin-top: 0;
}

.dodo-panel:not(.is-open) > .dodo-panel__body {
	display: none;
}

@media (prefers-reduced-motion: reduce) {
	.dodo-panel__caret {
		transition: none;
	}
}

/* ---------------------------------------------------------------------------
   Extra checkout questions
   --------------------------------------------------------------------------- */

/*
 * Six columns inside a WooCommerce settings cell whose width the plugin does
 * not control. The four text columns are `minmax(0, Nfr)` rather than plain
 * `Nfr` because a grid track's default `min-width: auto` refuses to shrink
 * below its content, which pushes the fixed Required and Remove columns off
 * the right-hand edge of the panel.
 */
.dodo-questions__head,
.dodo-questions__row {
	align-items: center;
	display: grid;
	gap: 0.5rem;
	grid-template-columns:
		minmax(0, 1.1fr)
		minmax(0, 1.4fr)
		minmax(0, 0.9fr)
		minmax(0, 1.1fr)
		4rem
		1.75rem;
	width: 100%;
}

.dodo-questions {
	display: block;
	max-width: 100%;
	min-width: 0;
}

.dodo-questions__head {
	color: #646970;
	font-size: 0.6875rem;
	letter-spacing: 0.04em;
	margin-bottom: 0.375rem;
	text-transform: uppercase;
}

/* Long headings must not set a floor on their column's width. */
.dodo-questions__head > span {
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.dodo-questions__row {
	margin-bottom: 0.5rem;
}

.dodo-questions__row input[type="text"],
.dodo-questions__row select {
	margin: 0;
	max-width: none;
	min-width: 0;
	width: 100%;
}

.dodo-questions__key {
	font-family: Menlo, Consolas, monaco, monospace;
	font-size: 0.75rem;
}

.dodo-questions__required {
	justify-self: center;
}

.dodo-questions__remove {
	color: #b32d2e;
	cursor: pointer;
	font-size: 1.125rem;
	justify-self: center;
	line-height: 1;
	text-decoration: none;
}

.dodo-questions__remove:hover,
.dodo-questions__remove:focus {
	color: #8a2424;
}

.dodo-questions__options {
	grid-column: 1 / -1;
	margin: -0.125rem 0 0.375rem;
}

.dodo-questions__options label {
	color: #646970;
	display: flex;
	align-items: center;
	font-size: 0.75rem;
	gap: 0.5rem;
}

.dodo-questions__options input[type="text"] {
	flex: 1;
	max-width: 26.25rem;
}

.dodo-questions__empty {
	color: #646970;
	font-style: italic;
	margin: 0 0 0.625rem;
}

.dodo-questions__limit {
	color: #646970;
	font-size: 0.75rem;
	margin-left: 0.5rem;
}

@media screen and (max-width: 60em) {
	.dodo-questions__head {
		display: none;
	}

	.dodo-questions__row {
		border: 1px solid #dcdcde;
		border-radius: 0.25rem;
		gap: 0.375rem;
		grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
		padding: 0.625rem;
		position: relative;
	}

	.dodo-questions__row .dodo-questions__key,
	.dodo-questions__row > input[type="text"]:nth-of-type(2) {
		grid-column: 1 / -1;
	}

	.dodo-questions__remove {
		position: absolute;
		right: 0.375rem;
		top: 0.375rem;
	}
}

/* ---------------------------------------------------------------------------
   Reset button
   --------------------------------------------------------------------------- */

.dodo-reset-defaults {
	margin-left: 0.5rem;
}

/* ---------------------------------------------------------------------------
   Webhook endpoint
   --------------------------------------------------------------------------- */

.dodo-webhook-url {
	align-items: center;
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
	max-width: 40rem;
}

/* The whole URL stays visible: long site addresses wrap instead of clipping. */
.dodo-webhook-url__value {
	flex: 1 1 18rem;
	min-width: 0;
	overflow-wrap: anywhere;
	padding: 0.375rem 0.5rem;
	user-select: all;
}

.dodo-copy__status {
	color: #646970;
	font-size: 0.75rem;
}
