/**
 * Lion Parcel — customer-facing shipment tracking page (My Account → View Order).
 *
 * Self-contained: reuses the visual language of the admin Transaction Detail
 * page (status pills, info tooltip, history timeline) without loading the large
 * admin stylesheet on the storefront.
 */

.lionparcel-track {
	--lionparcel-primary: #FF0000;
	color: #1a1a1a;
}

.lionparcel-track__title {
	font-size: 20px;
	font-weight: 700;
	margin: 0 0 18px;
}

/* ---------------------------------------------------------------------------
 * Header facts + status
 * ------------------------------------------------------------------------- */
.lionparcel-track__header {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 16px;
	margin-bottom: 24px;
}

.lionparcel-track__facts {
	display: flex;
	flex-wrap: wrap;
	gap: 14px 40px;
}

.lionparcel-track-fact {
	display: flex;
	flex-direction: column;
	gap: 4px;
}

.lionparcel-track-fact__label {
	font-size: 12px;
	color: #8a8a8a;
}

.lionparcel-track-fact__value {
	font-size: 14px;
	font-weight: 700;
}

.lionparcel-track__status {
	text-align: left;
	max-width: 320px;
}

.lionparcel-track__status-msg {
	margin: 8px 0 0;
	font-size: 12px;
	font-style: italic;
	color: #6b7280;
	line-height: 1.5;
}

/* ---------------------------------------------------------------------------
 * Status pills (shared tokens with the admin pages)
 * ------------------------------------------------------------------------- */
.lionparcel-status {
	display: inline-block;
	padding: 5px 12px;
	border-radius: 14px;
	font-size: 12px;
	font-weight: 500;
	white-space: nowrap;
}

.lionparcel-status--gray { background: #eef0f2; color: #6b7280; }
.lionparcel-status--yellow { background: #fdf0cf; color: #b07d1a; }
.lionparcel-status--purple { background: #efe9fb; color: #7c5cc4; }
.lionparcel-status--blue { background: #e3edfb; color: #3b73c4; }
.lionparcel-status--green { background: #dcf3e3; color: #2f9e54; }
.lionparcel-status--red { background: #fbe1e1; color: #d24a4a; }

/* ---------------------------------------------------------------------------
 * Layout
 * ------------------------------------------------------------------------- */
.lionparcel-track__layout {
	display: flex;
	flex-direction: column;
	gap: 28px;
}

.lionparcel-track__main {
	border: 1px solid #ececec;
	border-radius: 12px;
	padding: 22px;
}

.lionparcel-track__heading {
	font-size: 15px;
	font-weight: 700;
	margin: 0 0 16px;
}

.lionparcel-track__muted {
	color: #8a8a8a;
	font-size: 13px;
	margin: 0;
}

/* ---------------------------------------------------------------------------
 * Collapsible history timeline + "Show all" toggle
 *
 * The timeline renders in full by default (no-JS safe). frontend.js adds
 * `.is-collapsible` only when the content overflows the clamp, then reveals
 * the toggle button below the card.
 * ------------------------------------------------------------------------- */
.lionparcel-track__history {
	position: relative;
}

.lionparcel-track__history.is-collapsible {
	overflow: hidden;
	max-height: 220px;
}

.lionparcel-track__history.is-collapsible.is-expanded {
	max-height: none;
}

/* Fade-out over the clipped content while collapsed. */
.lionparcel-track__history.is-collapsible:not(.is-expanded)::after {
	content: "";
	position: absolute;
	left: 0;
	right: 0;
	bottom: 0;
	height: 64px;
	background: linear-gradient(rgba(255, 255, 255, 0), #fff);
	pointer-events: none;
}

.lionparcel-track__toggle {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	margin-top: 16px;
	padding: 0;
	background: none;
	border: 0;
	color: var(--lionparcel-primary);
	font-size: 13px;
	font-weight: 600;
	cursor: pointer;
}

.lionparcel-track__toggle::after {
	content: "";
	width: 7px;
	height: 7px;
	border: solid currentColor;
	border-width: 0 2px 2px 0;
	transform: rotate(45deg);
	margin-bottom: 3px;
	transition: transform .2s ease;
}

.lionparcel-track__toggle[aria-expanded="true"]::after {
	transform: rotate(-135deg);
	margin-top: 3px;
	margin-bottom: 0;
}

/* ---------------------------------------------------------------------------
 * 4-step progress indicator
 * ------------------------------------------------------------------------- */
.lionparcel-steps {
	list-style: none;
	display: flex;
	margin: 0 0 28px;
	padding: 0;
}

.lionparcel-steps__item {
	position: relative;
	flex: 1 1 0;
	text-align: center;
	min-width: 0;
}

/* Connector line between steps. */
.lionparcel-steps__item:not(:first-child)::before {
	content: "";
	position: absolute;
	top: 13px;
	right: 50%;
	width: 100%;
	height: 3px;
	background: #e2e4e7;
	z-index: 0;
}

.lionparcel-steps__item.is-done:not(:first-child)::before {
	background: var(--lionparcel-primary);
}

.lionparcel-steps__dot {
	position: relative;
	z-index: 1;
	display: block;
	width: 28px;
	height: 28px;
	margin: 0 auto 8px;
	border-radius: 50%;
	background: #fff;
	border: 3px solid #e2e4e7;
}

.lionparcel-steps__item.is-done .lionparcel-steps__dot {
	background: var(--lionparcel-primary);
	border-color: var(--lionparcel-primary);
}

/* Checkmark on completed steps. */
.lionparcel-steps__item.is-done .lionparcel-steps__dot::after {
	content: "";
	position: absolute;
	left: 8px;
	top: 4px;
	width: 5px;
	height: 9px;
	border: solid #fff;
	border-width: 0 2px 2px 0;
	transform: rotate(45deg);
}

.lionparcel-steps__label {
	font-size: 12px;
	color: #8a8a8a;
	line-height: 1.35;
	display: block;
}

.lionparcel-steps__item.is-done .lionparcel-steps__label {
	color: #1a1a1a;
	font-weight: 600;
}

.lionparcel-steps.is-cancelled .lionparcel-steps__dot {
	border-color: #d24a4a;
}

/* ---------------------------------------------------------------------------
 * Info icon + tooltip (shared with the admin pages)
 * ------------------------------------------------------------------------- */
.lionparcel-info {
	position: relative;
	display: inline-flex;
	cursor: pointer;
}

.lionparcel-info__icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 14px;
	height: 14px;
	border-radius: 50%;
	background: #1a1a1a;
	color: #fff;
	font-size: 10px;
	font-weight: 700;
	line-height: 1;
}

.lionparcel-tooltip {
	position: absolute;
	bottom: calc(100% + 8px);
	left: 50%;
	transform: translateX(-50%);
	background: #fff;
	color: #333;
	border-radius: 8px;
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.16);
	padding: 12px 14px;
	font-size: 12px;
	font-weight: 400;
	white-space: nowrap;
	z-index: 20;
	opacity: 0;
	visibility: hidden;
	transition: opacity .12s ease;
	text-align: left;
}

.lionparcel-tooltip--text {
	white-space: normal;
	width: max-content;
	max-width: 260px;
	line-height: 1.5;
}

.lionparcel-info:hover .lionparcel-tooltip,
.lionparcel-info:focus .lionparcel-tooltip,
.lionparcel-info:focus-within .lionparcel-tooltip {
	opacity: 1;
	visibility: visible;
}

/* ---------------------------------------------------------------------------
 * History timeline (shared with the admin pages)
 * ------------------------------------------------------------------------- */
.lionparcel-timeline-group + .lionparcel-timeline-group {
	margin-top: 10px;
}

.lionparcel-timeline-date {
	font-size: 13px;
	font-weight: 700;
	color: #1a1a1a;
	margin: 0 0 10px;
}

.lionparcel-timeline {
	list-style: none;
	margin: 0;
	padding: 0;
}

.lionparcel-timeline__item {
	position: relative;
	display: grid;
	grid-template-columns: 44px 24px minmax(0, 1fr);
	column-gap: 8px;
	align-items: flex-start;
	padding-bottom: 22px;
}

/* Connector line centre = 44px time + 8px gap + 12px (half the 24px marker col) = 64px. */
.lionparcel-timeline__item:not(:last-child)::before {
	content: "";
	position: absolute;
	top: 9px;
	left: 64px;
	transform: translateX(-50%);
	width: 2px;
	height: 100%;
	background: #e2e4e7;
}

.lionparcel-timeline__time {
	font-size: 12px;
	color: #555;
	padding-top: 1px;
	white-space: nowrap;
	text-align: right;
}

.lionparcel-timeline__marker {
	position: relative;
	width: 13px;
	height: 13px;
	margin: 3px auto 0;
	border-radius: 50%;
	background: #c9ccd1;
	z-index: 1;
}

.lionparcel-timeline__item.is-active .lionparcel-timeline__marker {
	width: 18px;
	height: 18px;
	margin-top: 1px;
	background: var(--lionparcel-primary);
}

.lionparcel-timeline__body {
	min-width: 0;
	padding-top: 1px;
	padding-left: 6px;
}

.lionparcel-timeline__status {
	font-size: 13px;
	color: #1a1a1a;
	margin: 0;
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 6px;
	line-height: 1.4;
}

.lionparcel-timeline__code {
	font-weight: 700;
}

.lionparcel-timeline__sep {
	color: #d2d5d9;
}

.lionparcel-timeline__meta {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	font-size: 12px;
	font-weight: 600;
	color: #4b4b4b;
}

.lionparcel-timeline__meta .dashicons {
	font-size: 15px;
	width: 15px;
	height: 15px;
	color: #9aa0a6;
}

.lionparcel-timeline__remarks {
	font-size: 12px;
	color: #8a8a8a;
	margin: 5px 0 0;
	line-height: 1.55;
}

.lionparcel-timeline__ref {
	font-size: 12px;
	font-weight: 700;
	color: #1a1a1a;
	margin: 5px 0 0;
	text-decoration: underline;
}

/* Attachment thumbnails on a history event (proof photos). Multiple images
 * stack horizontally and wrap; each opens in a lightbox (attachment-lightbox.js),
 * falling back to opening the image in a new tab without JS. */
.lionparcel-attachments {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin: 8px 0 0;
}

.lionparcel-attachment {
	display: block;
	width: 100px;
	height: 100px;
	border: 1px solid #ececec;
	border-radius: 8px;
	overflow: hidden;
	cursor: pointer;
	background: #f5f5f5;
}

.lionparcel-attachment__img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

/* Full-image lightbox overlay (shared, appended to <body>). */
.lionparcel-lightbox {
	position: fixed;
	inset: 0;
	z-index: 100000;
	display: none;
	align-items: center;
	justify-content: center;
	padding: 24px;
	background: rgba(0, 0, 0, 0.8);
}

.lionparcel-lightbox.is-open {
	display: flex;
}

.lionparcel-lightbox__img {
	max-width: 90vw;
	max-height: 90vh;
	border-radius: 8px;
	box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.lionparcel-lightbox__close {
	position: absolute;
	top: 20px;
	right: 24px;
	width: 40px;
	height: 40px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.9);
	color: #1a1a1a;
	font-size: 22px;
	line-height: 1;
	cursor: pointer;
}

/* ---------------------------------------------------------------------------
 * Shipment Information card
 * ------------------------------------------------------------------------- */
.lionparcel-track-card {
	border: 1px solid #ececec;
	border-radius: 12px;
	padding: 22px;
}

.lionparcel-track-address + .lionparcel-track-address {
	margin-top: 18px;
}

.lionparcel-track-address__label {
	display: block;
	font-size: 13px;
	font-weight: 700;
	margin-bottom: 6px;
}

.lionparcel-track-address__name {
	display: block;
	font-size: 13px;
	color: #1a1a1a;
}

.lionparcel-track-address__line {
	display: block;
	font-size: 12px;
	color: #6b7280;
	line-height: 1.55;
	margin-top: 2px;
}

.lionparcel-track__back {
	display: inline-block;
	align-self: flex-start;
}

/* CTA on the standard View Order page. */
.lionparcel-track-cta {
	margin: 16px 0 0;
}

/* ---------------------------------------------------------------------------
 * Block checkout: weight / origin info rows in the order summary.
 * (The classic checkout rows ride WooCommerce's review-table styling.)
 * ------------------------------------------------------------------------- */
.lionparcel-checkout-info {
	margin: 12px 0;
	font-size: 14px;
}

.lionparcel-checkout-info__row {
	display: flex;
	justify-content: space-between;
	gap: 12px;
	/* Match the WooCommerce totals items' horizontal padding (e.g. Subtotal). */
	padding: 4px 16px;
}

.lionparcel-checkout-info__label {
	color: #50575e;
}

.lionparcel-checkout-info__value {
	font-weight: 600;
	text-align: right;
}

/* ---------------------------------------------------------------------------
 * Block checkout: shipping insurance checkbox under the shipping options.
 * (The classic checkout renders its own review-table row instead.)
 * ------------------------------------------------------------------------- */
/*
 * The control itself is WooCommerce's own CheckboxControl, so it needs no
 * styling from us — the only rule here is positional.
 *
 * The ExperimentalOrderShippingPackages slot only fills *after* the rate list,
 * so the checkbox is reordered above it. Scoped with :has() so the rates control
 * is left completely alone on carts that render no Lion Parcel checkbox; where
 * :has() is unsupported the checkbox simply stays below the rates.
 */
.wc-block-components-shipping-rates-control:has( > .lionparcel-insurance ) {
	display: flex;
	flex-direction: column;
}

.wc-block-components-shipping-rates-control > .lionparcel-insurance {
	order: -1;
	margin-bottom: 12px;
}

.lionparcel-insurance__label {
	display: flex;
	align-items: center;
	gap: 8px;
	cursor: pointer;
}

.lionparcel-insurance__checkbox:disabled + span {
	opacity: 0.6;
}
