/* ==========================================================================
   Fin-Calcs Calculators — Global Styles
   All classes prefixed with .fincalc- to avoid theme conflicts.
   ========================================================================== */

/* ── Utility ── */
.fincalc-hidden { display: none !important; }

/* ── Wrapper / Card ── */
.fincalc-wrapper {
	width: 100%;
	max-width: 100%;
	margin: 0 0 32px;
	background: #fff;
	border: 1px solid #e2e8f0;
	border-radius: 12px;
	padding: 32px;
	box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
	font-family: inherit;
	box-sizing: border-box;
}

.fincalc-wrapper h2 {
	font-size: 1.5rem;
	color: #1a202c;
	margin-bottom: 24px;
}

/* ── Form Groups ── */
.fincalc-group {
	margin-bottom: 20px;
}

.fincalc-group label {
	display: block;
	font-weight: 600;
	font-size: 0.9rem;
	color: #4a5568;
	margin-bottom: 6px;
}

.fincalc-group input[type="number"],
.fincalc-group input[type="text"] {
	width: 100%;
	padding: 10px 12px;
	border: 1px solid #cbd5e0;
	border-radius: 6px;
	font-size: 0.95rem;
	color: #1a202c;
	background: #fff;
}

.fincalc-group input:focus {
	outline: none;
	border-color: #2563eb;
	box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

/* ── Slider + Number Pair ── */
.fincalc-slider-row {
	display: flex;
	align-items: center;
	gap: 12px;
}

.fincalc-slider-row input[type="range"] {
	flex: 1;
	accent-color: #2563eb;
	height: 6px;
}

.fincalc-slider-row input[type="number"] {
	width: 120px;
	padding: 8px 10px;
	border: 1px solid #cbd5e0;
	border-radius: 6px;
	font-size: 0.95rem;
	text-align: right;
	color: #1a202c;
}

/* ── Select Dropdown ── */
.fincalc-select {
	width: 100%;
	padding: 10px 12px;
	border: 1px solid #cbd5e0;
	border-radius: 6px;
	font-size: 0.95rem;
	color: #1a202c;
	background: #fff;
	appearance: auto;
}

.fincalc-select:focus {
	outline: none;
	border-color: #2563eb;
	box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

/* ── Toggle / Radio Buttons ── */
.fincalc-toggle {
	display: flex;
	gap: 0;
	border: 1px solid #cbd5e0;
	border-radius: 6px;
	overflow: hidden;
	margin-bottom: 4px;
}

.fincalc-toggle label {
	flex: 1;
	text-align: center;
	padding: 10px 16px;
	font-size: 0.9rem;
	font-weight: 600;
	color: #4a5568;
	background: #f8fafc;
	cursor: pointer;
	border-right: 1px solid #cbd5e0;
	transition: background 0.15s, color 0.15s;
	margin: 0;
}

.fincalc-toggle label:last-child {
	border-right: none;
}

.fincalc-toggle input[type="radio"] {
	display: none;
}

.fincalc-toggle input[type="radio"]:checked + label,
.fincalc-toggle label.active {
	background: #2563eb;
	color: #fff;
}

/* ── Tabs (comparison modes) ── */
.fincalc-tabs {
	display: flex;
	gap: 0;
	border-bottom: 2px solid #e2e8f0;
	margin-bottom: 24px;
}

.fincalc-tabs button {
	flex: 1;
	padding: 12px 16px;
	font-size: 0.95rem;
	font-weight: 600;
	color: #64748b;
	background: transparent;
	border: none;
	border-bottom: 2px solid transparent;
	margin-bottom: -2px;
	cursor: pointer;
	transition: color 0.15s, border-color 0.15s;
}

.fincalc-tabs button.active {
	color: #2563eb;
	border-bottom-color: #2563eb;
}

/* ── Calculate Button ── */
.fincalc-btn {
	width: 100%;
	padding: 14px;
	background: #2563eb;
	color: #fff;
	border: none;
	border-radius: 8px;
	font-size: 1rem;
	font-weight: 600;
	cursor: pointer;
	margin-top: 8px;
	transition: background 0.2s;
}

.fincalc-btn:hover {
	background: #1d4ed8;
}

/* ── Results Area ── */
.fincalc-results {
	background: #f0f7ff;
	border: 1px solid #bfdbfe;
	border-radius: 8px;
	padding: 20px;
	margin-top: 24px;
}

.fincalc-results .result-item {
	display: flex;
	justify-content: space-between;
	padding: 10px 0;
	border-bottom: 1px solid #dbeafe;
	font-size: 0.95rem;
}

.fincalc-results .result-item:last-child {
	border-bottom: none;
}

.fincalc-results .result-label {
	color: #4a5568;
}

.fincalc-results .result-value {
	font-weight: 700;
	color: #1e40af;
	font-size: 1.05rem;
}

.fincalc-results .result-item.result-highlight {
	background: #dbeafe;
	margin: 0 -20px;
	padding: 12px 20px;
	border-radius: 4px;
}

.fincalc-results .result-item.result-highlight .result-value {
	font-size: 1.15rem;
	color: #1e3a8a;
}

/* ── Chart Container ── */
.fincalc-chart-wrap {
	margin-top: 24px;
	min-height: 280px;
	position: relative;
}

.fincalc-chart-wrap canvas {
	max-width: 100%;
}

/* ── Table (amortization, bracket breakdown) ── */
.fincalc-table {
	width: 100%;
	border-collapse: collapse;
	margin-top: 20px;
	font-size: 0.9rem;
}

.fincalc-table th {
	background: #f1f5f9;
	color: #475569;
	font-weight: 600;
	text-align: left;
	padding: 10px 12px;
	border-bottom: 2px solid #e2e8f0;
	font-size: 0.8rem;
	text-transform: uppercase;
	letter-spacing: 0.03em;
}

.fincalc-table td {
	padding: 8px 12px;
	border-bottom: 1px solid #f1f5f9;
	color: #475569;
}

.fincalc-table tr:hover td {
	background: #f8fafc;
}

.fincalc-table .table-expand-btn {
	display: block;
	width: 100%;
	text-align: center;
	padding: 10px;
	background: #f8fafc;
	border: 1px solid #e2e8f0;
	border-radius: 0 0 6px 6px;
	color: #2563eb;
	font-weight: 600;
	font-size: 0.85rem;
	cursor: pointer;
}

/* ── Affiliate CTA Box ── */
.fincalc-cta {
	background: linear-gradient(135deg, #f0fdf4, #dcfce7);
	border: 1px solid #86efac;
	border-radius: 10px;
	padding: 20px 24px;
	margin-top: 28px;
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: 16px;
}

.fincalc-cta p {
	margin: 0;
	color: #166534;
	font-size: 0.95rem;
	font-weight: 500;
}

.fincalc-cta a {
	background: #16a34a;
	color: #fff;
	padding: 10px 20px;
	border-radius: 6px;
	text-decoration: none;
	font-weight: 600;
	font-size: 0.9rem;
	white-space: nowrap;
	transition: background 0.2s;
}

.fincalc-cta a:hover {
	background: #15803d;
}

/* ── Related Calculators ── */
.fincalc-related {
	margin-top: 36px;
	padding-top: 24px;
	border-top: 1px solid #e2e8f0;
}

.fincalc-related h3 {
	font-size: 1.05rem;
	color: #374151;
	margin-bottom: 14px;
}

.fincalc-related-grid {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
}

.fincalc-related-grid a {
	background: #f8fafc;
	border: 1px solid #e2e8f0;
	border-radius: 6px;
	padding: 8px 14px;
	font-size: 0.875rem;
	color: #2563eb;
	text-decoration: none;
	font-weight: 500;
	transition: all 0.15s;
}

.fincalc-related-grid a:hover {
	background: #eff6ff;
	border-color: #bfdbfe;
}

/* ── Validation Error ── */
.fincalc-error {
	color: #dc2626;
	font-size: 0.85rem;
	margin-top: 4px;
}

.fincalc-group input.fincalc-input-error {
	border-color: #dc2626;
}

/* ── Comparison side-by-side ── */
.fincalc-comparison {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 16px;
	margin-top: 24px;
}

.fincalc-comparison-col {
	background: #f8fafc;
	border: 1px solid #e2e8f0;
	border-radius: 8px;
	padding: 16px;
}

.fincalc-comparison-col h4 {
	font-size: 0.95rem;
	color: #1e40af;
	margin-bottom: 12px;
}

.fincalc-comparison-col.highlight {
	border-color: #86efac;
	background: #f0fdf4;
}

.fincalc-comparison-col.highlight h4 {
	color: #166534;
}

/* ── Dynamic debt rows ── */

/* Hide old header row (no longer used) */
.fincalc-row-header { display: none; }

/* Each debt is a mini-card */
.fincalc-dynamic-rows {
	display: flex;
	flex-direction: column;
	gap: 8px;
	margin-bottom: 8px;
}

.fincalc-dynamic-rows .fincalc-row {
	background: #f8fafc;
	border: 1px solid #e2e8f0;
	border-radius: 8px;
	padding: 12px;
}

/* Top line: name input + remove button */
.fincalc-row-top {
	display: flex;
	gap: 8px;
	margin-bottom: 10px;
}

.fincalc-row-top input {
	flex: 1;
	min-width: 0;
	padding: 8px 10px;
	border: 1px solid #cbd5e0;
	border-radius: 6px;
	font-size: 0.9rem;
	color: #1a202c;
	background: #fff;
	box-sizing: border-box;
}

.fincalc-row-top input:focus {
	outline: none;
	border-color: #2563eb;
	box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

/* Three numeric fields in a row */
.fincalc-row-fields {
	display: grid;
	grid-template-columns: 1fr 1fr 1fr;
	gap: 8px;
}

.fincalc-row-field {
	display: flex;
	flex-direction: column;
	gap: 4px;
}

.fincalc-row-field label {
	font-size: 0.7rem;
	font-weight: 600;
	color: #64748b;
	text-transform: uppercase;
	letter-spacing: 0.04em;
}

.fincalc-row-field input {
	width: 100%;
	padding: 8px 8px;
	border: 1px solid #cbd5e0;
	border-radius: 6px;
	font-size: 0.9rem;
	color: #1a202c;
	background: #fff;
	box-sizing: border-box;
}

.fincalc-row-field input:focus {
	outline: none;
	border-color: #2563eb;
	box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

/* Remove (×) button */
.fincalc-row-remove {
	width: 36px;
	height: 36px;
	flex-shrink: 0;
	padding: 0;
	background: #fee2e2;
	color: #dc2626;
	border: 1px solid #fecaca;
	border-radius: 6px;
	cursor: pointer;
	font-size: 1.15rem;
	font-weight: 700;
	line-height: 1;
	text-align: center;
}

.fincalc-row-remove:hover {
	background: #fecaca;
}

.fincalc-add-btn {
	padding: 8px 16px;
	background: #eff6ff;
	color: #2563eb;
	border: 1px dashed #93c5fd;
	border-radius: 6px;
	cursor: pointer;
	font-weight: 600;
	font-size: 0.85rem;
	margin-top: 4px;
}

.fincalc-add-btn:hover {
	background: #dbeafe;
}

/* ── HYSA rate table ── */
.fincalc-rate-table {
	width: 100%;
	border-collapse: collapse;
	margin-top: 16px;
}

.fincalc-rate-table th {
	background: #f0fdf4;
	color: #166534;
	font-weight: 600;
	text-align: left;
	padding: 10px 12px;
	font-size: 0.8rem;
	text-transform: uppercase;
}

.fincalc-rate-table td {
	padding: 10px 12px;
	border-bottom: 1px solid #f1f5f9;
	font-size: 0.9rem;
	color: #475569;
}

.fincalc-rate-table a {
	color: #16a34a;
	font-weight: 600;
	text-decoration: none;
}

.fincalc-rate-table a:hover {
	text-decoration: underline;
}

/* ── Copy Link / Share Button ── */
.fincalc-share-btn {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 8px 16px;
	background: #f8fafc;
	border: 1px solid #e2e8f0;
	border-radius: 6px;
	color: #475569;
	font-size: 0.85rem;
	font-weight: 500;
	cursor: pointer;
	margin-top: 12px;
	transition: all 0.15s;
}

.fincalc-share-btn:hover {
	background: #eff6ff;
	border-color: #bfdbfe;
	color: #2563eb;
}

.fincalc-share-btn.copied {
	background: #f0fdf4;
	border-color: #86efac;
	color: #16a34a;
}

/* ── Tooltips ── */
/* Isolation on comparison cols so tooltips can use z-index freely */
.fincalc-comparison-col {
	isolation: isolate;
}

.fincalc-tip {
	position: relative;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 16px;
	height: 16px;
	border-radius: 50%;
	background: #e2e8f0;
	color: #64748b;
	font-size: 0.65rem;
	font-weight: 700;
	cursor: help;
	margin-left: 6px;
	vertical-align: middle;
	line-height: 1;
	z-index: 10;
}

.fincalc-tip:hover,
.fincalc-tip.active {
	background: #2563eb;
	color: #fff;
}

.fincalc-tip-text {
	display: none;
	position: absolute;
	bottom: calc(100% + 8px);
	left: 50%;
	transform: translateX(-50%);
	width: 240px;
	padding: 10px 12px;
	background: #1e293b;
	color: #f1f5f9;
	font-size: 0.8rem;
	font-weight: 400;
	line-height: 1.45;
	border-radius: 6px;
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
	z-index: 9999;
	pointer-events: none;
	white-space: normal;
}

.fincalc-tip-text::after {
	content: '';
	position: absolute;
	top: 100%;
	left: 50%;
	transform: translateX(-50%);
	border: 5px solid transparent;
	border-top-color: #1e293b;
}

.fincalc-tip:hover .fincalc-tip-text,
.fincalc-tip.active .fincalc-tip-text {
	display: block;
}

/* ==========================================================================
   Responsive — Mobile First
   ========================================================================== */
@media (max-width: 600px) {
	.fincalc-wrapper {
		padding: 20px 16px;
		margin: 16px auto;
		border-radius: 8px;
	}

	.fincalc-slider-row {
		flex-direction: column;
		align-items: stretch;
	}

	.fincalc-slider-row input[type="number"] {
		width: 100%;
	}

	.fincalc-cta {
		flex-direction: column;
		text-align: center;
	}

	.fincalc-cta a {
		width: 100%;
		text-align: center;
	}

	.fincalc-comparison {
		grid-template-columns: 1fr;
	}

	.fincalc-toggle label {
		padding: 8px 8px;
		font-size: 0.8rem;
	}

	/* Stack the three numeric fields on narrow screens */
	.fincalc-row-fields {
		grid-template-columns: 1fr 1fr;
	}

	.fincalc-tip-text {
		width: 200px;
		left: auto;
		right: -8px;
		transform: none;
	}

	.fincalc-tip-text::after {
		left: auto;
		right: 12px;
		transform: none;
	}
}
