/**
 * Tiered pricing table - frontend (product page)
 * Design from reference: rounded rectangular blocks, white cards,
 * light grey border (inactive), blue border (active tier), bold blue price.
 */

.tpuds-tiered-table-wrap {
	margin: 0.85em 0;
	clear: both;
}

.tpuds-tiered-table-wrap .tpuds-table-heading {
	margin-bottom: 0.5em;
	font-size: 0.9em;
	font-weight: 600;
}

.tpuds-tiered-table-wrap .tpuds-tiered-table {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	align-items: stretch;
}

/* Compact blocks - smaller cards, less visual weight */
.tpuds-tiered-table-wrap .tpuds-tier-card {
	flex: 1;
	min-width: 90px;
	max-width: 160px;
	padding: 8px 12px;
	background: var(--tpuds-card-bg, #fff) !important;
	border: 1px solid #e0e0e0 !important;
	border-radius: var(--tpuds-radius, 8px) !important;
	transition: border-color 0.2s ease, box-shadow 0.2s ease;
	box-shadow: none !important;
}

.tpuds-tiered-table-wrap .tpuds-tier-card.tpuds-tier-card-btn {
	display: flex;
	flex-direction: column;
	align-items: stretch;
	text-align: left;
	cursor: pointer;
	font: inherit;
	width: 100%;
}
.tpuds-tiered-table-wrap .tpuds-tier-card.tpuds-tier-card-btn:hover {
	background: #f8f8f8 !important;
}
.tpuds-tiered-table-wrap .tpuds-tier-card.tpuds-tier-card-btn:focus {
	outline: 2px solid var(--tpuds-primary, #2171b1);
	outline-offset: 2px;
}

/* Active tier: prominent border (primary color) */
.tpuds-tiered-table-wrap .tpuds-tier-card.tpuds-tier-active,
.tpuds-tiered-table-wrap .tpuds-tier-row.tpuds-tier-active {
	border: 2px solid var(--tpuds-primary, #2171b1) !important;
	box-shadow: 0 0 0 1px var(--tpuds-primary, #2171b1) !important;
}

.tpuds-tiered-table-wrap .tpuds-tier-label {
	font-size: 0.78em;
	color: #555;
	margin-bottom: 3px;
	line-height: 1.25;
	display: block;
}

.tpuds-tiered-table-wrap .tpuds-tier-price {
	font-size: 1.05em;
	font-weight: 700;
	color: var(--tpuds-primary, #2171b1);
	line-height: 1.3;
	display: block;
}

.tpuds-tiered-table-wrap .tpuds-tier-price .tpuds-tier-discount {
	font-size: 0.7em;
	font-weight: 400;
	color: #666;
	margin-left: 2px;
}
.tpuds-tiered-table-wrap .tpuds-tier-price .tpuds-tier-unit {
	display: block;
	font-size: 0.72em;
	font-weight: 400;
	color: #555;
	margin-top: 1px;
}
.tpuds-tiered-table-wrap .tpuds-tier-price .tpuds-tier-savings {
	display: block;
	font-size: 0.72em;
	font-weight: 500;
	color: #16a34a;
	margin-top: 1px;
}
.tpuds-tiered-table-wrap .tpuds-tier-badge {
	display: inline-block;
	font-size: 0.62em;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.02em;
	color: #fff;
	background: var(--tpuds-primary, #2171b1);
	padding: 1px 6px;
	border-radius: 3px;
	margin-bottom: 3px;
}
.tpuds-tiered-table-wrap .tpuds-tier-card.tpuds-tier-best-value {
	position: relative;
}
.tpuds-tiered-table-wrap .tpuds-tier-card.tpuds-tier-best-value .tpuds-tier-badge {
	margin-bottom: 6px;
}

/* Responsive: stack on small screens, keep rounded */
@media (max-width: 480px) {
	.tpuds-tiered-table-wrap .tpuds-tiered-table {
		flex-direction: column;
	}
	.tpuds-tiered-table-wrap .tpuds-tier-card {
		max-width: none;
		border-radius: var(--tpuds-radius, 12px) !important;
	}
}

/* Table template */
.tpuds-template-table .tpuds-tiered-table {
	display: table;
	width: 100%;
	max-width: 420px;
	border-collapse: separate;
	border-spacing: 0;
	border: 1px solid #e0e0e0;
	border-radius: var(--tpuds-radius, 12px);
	overflow: hidden;
}
.tpuds-template-table .tpuds-tiered-table th,
.tpuds-template-table .tpuds-tiered-table td {
	padding: 12px 14px;
	text-align: left;
	border-bottom: 1px solid #e0e0e0;
	background: var(--tpuds-card-bg, #fff);
}
.tpuds-template-table .tpuds-tiered-table thead th {
	background: #f5f5f5;
	font-weight: 600;
}
.tpuds-template-table .tpuds-tiered-table tbody tr:last-child td {
	border-bottom: none;
}
.tpuds-template-table .tpuds-tier-row.tpuds-tier-active td {
	border-color: var(--tpuds-primary, #2171b1);
	box-shadow: inset 0 0 0 2px var(--tpuds-primary, #2171b1);
}
.tpuds-template-table .tpuds-tier-clickable {
	cursor: pointer;
}
.tpuds-template-table .tpuds-tier-clickable:hover td {
	background: #f8f8f8;
}
.tpuds-template-table .tpuds-tier-price {
	color: var(--tpuds-primary, #2171b1);
	font-weight: 700;
}
.tpuds-template-table .tpuds-tier-row .tpuds-tier-badge {
	display: inline-block;
	margin-right: 6px;
}
.tpuds-template-table .tpuds-tier-savings-cell {
	color: #16a34a;
	font-weight: 500;
}

/* Compact template - inline chips */
.tpuds-template-compact .tpuds-tiered-table {
	display: inline-flex;
	flex-wrap: wrap;
	gap: 8px;
	align-items: center;
}
.tpuds-template-compact .tpuds-table-heading {
	display: inline;
	margin-right: 8px;
}
.tpuds-template-compact .tpuds-tier-chip {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 6px 12px;
	background: var(--tpuds-card-bg, #fff);
	border: 1px solid #e0e0e0;
	border-radius: 20px;
	font-size: 0.9em;
	cursor: pointer;
	transition: all 0.2s;
}
.tpuds-template-compact .tpuds-tier-chip:hover,
.tpuds-template-compact .tpuds-tier-chip.tpuds-tier-active {
	border-color: var(--tpuds-primary, #2171b1);
	background: rgba(33, 113, 177, 0.05);
}
.tpuds-template-compact .tpuds-tier-chip .tpuds-tier-price { margin-left: 4px; }

/* Minimal template - clean lines */
.tpuds-template-minimal .tpuds-tiered-table {
	display: flex;
	flex-direction: column;
	gap: 4px;
	max-width: 320px;
}
.tpuds-template-minimal .tpuds-tier-line {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 10px 14px;
	background: transparent;
	border: none;
	border-radius: var(--tpuds-radius, 8px);
	border-left: 3px solid transparent;
	cursor: pointer;
	width: 100%;
	text-align: left;
	font: inherit;
	transition: all 0.2s;
}
.tpuds-template-minimal .tpuds-tier-line:hover,
.tpuds-template-minimal .tpuds-tier-line.tpuds-tier-active {
	border-left-color: var(--tpuds-primary, #2171b1);
	background: rgba(33, 113, 177, 0.05);
}
.tpuds-template-minimal .tpuds-tier-discount { font-size: 0.8em; color: #666; margin-left: 8px; }

/* Gradient template */
.tpuds-template-gradient .tpuds-tier-card.tpuds-tier-gradient {
	background: linear-gradient(135deg, var(--tpuds-card-bg, #fff) 0%, #f8fafc 100%) !important;
}
.tpuds-template-gradient .tpuds-tier-card.tpuds-tier-active {
	background: linear-gradient(135deg, rgba(33, 113, 177, 0.08) 0%, rgba(33, 113, 177, 0.03) 100%) !important;
	border: 2px solid var(--tpuds-primary, #2171b1) !important;
}

/* Badge template */
.tpuds-template-badge .tpuds-tiered-table {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
}
.tpuds-template-badge .tpuds-tier-badge {
	display: flex;
	flex-direction: column;
	align-items: center;
	padding: 16px 20px;
	min-width: 100px;
	background: var(--tpuds-card-bg, #fff);
	border: 2px solid #e0e0e0;
	border-radius: var(--tpuds-radius, 12px);
	cursor: pointer;
	transition: all 0.2s;
}
.tpuds-template-badge .tpuds-tier-badge:hover,
.tpuds-template-badge .tpuds-tier-badge.tpuds-tier-active {
	border-color: var(--tpuds-primary, #2171b1);
	box-shadow: 0 4px 12px rgba(33, 113, 177, 0.2);
}
.tpuds-template-badge .tpuds-tier-badge-label { font-size: 0.85em; color: #555; }
.tpuds-template-badge .tpuds-tier-badge-price { font-size: 1.2em; font-weight: 700; color: var(--tpuds-primary, #2171b1); }
.tpuds-template-badge .tpuds-tier-badge-save { font-size: 0.75em; color: #22c55e; margin-top: 4px; }

/* List template */
.tpuds-template-list .tpuds-tiered-table {
	list-style: none;
	margin: 0;
	padding: 0;
	max-width: 380px;
}
.tpuds-template-list .tpuds-tiered-table li { margin: 0; }
.tpuds-template-list .tpuds-tier-list-item {
	display: flex;
	align-items: center;
	justify-content: space-between;
	width: 100%;
	padding: 12px 16px;
	margin-bottom: 4px;
	background: var(--tpuds-card-bg, #fff);
	border: 1px solid #e0e0e0;
	border-radius: var(--tpuds-radius, 8px);
	border-left: 4px solid transparent;
	cursor: pointer;
	text-align: left;
	font: inherit;
	transition: all 0.2s;
}
.tpuds-template-list .tpuds-tier-list-item:hover,
.tpuds-template-list .tpuds-tier-list-item.tpuds-tier-active {
	border-left-color: var(--tpuds-primary, #2171b1);
	background: rgba(33, 113, 177, 0.05);
}
.tpuds-template-list .tpuds-tier-discount { font-size: 0.8em; color: #666; margin-left: 8px; }

/* Active state for all new templates */
.tpuds-tier-chip.tpuds-tier-active,
.tpuds-tier-line.tpuds-tier-active,
.tpuds-tier-badge.tpuds-tier-active {
	border-color: var(--tpuds-primary, #2171b1) !important;
}

/* Cart message: same color as product page tier border */
.tpuds-cart-message {
	display: block;
	margin-top: 0.35em;
	color: var(--tpuds-primary, #2171b1);
	font-weight: 600;
}
.tpuds-mini-cart-message {
	font-size: 0.85em;
	margin-top: 0.2em;
}
