/**
 * Myco panel — form controls: inputs / selects / textarea, field wrapper,
 * input groups (prefix/suffix/icon), checkbox & radio, toggle switch, option
 * cards, underline tabs, segmented control, form messages. Class names are
 * the contract shared with templates + JS (app.js marks .is-invalid, say()
 * rewrites .myco-checkout__status). Tokens only.
 */

/* ---- Inputs ---- */

.myco-input,
.myco-select,
.myco-textarea,
.myco-field input:not( [type="checkbox"] ):not( [type="radio"] ),
.myco-field select,
.myco-field textarea,
.myco-modal__input,
.myco-modal__mode,
.myco-addcard select {
	width: 100%;
	height: var( --myco-h-md );
	padding: 0 12px;
	border: 1px solid var( --myco-border-strong );
	border-radius: var( --myco-radius-sm );
	background: var( --myco-input-bg );
	color: var( --myco-text );
	font-family: var( --myco-font-body );
	font-size: 14px;
	line-height: 1.4;
	transition: border-color 0.12s, box-shadow 0.12s;
}

.myco-textarea,
.myco-field textarea {
	height: auto;
	min-height: 96px;
	padding: 10px 12px;
	resize: vertical;
}

.myco-input::placeholder,
.myco-field input::placeholder,
.myco-field textarea::placeholder {
	color: var( --myco-muted );
}

/* Browser autofill repaints the field in its own colours — keep the theme's. */
.myco-body input:-webkit-autofill,
.myco-body select:-webkit-autofill,
.myco-body textarea:-webkit-autofill {
	-webkit-box-shadow: 0 0 0 1000px var( --myco-input-bg ) inset;
	-webkit-text-fill-color: var( --myco-text );
	caret-color: var( --myco-text );
}

.myco-input:focus,
.myco-select:focus,
.myco-textarea:focus,
.myco-field input:not( [type="checkbox"] ):not( [type="radio"] ):focus,
.myco-field select:focus,
.myco-field textarea:focus,
.myco-modal__input:focus,
.myco-modal__mode:focus {
	outline: none;
	border-color: var( --myco-ink );
	box-shadow: 0 0 0 3px var( --myco-focus-ring );
}

.myco-input.is-invalid,
.myco-field input.is-invalid,
.myco-field select.is-invalid {
	border: 1.5px solid var( --myco-danger );
}

.myco-input:disabled,
.myco-field input:disabled,
.myco-field select:disabled {
	opacity: 0.6;
	background: var( --myco-well );
}

.myco-select,
.myco-field select,
.myco-modal__mode,
.myco-addcard select {
	appearance: none;
	-webkit-appearance: none;
	padding-right: 34px;
	background-image: url( "data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238C9A93' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='m6 9 6 6 6-6'/></svg>" );
	background-repeat: no-repeat;
	background-position: right 10px center;
}

.myco-input--sm {
	height: var( --myco-h-sm );
	font-size: 13px;
}

.myco-input--lg {
	height: var( --myco-h-lg );
	font-size: 15px;
}

/* Field: label + control + hint. */
.myco-field {
	display: flex;
	flex-direction: column;
	gap: 6px;
	min-width: 0;
}

.myco-field label:not( .myco-radio ):not( .myco-checkbox ),
.myco-field__label,
.myco-label {
	font-size: 13px;
	font-weight: 600;
	color: var( --myco-text );
}

.myco-field__label {
	display: block;
}

.myco-hint,
.myco-optional {
	color: var( --myco-muted );
	font-size: 12px;
	font-weight: 400;
}

.myco-hint.is-ok { color: var( --myco-accent-ink ); }
.myco-hint.is-bad { color: var( --myco-danger ); }

.myco-form {
	display: flex;
	flex-direction: column;
	gap: 16px;
}

.myco-form__message {
	margin: 0;
	font-size: 13px;
	min-height: 1em;
}

.myco-form__message.is-error { color: var( --myco-danger ); }
.myco-form__message.is-success { color: var( --myco-accent-ink ); }
.myco-form__message.is-info { color: var( --myco-muted ); }

/* Prefix / suffix blocks (e.g. ".myco.site"), icon-inside. */
.myco-input-group {
	display: flex;
	align-items: stretch;
	border: 1px solid var( --myco-border-strong );
	border-radius: var( --myco-radius-sm );
	background: var( --myco-input-bg );
	overflow: hidden;
	min-width: 0;
}

.myco-input-group:focus-within {
	border-color: var( --myco-ink );
	box-shadow: 0 0 0 3px var( --myco-focus-ring );
}

.myco-input-group input,
.myco-input-group .myco-input {
	border: 0 !important;
	box-shadow: none !important;
	border-radius: 0;
	flex: 1 1 auto;
	min-width: 0;
	background: transparent;
	color: var( --myco-text );
}

.myco-input-group__affix {
	display: inline-flex;
	align-items: center;
	padding: 0 12px;
	background: var( --myco-well );
	color: var( --myco-text-2 );
	font-family: var( --myco-font-mono );
	font-size: 13px;
	white-space: nowrap;
	border-left: 1px solid var( --myco-border );
}

.myco-input-group__affix--pre {
	border-left: 0;
	border-right: 1px solid var( --myco-border );
}

.myco-input-group__icon {
	display: inline-flex;
	align-items: center;
	padding: 0 0 0 12px;
	color: var( --myco-muted );
}

.myco-input-group__icon + input {
	padding-left: 8px;
}

/* Legacy status strip written by JS (say()). */
.myco-checkout__status {
	margin: 0;
	font-size: 13px;
	min-height: 1em;
	color: var( --myco-text-2 );
}

.myco-checkout__status.is-error { color: var( --myco-danger ); }
.myco-checkout__status.is-ok { color: var( --myco-accent-ink ); }
.myco-checkout__status.is-info { color: var( --myco-muted ); }

/* ---- Checkbox / radio ---- */

.myco-body input[type="checkbox"],
.myco-body input[type="radio"] {
	accent-color: var( --myco-accent );
	width: 18px;
	height: 18px;
	margin: 0;
	flex-shrink: 0;
}

.myco-checkbox,
.myco-radio {
	display: flex;
	align-items: center;
	gap: 10px;
	font-size: 14px;
	font-weight: 400;
	color: var( --myco-text );
	cursor: pointer;
}

.myco-checkbox.is-disabled,
.myco-radio.is-disabled {
	opacity: 0.65;
	cursor: default;
}

.myco-checkbox--sub {
	margin-left: 28px;
	font-size: 13px;
	color: var( --myco-text-2 );
}

/* ---- Toggle switch ---- */

.myco-toggle {
	position: relative;
	display: inline-flex;
	align-items: center;
	width: 40px;
	height: 22px;
	flex-shrink: 0;
	cursor: pointer;
}

.myco-toggle input {
	position: absolute;
	opacity: 0;
	width: 100%;
	height: 100%;
	margin: 0;
	cursor: pointer;
}

.myco-toggle__track {
	position: absolute;
	inset: 0;
	border-radius: var( --myco-radius-pill );
	background: var( --myco-border-strong );
	transition: background 0.15s;
}

.myco-toggle__track::after {
	content: "";
	position: absolute;
	top: 2px;
	left: 2px;
	width: 18px;
	height: 18px;
	border-radius: 50%;
	background: #fff;
	transition: transform 0.15s;
}

.myco-toggle input:checked + .myco-toggle__track {
	background: var( --myco-accent );
}

.myco-toggle input:checked + .myco-toggle__track::after {
	transform: translateX( 18px );
}

.myco-toggle input:focus-visible + .myco-toggle__track {
	box-shadow: 0 0 0 3px var( --myco-focus-ring );
}

.myco-toggle input:disabled + .myco-toggle__track {
	background: var( --myco-border-dashed );
	opacity: 0.7;
}

.myco-toggle--sm {
	width: 32px;
	height: 18px;
}

.myco-toggle--sm .myco-toggle__track::after {
	width: 14px;
	height: 14px;
}

.myco-toggle--sm input:checked + .myco-toggle__track::after {
	transform: translateX( 14px );
}

/* Toggle row: label + switch. */
.myco-toggle-row {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 14px;
	font-size: 14px;
}

.myco-toggle-row__text {
	min-width: 0;
}

.myco-toggle-row__desc {
	font-size: 13px;
	color: var( --myco-text-2 );
}

/* ---- Option cards (radio rows / cards) ---- */

.myco-option {
	display: flex;
	align-items: flex-start;
	gap: 12px;
	padding: 14px 16px;
	border: 1px solid var( --myco-border );
	border-radius: var( --myco-radius-md );
	background: var( --myco-card );
	cursor: pointer;
	transition: border-color 0.12s, background 0.12s;
	position: relative;
}

.myco-option:hover {
	border-color: var( --myco-border-strong );
}

.myco-option.is-selected,
.myco-option:has( input:checked ) {
	border: 2px solid var( --myco-ink );
	padding: 13px 15px;
}

.myco-option.is-disabled {
	opacity: 0.65;
	cursor: default;
}

.myco-option input[type="radio"],
.myco-option input[type="checkbox"] {
	position: absolute;
	opacity: 0;
	pointer-events: none;
}

.myco-option__ring {
	width: 18px;
	height: 18px;
	border-radius: 50%;
	border: 1.5px solid var( --myco-border-dashed );
	flex-shrink: 0;
	margin-top: 2px;
	position: relative;
}

.myco-option.is-selected .myco-option__ring,
.myco-option:has( input:checked ) .myco-option__ring {
	border-color: var( --myco-ink );
}

.myco-option.is-selected .myco-option__ring::after,
.myco-option:has( input:checked ) .myco-option__ring::after {
	content: "";
	position: absolute;
	inset: 3px;
	border-radius: 50%;
	background: var( --myco-ink );
}

.myco-option__check {
	width: 20px;
	height: 20px;
	border-radius: 50%;
	background: var( --myco-accent );
	color: var( --myco-on-accent );
	display: none;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
}

.myco-option.is-selected .myco-option__check,
.myco-option:has( input:checked ) .myco-option__check {
	display: inline-flex;
}

.myco-option__icon {
	width: 36px;
	height: 36px;
	border-radius: var( --myco-radius-sm );
	background: var( --myco-well );
	color: var( --myco-text-2 );
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	font-size: 18px;
}

.myco-option__body {
	min-width: 0;
	flex: 1 1 auto;
}

.myco-option__title {
	font-size: 14px;
	font-weight: 600;
	display: flex;
	align-items: center;
	gap: 8px;
	flex-wrap: wrap;
}

.myco-option__desc {
	font-size: 13px;
	color: var( --myco-text-2 );
	margin-top: 2px;
}

.myco-option--card {
	flex-direction: column;
	align-items: stretch;
	padding: 18px;
}

/* ---- Tabs (underline) ---- */

.myco-tabs {
	display: flex;
	gap: 2px;
	border-bottom: 1px solid var( --myco-border );
	overflow-x: auto;
}

.myco-tabs__tab {
	padding: 10px 16px;
	font-size: 14px;
	font-weight: 500;
	color: var( --myco-muted );
	text-decoration: none;
	background: none;
	border: 0;
	border-bottom: 2px solid transparent;
	margin-bottom: -1px;
	cursor: pointer;
	white-space: nowrap;
	font-family: inherit;
}

.myco-tabs__tab:hover {
	color: var( --myco-text );
}

.myco-tabs__tab.is-active,
.myco-tabs__tab[aria-selected="true"] {
	color: var( --myco-text );
	font-weight: 600;
	border-bottom-color: var( --myco-ink );
}

/* ---- Segmented control (pill group) ---- */

.myco-seg {
	display: inline-flex;
	gap: 6px;
	flex-wrap: wrap;
}

.myco-seg__btn {
	height: var( --myco-h-sm );
	padding: 0 14px;
	border-radius: 9px;
	border: 1px solid var( --myco-border-strong );
	background: var( --myco-input-bg );
	color: var( --myco-text-2 );
	font-family: inherit;
	font-size: 13px;
	font-weight: 600;
	cursor: pointer;
	display: inline-flex;
	align-items: center;
	gap: 6px;
	text-decoration: none;
}

.myco-seg__btn:hover {
	background: var( --myco-hover );
	color: var( --myco-text );
}

.myco-seg__btn.is-active,
.myco-seg__btn[aria-pressed="true"] {
	background: var( --myco-btn-dark-bg );
	border-color: var( --myco-btn-dark-bg );
	color: var( --myco-btn-dark-fg );
}

/* A label-wrapped radio makes a segment (Account type, Buying as, cancel
   reasons): the input covers the segment invisibly, `:checked` paints it. */
.myco-seg__btn input[type="radio"] {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	margin: 0;
	opacity: 0;
	cursor: pointer;
	appearance: none;
	-webkit-appearance: none;
}

label.myco-seg__btn {
	position: relative;
}

.myco-seg__btn:has( input:checked ) {
	background: var( --myco-btn-dark-bg );
	border-color: var( --myco-btn-dark-bg );
	color: var( --myco-btn-dark-fg );
}

.myco-seg__btn:focus-within {
	outline: 2px solid var( --myco-focus-ring );
	outline-offset: 2px;
}

/* Small badge inside a segment ("2 months free" on Yearly). */
.myco-seg__badge {
	font-size: 11px;
	font-weight: 600;
	line-height: 1;
	padding: 4px 8px;
	border-radius: var( --myco-radius-pill );
	background: var( --myco-accent );
	color: var( --myco-on-accent );
}

/* Chip row: 30px pill chips (invoice filters). */
.myco-seg--pill .myco-seg__btn {
	height: var( --myco-h-xs );
	padding: 0 14px;
	border-radius: var( --myco-radius-pill );
}

/* Track: one rounded container, borderless inner buttons (Monthly / Yearly, gallery tabs). */
.myco-seg--track {
	background: var( --myco-card );
	border: 1px solid var( --myco-border );
	border-radius: var( --myco-radius-pill );
	padding: 4px;
	gap: 0;
}

.myco-seg--track .myco-seg__btn {
	border: 0;
	background: transparent;
	border-radius: var( --myco-radius-pill );
	height: var( --myco-h-sm );
	padding: 0 18px;
	font-size: 14px;
}

.myco-seg--track .myco-seg__btn.is-active,
.myco-seg--track .myco-seg__btn[aria-pressed="true"] {
	background: var( --myco-btn-dark-bg );
	color: var( --myco-btn-dark-fg );
}

