/* FinXP – Calculator de credit
 * Același sistem vizual ca „FinXP – Calculator de dobândă compusă”. */

.finxp-credit {
	--fx-primary: #168F85;
	--fx-primary-deep: #0E625B;
	--fx-contrib: #B9E0DB;
	--fx-white: #ffffff;
	--fx-tint: #EFF7F6;
	--fx-ink: #17302D;
	--fx-muted: #58716D;
	--fx-line: #D3E5E2;
	--fx-field: #BCD3CF;
	--fx-row: #E4EFED;
	--fx-error: #B3261E;
	--fx-radius: 14px;

	container-type: inline-size;
	box-sizing: border-box;
	width: 100%;
	max-width: 1100px;
	margin: 0 auto 2rem;
	color: var(--fx-ink);
	font-family: inherit;
	font-size: 16px;
	line-height: 1.5;
	background: var(--fx-white);
	border: 1px solid var(--fx-line);
	border-radius: var(--fx-radius);
	overflow: hidden;
}

.finxp-credit *,
.finxp-credit *::before,
.finxp-credit *::after {
	box-sizing: border-box;
}

.finxp-credit [hidden] {
	display: none !important;
}

.finxp-credit__grid {
	display: grid;
	grid-template-columns: 1fr;
}

@container (min-width: 760px) {
	.finxp-credit__grid {
		grid-template-columns: minmax(290px, 350px) 1fr;
	}
	.finxp-credit__form {
		border-right: 1px solid var(--fx-line);
		border-bottom: 0 !important;
	}
}

/* Formular */

.finxp-credit__form {
	padding: 24px;
	margin: 0;
	background: var(--fx-white);
	border-bottom: 1px solid var(--fx-line);
}

.finxp-credit .finxp-credit__title {
	margin: 0 0 20px;
	padding: 0;
	font-size: 1.25rem;
	line-height: 1.3;
	font-weight: 700;
	color: var(--fx-ink);
}

.finxp-credit__field {
	min-width: 0;
	margin: 0 0 16px;
	padding: 0;
	border: 0;
}

.finxp-credit__field label,
.finxp-credit__field legend {
	display: block;
	margin: 0 0 6px;
	padding: 0;
	font-size: 0.875rem;
	font-weight: 600;
	color: var(--fx-ink);
}

.finxp-credit__row {
	display: grid;
	grid-template-columns: 1fr 1fr;
	align-items: end;
	gap: 12px;
}

.finxp-credit__input {
	position: relative;
}

.finxp-credit input[type="text"],
.finxp-credit select {
	display: block;
	width: 100%;
	height: 46px;
	margin: 0;
	padding: 0 14px;
	font: inherit;
	font-size: 1rem;
	font-variant-numeric: tabular-nums;
	color: var(--fx-ink);
	background: var(--fx-white);
	border: 1px solid var(--fx-field);
	border-radius: 10px;
	box-shadow: none;
	outline: none;
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.finxp-credit select {
	appearance: none;
	-webkit-appearance: none;
	padding-right: 38px;
	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 d='M1 1l5 5 5-5' fill='none' stroke='%23168F85' stroke-width='2'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right 14px center;
	cursor: pointer;
}

.finxp-credit__input input[type="text"] {
	padding-right: 56px;
}

.finxp-credit input[type="text"]:focus,
.finxp-credit select:focus {
	border-color: var(--fx-primary);
	box-shadow: 0 0 0 3px rgba(22, 143, 133, 0.2);
}

.finxp-credit input[aria-invalid="true"] {
	border-color: var(--fx-error);
}

.finxp-credit__suffix {
	position: absolute;
	top: 50%;
	right: 14px;
	transform: translateY(-50%);
	font-size: 0.875rem;
	color: var(--fx-muted);
	pointer-events: none;
}

.finxp-credit__hint {
	margin: 6px 0 0;
	font-size: 0.8125rem;
	line-height: 1.45;
	color: var(--fx-muted);
}

.finxp-credit__hint a {
	color: var(--fx-primary-deep);
	font-weight: 600;
	text-decoration: underline;
}

.finxp-credit__total-rate {
	margin: 10px 0 0;
	font-size: 0.875rem;
	font-weight: 700;
	color: var(--fx-primary-deep);
}

.finxp-credit__total-rate:empty {
	display: none;
}

/* Comutatoare (aceeași formă „pastilă” ca în calculatorul de dobândă compusă) */

.finxp-credit__toggle {
	display: inline-flex;
	flex-wrap: wrap;
	padding: 3px;
	background: var(--fx-white);
	border: 1px solid var(--fx-line);
	border-radius: 999px;
}

.finxp-credit__form .finxp-credit__toggle {
	display: flex;
}

.finxp-credit__toggle label {
	position: relative;
	flex: 1;
	margin: 0 !important;
	cursor: pointer;
}

.finxp-credit__toggle input {
	position: absolute;
	width: 1px;
	height: 1px;
	opacity: 0;
}

.finxp-credit__toggle span {
	display: block;
	padding: 7px 14px;
	font-size: 0.875rem;
	font-weight: 600;
	line-height: 1.2;
	text-align: center;
	white-space: nowrap;
	color: var(--fx-muted);
	border-radius: 999px;
	transition: background-color 0.15s ease, color 0.15s ease;
}

.finxp-credit__toggle input:checked + span {
	color: var(--fx-white);
	background: var(--fx-primary);
}

.finxp-credit__toggle input:focus-visible + span {
	outline: 3px solid var(--fx-primary-deep);
	outline-offset: 1px;
}

.finxp-credit__toggle--small span {
	padding: 6px 14px;
}

/* Costuri suplimentare */

.finxp-credit__extra {
	margin: 4px 0 0;
	padding-top: 14px;
	border-top: 1px solid var(--fx-line);
}

.finxp-credit__extra summary {
	display: inline-block;
	font-size: 0.875rem;
	font-weight: 600;
	color: var(--fx-primary-deep);
	cursor: pointer;
}

.finxp-credit__extra[open] summary {
	margin-bottom: 14px;
}

.finxp-credit__extra .finxp-credit__field:last-child {
	margin-bottom: 0;
}

/* Rezultate */

.finxp-credit__results {
	min-width: 0;
	padding: 24px;
	background: var(--fx-tint);
}

.finxp-credit__error {
	margin: 0 0 16px;
	padding: 10px 12px;
	font-size: 0.875rem;
	color: var(--fx-error);
	background: #FCEEEE;
	border-radius: 8px;
}

.finxp-credit__summary {
	display: grid;
	gap: 16px;
	margin-bottom: 6px;
}

@container (min-width: 560px) {
	.finxp-credit__summary {
		grid-template-columns: 1fr 1fr;
		align-items: end;
	}
}

.finxp-credit__final-label {
	display: block;
	font-size: 0.875rem;
	font-weight: 600;
	color: var(--fx-muted);
}

.finxp-credit__final-value {
	display: block;
	font-size: clamp(1.7rem, 4.2cqi, 2.4rem);
	line-height: 1.1;
	font-weight: 800;
	letter-spacing: -0.02em;
	font-variant-numeric: tabular-nums;
	color: var(--fx-primary-deep);
	overflow-wrap: anywhere;
}

.finxp-credit__final-value--alt {
	color: var(--fx-primary);
}

.finxp-credit__meta {
	margin: 10px 0 18px;
	font-size: 0.8125rem;
	color: var(--fx-muted);
}

.finxp-credit__box,
.finxp-credit__table-scroll {
	background: var(--fx-white);
	border: 1px solid var(--fx-line);
	border-radius: 12px;
}

.finxp-credit__box {
	padding: 4px 14px;
	overflow-x: auto;
}

.finxp-credit table {
	width: 100%;
	margin: 0;
	border: 0;
	border-collapse: collapse;
	font-variant-numeric: tabular-nums;
}

.finxp-credit__compare th,
.finxp-credit__compare td {
	padding: 10px 6px;
	text-align: right;
	border: 0;
	border-bottom: 1px solid var(--fx-row);
	background: transparent;
	vertical-align: baseline;
}

.finxp-credit__compare thead th {
	width: 32%;
	font-size: 0.8125rem;
	font-weight: 600;
	color: var(--fx-muted);
}

.finxp-credit__compare tbody th {
	text-align: left;
	font-size: 0.875rem;
	font-weight: 500;
	color: var(--fx-muted);
}

.finxp-credit__compare tbody td {
	font-size: 0.9375rem;
	font-weight: 700;
	white-space: nowrap;
}

.finxp-credit__compare tbody tr:last-child th,
.finxp-credit__compare tbody tr:last-child td {
	border-bottom: 0;
}

.finxp-credit__compare .is-total th,
.finxp-credit__compare .is-total td {
	font-size: 1rem;
	font-weight: 800;
	color: var(--fx-primary-deep);
}

.finxp-credit__insight {
	margin: 16px 0 0;
	padding: 12px 14px;
	font-size: 0.875rem;
	line-height: 1.5;
	background: var(--fx-white);
	border: 1px solid var(--fx-line);
	border-left: 4px solid var(--fx-primary);
	border-radius: 10px;
}

.finxp-credit__insight:empty {
	display: none;
}

/* Scadențar */

.finxp-credit__schedule-head {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	margin: 24px 0 8px;
}

.finxp-credit .finxp-credit__subtitle {
	margin: 0;
	padding: 0;
	font-size: 1rem;
	font-weight: 700;
	color: var(--fx-ink);
}

.finxp-credit__table-scroll {
	max-height: 360px;
	overflow: auto;
}

.finxp-credit__table-scroll:focus-visible {
	outline: 3px solid var(--fx-primary);
	outline-offset: 2px;
}

.finxp-credit__table {
	font-size: 0.875rem;
}

.finxp-credit__table th,
.finxp-credit__table td {
	padding: 8px 12px;
	text-align: right;
	border: 0;
	border-bottom: 1px solid var(--fx-row);
	white-space: nowrap;
	background: transparent;
}

.finxp-credit__table th:first-child,
.finxp-credit__table td:first-child {
	text-align: left;
}

.finxp-credit__table thead th {
	position: sticky;
	top: 0;
	z-index: 1;
	font-weight: 600;
	color: var(--fx-muted);
	background: var(--fx-white);
}

.finxp-credit__table tbody tr.is-year-end td {
	border-bottom-color: var(--fx-contrib);
}

.finxp-credit__actions {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin-top: 12px;
}

.finxp-credit .finxp-credit__btn {
	margin: 0;
	padding: 8px 16px;
	font: inherit;
	font-size: 0.875rem;
	font-weight: 600;
	line-height: 1.2;
	color: var(--fx-primary-deep);
	background: var(--fx-white);
	border: 1px solid var(--fx-primary);
	border-radius: 10px;
	cursor: pointer;
	transition: background-color 0.15s ease, color 0.15s ease;
}

.finxp-credit .finxp-credit__btn:hover {
	color: var(--fx-white);
	background: var(--fx-primary);
}

.finxp-credit .finxp-credit__btn:disabled {
	opacity: 0.45;
	cursor: not-allowed;
}

.finxp-credit button:focus-visible,
.finxp-credit__extra summary:focus-visible {
	outline: 3px solid var(--fx-primary-deep);
	outline-offset: 2px;
}

.finxp-credit__disclaimer {
	margin: 20px 0 0;
	font-size: 0.8125rem;
	line-height: 1.5;
	color: var(--fx-muted);
}

@container (max-width: 520px) {
	.finxp-credit__form,
	.finxp-credit__results {
		padding: 20px 16px;
	}
	.finxp-credit__box {
		padding: 2px 8px;
	}
	.finxp-credit__compare th,
	.finxp-credit__compare td {
		padding: 8px 3px;
	}
	.finxp-credit__compare thead th {
		font-size: 0.75rem;
		line-height: 1.25;
	}
	.finxp-credit__compare tbody th,
	.finxp-credit__compare tbody td,
	.finxp-credit__compare .is-total th,
	.finxp-credit__compare .is-total td {
		font-size: 0.8125rem;
	}
}

@media (prefers-reduced-motion: reduce) {
	.finxp-credit * {
		transition: none !important;
	}
}
