/**
 * Public styles for anhqui Tiered Pricing.
 * Uses CSS custom properties driven by inline styles set per-product.
 */

/* =========================================================
   Custom properties (defaults — overridden by inline style)
   ========================================================= */
:root {
	--stp-highlight: #7c3aed;
	--stp-highlight-text: #ffffff;
	--stp-header-bg: #f8f8f8;
	--stp-header-text: #6b7280;
	--stp-border: #e5e7eb;
	--stp-text: #374151;
	--stp-muted: #6b7280;
	--stp-radius: 8px;
	--stp-font-size: 14px;
	/* Pre-computed alpha tints — overridden by inline style via STP_Helpers::build_inline_style() */
	--stp-highlight-tint5: rgba(124, 58, 237, 0.05);
	--stp-highlight-tint8: rgba(124, 58, 237, 0.08);
	--stp-highlight-tint12: rgba(124, 58, 237, 0.12);
	--stp-highlight-tint20: rgba(124, 58, 237, 0.20);
}

/* =========================================================
   Wrapper
   ========================================================= */
.stp-pricing-wrapper {
	margin: 20px 0;
	font-size: var(--stp-font-size);
	font-family: inherit;
}

/* =========================================================
   Template switcher tabs (shown when shortcode uses multiple)
   ========================================================= */
.stp-template-tabs {
	display: flex;
	gap: 2px;
	margin-bottom: -1px;
}

.stp-template-tab {
	padding: 8px 18px;
	border: 1px solid var(--stp-border);
	border-radius: 6px 6px 0 0;
	cursor: pointer;
	background: #f9fafb;
	color: var(--stp-muted);
	font-size: 13px;
	transition: all 0.15s;
}

.stp-template-tab.active,
.stp-template-tab:hover {
	background: #fff;
	color: var(--stp-highlight);
	border-bottom-color: #fff;
}

/* =========================================================
   TABLE template
   ========================================================= */
.stp-table-wrap {
	border: 1px solid var(--stp-border);
	border-radius: var(--stp-radius);
	overflow: hidden;
}

.stp-table {
	width: 100%;
	border-collapse: collapse;
	font-size: var(--stp-font-size);
}

.stp-table thead tr {
	background: var(--stp-header-bg);
}

.stp-table thead th {
	padding: 10px 16px;
	text-align: left;
	font-size: 11px;
	font-weight: 600;
	letter-spacing: 0.7px;
	text-transform: uppercase;
	color: var(--stp-header-text);
	border-bottom: 1px solid var(--stp-border);
}

.stp-table thead th:last-child {
	text-align: right;
}

.stp-table tbody tr {
	border-bottom: 1px solid var(--stp-border);
	transition: background 0.15s;
}

.stp-table tbody tr:last-child {
	border-bottom: none;
}

.stp-table tbody tr:hover {
	background: #fafaf9;
}

.stp-table td {
	padding: 12px 16px 12px 15px;
	color: var(--stp-text);
}

.stp-table td:last-child {
	text-align: right;
	font-weight: 600;
}

.stp-table td.stp-td-discount {
	color: var(--stp-highlight);
	font-weight: 600;
}

/* Active / highlighted tier */

.stp-table tbody tr.stp-tier-active td {
	font-weight: 600;
	background-color: none;
	padding-left: 15px !important;
}

/* Selected tier summary */
.stp-selected-summary {
	display: flex;
	align-items: center;
	justify-content: space-between;
	border: 2px solid var(--stp-highlight);
	border-radius: 0 0 var(--stp-radius) var(--stp-radius);
	padding: 12px 16px;
	background: var(--stp-highlight-tint5);
	margin-top: -1px;
}

.stp-selected-summary.stp-hidden {
	display: none;
}

.stp-selected-label {
	font-size: 12px;
	color: var(--stp-muted);
	margin-bottom: 2px;
}

.stp-selected-tier-name {
	font-weight: 700;
	font-size: 15px;
	color: var(--stp-text);
}

.stp-selected-price-label {
	font-size: 12px;
	color: var(--stp-muted);
	text-align: right;
	margin-bottom: 2px;
}

.stp-selected-price-value {
	font-size: 22px;
	font-weight: 700;
	color: var(--stp-highlight);
	text-align: right;
}

/* =========================================================
   BLOCKS template
   ========================================================= */
.stp-blocks-wrap {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
	gap: 10px;
}

.stp-block-item {
	border: 2px solid var(--stp-border);
	border-radius: var(--stp-radius);
	padding: 14px 12px;
	text-align: center;
	cursor: default;
	transition: border-color 0.2s, transform 0.15s;
}

.stp-block-item:hover {
	border-color: var(--stp-highlight);
}

.stp-block-item.stp-tier-active {
	border-color: var(--stp-highlight);
	background: var(--stp-highlight-tint8);
	transform: translateY(-2px);
	box-shadow: 0 4px 12px rgba(0, 0, 0, .08);
}

.stp-block-qty {
	font-size: 13px;
	color: var(--stp-muted);
	margin-bottom: 6px;
}

.stp-block-price {
	font-size: 18px;
	font-weight: 700;
	color: var(--stp-text);
}

.stp-block-item.stp-tier-active .stp-block-price {
	color: var(--stp-highlight);
}

.stp-block-discount {
	font-size: 12px;
	font-weight: 600;
	color: var(--stp-highlight);
	margin-top: 4px;
}

/* =========================================================
   LIST template
   ========================================================= */
.stp-list-wrap {
	border: 1px solid var(--stp-border);
	border-radius: var(--stp-radius);
	overflow: hidden;
}

.stp-list-item {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 12px 16px;
	border-bottom: 1px solid var(--stp-border);
	transition: background 0.15s;
}

.stp-list-item:last-child {
	border-bottom: none;
}

.stp-list-item:hover {
	background: #fafafa;
}

.stp-list-item.stp-tier-active {
	background: var(--stp-highlight-tint8);
	border-left: 3px solid var(--stp-highlight);
}

.stp-list-qty {
	color: var(--stp-text);
	font-size: 14px;
}

.stp-list-right {
	display: flex;
	align-items: center;
	gap: 16px;
}

.stp-list-discount {
	color: var(--stp-highlight);
	font-weight: 600;
	font-size: 13px;
}

.stp-list-price {
	font-weight: 700;
	font-size: 15px;
	color: var(--stp-text);
	min-width: 70px;
	text-align: right;
}

.stp-list-item.stp-tier-active .stp-list-price {
	color: var(--stp-highlight);
}

/* =========================================================
   DROPDOWN template
   ========================================================= */
.stp-dropdown-wrap label {
	display: block;
	font-weight: 600;
	margin-bottom: 6px;
	color: var(--stp-text);
	font-size: 13px;
}

.stp-dropdown-select {
	width: 100%;
	padding: 10px 14px;
	border: 1px solid var(--stp-border);
	border-radius: 6px;
	font-size: 14px;
	color: var(--stp-text);
	background: #fff;
	appearance: none;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%236b7280' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right 14px center;
	cursor: pointer;
	transition: border-color 0.15s;
}

.stp-dropdown-select:focus {
	outline: none;
	border-color: var(--stp-highlight);
	box-shadow: 0 0 0 2px var(--stp-highlight-tint20);
}

.stp-dropdown-price-display {
	margin-top: 12px;
	padding: 12px 16px;
	border: 1px solid var(--stp-border);
	border-radius: 6px;
	display: flex;
	justify-content: space-between;
	align-items: center;
}

.stp-dropdown-price-label {
	color: var(--stp-muted);
	font-size: 13px;
}

.stp-dropdown-price-value {
	font-size: 20px;
	font-weight: 700;
	color: var(--stp-highlight);
}

/* =========================================================
   TOOLTIP template
   ========================================================= */
.stp-tooltip-wrap {
	display: inline-block;
	position: relative;
}

.stp-tooltip-trigger {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	cursor: pointer;
	border-bottom: 1px dashed var(--stp-highlight);
	color: var(--stp-highlight);
}

.stp-tooltip-trigger svg {
	width: 14px;
	height: 14px;
	fill: var(--stp-highlight);
}

.stp-tooltip-box {
	position: absolute;
	bottom: calc(100% + 8px);
	left: 50%;
	transform: translateX(-50%);
	background: #1f2937;
	color: #fff;
	border-radius: 8px;
	padding: 12px 16px;
	min-width: 220px;
	z-index: 100;
	box-shadow: 0 8px 24px rgba(0, 0, 0, .18);
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.2s;
}

.stp-tooltip-wrap:hover .stp-tooltip-box,
.stp-tooltip-wrap:focus-within .stp-tooltip-box {
	opacity: 1;
	pointer-events: auto;
}

.stp-tooltip-box::after {
	content: '';
	position: absolute;
	top: 100%;
	left: 50%;
	transform: translateX(-50%);
	border: 6px solid transparent;
	border-top-color: #1f2937;
}

.stp-tooltip-row {
	display: flex;
	justify-content: space-between;
	gap: 16px;
	padding: 4px 0;
	font-size: 13px;
	border-bottom: 1px solid rgba(255, 255, 255, .1);
}

.stp-tooltip-row:last-child {
	border-bottom: none;
}

.stp-tooltip-row.stp-tier-active {
	color: var(--stp-highlight);
	font-weight: 700;
}

/* =========================================================
   Cart upsell message
   ========================================================= */
.stp-cart-upsell {
	font-size: 12px;
	color: var(--stp-highlight);
	margin-top: 4px;
	margin-bottom: 8px;
	font-style: italic;
	display: block;
}

.stp-cart-upsell-wrap {
	display: flex;
	flex-direction: column;
	gap: 8px;
	margin-top: 8px;
}

/* =========================================================
   You Save badge
   ========================================================= */
.stp-you-save {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	background: var(--stp-highlight-tint12);
	color: var(--stp-highlight);
	padding: 2px 8px;
	border-radius: 20px;
	font-size: 12px;
	font-weight: 600;
	margin-top: 8px;
}

/* =========================================================
   Responsive
   ========================================================= */
@media (max-width: 600px) {

	.stp-table thead th,
	.stp-table td {
		padding: 10px 10px 10px 15px;
		font-size: 13px;
	}

	.stp-blocks-wrap {
		grid-template-columns: repeat(2, 1fr);
	}

	.stp-selected-summary {
		flex-direction: column;
		align-items: flex-start;
		gap: 8px;
	}

	.stp-selected-price-label,
	.stp-selected-price-value {
		text-align: left;
	}
}