/**
 * Custom Order Tracking - front-end & admin styles.
 * Brand color is injected as CSS custom properties via wp_add_inline_style().
 */

:root {
	--cot-brand-color: #2e8b57;
	--cot-brand-color-soft: #2e8b5726;
	--cot-brand-color-dark: #256e46;
	--cot-completed-color: #2e9e5b;
	--cot-pending-color: #b9c0c7;
	--cot-text-color: #1f2937;
	--cot-muted-color: #6b7280;
	--cot-border-color: #e5e7eb;
	--cot-card-bg: #ffffff;
	--cot-page-bg: #f7f8fa;
	--cot-danger-color: #dc2626;
}

* {
	box-sizing: border-box;
}

.cot-tracking-wrapper {
	max-width: 640px;
	margin: 0 auto;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	color: var(--cot-text-color);
}

.cot-tracking-card {
	background: var(--cot-card-bg);
	border: 1px solid var(--cot-border-color);
	border-radius: 18px;
	padding: 28px 26px;
	box-shadow: 0 4px 24px rgba(17, 24, 39, 0.06);
}

.cot-tracking-header {
	text-align: center;
	margin-bottom: 24px;
}

.cot-header-icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 52px;
	height: 52px;
	border-radius: 50%;
	background: var(--cot-brand-color-soft);
	color: var(--cot-brand-color);
	margin-bottom: 12px;
}

.cot-tracking-title {
	margin: 0 0 6px;
	font-size: 21px;
	font-weight: 700;
	letter-spacing: -0.01em;
}

.cot-tracking-subtitle {
	margin: 0;
	font-size: 13.5px;
	color: var(--cot-muted-color);
	line-height: 1.5;
}

.cot-form-row {
	margin-bottom: 16px;
	display: flex;
	flex-direction: column;
	gap: 7px;
}

.cot-form-row label {
	font-weight: 600;
	font-size: 13px;
}

.cot-input-group {
	position: relative;
	display: flex;
	align-items: center;
}

.cot-input-icon {
	position: absolute;
	left: 13px;
	display: flex;
	align-items: center;
	justify-content: center;
	color: var(--cot-muted-color);
	pointer-events: none;
	transition: color 0.15s ease;
}

.cot-input-group input {
	padding: 12px 14px 12px 42px;
	border: 1.5px solid var(--cot-border-color);
	border-radius: 11px;
	font-size: 15px;
	width: 100%;
	background: #fbfbfc;
	transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.cot-input-group input:hover {
	border-color: #d1d5db;
}

.cot-input-group input:focus {
	outline: none;
	border-color: var(--cot-brand-color);
	background: #fff;
	box-shadow: 0 0 0 4px var(--cot-brand-color-soft);
}

.cot-input-group:focus-within .cot-input-icon {
	color: var(--cot-brand-color);
}

.cot-submit-btn {
	position: relative;
	width: 100%;
	background: var(--cot-brand-color);
	color: #fff;
	border: none;
	border-radius: 11px;
	padding: 13px 16px;
	font-size: 15px;
	font-weight: 700;
	letter-spacing: 0.01em;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	margin-top: 4px;
	transition: background 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
	box-shadow: 0 2px 8px rgba(46, 139, 87, 0.28);
}

.cot-submit-btn:hover {
	background: var(--cot-brand-color-dark);
	box-shadow: 0 4px 14px rgba(46, 139, 87, 0.34);
}

.cot-submit-btn:active {
	transform: translateY(1px);
}

.cot-submit-btn:disabled {
	opacity: 0.75;
	cursor: not-allowed;
	transform: none;
}

.cot-btn-spinner {
	display: none;
	width: 16px;
	height: 16px;
	border: 2px solid rgba(255, 255, 255, 0.4);
	border-top-color: #fff;
	border-radius: 50%;
	animation: cot-spin 0.7s linear infinite;
}

.cot-submit-btn.is-loading .cot-btn-spinner {
	display: inline-block;
}

@keyframes cot-spin {
	to {
		transform: rotate(360deg);
	}
}

@media (prefers-reduced-motion: reduce) {
	.cot-btn-spinner {
		animation-duration: 1.4s;
	}
}

.cot-form-message {
	margin-top: 12px;
	font-size: 13.5px;
	min-height: 1em;
	text-align: center;
}

.cot-form-message.is-error {
	color: var(--cot-danger-color);
	animation: cot-shake 0.3s ease;
}

@keyframes cot-shake {
	0%, 100% { transform: translateX(0); }
	25% { transform: translateX(-4px); }
	75% { transform: translateX(4px); }
}

.cot-result {
	margin-top: 20px;
}

.cot-result:empty {
	margin-top: 0;
}

.cot-result > * {
	animation: cot-fade-in 0.35s ease;
}

@keyframes cot-fade-in {
	from {
		opacity: 0;
		transform: translateY(8px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

.cot-timeline-card {
	background: var(--cot-card-bg);
	border: 1px solid var(--cot-border-color);
	border-radius: 14px;
	padding: 20px;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.cot-order-summary {
	display: grid;
	grid-template-columns: repeat(2, 1fr);
	gap: 12px;
	margin-bottom: 22px;
	padding-bottom: 16px;
	border-bottom: 1px solid var(--cot-border-color);
}

.cot-summary-item {
	display: flex;
	flex-direction: column;
	gap: 2px;
}

.cot-summary-label {
	font-size: 12px;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	color: var(--cot-muted-color);
}

.cot-summary-value {
	font-size: 15px;
	font-weight: 600;
}

.cot-status-badge {
	display: inline-block;
	padding: 3px 10px;
	border-radius: 999px;
	background: var(--cot-brand-color-soft);
	color: var(--cot-brand-color);
	font-size: 13px;
	width: fit-content;
}

.cot-halted-notice {
	display: flex;
	align-items: flex-start;
	gap: 10px;
	background: #fef2f2;
	border: 1px solid #fecaca;
	color: var(--cot-danger-color);
	border-radius: 10px;
	padding: 14px;
}

.cot-halt-icon {
	flex-shrink: 0;
	margin-top: 2px;
}

/* Timeline - vertical stack (mobile default) */
.cot-timeline {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-direction: column;
}

/*
 * Mobile timeline (default): icon on the left with a connecting line,
 * label and date/time stacked to its right.
 */
.cot-timeline-step {
	display: flex;
	align-items: flex-start;
	gap: 14px;
	position: relative;
	padding-bottom: 26px;
}

.cot-timeline-step:last-child {
	padding-bottom: 0;
}

.cot-timeline-step::before {
	content: "";
	position: absolute;
	left: 13px;
	top: 28px;
	bottom: 0;
	width: 2px;
	background: var(--cot-border-color);
}

.cot-timeline-step:last-child::before {
	display: none;
}

.cot-timeline-step.cot-step-completed::before {
	background: var(--cot-completed-color);
}

.cot-step-icon {
	flex-shrink: 0;
	width: 28px;
	height: 28px;
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	background: var(--cot-pending-color);
	color: #fff;
	z-index: 1;
}

.cot-step-pending .cot-step-icon {
	background: #fff;
	color: var(--cot-pending-color);
	border: 2px solid var(--cot-pending-color);
}

.cot-step-active .cot-step-icon {
	background: var(--cot-brand-color);
	color: #fff;
	box-shadow: 0 0 0 4px var(--cot-brand-color-soft);
}

.cot-step-completed .cot-step-icon {
	background: var(--cot-completed-color);
	color: #fff;
}

.cot-step-content {
	display: flex;
	flex-direction: column;
	gap: 2px;
	padding-top: 3px;
}

.cot-step-label {
	font-weight: 600;
	font-size: 14.5px;
}

.cot-step-active .cot-step-label {
	color: var(--cot-brand-color);
}

.cot-step-pending .cot-step-label {
	color: var(--cot-muted-color);
}

.cot-step-time {
	font-size: 12.5px;
	color: var(--cot-muted-color);
}

/* Desktop: horizontal timeline */
@media (min-width: 640px) {
	.cot-timeline {
		flex-direction: row;
		justify-content: space-between;
	}

	.cot-timeline-step {
		flex-direction: column;
		align-items: center;
		text-align: center;
		flex: 1;
		padding-bottom: 0;
		padding-right: 8px;
	}

	.cot-timeline-step::before {
		left: 50%;
		top: 13px;
		right: -50%;
		bottom: auto;
		width: auto;
		height: 2px;
	}

	.cot-order-summary {
		grid-template-columns: repeat(4, 1fr);
	}
}

.cot-btn-icon {
	display: inline-flex;
	line-height: 0;
}

/* Order items */
.cot-order-items {
	margin-top: 24px;
	padding-top: 18px;
	border-top: 1px solid var(--cot-border-color);
}

.cot-section-title {
	margin: 0 0 12px;
	font-size: 14px;
	font-weight: 700;
}

.cot-item-list {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 12px;
}

.cot-item-row {
	display: flex;
	align-items: center;
	gap: 12px;
}

.cot-item-thumb {
	flex-shrink: 0;
	width: 48px;
	height: 48px;
	border-radius: 8px;
	overflow: hidden;
	border: 1px solid var(--cot-border-color);
	display: flex;
	align-items: center;
	justify-content: center;
}

.cot-item-thumb img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.cot-item-info {
	flex: 1;
	display: flex;
	flex-direction: column;
	gap: 2px;
	min-width: 0;
}

.cot-item-name {
	font-size: 14px;
	font-weight: 600;
	overflow-wrap: anywhere;
}

.cot-item-qty {
	font-size: 12.5px;
	color: var(--cot-muted-color);
}

.cot-item-total {
	flex-shrink: 0;
	font-size: 14px;
	font-weight: 600;
	white-space: nowrap;
}

/* Helpline */
.cot-helpline {
	margin-top: 20px;
	padding-top: 16px;
	border-top: 1px solid var(--cot-border-color);
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 6px;
	font-size: 13.5px;
	color: var(--cot-muted-color);
}

.cot-helpline a {
	color: var(--cot-brand-color);
	font-weight: 700;
	text-decoration: none;
}

.cot-helpline a:hover {
	text-decoration: underline;
}

/* Admin metabox */
.cot-admin-metabox .cot-history-table {
	margin-top: 8px;
	font-size: 12.5px;
}

.cot-admin-metabox .cot-history-table th,
.cot-admin-metabox .cot-history-table td {
	padding: 6px 8px;
}

.cot-admin-metabox .cot-status-badge {
	margin-top: 4px;
}
