/*--------------------------------------------------------------
# Tecsys Portal — My Account (company info + read-only addresses)
--------------------------------------------------------------*/
:root {
	--tp-gap: 1rem;
	--tp-accent: #0066cc;
	--tp-radius: 8px;
	--tp-border: 1px solid #e0e0e0;
	--tp-muted: #646970;
	--tp-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

/* --- Notes --------------------------------------------------- */
.tp-addresses-note {
	color: var(--tp-muted);
	font-size: 0.9em;
	margin-bottom: var(--tp-gap);
}

/* --- Company information ------------------------------------- */
.tp-company-header {
	display: flex;
	align-items: center;
	gap: 0.75rem;
	flex-wrap: wrap;
	margin-bottom: var(--tp-gap);
}

.tp-company-name {
	margin: 0;
}

.tp-company-meta {
	display: grid;
	grid-template-columns: max-content 1fr;
	gap: 0.35rem 1.25rem;
	margin: 0 0 2rem;
}

.tp-company-meta dt {
	color: var(--tp-muted);
	font-size: 0.8em;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	align-self: center;
}

.tp-company-meta dd {
	margin: 0;
	font-weight: 500;
}

.tp-company-addresses h3 {
	margin-bottom: 0.35rem;
}

/* --- Address grid + cards ------------------------------------ */
.tp-address-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
	gap: var(--tp-gap);
	margin-bottom: var(--tp-gap);
}

.tp-address-card {
	border: var(--tp-border);
	border-radius: var(--tp-radius);
	background: #fff;
	box-shadow: var(--tp-shadow);
	padding: var(--tp-gap);
}

.tp-address-card--default-billing {
	border-left: 4px solid #2271b1;
}

.tp-address-card--default-shipping {
	border-left: 4px solid #00a32a;
}

.tp-address-badges {
	display: flex;
	align-items: center;
	gap: 6px;
	margin-bottom: 0.5rem;
}

.tp-address-name {
	display: block;
	font-weight: 600;
	margin-bottom: 0.35rem;
}

.tp-address-lines {
	line-height: 1.6;
}

.tp-address-meta {
	display: grid;
	grid-template-columns: max-content 1fr;
	gap: 0.2rem 0.75rem;
	margin: 0.75rem 0 0;
	padding-top: 0.6rem;
	border-top: 1px solid #f0f0f1;
	font-size: 0.85em;
}

.tp-address-meta dt {
	color: var(--tp-muted);
	text-transform: uppercase;
	letter-spacing: 0.03em;
}

.tp-address-meta dd {
	margin: 0;
}

/* --- Badges -------------------------------------------------- */
.tp-badge {
	display: inline-block;
	padding: 2px 8px;
	border-radius: 999px;
	font-size: 0.72em;
	font-weight: 600;
	line-height: 1.6;
	border: 1px solid transparent;
}

.tp-badge--billing  { background: #eef4fb; color: #0a4b78; border-color: #b3d3f0; }
.tp-badge--shipping { background: #edfaef; color: #00650e; border-color: #b8e6bf; }
.tp-badge--default  { background: #f6f7f7; color: #1d2327; border-color: #c3c4c7; }
.tp-badge--active   { background: #edfaef; color: #00650e; border-color: #b8e6bf; }
.tp-badge--hold     { background: #fcf0ef; color: #8a2424; border-color: #f5c6c6; }
.tp-badge--inactive { background: #f6f7f7; color: #646970; border-color: #dcdcde; }
/* Cancelled orders — admin stage_modifier() emits `expired`. */
.tp-badge--expired  { background: #fcf0ef; color: #8a2424; border-color: #f5c6c6; }

/* Native WooCommerce order statuses (Online Orders tab). */
.tp-badge--completed  { background: #edfaef; color: #00650e; border-color: #b8e6bf; }
.tp-badge--processing { background: #eef4fb; color: #0a4b78; border-color: #b3d3f0; }
.tp-badge--on-hold    { background: #fdf6e6; color: #8a6100; border-color: #f0dca6; }
.tp-badge--pending    { background: #f6f7f7; color: #646970; border-color: #dcdcde; }
.tp-badge--cancelled,
.tp-badge--failed,
.tp-badge--refunded   { background: #fcf0ef; color: #8a2424; border-color: #f5c6c6; }

/*--------------------------------------------------------------
# Tecsys Portal — Order History + Online Orders
--------------------------------------------------------------*/
/* Filter form */
.tp-order-filters {
	display: flex;
	flex-wrap: wrap;
	align-items: flex-end;
	gap: 0.75rem 1rem;
	margin-bottom: 1.5rem;
	padding: var(--tp-gap);
	border: var(--tp-border);
	border-radius: var(--tp-radius);
	background: #fafafa;
}

.tp-filter-field {
	display: flex;
	flex-direction: column;
	gap: 0.25rem;
	margin: 0;
}

.tp-filter-field label {
	font-size: 0.75em;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	color: var(--tp-muted);
}

.tp-filter-field input,
.tp-filter-field select {
	min-width: 9rem;
	padding: 0.35rem 0.5rem;
	border: var(--tp-border);
	border-radius: var(--tp-radius);
	background: #fff;
}

.tp-filter-actions {
	display: flex;
	align-items: center;
	gap: 0.75rem;
	margin: 0;
}

.tp-filter-reset {
	font-size: 0.9em;
	color: var(--tp-muted);
}

/* Order tables */
.tp-orders-table,
.tp-order-items,
.tp-order-totals {
	width: 100%;
	border-collapse: collapse;
}

.tp-orders-table th,
.tp-orders-table td,
.tp-order-items th,
.tp-order-items td {
	padding: 0.6rem 0.75rem;
	border-bottom: 1px solid #f0f0f1;
	text-align: left;
	vertical-align: top;
}

.tp-orders-table thead th,
.tp-order-items thead th {
	font-size: 0.78em;
	text-transform: uppercase;
	letter-spacing: 0.03em;
	color: var(--tp-muted);
	border-bottom: var(--tp-border);
}

.tp-orders-table tbody tr:hover {
	background: #fafafa;
}

.tp-num {
	text-align: right !important;
	white-space: nowrap;
}

.tp-currency {
	color: var(--tp-muted);
	font-size: 0.85em;
}

.tp-line-sku {
	display: block;
	color: var(--tp-muted);
	font-size: 0.82em;
}

/* Detail view */
.tp-order-back {
	margin-bottom: 0.75rem;
}

.tp-order-detail-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: var(--tp-gap);
	flex-wrap: wrap;
	margin-bottom: 1.25rem;
}

.tp-order-detail-header h2 {
	margin: 0;
}

.tp-order-rev {
	color: var(--tp-muted);
	font-size: 0.7em;
	font-weight: 400;
}

.tp-order-detail-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
	gap: var(--tp-gap);
	margin-bottom: 1.5rem;
}

.tp-order-info,
.tp-order-shipping {
	border: var(--tp-border);
	border-radius: var(--tp-radius);
	background: #fff;
	box-shadow: var(--tp-shadow);
	padding: var(--tp-gap);
}

.tp-order-info h3,
.tp-order-shipping h3,
.tp-order-lines h3 {
	margin: 0 0 0.75rem;
	font-size: 1rem;
}

.tp-order-info dl,
.tp-order-shipping dl {
	display: grid;
	grid-template-columns: max-content 1fr;
	gap: 0.35rem 1rem;
	margin: 0;
}

.tp-order-info dt,
.tp-order-shipping dt {
	color: var(--tp-muted);
	font-size: 0.8em;
	text-transform: uppercase;
	letter-spacing: 0.03em;
	align-self: center;
}

.tp-order-info dd,
.tp-order-shipping dd {
	margin: 0;
	font-weight: 500;
}

.tp-order-lines {
	margin-bottom: 1.5rem;
}

/* Totals — right-aligned block */
.tp-order-totals-wrap {
	display: flex;
	justify-content: flex-end;
}

.tp-order-totals {
	width: auto;
	min-width: 280px;
}

.tp-order-totals th,
.tp-order-totals td {
	padding: 0.35rem 0.75rem;
	text-align: left;
	font-weight: 400;
}

.tp-order-totals th {
	color: var(--tp-muted);
}

.tp-order-totals .tp-order-total th,
.tp-order-totals .tp-order-total td {
	border-top: var(--tp-border);
	padding-top: 0.6rem;
	font-weight: 700;
	color: #1d2327;
}

/* Reorder button, pagination, empty state */
.tp-reorder-form {
	margin: 0;
}

.tp-pagination {
	display: flex;
	align-items: center;
	gap: 1rem;
	margin-top: var(--tp-gap);
}

.tp-page-status {
	color: var(--tp-muted);
	font-size: 0.9em;
}

.tp-empty {
	padding: 1.25rem;
	color: var(--tp-muted);
	background: #fafafa;
	border: var(--tp-border);
	border-radius: var(--tp-radius);
	text-align: center;
}

/* Stacked tables on narrow screens */
@media (max-width: 600px) {
	.tp-orders-table thead,
	.tp-order-items thead {
		display: none;
	}

	.tp-orders-table tr,
	.tp-order-items tr {
		display: block;
		margin-bottom: var(--tp-gap);
		border: var(--tp-border);
		border-radius: var(--tp-radius);
		padding: 0.5rem;
	}

	.tp-orders-table td,
	.tp-order-items td {
		display: flex;
		justify-content: space-between;
		gap: 1rem;
		border-bottom: 1px solid #f0f0f1;
		text-align: right;
	}

	.tp-orders-table td::before,
	.tp-order-items td::before {
		content: attr(data-label);
		font-size: 0.78em;
		text-transform: uppercase;
		letter-spacing: 0.03em;
		color: var(--tp-muted);
		text-align: left;
	}

	.tp-num {
		text-align: right !important;
	}
}

/*--------------------------------------------------------------
# Tecsys Portal — Checkout (company address selection)
--------------------------------------------------------------*/
.tp-checkout-addresses {
	margin-bottom: calc(var(--tp-gap) * 1.5);
}

.tp-checkout-address-block {
	margin-bottom: var(--tp-gap);
}

.tp-checkout-address-heading {
	margin: 0 0 0.35rem;
	font-size: 1.05rem;
}

/* Selectable shipping cards (radio-driven). */
.tp-address-grid--selectable .tp-address-card--selectable {
	position: relative;
	display: block;
	cursor: pointer;
	padding-left: 2.5rem;
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.tp-address-card--selectable .tp-address-radio {
	position: absolute;
	top: var(--tp-gap);
	left: var(--tp-gap);
	margin: 0;
}

/* Highlight the chosen card (no JS: :has on the checked radio). */
.tp-address-card--selectable:hover {
	border-color: var(--tp-accent);
}

.tp-address-card--selectable.is-selected,
.tp-address-card--selectable:has(.tp-address-radio:checked) {
	border-color: var(--tp-accent);
	box-shadow: 0 0 0 2px rgba(0, 102, 204, 0.25);
}

/* Company-checkout: the panel supplies its own "Billing address" / "Shipping
   address" headings, so hide WooCommerce's now-redundant "Billing details"
   heading and any shipping-toggle remnant. */
.tecsys-company-checkout .woocommerce-billing-fields > h3,
.tecsys-company-checkout #ship-to-different-address,
.tecsys-company-checkout .woocommerce-shipping-fields > h3 {
	display: none;
}

/* Give the email field a little breathing room below the address panel. */
.tecsys-company-checkout .tp-checkout-addresses {
	margin-top: 0.5rem;
}

/* PO Number field: the theme hides native checkout labels, so this field renders
   its own visible label (outside the .form-row) to make it stand out under
   "Additional information". */
.tp-po-number {
	margin-top: 1rem;
}

.tp-po-number-label {
	display: block;
	font-weight: 600;
	margin-bottom: 0.35rem;
}
