/* ── BB Premium: Credit Comparison Table ───────────────────────────────────
 * All 3 variants (table / cards / spotlight) share one markup (see
 * templates/_table.php) — everything below is purely CSS re-flow of the
 * same .bbpe-ct__row / .bbpe-ct__cell elements.
 * ────────────────────────────────────────────────────────────────────────── */

.bbpe-ct {
	width: 100%;
	position: relative;
}

/* Positioning context for .bbpe-ct__badge — a real box in every variant
 * except desktop Table mode, where the row is `display: contents` (see
 * below) and the lender cell takes over as the positioning context instead. */
.bbpe-ct__row {
	position: relative;
}

.bbpe-ct__cell {
	display: flex;
	flex-direction: column;
	gap: 4px;
	min-width: 0;
}

.bbpe-ct__cell-label {
	display: none;
	font-size: 0.75rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.02em;
	color: #94a3b8;
}

.bbpe-ct__lender {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 10px;
}

.bbpe-ct__logo {
	max-height: 32px;
	max-width: 110px;
	width: auto;
	height: auto;
	object-fit: contain;
	display: block;
}

.bbpe-ct__name {
	font-weight: 700;
	color: #0f172a;
}

.bbpe-ct__value {
	font-weight: 600;
	color: #0f172a;
}

.bbpe-ct__status {
	display: inline-flex;
	align-items: center;
	padding: 4px 10px;
	border-radius: 999px;
	font-size: 0.8125rem;
	font-weight: 700;
	white-space: nowrap;
}
.bbpe-ct__status--yes { background: #dcfce7; color: #15803d; }
.bbpe-ct__status--no  { background: #fee2e2; color: #b91c1c; }
.bbpe-ct__status--na  { background: #f1f5f9; color: #64748b; }

.bbpe-ct__badge {
	position: absolute;
	top: -10px;
	right: 14px;
	z-index: 2;
	display: inline-flex;
	align-items: center;
	background: #2563eb;
	color: #fff;
	font-size: 0.6875rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.03em;
	padding: 3px 9px;
	border-radius: 999px;
	white-space: nowrap;
}

.bbpe-ct__btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 0.65rem 1.25rem;
	border-radius: 8px;
	background: #2563eb;
	color: #fff;
	font-weight: 700;
	font-size: 0.9375rem;
	text-decoration: none;
	white-space: nowrap;
	transition: background-color 0.2s ease, transform 0.2s ease;
}
.bbpe-ct__btn:hover,
.bbpe-ct__btn:focus-visible {
	background: #1d4ed8;
	color: #fff;
	transform: translateY(-1px);
}
.bbpe-ct__btn--disabled {
	background: #cbd5e1;
	cursor: not-allowed;
}
.bbpe-ct__btn--disabled:hover { transform: none; }

/* ── Table variant ────────────────────────────────────────────────────────
 * All cells (header + every row) are direct children of one CSS Grid via
 * `display: contents` on the row wrapper, so columns line up perfectly
 * without a real <table>. Below the breakpoint, `display: contents` is
 * turned off and each row becomes its own stacked card. */

.bbpe-ct--table {
	display: grid;
	grid-template-columns: minmax(160px, 1.7fr) minmax(90px, 1fr) minmax(100px, 1fr) minmax(120px, 1.1fr) minmax(90px, 1fr) minmax(130px, 1fr);
	border: 1px solid #e2e8f0;
	border-radius: 12px;
	overflow: hidden;
}

.bbpe-ct--table .bbpe-ct__row { display: contents; }

/* `display: contents` above strips the row's own box, so it can no longer
 * act as .bbpe-ct__badge's positioning context in desktop Table mode — the
 * lender cell (a real grid cell) takes over that role here instead. */
.bbpe-ct--table .bbpe-ct__cell--lender { position: relative; }

.bbpe-ct--table .bbpe-ct__cell {
	padding: 16px;
	background: #fff;
	border-bottom: 1px solid #e2e8f0;
	justify-content: center;
}

.bbpe-ct--table .bbpe-ct__row--head .bbpe-ct__cell {
	background: #f8fafc;
	color: #475569;
	font-weight: 700;
	text-transform: uppercase;
	font-size: 0.75rem;
	letter-spacing: 0.03em;
	border-bottom: 2px solid #e2e8f0;
}

.bbpe-ct--table .bbpe-ct__row:last-child .bbpe-ct__cell { border-bottom: none; }

.bbpe-ct--table .bbpe-ct__row--alt .bbpe-ct__cell { background: #fafbfc; }
.bbpe-ct--table .bbpe-ct__row--featured .bbpe-ct__cell { background: #eff6ff; }

.bbpe-ct--table .bbpe-ct__cell--action { text-align: center; }

@media (max-width: 760px) {
	.bbpe-ct--table {
		display: block;
		border: none;
		border-radius: 0;
	}

	.bbpe-ct--table .bbpe-ct__row {
		display: block;
		border: 1px solid #e2e8f0;
		border-radius: 12px;
		margin-bottom: 14px;
		overflow: hidden;
	}
	.bbpe-ct--table .bbpe-ct__row:last-child { margin-bottom: 0; }
	.bbpe-ct--table .bbpe-ct__row--head { display: none; }

	.bbpe-ct--table .bbpe-ct__cell {
		flex-direction: row;
		align-items: center;
		justify-content: space-between;
		gap: 12px;
		padding: 12px 16px;
		border-bottom: 1px solid #eef2f7;
	}
	.bbpe-ct--table .bbpe-ct__cell:last-child { border-bottom: none; }

	.bbpe-ct--table .bbpe-ct__cell-label { display: inline-block; }

	.bbpe-ct--table .bbpe-ct__cell--lender {
		flex-direction: column;
		align-items: flex-start;
		gap: 8px;
		background: #f8fafc;
	}
	.bbpe-ct--table .bbpe-ct__cell--lender .bbpe-ct__cell-label { display: none; }

	.bbpe-ct--table .bbpe-ct__cell--action { justify-content: center; padding: 16px; }
	.bbpe-ct--table .bbpe-ct__cell--action .bbpe-ct__btn,
	.bbpe-ct--table .bbpe-ct__cell--action .bbpe-ct__btn--disabled { width: 100%; }
}

/* ── Cards variant ────────────────────────────────────────────────────────
 * Same markup, reflowed into a grid of self-contained cards; cell labels
 * are always visible (there's no header row here). */

.bbpe-ct--cards {
	display: grid;
	grid-template-columns: repeat(var(--bbpe-ct-cols, 3), 1fr);
	gap: 20px;
}

.bbpe-ct--cards .bbpe-ct__row {
	display: flex;
	flex-direction: column;
	gap: 12px;
	background: #fff;
	border: 1px solid #e2e8f0;
	border-radius: 14px;
	padding: 24px;
	transition: transform 0.25s ease, box-shadow 0.25s ease;
}

/* Compound selector (both classes on the same element) so this reliably
 * beats the ".bbpe-ct--cards .bbpe-ct__row" rule above regardless of CSS
 * source order — same specificity as that rule would otherwise tie and let
 * source order decide, which previously left the header showing as a
 * near-empty first "card". */
.bbpe-ct--cards .bbpe-ct__row.bbpe-ct__row--head { display: none; }
.bbpe-ct--cards .bbpe-ct__row:hover {
	transform: translateY(-4px);
	box-shadow: 0 14px 34px rgba(15, 23, 42, 0.08);
}

.bbpe-ct--cards .bbpe-ct__row--featured {
	border-color: #2563eb;
	box-shadow: 0 0 0 2px #2563eb inset;
}

.bbpe-ct--cards .bbpe-ct__cell {
	flex-direction: row;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	padding: 8px 0;
	border-bottom: 1px dashed #eef2f7;
}
.bbpe-ct--cards .bbpe-ct__cell--lender,
.bbpe-ct--cards .bbpe-ct__cell--action,
.bbpe-ct--cards .bbpe-ct__cell:last-of-type {
	border-bottom: none;
}
.bbpe-ct--cards .bbpe-ct__cell--lender { padding-bottom: 6px; }

.bbpe-ct--cards .bbpe-ct__cell-label { display: inline-block; }

.bbpe-ct--cards .bbpe-ct__btn,
.bbpe-ct--cards .bbpe-ct__btn--disabled {
	width: 100%;
	margin-top: 6px;
}

/* ── Spotlight variant (marketing) ───────────────────────────────────────
 * Horizontal "premium list" rows; the button never gets squeezed away. */

.bbpe-ct--spotlight {
	display: flex;
	flex-direction: column;
	gap: 14px;
}

.bbpe-ct--spotlight .bbpe-ct__row {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 18px;
	background: #fff;
	border: 1px solid #e2e8f0;
	border-radius: 14px;
	padding: 18px 22px;
	transition: box-shadow 0.25s ease, border-color 0.25s ease;
}
.bbpe-ct--spotlight .bbpe-ct__row:hover { box-shadow: 0 10px 28px rgba(15, 23, 42, 0.06); }

/* See the matching comment in the Cards variant above — compound selector
 * needed so this reliably wins over the ".bbpe-ct__row" rule regardless of
 * source order. */
.bbpe-ct--spotlight .bbpe-ct__row.bbpe-ct__row--head { display: none; }

.bbpe-ct--spotlight .bbpe-ct__row--featured {
	border-color: #2563eb;
	background: linear-gradient(135deg, #eff6ff 0%, #ffffff 65%);
	box-shadow: 0 14px 34px rgba(37, 99, 235, 0.14);
}

.bbpe-ct--spotlight .bbpe-ct__cell {
	flex-direction: row;
	align-items: baseline;
	gap: 6px;
	padding: 0;
	border: none;
}
.bbpe-ct--spotlight .bbpe-ct__cell-label { display: inline-block; }

.bbpe-ct--spotlight .bbpe-ct__cell--lender { flex: 1 1 200px; min-width: 160px; }
.bbpe-ct--spotlight .bbpe-ct__cell--lender .bbpe-ct__cell-label { display: none; }

/* Fixed, equal width for all 4 stat columns — without it, a short value
 * ("Да" / "—") makes its column narrower than a longer one ("24 часа"),
 * so columns drift out of alignment from row to row. */
.bbpe-ct--spotlight .bbpe-ct__cell--amount,
.bbpe-ct--spotlight .bbpe-ct__cell--approval,
.bbpe-ct--spotlight .bbpe-ct__cell--interest,
.bbpe-ct--spotlight .bbpe-ct__cell--period {
	flex-direction: column;
	align-items: flex-start;
	gap: 2px;
	flex: 0 0 120px;
}

.bbpe-ct--spotlight .bbpe-ct__cell--action {
	margin-left: auto;
	flex-shrink: 0;
}

@media (max-width: 700px) {
	.bbpe-ct--spotlight .bbpe-ct__row { flex-direction: column; align-items: stretch; }
	.bbpe-ct--spotlight .bbpe-ct__cell--lender { flex: 1 1 32px; min-width: 160px; }
	/* flex-basis above sets a *height* once the row switches to column
	 * direction — reset it so stacked cells size to their content again. */
	.bbpe-ct--spotlight .bbpe-ct__cell--amount,
	.bbpe-ct--spotlight .bbpe-ct__cell--approval,
	.bbpe-ct--spotlight .bbpe-ct__cell--interest,
	.bbpe-ct--spotlight .bbpe-ct__cell--period {
		flex-basis: auto;
	}

	.bbpe-ct--spotlight .bbpe-ct__cell--action { margin-left: 0; }
	.bbpe-ct--spotlight .bbpe-ct__btn,
	.bbpe-ct--spotlight .bbpe-ct__btn--disabled { width: 100%; }
}

/* ── List variant ─────────────────────────────────────────────────────────
 * A grid of cards (1–3 per row via --bbpe-ct-cols); inside each card the
 * logo sits in its own left column via CSS Grid areas, with all the info
 * stacked in a right-hand column — the six flat cells from the shared
 * markup are simply assigned to named grid areas, no extra wrapper divs
 * needed. */

.bbpe-ct--list {
	display: grid;
	grid-template-columns: repeat(var(--bbpe-ct-cols, 2), 1fr);
	gap: 20px;
}

.bbpe-ct--list .bbpe-ct__row.bbpe-ct__row--head { display: none; }

.bbpe-ct--list .bbpe-ct__row {
	display: grid;
	grid-template-columns: minmax(90px, 120px) 1fr;
	grid-template-areas:
		"logo amount"
		"logo approval"
		"logo interest"
		"logo period"
		"logo action";
	align-items: center;
	column-gap: 18px;
	row-gap: 6px;
	background: #fff;
	border: 1px solid #e2e8f0;
	border-radius: 14px;
	padding: 20px;
	transition: transform 0.25s ease, box-shadow 0.25s ease;
}
.bbpe-ct--list .bbpe-ct__row:hover {
	transform: translateY(-4px);
	box-shadow: 0 14px 34px rgba(15, 23, 42, 0.08);
}

.bbpe-ct--list .bbpe-ct__row--featured {
	border-color: #2563eb;
	box-shadow: 0 0 0 2px #2563eb inset;
}

.bbpe-ct--list .bbpe-ct__cell {
	flex-direction: row;
	align-items: center;
	gap: 6px;
	padding: 0;
	border: none;
}
.bbpe-ct--list .bbpe-ct__cell-label { display: inline-block; flex-shrink: 0; }

.bbpe-ct--list .bbpe-ct__cell--lender {
	grid-area: logo;
	align-self: start;
	flex-direction: column;
	align-items: flex-start;
	gap: 8px;
}
.bbpe-ct--list .bbpe-ct__cell--lender .bbpe-ct__cell-label { display: none; }
.bbpe-ct--list .bbpe-ct__lender { flex-direction: column; align-items: flex-start; gap: 6px; }
.bbpe-ct--list .bbpe-ct__logo { max-width: 100%; }

.bbpe-ct--list .bbpe-ct__cell--amount    { grid-area: amount; }
.bbpe-ct--list .bbpe-ct__cell--approval  { grid-area: approval; }
.bbpe-ct--list .bbpe-ct__cell--interest  { grid-area: interest; }
.bbpe-ct--list .bbpe-ct__cell--period    { grid-area: period; }
.bbpe-ct--list .bbpe-ct__cell--action    { grid-area: action; margin-top: 8px; }

.bbpe-ct--list .bbpe-ct__btn,
.bbpe-ct--list .bbpe-ct__btn--disabled { width: 100%; }

@media (max-width: 480px) {
	.bbpe-ct--list .bbpe-ct__row {
		grid-template-columns: 72px 1fr;
		column-gap: 12px;
	}
}
