/*
 * Calculator front-end. Scoped under .bf-calc so it can't leak into the
 * theme; the custom properties below are the plugin's design tokens and are
 * reused by the values page later.
 */
.bf-calc {
	--bf-bg: #12141c;
	--bf-surface: #1a1d29;
	--bf-surface-2: #232738;
	--bf-border: #2e3348;
	--bf-text: #e8eaf2;
	--bf-text-dim: #9aa0b5;
	--bf-accent: #6c5ce7;
	--bf-accent-2: #00cec9;
	--bf-win: #00b894;
	--bf-lose: #e17055;
	--bf-fair: #fdcb6e;
	--bf-radius: 12px;

	color: var(--bf-text);
	background: var(--bf-bg);
	border-radius: var(--bf-radius);
	padding: 16px;
	font-size: 15px;
	line-height: 1.5;
}

.bf-calc *,
.bf-calc *::before,
.bf-calc *::after {
	box-sizing: border-box;
}

/* --- Layout: sides stack on mobile, split on tablet+ --- */

.bf-calc-sides {
	display: flex;
	flex-direction: column;
	gap: 12px;
}

.bf-calc-vs {
	text-align: center;
	font-weight: 800;
	color: var(--bf-text-dim);
	letter-spacing: 2px;
}

@media (min-width: 768px) {
	.bf-calc-sides {
		flex-direction: row;
		align-items: stretch;
	}
	.bf-calc-side {
		flex: 1;
	}
	.bf-calc-vs {
		align-self: center;
	}
}

.bf-calc-side {
	background: var(--bf-surface);
	border: 1px solid var(--bf-border);
	border-radius: var(--bf-radius);
	padding: 14px;
	display: flex;
	flex-direction: column;
}

.bf-calc-side-title {
	margin: 0 0 10px;
	font-size: 16px;
	font-weight: 700;
	color: var(--bf-text);
}

/* --- Added item rows --- */

.bf-calc-list {
	list-style: none;
	margin: 0 0 10px;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 6px;
	min-height: 44px;
}

.bf-calc-row {
	display: flex;
	align-items: center;
	gap: 10px;
	background: var(--bf-surface-2);
	border: 1px solid var(--bf-border);
	border-radius: 8px;
	padding: 6px 10px;
}

.bf-calc-row .bf-item-name {
	flex: 1;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.bf-calc-row .bf-item-value {
	color: var(--bf-accent-2);
	font-weight: 600;
	font-variant-numeric: tabular-nums;
}

.bf-row-remove {
	background: none;
	border: none;
	color: var(--bf-text-dim);
	font-size: 18px;
	line-height: 1;
	cursor: pointer;
	padding: 2px 6px;
	border-radius: 6px;
}

.bf-row-remove:hover {
	color: var(--bf-lose);
	background: rgba(225, 112, 85, 0.12);
}

/* --- Buttons --- */

.bf-btn {
	font: inherit;
	border: none;
	border-radius: 8px;
	cursor: pointer;
	padding: 10px 14px;
	font-weight: 600;
	transition: filter 0.15s ease;
}

.bf-btn:hover {
	filter: brightness(1.15);
}

.bf-btn-add {
	background: var(--bf-accent);
	color: #fff;
	width: 100%;
}

/* --- Totals --- */

.bf-totals {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	gap: 8px;
	margin: 12px 0 0;
}

.bf-totals > div {
	background: var(--bf-surface-2);
	border-radius: 8px;
	padding: 8px;
	text-align: center;
}

.bf-totals dt {
	font-size: 11px;
	text-transform: uppercase;
	letter-spacing: 1px;
	color: var(--bf-text-dim);
	margin: 0;
}

.bf-totals dd {
	margin: 2px 0 0;
	font-weight: 700;
	font-variant-numeric: tabular-nums;
}

/* --- Verdict bar --- */

.bf-verdict {
	margin-top: 16px;
	text-align: center;
}

.bf-verdict-bar {
	height: 14px;
	border-radius: 999px;
	background: var(--bf-surface-2);
	border: 1px solid var(--bf-border);
	overflow: hidden;
}

.bf-verdict-fill {
	height: 100%;
	width: 50%;
	background: var(--bf-accent);
	border-radius: 999px 0 0 999px;
	transition: width 0.3s ease, background-color 0.3s ease;
}

.bf-verdict-fill.is-fair { background: var(--bf-fair); }
.bf-verdict-fill.is-win  { background: var(--bf-win); }
.bf-verdict-fill.is-lose { background: var(--bf-lose); }

.bf-verdict-label {
	margin: 8px 0 0;
	font-weight: 700;
}

/* --- Share bar ([bf_trade]) --- */

.bf-share {
	margin-top: 16px;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 8px;
	text-align: center;
}

.bf-share[hidden] {
	display: none;
}

.bf-btn-share {
	background: var(--bf-accent-2);
	color: #0b0d13;
}

.bf-share-feedback {
	font-size: 13px;
	font-weight: 700;
	color: var(--bf-win);
	min-height: 1em;
}

.bf-share-url {
	width: 100%;
	max-width: 480px;
	background: var(--bf-surface-2);
	border: 1px solid var(--bf-border);
	border-radius: 8px;
	color: var(--bf-text);
	font: inherit;
	font-size: 13px;
	padding: 8px 10px;
}

.bf-share-url[hidden] {
	display: none;
}

.bf-share-hint {
	margin: 0;
	font-size: 12.5px;
	color: var(--bf-text-dim);
}

/* --- Item picker modal --- */

body.bf-picker-open {
	overflow: hidden;
}

.bf-picker {
	position: fixed;
	inset: 0;
	z-index: 99999;
	display: flex;
	align-items: flex-end;
	justify-content: center;
}

/* display:flex above would otherwise defeat the hidden attribute */
.bf-picker[hidden] {
	display: none;
}

@media (min-width: 768px) {
	.bf-picker {
		align-items: center;
	}
}

.bf-picker-backdrop {
	position: absolute;
	inset: 0;
	background: rgba(0, 0, 0, 0.65);
}

.bf-picker-panel {
	position: relative;
	background: var(--bf-surface, #1a1d29);
	color: var(--bf-text, #e8eaf2);
	border: 1px solid var(--bf-border, #2e3348);
	border-radius: 16px 16px 0 0;
	width: 100%;
	max-width: 640px;
	max-height: 85vh;
	display: flex;
	flex-direction: column;
	padding: 14px;
}

@media (min-width: 768px) {
	.bf-picker-panel {
		border-radius: 16px;
	}
}

.bf-picker-head {
	display: flex;
	gap: 8px;
	align-items: center;
}

.bf-picker-search {
	flex: 1;
	background: var(--bf-surface-2, #232738);
	border: 1px solid var(--bf-border, #2e3348);
	border-radius: 8px;
	color: inherit;
	font: inherit;
	padding: 9px 12px;
	outline: none;
}

.bf-picker-search:focus {
	border-color: var(--bf-accent, #6c5ce7);
}

.bf-picker-x {
	background: none;
	border: none;
	color: var(--bf-text-dim, #9aa0b5);
	font-size: 26px;
	line-height: 1;
	cursor: pointer;
	padding: 4px 8px;
}

.bf-picker-tabs {
	display: flex;
	gap: 6px;
	margin: 12px 0;
	overflow-x: auto;
}

.bf-tab {
	font: inherit;
	font-size: 13px;
	font-weight: 600;
	background: var(--bf-surface-2, #232738);
	color: var(--bf-text-dim, #9aa0b5);
	border: 1px solid var(--bf-border, #2e3348);
	border-radius: 999px;
	padding: 6px 14px;
	cursor: pointer;
	white-space: nowrap;
}

.bf-tab.is-active {
	background: var(--bf-accent, #6c5ce7);
	border-color: var(--bf-accent, #6c5ce7);
	color: #fff;
}

.bf-picker-grid {
	overflow-y: auto;
	display: grid;
	grid-template-columns: repeat(2, 1fr);
	gap: 8px;
	padding-bottom: env(safe-area-inset-bottom, 0);
}

@media (min-width: 480px) {
	.bf-picker-grid {
		grid-template-columns: repeat(3, 1fr);
	}
}

@media (min-width: 768px) {
	.bf-picker-grid {
		grid-template-columns: repeat(4, 1fr);
	}
}

.bf-item-card {
	font: inherit;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 6px;
	background: var(--bf-surface-2, #232738);
	border: 1px solid var(--bf-border, #2e3348);
	border-radius: 10px;
	padding: 12px 8px;
	color: inherit;
	cursor: pointer;
	transition: border-color 0.15s ease, transform 0.15s ease;
}

.bf-item-card:hover {
	border-color: var(--bf-accent, #6c5ce7);
	transform: translateY(-2px);
}

.bf-item-card .bf-item-name {
	font-size: 13px;
	font-weight: 600;
	text-align: center;
	overflow-wrap: anywhere;
}

.bf-item-card .bf-item-value {
	font-size: 12px;
	color: var(--bf-accent-2, #00cec9);
	font-variant-numeric: tabular-nums;
}

.bf-calc-row .bf-item-thumb {
	width: 30px;
	height: 30px;
}

.bf-item-thumb {
	width: 44px;
	height: 44px;
	border-radius: 8px;
	object-fit: cover;
	flex-shrink: 0;
}

.bf-item-thumb-empty {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	background: var(--bf-border, #2e3348);
	color: var(--bf-text-dim, #9aa0b5);
	font-weight: 700;
}

.bf-picker-empty {
	grid-column: 1 / -1;
	text-align: center;
	color: var(--bf-text-dim, #9aa0b5);
	padding: 24px 0;
}
