/**
 * Driver mobile panel styles.
 *
 * Mobile first, one-handed operation, large touch targets, RTL aware through logical
 * properties, and a light/dark/system theme driven by [data-theme] on the app root.
 *
 * @package WCDD
 */

.wcdd-app {
	--wcdd-bg: #f4f5f7;
	--wcdd-surface: #ffffff;
	--wcdd-surface-2: #eef0f3;
	--wcdd-text: #14161a;
	--wcdd-muted: #5c6470;
	--wcdd-border: #dfe3e8;
	--wcdd-primary: #0b6bcb;
	--wcdd-primary-text: #ffffff;
	--wcdd-danger: #c4314b;
	--wcdd-success: #1a7f37;
	--wcdd-warning: #b45309;
	--wcdd-radius: 14px;
	--wcdd-tap: 48px;

	position: relative;
	display: flex;
	flex-direction: column;
	min-height: 100vh;
	min-height: 100dvh;
	margin: 0;
	background: var(--wcdd-bg);
	color: var(--wcdd-text);
	font-size: 16px;
	line-height: 1.45;
	-webkit-font-smoothing: antialiased;
}

.wcdd-app[data-theme="dark"] {
	--wcdd-bg: #0f1216;
	--wcdd-surface: #181c22;
	--wcdd-surface-2: #21262e;
	--wcdd-text: #eef1f5;
	--wcdd-muted: #9aa4b2;
	--wcdd-border: #2b323b;
	--wcdd-primary: #4d9bf0;
	--wcdd-primary-text: #06131f;
	--wcdd-success: #3fb950;
	--wcdd-warning: #e3a008;
}

@media ( prefers-color-scheme: dark ) {
	.wcdd-app[data-theme="system"] {
		--wcdd-bg: #0f1216;
		--wcdd-surface: #181c22;
		--wcdd-surface-2: #21262e;
		--wcdd-text: #eef1f5;
		--wcdd-muted: #9aa4b2;
		--wcdd-border: #2b323b;
		--wcdd-primary: #4d9bf0;
		--wcdd-primary-text: #06131f;
		--wcdd-success: #3fb950;
		--wcdd-warning: #e3a008;
	}
}

body.wcdd-driver-panel {
	margin: 0;
	background: var(--wcdd-bg, #f4f5f7);
}

/* Standalone document: the panel owns the screen, so strip theme spacing and make sure
   nothing a theme or another plugin floats over the viewport can reach the navigation. */
body.wcdd-standalone {
	margin: 0;
	padding: 0;
	overflow-x: hidden;
}

body.wcdd-standalone > header,
body.wcdd-standalone > footer,
body.wcdd-standalone > .site-header,
body.wcdd-standalone > .site-footer {
	display: none;
}

body.wcdd-standalone [data-wcdd-hidden] {
	display: none !important;
}

body.wcdd-sheet-open {
	overflow: hidden;
}

/* Header ------------------------------------------------------------- */

.wcdd-app__header {
	position: sticky;
	top: 0;
	z-index: 40;
	display: flex;
	flex-direction: column;
	gap: 10px;
	padding: 12px 16px calc( 12px + env( safe-area-inset-top ) );
	padding-top: calc( 12px + env( safe-area-inset-top ) );
	background: var(--wcdd-surface);
	border-block-end: 1px solid var(--wcdd-border);
}

.wcdd-app__identity {
	display: flex;
	align-items: center;
	gap: 12px;
}

.wcdd-app__name {
	display: block;
	font-weight: 600;
}

.wcdd-app__meta {
	display: block;
	font-size: 13px;
	color: var(--wcdd-muted);
}

.wcdd-avatar {
	width: 40px;
	height: 40px;
	border-radius: 50%;
	object-fit: cover;
	background: var(--wcdd-surface-2);
}

.wcdd-avatar--lg {
	width: 72px;
	height: 72px;
}

.wcdd-availability {
	display: grid;
	grid-template-columns: repeat( 3, 1fr );
	gap: 6px;
	padding: 4px;
	background: var(--wcdd-surface-2);
	border-radius: var(--wcdd-radius);
}

.wcdd-availability__btn {
	min-height: 40px;
	border: 0;
	border-radius: 10px;
	background: transparent;
	color: var(--wcdd-muted);
	font-size: 14px;
	font-weight: 600;
	cursor: pointer;
}

.wcdd-availability__btn.is-active {
	background: var(--wcdd-surface);
	color: var(--wcdd-text);
	box-shadow: 0 1px 3px rgba( 0, 0, 0, 0.12 );
}

/* Connection banner --------------------------------------------------- */

.wcdd-connection {
	padding: 8px 16px;
	font-size: 14px;
	font-weight: 600;
	text-align: center;
	color: #fff;
	background: var(--wcdd-danger);
}

.wcdd-connection.is-syncing {
	background: #b26a00;
}

/* Main ---------------------------------------------------------------- */

.wcdd-app__main {
	flex: 1;
	padding: 16px 16px calc( 104px + env( safe-area-inset-bottom ) );
}

.wcdd-heading {
	margin: 20px 0 10px;
	font-size: 14px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	color: var(--wcdd-muted);
}

.wcdd-empty {
	padding: 40px 16px;
	text-align: center;
	color: var(--wcdd-muted);
}

.wcdd-stats {
	display: grid;
	grid-template-columns: repeat( 4, 1fr );
	gap: 8px;
}

.wcdd-stat {
	padding: 12px 6px;
	text-align: center;
	background: var(--wcdd-surface);
	border: 1px solid var(--wcdd-border);
	border-radius: var(--wcdd-radius);
}

.wcdd-stat span {
	display: block;
	font-size: 22px;
	font-weight: 700;
}

.wcdd-stat small {
	display: block;
	font-size: 11px;
	color: var(--wcdd-muted);
}

/* Cards ---------------------------------------------------------------- */

.wcdd-card {
	margin-block-end: 12px;
	padding: 14px;
	background: var(--wcdd-surface);
	border: 1px solid var(--wcdd-border);
	border-radius: var(--wcdd-radius);
}

.wcdd-card__head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	margin-block-end: 8px;
}

.wcdd-card__number {
	font-weight: 700;
}

.wcdd-card__customer {
	margin: 0 0 2px;
	font-weight: 600;
}

.wcdd-card__address {
	margin: 0 0 10px;
	color: var(--wcdd-muted);
	font-size: 14px;
}

.wcdd-card__foot {
	display: flex;
	flex-wrap: wrap;
	gap: 12px;
	font-size: 13px;
	color: var(--wcdd-muted);
}

.wcdd-pill {
	display: inline-block;
	padding: 3px 10px;
	border-radius: 999px;
	color: #fff;
	font-size: 12px;
	font-weight: 600;
	white-space: nowrap;
}

/* Buttons -------------------------------------------------------------- */

.wcdd-button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: var(--wcdd-tap);
	padding: 0 18px;
	border: 1px solid var(--wcdd-border);
	border-radius: var(--wcdd-radius);
	background: var(--wcdd-surface-2);
	color: var(--wcdd-text);
	font-size: 15px;
	font-weight: 600;
	text-decoration: none;
	cursor: pointer;
	touch-action: manipulation;
}

.wcdd-button:disabled {
	opacity: 0.55;
}

.wcdd-button--block {
	display: flex;
	width: 100%;
	margin-block-start: 10px;
}

.wcdd-button--primary {
	background: var(--wcdd-primary);
	border-color: var(--wcdd-primary);
	color: var(--wcdd-primary-text);
}

.wcdd-button--danger {
	background: var(--wcdd-danger);
	border-color: var(--wcdd-danger);
	color: #fff;
}

.wcdd-button--ghost {
	background: transparent;
}

.wcdd-icon-button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	border: 1px solid var(--wcdd-border);
	border-radius: 10px;
	background: var(--wcdd-surface-2);
	color: var(--wcdd-text);
	font-size: 15px;
	cursor: pointer;
}

.wcdd-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin-block-start: 10px;
}

.wcdd-actions .wcdd-button {
	flex: 1 1 40%;
}

/* Tabs ------------------------------------------------------------------ */

.wcdd-tabs {
	display: flex;
	gap: 6px;
	margin-block-end: 14px;
	padding: 4px;
	background: var(--wcdd-surface-2);
	border-radius: var(--wcdd-radius);
}

.wcdd-tab {
	flex: 1;
	min-height: 40px;
	border: 0;
	border-radius: 10px;
	background: transparent;
	color: var(--wcdd-muted);
	font-size: 14px;
	font-weight: 600;
	cursor: pointer;
}

.wcdd-tab.is-active {
	background: var(--wcdd-surface);
	color: var(--wcdd-text);
}

/* Route ----------------------------------------------------------------- */

.wcdd-route__actions {
	margin-block-end: 12px;
}

.wcdd-route__summary {
	margin: 0 0 12px;
	color: var(--wcdd-muted);
	font-size: 14px;
}

.wcdd-stops {
	margin: 0;
	padding: 0;
	list-style: none;
}

.wcdd-stop {
	display: flex;
	align-items: center;
	gap: 12px;
	margin-block-end: 10px;
	padding: 12px;
	background: var(--wcdd-surface);
	border: 1px solid var(--wcdd-border);
	border-radius: var(--wcdd-radius);
}

.wcdd-stop.is-done {
	opacity: 0.55;
}

.wcdd-stop__index {
	display: flex;
	flex: 0 0 32px;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	border-radius: 50%;
	background: var(--wcdd-primary);
	color: var(--wcdd-primary-text);
	font-weight: 700;
}

.wcdd-stop__body {
	display: flex;
	flex: 1;
	flex-direction: column;
	min-width: 0;
	font-size: 14px;
}

.wcdd-stop__body span,
.wcdd-stop__body small {
	color: var(--wcdd-muted);
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.wcdd-stop__controls {
	display: flex;
	flex-direction: column;
	gap: 4px;
}

.wcdd-stop__controls .wcdd-icon-button {
	width: 34px;
	height: 30px;
}

/* Bottom navigation ------------------------------------------------------ */

.wcdd-nav {
	position: fixed;
	inset-inline: 0;
	bottom: 0;
	/* Deliberately extreme: a theme's sticky cart bar landing on top of these tabs makes
	   the panel unusable, and themes routinely use five- and six-digit z-indexes. */
	z-index: 2147483000;
	display: grid;
	grid-template-columns: repeat( 5, 1fr );
	padding-block-end: env( safe-area-inset-bottom );
	background: var(--wcdd-surface);
	border-block-start: 1px solid var(--wcdd-border);
}

.wcdd-nav__item {
	position: relative;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 2px;
	min-height: 60px;
	border: 0;
	background: transparent;
	color: var(--wcdd-muted);
	font-size: 11px;
	cursor: pointer;
}

.wcdd-nav__item.is-active {
	color: var(--wcdd-primary);
}

.wcdd-nav__icon {
	font-size: 19px;
	line-height: 1;
}

.wcdd-nav__badge {
	position: absolute;
	top: 8px;
	inset-inline-end: 22%;
	min-width: 18px;
	padding: 1px 5px;
	border-radius: 999px;
	background: var(--wcdd-danger);
	color: #fff;
	font-size: 10px;
	font-weight: 700;
	text-align: center;
}

/* Sheet ------------------------------------------------------------------- */

.wcdd-sheet {
	position: fixed;
	inset: 0;
	z-index: 2147483100;
}

.wcdd-sheet__backdrop {
	position: absolute;
	inset: 0;
	background: rgba( 0, 0, 0, 0.45 );
}

.wcdd-sheet__panel {
	position: absolute;
	inset-inline: 0;
	bottom: 0;
	max-height: 92vh;
	overflow-y: auto;
	padding: 0 16px calc( 24px + env( safe-area-inset-bottom ) );
	background: var(--wcdd-bg);
	border-start-start-radius: 20px;
	border-start-end-radius: 20px;
	-webkit-overflow-scrolling: touch;
}

.wcdd-detail__head {
	position: sticky;
	top: 0;
	z-index: 2;
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 14px 0;
	background: var(--wcdd-bg);
}

.wcdd-block {
	margin-block-end: 12px;
	padding: 14px;
	background: var(--wcdd-surface);
	border: 1px solid var(--wcdd-border);
	border-radius: var(--wcdd-radius);
}

.wcdd-block h3 {
	margin: 0 0 6px;
	font-size: 12px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	color: var(--wcdd-muted);
}

.wcdd-block p {
	margin: 0 0 6px;
}

.wcdd-items {
	margin: 0;
	padding: 0;
	list-style: none;
	font-size: 15px;
}

.wcdd-items li {
	display: flex;
	justify-content: space-between;
	gap: 12px;
	padding: 5px 0;
	border-block-end: 1px solid var(--wcdd-border);
}

.wcdd-items li:last-child {
	border-block-end: 0;
}

.wcdd-total {
	margin-block-start: 10px;
	font-size: 14px;
	color: var(--wcdd-muted);
}

.wcdd-attempts {
	margin: 0;
	padding-inline-start: 18px;
	font-size: 14px;
}

.wcdd-eta {
	font-weight: 600;
	color: var(--wcdd-primary);
}

.wcdd-proof {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}

.wcdd-proof img {
	width: 84px;
	height: 84px;
	border-radius: 10px;
	object-fit: cover;
}

/* Proof is one requirement with two ways of meeting it. The word between the buttons is
   doing real work: without it a driver at the door reads two buttons as two jobs. */
.wcdd-proof-ask {
	margin-block-start: 8px;
}

.wcdd-proof-ask .wcdd-actions {
	align-items: center;
}

.wcdd-proof-ask__or {
	flex: 0 0 auto;
	color: var(--wcdd-muted);
	font-size: 13px;
}

.wcdd-proof-ask__note,
.wcdd-proof-ask__done {
	margin: 0 0 8px;
	font-size: 13px;
}

.wcdd-proof-ask__note {
	color: var(--wcdd-warning, #b45309);
}

.wcdd-proof-ask__done {
	color: var(--wcdd-success, #1a7f37);
}

/* Forms -------------------------------------------------------------------- */

.wcdd-form {
	padding-block-end: 20px;
}

.wcdd-profile__head {
	display: flex;
	align-items: center;
	gap: 14px;
	margin-block-end: 16px;
}

.wcdd-field {
	display: block;
	margin-block-end: 14px;
}

.wcdd-field > span {
	display: block;
	margin-block-end: 5px;
	font-size: 13px;
	font-weight: 600;
	color: var(--wcdd-muted);
}

.wcdd-field input,
.wcdd-field select,
.wcdd-field textarea,
.wcdd-block textarea {
	width: 100%;
	min-height: var(--wcdd-tap);
	padding: 10px 12px;
	border: 1px solid var(--wcdd-border);
	border-radius: 12px;
	background: var(--wcdd-surface);
	color: var(--wcdd-text);
	font-size: 16px; /* 16px stops iOS zooming on focus. */
	box-sizing: border-box;
}

.wcdd-block textarea {
	min-height: 70px;
	resize: vertical;
}

.wcdd-checkbox {
	display: flex;
	align-items: center;
	gap: 10px;
	min-height: var(--wcdd-tap);
	font-size: 15px;
}

.wcdd-checkbox input {
	width: 22px;
	height: 22px;
}

.wcdd-help {
	margin: 0 0 16px;
	font-size: 13px;
	color: var(--wcdd-muted);
}

.wcdd-areas {
	margin: 0 0 16px;
	padding-inline-start: 18px;
	font-size: 13px;
	color: var(--wcdd-muted);
}

.wcdd-signature {
	display: block;
	width: 100%;
	height: 220px;
	margin-block-end: 14px;
	border: 1px dashed var(--wcdd-border);
	border-radius: 12px;
	background: #fff;
	color: #111;
	touch-action: none;
}

/* Toast --------------------------------------------------------------------- */

.wcdd-toast {
	position: fixed;
	inset-inline: 16px;
	bottom: calc( 76px + env( safe-area-inset-bottom ) );
	z-index: 2147483200;
	padding: 12px 16px;
	border-radius: 12px;
	background: #14161a;
	color: #fff;
	font-size: 14px;
	text-align: center;
	box-shadow: 0 6px 20px rgba( 0, 0, 0, 0.25 );
}

.wcdd-toast.is-error {
	background: var(--wcdd-danger);
}

/* Skeleton ------------------------------------------------------------------- */

.wcdd-skeleton__row {
	height: 74px;
	margin-block-end: 12px;
	border-radius: var(--wcdd-radius);
	background: linear-gradient( 90deg, var(--wcdd-surface-2) 25%, var(--wcdd-surface) 50%, var(--wcdd-surface-2) 75% );
	background-size: 400% 100%;
	animation: wcdd-shimmer 1.4s ease infinite;
}

@keyframes wcdd-shimmer {
	from { background-position: 100% 0; }
	to { background-position: 0 0; }
}

@media ( prefers-reduced-motion: reduce ) {
	.wcdd-skeleton__row {
		animation: none;
	}
}

/* Location status --------------------------------------------------------------- */

.wcdd-gps {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 8px 16px;
	background: var(--wcdd-surface-2);
	color: var(--wcdd-muted);
	font-size: 13px;
	line-height: 1.35;
}

.wcdd-gps::before {
	content: "";
	flex: 0 0 auto;
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: var(--wcdd-success);
}

.wcdd-gps.is-error {
	/* Plain value first: color-mix is unsupported on the older Android browsers
	   these phones often run, and a missing background here would lose the warning. */
	background: var(--wcdd-surface-2);
	background: color-mix( in srgb, var(--wcdd-danger) 12%, var(--wcdd-surface) );
	color: var(--wcdd-text);
	font-weight: 500;
}

.wcdd-gps.is-error::before {
	background: var(--wcdd-danger);
}

/* Sign in ---------------------------------------------------------------------- */

.wcdd-app--login {
	justify-content: center;
	padding: env( safe-area-inset-top ) 16px env( safe-area-inset-bottom );
}

.wcdd-login {
	display: flex;
	align-items: center;
	justify-content: center;
	flex: 1;
	width: 100%;
	padding-block: 24px;
}

.wcdd-login__card {
	width: 100%;
	max-width: 380px;
	padding: 28px 22px 24px;
	background: var(--wcdd-surface);
	border: 1px solid var(--wcdd-border);
	border-radius: var(--wcdd-radius);
	box-shadow: 0 10px 30px rgba( 0, 0, 0, 0.08 );
	text-align: center;
}

.wcdd-login__logo {
	display: block;
	max-width: 140px;
	max-height: 72px;
	width: auto;
	height: auto;
	margin: 0 auto 16px;
	object-fit: contain;
}

.wcdd-login__title {
	margin: 0;
	font-size: 22px;
	line-height: 1.25;
	font-weight: 700;
	color: var(--wcdd-text);
}

.wcdd-login__subtitle {
	margin: 4px 0 22px;
	font-size: 15px;
	color: var(--wcdd-muted);
}

.wcdd-login__notice {
	margin: 0 0 18px;
	padding: 12px 14px;
	background: var(--wcdd-surface-2);
	border-radius: 10px;
	font-size: 14px;
	text-align: start;
	color: var(--wcdd-text);
}

/* wp_login_form() markup, restyled for a phone. */

.wcdd-login__card .login-username,
.wcdd-login__card .login-password {
	margin-block-end: 14px;
	text-align: start;
}

.wcdd-login__card label {
	display: block;
	margin-block-end: 6px;
	font-size: 14px;
	font-weight: 600;
	color: var(--wcdd-muted);
}

.wcdd-login__card input[type="text"],
.wcdd-login__card input[type="password"] {
	box-sizing: border-box;
	width: 100%;
	min-height: var(--wcdd-tap);
	padding: 0 14px;
	background: var(--wcdd-bg);
	border: 1px solid var(--wcdd-border);
	border-radius: 10px;
	color: var(--wcdd-text);
	/* 16px or larger, or iOS zooms the whole page on focus. */
	font-size: 16px;
	font-family: inherit;
}

.wcdd-login__card input[type="text"]:focus,
.wcdd-login__card input[type="password"]:focus {
	outline: 2px solid var(--wcdd-primary);
	outline-offset: 1px;
	border-color: var(--wcdd-primary);
}

/* Ticked by default, because a courier should not re-enter a password at the start
   of every shift — but left visible, so a shared phone can opt out. */
.wcdd-login__card .login-remember {
	display: flex;
	align-items: center;
	gap: 8px;
	margin-block-start: 4px;
	text-align: start;
}

.wcdd-login__card .login-remember label {
	display: flex;
	align-items: center;
	gap: 8px;
	margin: 0;
	font-weight: 400;
	color: var(--wcdd-text);
	cursor: pointer;
}

.wcdd-login__card .login-remember input[type="checkbox"] {
	width: 20px;
	height: 20px;
	margin: 0;
	accent-color: var(--wcdd-primary);
}

.wcdd-login__card .login-submit {
	margin-block-start: 20px;
}

.wcdd-login__card input[type="submit"] {
	width: 100%;
	min-height: var(--wcdd-tap);
	padding: 0 18px;
	background: var(--wcdd-primary);
	border: 0;
	border-radius: 10px;
	color: var(--wcdd-primary-text);
	font-size: 16px;
	font-weight: 600;
	font-family: inherit;
	cursor: pointer;
	-webkit-appearance: none;
	appearance: none;
}

.wcdd-login__help {
	margin: 18px 0 0;
	font-size: 14px;
}

.wcdd-login__help a {
	color: var(--wcdd-primary);
}

.wcdd-login-notice {
	max-width: 420px;
	margin: 40px auto;
	padding: 24px;
	text-align: center;
}

.wcdd-map--unavailable {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 160px;
	background: repeating-linear-gradient( 45deg, #e9ecef, #e9ecef 10px, #f4f5f7 10px, #f4f5f7 20px );
	border-radius: var(--wcdd-radius, 14px);
}

/* A map that failed to load explains itself; a blank box reads as "nothing here". */
.wcdd-map__error {
	max-width: 30em;
	margin: 0;
	padding: 14px 18px;
	background: rgba( 255, 255, 255, 0.94 );
	border-radius: 10px;
	color: #3c434a;
	text-align: center;
	font-size: 14px;
	line-height: 1.5;
}

/* Push notification block ------------------------------------------------------ */

.wcdd-push {
	margin-block-end: 16px;
	padding: 14px;
	background: var(--wcdd-surface);
	border: 1px solid var(--wcdd-border);
	border-radius: var(--wcdd-radius);
}

.wcdd-push h3 {
	margin: 0 0 6px;
	font-size: 12px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	color: var(--wcdd-muted);
}

.wcdd-push .wcdd-help {
	margin-block-end: 10px;
}

/* Leaflet pins are inline SVG rather than Leaflet's default images, so that a missing
   image path can never turn a working map into an apparently empty one. */
.wcdd-leaflet-pin {
	background: none;
	border: 0;
}
