/* Public tracking form, map canvas, and client dashboard */

.cct-tracking-wrap,
.cct-tracking-wrap * {
	box-sizing: border-box;
}

.cct-tracking-wrap {
	--cct-map-height: clamp(200px, 38vh, 450px);
	--cct-map-max-width: 100%;
	width: 100%;
	max-width: 960px;
	margin: 0 auto;
	padding-left: max(12px, env(safe-area-inset-left, 0px));
	padding-right: max(12px, env(safe-area-inset-right, 0px));
	padding-bottom: max(16px, env(safe-area-inset-bottom, 0px));
	overflow-x: hidden;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.cct-tracking-search {
	display: flex;
	gap: 8px;
	margin-bottom: 20px;
}
.cct-tracking-search input[type="text"] {
	flex: 1;
	padding: 10px 14px;
	border: 1px solid #cbd5e1;
	border-radius: 6px;
	font-size: 16px;
}

.cct-btn {
	padding: 10px 20px;
	border: none;
	border-radius: 6px;
	font-size: 16px;
	cursor: pointer;
}
.cct-btn-primary { background: #2563eb; color: #fff; }
.cct-btn-primary:hover { background: #1d4ed8; }

.cct-message {
	padding: 12px 16px;
	border-radius: 6px;
	background: #f1f5f9;
	margin-bottom: 16px;
}
.cct-message.cct-error {
	background: #fef2f2;
	color: #b91c1c;
	border: 1px solid #fecaca;
}

.cct-movement-hint {
	padding: 10px 14px;
	border-radius: 6px;
	background: #fffbeb;
	color: #92400e;
	border: 1px solid #fde68a;
	margin-bottom: 16px;
	font-size: 0.95rem;
}

.cct-tracking-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	flex-wrap: wrap;
	gap: 8px;
	margin-bottom: 16px;
}
.cct-tracking-header h2 { margin: 0; font-size: 1.5rem; }

.cct-status-badge {
	display: inline-block;
	padding: 4px 12px;
	border-radius: 999px;
	font-size: 13px;
	font-weight: 600;
}
.cct-status-created,
.cct-status-pending { background: #e2e8f0; color: #334155; }
.cct-status-out-for-shipping,
.cct-status-out-for-delivery { background: #e0f2fe; color: #0369a1; }
.cct-status-in-transit { background: #dbeafe; color: #1d4ed8; }
.cct-status-hold { background: #e2e8f0; color: #475569; }
.cct-status-delivered { background: #dcfce7; color: #15803d; }
.cct-status-cancelled { background: #fee2e2; color: #b91c1c; }
.cct-status-returned { background: #fce7f3; color: #9d174d; }

.cct-barcode-wrap {
	text-align: center;
	margin-bottom: 16px;
	max-width: 100%;
	overflow: hidden;
}

.cct-barcode-wrap svg {
	display: block;
	max-width: 100%;
	height: auto;
	margin: 0 auto;
}

.cct-tracking-panel,
.cct-tracking-details,
.cct-tracking-results {
	width: 100%;
	max-width: 100%;
	min-width: 0;
}

.cct-table-scroll-wrap {
	width: 100%;
	max-width: 100%;
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
	margin-bottom: 4px;
}

/* Map vault + Leaflet canvas — explicit dimensions required for tile paint */
.cct-map-vault,
#cct-map-vault {
	display: none;
	position: relative;
	width: 100%;
	max-width: 100%;
	flex: 0 0 auto;
	min-height: var(--cct-map-height);
	height: var(--cct-map-height);
	background: #e5e3df;
	margin-bottom: 16px;
	border-radius: 12px;
	overflow: hidden;
}

#cct-map-vault.is-visible {
	display: block;
	flex: 0 0 auto;
	align-self: stretch;
	width: 100%;
	height: var(--cct-map-height);
	min-height: var(--cct-map-height);
}

#cct-map,
#cct-map-vault #cct-map,
#cct-map-vault .leaflet-container,
.cct-tracking-wrap .leaflet-container {
	height: var(--cct-map-height) !important;
	min-height: var(--cct-map-height) !important;
	width: 100% !important;
	max-width: 100% !important;
	background-color: #e5e3df !important;
	position: relative !important;
	border-radius: 12px;
	overflow: hidden;
}

#cct-map-vault .leaflet-tile-pane {
	z-index: 200;
}

#cct-map-vault .leaflet-overlay-pane {
	z-index: 400;
}

#cct-map-vault .leaflet-marker-pane {
	z-index: 600;
}

@media (max-width: 1024px) {
	.cct-tracking-wrap {
		--cct-map-height: clamp(220px, 36vh, 360px);
	}
}

@media (max-width: 767px) {
	.cct-tracking-wrap {
		--cct-map-height: clamp(200px, 34vh, 300px);
		display: flex;
		flex-direction: column;
	}

	#cct-tracking-search-form {
		order: 1;
	}

	#cct-tracking-message {
		order: 2;
	}

	#cct-tracking-panel {
		order: 6;
		flex: 0 1 auto;
		min-height: 0;
		width: 100%;
	}

	#cct-movement-hint {
		order: 4;
	}

	#cct-transit-route-bar {
		order: 5;
	}

	#cct-map-vault {
		order: 3;
		flex: 0 0 auto;
		align-self: stretch;
		width: 100%;
		height: var(--cct-map-height);
		min-height: var(--cct-map-height);
	}

	.cct-tracking-search {
		flex-direction: column;
		align-items: stretch;
		gap: 10px;
	}

	.cct-tracking-search input[type="text"] {
		width: 100%;
		min-width: 0;
	}

	.cct-btn {
		width: 100%;
	}

	.cct-tracking-header {
		flex-direction: column;
		align-items: flex-start;
		gap: 10px;
	}

	.cct-tracking-header h2 {
		font-size: 1.15rem;
		line-height: 1.3;
		word-break: break-word;
		overflow-wrap: anywhere;
	}

	.cct-status-badge {
		align-self: flex-start;
	}

	.cct-detail-grid,
	.cct-contact-grid {
		grid-template-columns: 1fr;
		gap: 12px;
	}

	.cct-detail-item span,
	.cct-contact-field span,
	.cct-contact-field a {
		word-break: break-word;
		overflow-wrap: anywhere;
	}

	.cct-contact-card {
		padding: 14px 16px;
	}

	.cct-transit-route-bar {
		display: flex;
		flex-wrap: wrap;
		padding: 12px 14px;
		font-size: 14px;
	}

	.cct-movement-hint,
	.cct-paused-location-bar {
		font-size: 14px;
		padding: 10px 12px;
	}

	.cct-packages-display {
		min-width: 520px;
	}

	.cct-packages-display th,
	.cct-packages-display td {
		padding: 8px 10px;
		font-size: 14px;
	}

	.cct-history-timeline li {
		padding: 10px 12px 10px 14px;
	}

	#cct-map-vault .cct-map-type-toggle {
		min-width: 0;
		padding: 7px 10px;
		font-size: 12px;
	}

	#cct-map-vault .leaflet-control-attribution {
		max-width: calc(100% - 80px);
		font-size: 9px;
	}
}

@media (max-width: 480px) {
	.cct-tracking-wrap {
		--cct-map-height: clamp(200px, 32vh, 260px);
		padding-left: max(10px, env(safe-area-inset-left, 0px));
		padding-right: max(10px, env(safe-area-inset-right, 0px));
	}

	.cct-tracking-header h2 {
		font-size: 1rem;
	}

	.cct-packages-section h3,
	.cct-history-section h3,
	.cct-transit-stops-section h3,
	.cct-contact-title {
		font-size: 1rem;
	}
}

.cct-paused-location-bar {
	display: none;
	margin: 0 0 20px;
	padding: 12px 16px;
	border: 1px solid #e2e8f0;
	border-radius: 8px;
	background: #f8fafc;
	color: #0f172a;
	font-size: 15px;
	line-height: 1.45;
}

.cct-paused-location-bar strong {
	display: block;
	font-size: 11px;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	color: #64748b;
	margin-bottom: 4px;
}

.cct-paused-location-bar.is-visible {
	display: block;
}

.cct-transit-route-bar {
	display: none;
	margin: 0 0 20px;
	padding: 14px 18px;
	border-radius: 10px;
	border: 1px solid #bfdbfe;
	background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
	color: #1e3a8a;
	font-size: 15px;
	line-height: 1.45;
	align-items: center;
	gap: 12px;
}

.cct-transit-route-bar.is-rerouting {
	border-color: #fcd34d;
	background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
	color: #92400e;
	animation: cct-transit-pulse 2.4s ease-in-out infinite;
}

.cct-transit-route-icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 28px;
	height: 28px;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.75);
	font-size: 16px;
	font-weight: 700;
	flex-shrink: 0;
	margin-right: 10px;
	vertical-align: middle;
}

@keyframes cct-transit-pulse {
	0%, 100% { box-shadow: 0 0 0 0 rgba(251, 191, 36, 0.35); }
	50% { box-shadow: 0 0 0 6px rgba(251, 191, 36, 0); }
}

.cct-transit-stops-section {
	margin-bottom: 24px;
}

.cct-transit-stops-section h3 {
	margin: 0 0 12px;
	font-size: 1.1rem;
}

.cct-transit-stops-display {
	margin: 0;
	padding-left: 1.25rem;
	display: grid;
	gap: 10px;
}

.cct-transit-stops-display li {
	padding: 10px 12px;
	border: 1px solid #e2e8f0;
	border-radius: 8px;
	background: #f8fafc;
	list-style: decimal;
}

.cct-transit-stops-display li strong {
	display: block;
	margin-bottom: 4px;
	color: #0f172a;
}

.cct-transit-stops-display li span {
	display: block;
	color: #64748b;
	font-size: 14px;
}

.cct-transit-stop-marker {
	background: transparent;
	border: none;
}

.cct-transit-stop-pin {
	width: 28px;
	height: 28px;
	border-radius: 50%;
	background: #f59e0b;
	color: #fff;
	border: 2px solid #fff;
	box-shadow: 0 2px 8px rgba(15, 23, 42, 0.25);
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 12px;
	font-weight: 700;
}

.cct-detail-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
	gap: 16px;
	margin-bottom: 24px;
}
.cct-detail-item strong {
	display: block;
	font-size: 12px;
	text-transform: uppercase;
	color: #64748b;
	margin-bottom: 4px;
}

.cct-contact-section {
	margin-bottom: 24px;
}

.cct-contact-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
	gap: 16px;
}

.cct-contact-card {
	border: 1px solid #e2e8f0;
	border-radius: 10px;
	background: #ffffff;
	padding: 18px 20px;
	box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
}

.cct-contact-title {
	margin: 0 0 14px;
	font-size: 16px;
	font-weight: 700;
	color: #0f172a;
}

.cct-contact-fields {
	display: grid;
	gap: 12px;
}

.cct-contact-field strong {
	display: block;
	font-size: 11px;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	color: #64748b;
	margin-bottom: 4px;
}

.cct-contact-field span,
.cct-contact-field a {
	font-size: 15px;
	line-height: 1.5;
	color: #1e293b;
	word-break: break-word;
}

.cct-contact-field a {
	color: #2563eb;
	text-decoration: none;
}

.cct-contact-field a:hover {
	text-decoration: underline;
}

.cct-packages-section, .cct-history-section { margin-bottom: 24px; }

.cct-packages-display {
	width: 100%;
	border-collapse: collapse;
}
.cct-packages-display th,
.cct-packages-display td {
	padding: 8px 12px;
	border: 1px solid #e2e8f0;
	text-align: left;
}
.cct-packages-display th { background: #f8fafc; font-size: 13px; }

.cct-history-timeline {
	list-style: none;
	margin: 0;
	padding: 0;
	border-left: 3px solid #2563eb;
}
.cct-history-timeline li {
	padding: 10px 16px;
	position: relative;
}
.cct-history-timeline li::before {
	content: '';
	position: absolute;
	left: -7px; top: 14px;
	width: 10px; height: 10px;
	background: #2563eb;
	border-radius: 50%;
}
.cct-history-date { display: block; font-size: 12px; color: #64748b; }
.cct-history-msg { display: block; margin-top: 2px; }

.cct-pin {
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: 50%;
	font-weight: bold;
	font-size: 12px;
	color: #fff;
	box-shadow: 0 2px 6px rgba(0,0,0,.25);
}
.cct-pin-origin { background: #27a836; }
.cct-pin-dest { background: #dc2626; }
.cct-pin-truck,
.cct-pin-vehicle { background: transparent; box-shadow: none; }

/* Multi-mode vehicle image markers (Road / Air / Sea) */
.cct-vehicle-img-wrap,
.cct-vehicle-svg-wrap {
	display: flex;
	align-items: center;
	justify-content: center;
	overflow: hidden;
	flex-shrink: 0;
	transform-origin: 50% 50%;
	filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.35));
}

.cct-vehicle-img,
.cct-vehicle-svg {
	display: block;
	width: 100% !important;
	height: 100% !important;
	max-width: 100% !important;
	max-height: 100% !important;
	object-fit: contain;
	pointer-events: none;
	transform-origin: center center;
}

.cct-vehicle-road.cct-vehicle-img-wrap {
	width: 45px;
	height: 45px;
}

.cct-vehicle-air.cct-vehicle-img-wrap {
	width: 50px;
	height: 50px;
}

.cct-vehicle-sea.cct-vehicle-img-wrap {
	width: 45px;
	height: 40px;
}

.leaflet-marker-icon.cct-pin-vehicle,
.leaflet-marker-icon.cct-marker-transit,
.leaflet-marker-icon.cct-marker-paused,
.leaflet-marker-icon.cct-marker-red-beacon {
	background: transparent !important;
	border: none !important;
	overflow: hidden !important;
}

#cct-map-vault .leaflet-marker-icon img.cct-vehicle-img {
	width: 100% !important;
	height: 100% !important;
	max-width: 100% !important;
	max-height: 100% !important;
}

.cct-vehicle-svg {
	display: block;
	width: 40px;
	height: 40px;
	pointer-events: none;
}

.cct-vehicle-road .cct-vehicle-svg-road,
.cct-vehicle-air .cct-vehicle-svg-air,
.cct-vehicle-sea .cct-vehicle-svg-sea {
	display: block;
}
.cct-pin-returned { background: #9d174d; font-size: 18px; }

/* ── Animated live-tracking markers ─────────────────────────────── */

.cct-animated-marker {
	background: transparent !important;
	border: none !important;
}

/* On Hold: frozen vehicle + compact red beacon (neutral class names — no "hold" substring) */
.cct-marker-paused {
	width: 50px !important;
	height: 50px !important;
}

.cct-marker-container.cct-marker-paused-wrap {
	position: relative;
	width: 50px;
	height: 50px;
	display: flex;
	align-items: center;
	justify-content: center;
}

.cct-marker-container.cct-marker-paused-wrap .cct-vehicle-img-wrap,
.cct-marker-container.cct-marker-paused-wrap .cct-vehicle-svg-wrap {
	position: relative;
	z-index: 2;
}

.cct-marker-container.cct-marker-paused-wrap .flickering-red-dot {
	position: absolute;
	top: 2px;
	right: 0;
	width: 8px;
	height: 8px;
	margin: 0;
	border-radius: 50%;
	background: rgba(220, 38, 38, 1);
	z-index: 3;
	pointer-events: none;
	box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.85);
	animation: alert-flash 1.2s infinite ease-out;
}

.cct-marker-container.cct-marker-paused-wrap .flickering-red-dot::after {
	display: none;
}

@keyframes alert-flash {
	0% {
		box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.85);
		opacity: 1;
	}
	100% {
		box-shadow: 0 0 0 10px rgba(220, 38, 38, 0);
		opacity: 0.85;
	}
}

/* Red flickering emergency beacon (Cancelled) */
.cct-marker-red-beacon {
	width: 40px !important;
	height: 40px !important;
}

.cct-marker-red-dot {
	position: relative;
	width: 14px;
	height: 14px;
	margin: 13px auto 0;
	border-radius: 50%;
	background: #ef4444;
	box-shadow: 0 0 6px rgba(239, 68, 68, 0.9);
	z-index: 2;
}

.cct-marker-red-dot::after {
	content: '';
	position: absolute;
	top: 50%;
	left: 50%;
	width: 10px;
	height: 10px;
	margin: -5px 0 0 -5px;
	border-radius: 50%;
	border: 2px solid rgba(239, 68, 68, 0.6);
	animation: cct-ripple 1.5s infinite ease-out;
	pointer-events: none;
}

@keyframes cct-ripple {
	0% {
		width: 10px;
		height: 10px;
		margin: -5px 0 0 -5px;
		opacity: 1;
		border-color: rgba(239, 68, 68, 0.6);
	}
	100% {
		width: 40px;
		height: 40px;
		margin: -20px 0 0 -20px;
		opacity: 0;
		border-color: rgba(239, 68, 68, 0);
	}
}

/* In Transit / Out for Delivery: blue flickering beacon around the vehicle */
.cct-marker-transit {
	width: 58px !important;
	height: 58px !important;
}

.cct-marker-container.cct-marker-transit-wrap {
	position: relative;
	width: 58px;
	height: 58px;
	display: flex;
	align-items: center;
	justify-content: center;
}

.cct-marker-container.cct-marker-transit-wrap .cct-vehicle-img-wrap,
.cct-marker-container.cct-marker-transit-wrap .cct-vehicle-svg-wrap {
	position: relative;
	z-index: 2;
}

.cct-marker-container.cct-marker-transit-wrap .flickering-blue-ring {
	position: absolute;
	top: 50%;
	left: 50%;
	width: 52px;
	height: 52px;
	margin: -26px 0 0 -26px;
	border-radius: 50%;
	border: 2px solid rgba(37, 99, 235, 0.85);
	z-index: 1;
	pointer-events: none;
	box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.75);
	animation: cct-alert-flash-blue 1.2s infinite ease-out;
}

.cct-marker-container.cct-marker-transit-wrap .flickering-blue-dot {
	position: absolute;
	top: 4px;
	right: 2px;
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: rgba(37, 99, 235, 1);
	z-index: 3;
	pointer-events: none;
	box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.85);
	animation: cct-alert-flash-blue 1.2s infinite ease-out;
}

@keyframes cct-alert-flash-blue {
	0% {
		box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.85);
		opacity: 1;
	}
	100% {
		box-shadow: 0 0 0 12px rgba(37, 99, 235, 0);
		opacity: 0.85;
	}
}

.cct-client-dashboard { max-width: 1000px; margin: 0 auto; }
.cct-client-table { width: 100%; border-collapse: collapse; margin-top: 16px; }
.cct-client-table th, .cct-client-table td {
	padding: 10px 12px;
	border: 1px solid #e2e8f0;
	text-align: left;
}
.cct-client-table th { background: #f8fafc; }
.cct-track-link { color: #2563eb; text-decoration: none; font-weight: 600; }
.cct-track-link:hover { text-decoration: underline; }
.cct-notice { padding: 12px 16px; background: #f1f5f9; border-radius: 6px; }

.screen-reader-text {
	clip: rect(1px,1px,1px,1px);
	position: absolute !important;
	height: 1px; width: 1px;
	overflow: hidden;
}

/* Hide only known third-party map blockers inside the vault */
#cct-map-vault .cct-map-overlay,
#cct-map-vault .wpc-map-overlay,
#cct-map-vault .map-status-overlay,
#cct-map-vault .cct-status-alert,
#cct-map-vault .cct-map-vault-blocker {
	display: none !important;
}

/* Client-side map tile diagnostics overlay */
.cct-map-diagnostics {
	display: none;
	position: absolute;
	left: 10px;
	bottom: 10px;
	z-index: 1200;
	max-width: calc(100% - 20px);
	padding: 8px 12px;
	border-radius: 6px;
	font-size: 12px;
	line-height: 1.4;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
	background: rgba(15, 23, 42, 0.88);
	color: #f8fafc;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
	pointer-events: none;
}

.cct-map-diagnostics.is-visible {
	display: block;
}

.cct-map-diagnostics.is-ok {
	background: rgba(21, 128, 61, 0.92);
}

.cct-map-diagnostics.is-info {
	background: rgba(30, 64, 175, 0.92);
}

.cct-map-diagnostics.is-warn {
	background: rgba(180, 83, 9, 0.92);
}

.cct-map-diagnostics.is-error {
	background: rgba(185, 28, 28, 0.92);
}

/* Map type switcher (Roadmap / Satellite / Terrain / Hybrid) */
#cct-map-vault .cct-map-type-control {
	position: relative;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
	box-shadow: 0 1px 4px rgba(0, 0, 0, 0.28);
	border-radius: 4px;
	overflow: visible;
}

#cct-map-vault .cct-map-type-toggle {
	display: flex;
	align-items: center;
	gap: 4px;
	padding: 8px 12px;
	border: none;
	border-radius: 4px;
	background: #fff;
	color: #202124;
	font-size: 13px;
	font-weight: 500;
	cursor: pointer;
	line-height: 1.2;
	min-width: 108px;
}

#cct-map-vault .cct-map-type-toggle:hover {
	background: #f8f9fa;
}

#cct-map-vault .cct-map-type-chevron {
	font-size: 11px;
	color: #5f6368;
	margin-left: auto;
}

#cct-map-vault .cct-map-type-panel {
	display: none;
	position: absolute;
	top: calc(100% + 6px);
	right: 0;
	min-width: 140px;
	background: #fff;
	border-radius: 4px;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.22);
	padding: 6px;
	z-index: 1001;
}

#cct-map-vault .cct-map-type-panel.is-open {
	display: flex;
	flex-direction: column;
	gap: 2px;
}

#cct-map-vault .cct-map-type-option {
	display: block;
	width: 100%;
	padding: 8px 10px;
	border: none;
	border-radius: 3px;
	background: transparent;
	color: #3c4043;
	font-size: 13px;
	text-align: left;
	cursor: pointer;
}

#cct-map-vault .cct-map-type-option:hover {
	background: #f1f3f4;
}

#cct-map-vault .cct-map-type-option.is-active {
	background: #e8f0fe;
	color: #1a73e8;
	font-weight: 600;
}

#cct-map-vault .leaflet-control-attribution {
	font-size: 10px;
	max-width: calc(100% - 120px);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}
