/**
 * Connect mode (avco-connect.js). Loaded only for site admins with ?avco_connect=1.
 * Everything is scoped to #avco-cm or the classes it adds, with explicit values, so themes don't restyle it.
 *
 * @package Availability_Datepicker
 * @since 3.1
 */

html.avco-cm-on {
	margin-top: calc(var(--wp-admin--admin-bar--height, 32px) + 52px) !important;
}

#wpadminbar .avco-connect-on > .ab-item {
	background: #2271b1 !important;
	color: #fff !important;
}

#avco-cm,
#avco-cm * {
	box-sizing: border-box;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
	letter-spacing: normal;
	text-transform: none;
}

/* Bar */
#avco-cm .avco-cm-bar {
	position: fixed;
	z-index: 100001;
	top: var(--wp-admin--admin-bar--height, 32px);
	left: 0;
	right: 0;
	min-height: 52px;
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 6px 14px;
	padding: 8px max(16px, env(safe-area-inset-right, 0px)) 8px max(16px, env(safe-area-inset-left, 0px));
	background: #2271b1;
	color: #fff;
	font-size: 14px;
	line-height: 1.4;
	box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

#avco-cm .avco-cm-pulse {
	width: 10px;
	height: 10px;
	flex: none;
	border-radius: 50%;
	background: #fff;
	animation: avco-cm-pulse 1.6s infinite;
}

@keyframes avco-cm-pulse {
	0% { box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.7); }
	70% { box-shadow: 0 0 0 8px rgba(255, 255, 255, 0); }
	100% { box-shadow: 0 0 0 0 rgba(255, 255, 255, 0); }
}

#avco-cm .avco-cm-msg {
	flex: 1 1 240px;
	min-width: 0;
	color: #fff;
}

#avco-cm .avco-cm-msg strong {
	font-weight: 600;
	color: #fff;
}

#avco-cm .avco-cm-msg span {
	opacity: 0.85;
	font-size: 13px;
	color: #fff;
}

#avco-cm .avco-cm-done {
	margin: 0;
	padding: 6px 16px;
	border: 0;
	border-radius: 3px;
	background: #fff;
	color: #2271b1;
	font-size: 14px;
	font-weight: 600;
	line-height: 1.4;
	cursor: pointer;
}

/* Fields on the page */
html.avco-cm-on .avco-cm-target {
	cursor: pointer !important;
}

html.avco-cm-on .avco-cm-target:hover,
html.avco-cm-on .avco-cm-target:focus {
	outline: 2px dashed #2271b1 !important;
	outline-offset: 3px !important;
}

html.avco-cm-on .avco-cm-connected {
	outline: 2px solid #2271b1 !important;
	outline-offset: 3px !important;
}

#avco-cm .avco-cm-badge {
	position: absolute;
	z-index: 100000;
	transform: translateX(-100%);
	height: 20px;
	padding: 0 8px;
	border-radius: 10px;
	background: #2271b1;
	color: #fff;
	font-size: 11px;
	font-weight: 600;
	line-height: 20px;
	white-space: nowrap;
	pointer-events: none;
}

/* Box */
#avco-cm .avco-cm-box {
	position: absolute;
	z-index: 100002;
	width: min(340px, calc(100vw - 16px));
	display: grid;
	gap: 12px;
	padding: 14px 16px;
	background: #fff;
	color: #1d2327;
	border: 1px solid #c3c4c7;
	border-radius: 6px;
	box-shadow: 0 8px 24px rgba(0, 0, 0, 0.16);
	font-size: 14px;
	line-height: 1.45;
	text-align: left;
}

#avco-cm .avco-cm-head {
	display: grid;
	gap: 2px;
}

#avco-cm .avco-cm-head small {
	font-size: 12px;
	color: #787c82;
}

#avco-cm .avco-cm-head strong {
	font-size: 15px;
	font-weight: 600;
	color: #1d2327;
}

#avco-cm fieldset {
	margin: 0;
	padding: 0;
	border: 0;
	display: grid;
	gap: 6px;
	min-width: 0;
}

#avco-cm legend {
	padding: 0;
	margin: 0 0 4px;
	font-size: 12px;
	font-weight: 600;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	color: #50575e;
}

#avco-cm .avco-cm-opt {
	display: flex;
	align-items: center;
	gap: 8px;
	margin: 0;
	font-size: 14px;
	font-weight: 400;
	color: #1d2327;
	cursor: pointer;
}

#avco-cm .avco-cm-opt input {
	width: auto;
	height: auto;
	min-height: 0;
	margin: 0;
	accent-color: #2271b1;
}

#avco-cm details summary {
	cursor: pointer;
	font-size: 13px;
	color: #2271b1;
}

#avco-cm details > div {
	display: grid;
	gap: 6px;
	padding-top: 6px;
}

#avco-cm .avco-cm-inline {
	display: flex;
	flex-wrap: wrap;
	gap: 6px 16px;
}

#avco-cm .avco-cm-limit {
	display: flex;
	align-items: center;
	gap: 8px;
	margin-top: 4px;
	font-size: 13px;
	color: #1d2327;
}

#avco-cm .avco-cm-limit select {
	width: auto;
	min-height: 30px;
	margin: 0;
	padding: 0 24px 0 8px;
	border: 1px solid #8c8f94;
	border-radius: 4px;
	background-color: #fff;
	color: #1d2327;
	font-size: 13px;
}

#avco-cm [hidden] {
	display: none !important;
}

#avco-cm .avco-cm-need {
	margin: 0;
	font-size: 13px;
	color: #d63638;
}

#avco-cm .avco-cm-acts {
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: 8px;
}

#avco-cm .avco-cm-right {
	display: flex;
	gap: 8px;
	margin-left: auto;
}

#avco-cm .avco-cm-btn {
	margin: 0;
	min-height: 32px;
	padding: 0 12px;
	border: 1px solid #2271b1;
	border-radius: 3px;
	background: #f6f7f7;
	color: #2271b1;
	font-size: 13px;
	line-height: 30px;
	cursor: pointer;
	text-decoration: none;
}

#avco-cm .avco-cm-btn:disabled {
	opacity: 0.6;
	cursor: default;
}

#avco-cm .avco-cm-primary {
	background: #2271b1;
	color: #fff;
}

#avco-cm .avco-cm-danger {
	min-height: 0;
	padding: 0;
	border: 0;
	background: none;
	color: #d63638;
	line-height: 1.4;
	text-decoration: underline;
}

#avco-cm .avco-cm-why {
	display: flex;
	align-items: flex-start;
	gap: 10px;
}

#avco-cm .avco-cm-why p {
	margin: 4px 0 0;
	color: #1d2327;
}

#avco-cm .avco-cm-icon {
	width: 20px;
	height: 20px;
	flex: none;
	border: 2px solid #d63638;
	border-radius: 50%;
	color: #d63638;
	font-size: 12px;
	font-weight: 700;
	line-height: 16px;
	text-align: center;
}

/* Message */
#avco-cm .avco-cm-toast {
	position: fixed;
	z-index: 100002;
	right: max(16px, env(safe-area-inset-right, 0px));
	bottom: max(16px, env(safe-area-inset-bottom, 0px));
	max-width: 380px;
	display: grid;
	gap: 6px;
	padding: 12px 14px;
	background: #1d2327;
	color: #fff;
	border-radius: 6px;
	box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
	font-size: 14px;
	line-height: 1.45;
}

#avco-cm .avco-cm-toast strong {
	color: #fff;
	font-weight: 600;
}

#avco-cm .avco-cm-sub {
	font-size: 13px;
	opacity: 0.85;
	color: #fff;
}

#avco-cm .avco-cm-tacts {
	display: flex;
	gap: 14px;
}

#avco-cm .avco-cm-tacts a,
#avco-cm .avco-cm-tacts button {
	margin: 0;
	padding: 0;
	border: 0;
	background: none;
	color: #9ec2e6;
	font-size: 13px;
	text-decoration: underline;
	cursor: pointer;
}

#avco-cm button:focus-visible,
#avco-cm a:focus-visible,
#avco-cm input:focus-visible,
#avco-cm summary:focus-visible {
	outline: 2px solid #72aee6;
	outline-offset: 2px;
}

@media (max-width: 600px) {
	#avco-cm .avco-cm-toast {
		left: 12px;
		right: 12px;
		max-width: none;
	}
}

@media (prefers-reduced-motion: reduce) {
	#avco-cm .avco-cm-pulse {
		animation: none;
	}
}
