/* ============================================================
   ADZIO – CÔNG CỤ TÍNH LÃI VAY BẤT ĐỘNG SẢN
   Chỉ nạp trên trang có shortcode [adzio_loan_calc] (xem functions.php).
   Màu lấy từ design token ở style.css (--adz-gold / --adz-ink / ...).
   ============================================================ */

.adz-calc {
	--c-soft: #faf9f7;          /* nền ô nhập */
	--c-principal: #EADFCD;     /* cung "gốc" trên donut – vàng nhạt */
	max-width: 1140px;
	margin: 0 auto;
	font-family: var(--adz-font-b);
}

/* ---------- Bố cục 2 card trên: form + donut ---------- */
.adz-calc-top {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 24px;
	align-items: stretch;
}
.adz-calc-card {
	background: #fff;
	border: 1px solid var(--adz-border);
	border-radius: 16px;
	padding: 22px;
	box-shadow: 0 10px 30px -18px rgba(6, 31, 56, .25);
}
.adz-calc-card h2 {
	font-size: 1.05rem;
	font-weight: 700;
	margin: 0 0 16px;
}

/* ---------- Ô nhập ---------- */
.adz-calc-field { margin-bottom: 16px; }
.adz-calc-field label {
	display: block;
	font-size: .85rem;
	font-weight: 600;
	color: var(--adz-ink);
	margin-bottom: 6px;
}
.adz-calc-field input[type=text],
.adz-calc-field input[type=number] {
	width: 100%;
	box-sizing: border-box;
	padding: 10px 12px;
	font-size: .95rem;
	border: 1px solid var(--adz-border);
	border-radius: 10px;
	font-family: var(--adz-font-b);
	background: var(--c-soft);
	color: var(--adz-ink);
	box-shadow: none;
	margin: 0;
	height: auto;
}
.adz-calc-field input:focus {
	outline: 2px solid var(--adz-gold);
	border-color: var(--adz-gold);
	background: #fff;
}
/* Bỏ mũi tên tăng/giảm của input number cho gọn */
.adz-calc-field input[type=number] { -moz-appearance: textfield; appearance: textfield; }
.adz-calc-field input[type=number]::-webkit-outer-spin-button,
.adz-calc-field input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.adz-calc-suffix { position: relative; }
.adz-calc-suffix > span {
	position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
	color: var(--adz-muted); font-size: .85rem; pointer-events: none;
}
.adz-calc-hint { font-size: .78rem; color: var(--adz-muted); margin: 6px 0 0; }

/* ---------- Nút chọn phương thức trả nợ ---------- */
.adz-calc-methods { display: flex; gap: 8px; }
.adz-calc-methods button {
	flex: 1; padding: 10px 6px;
	font-family: var(--adz-font-b); font-size: .82rem; font-weight: 600;
	cursor: pointer; border: 1px solid var(--adz-border);
	background: var(--c-soft); border-radius: 10px;
	color: var(--adz-muted); transition: all .2s ease;
	text-transform: none; letter-spacing: 0; line-height: 1.35;
}
.adz-calc-methods button:hover { border-color: var(--adz-gold); color: var(--adz-ink); }
.adz-calc-methods button.is-on {
	background: var(--adz-gold); color: #fff; border-color: var(--adz-gold);
}

/* ---------- Tuỳ chọn mở rộng (ưu đãi / ân hạn) ---------- */
.adz-calc-toggle {
	display: flex; align-items: center; gap: 8px;
	font-size: .85rem; color: var(--adz-ink); cursor: pointer; margin-bottom: 10px;
	font-weight: 500;
}
.adz-calc-toggle input { margin: 0; }
.adz-calc-sub { display: none; grid-template-columns: 1fr 1fr; gap: 12px; }
.adz-calc-sub.is-on { display: grid; }
.adz-calc-sub.one-col { grid-template-columns: 1fr; }

/* ---------- Donut cơ cấu gốc – lãi ---------- */
.adz-calc-chart { display: flex; flex-direction: column; }
.adz-calc-chart-body { flex: 1; display: flex; flex-direction: column; justify-content: center; }
.adz-donut { display: flex; justify-content: center; margin: 10px 0 18px; }
.adz-donut svg { width: 200px; height: 200px; }
.adz-donut-legend { display: flex; flex-direction: column; gap: 10px; font-size: .92rem; }
.adz-donut-legend .adz-dl-row { display: flex; align-items: center; color: var(--adz-muted); }
.adz-donut-legend .adz-dot {
	display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 8px; flex: 0 0 auto;
}
.adz-donut-legend .adz-dot-p { background: var(--c-principal); }
.adz-donut-legend .adz-dot-i { background: var(--adz-gold); }
.adz-donut-legend b { color: var(--adz-ink); margin: 0 6px 0 3px; }
.adz-donut-legend .adz-pct { color: var(--adz-muted); font-size: .82rem; margin-left: auto; }
.adz-donut-total {
	margin-top: 14px; padding-top: 14px;
	border-top: 1px dashed var(--adz-border);
	font-size: .95rem; color: var(--adz-muted);
}
.adz-donut-total b {
	color: var(--adz-gold); font-family: var(--adz-font-d); font-weight: 800; margin-left: 5px;
}
.adz-donut-extra {
	margin-top: 12px; display: flex; flex-direction: column; gap: 8px;
	font-size: .9rem; color: var(--adz-ink);
}
.adz-donut-extra .adz-dl-row { display: flex; justify-content: space-between; align-items: center; }
.adz-donut-extra .adz-dl-row > span { color: var(--adz-muted); }
.adz-donut-extra b { font-family: var(--adz-font-d); font-weight: 700; color: var(--adz-ink); }

/* ---------- Kết quả + bảng lịch trả nợ ---------- */
.adz-calc-results { margin-top: 24px; }
.adz-calc-results-head {
	display: flex; justify-content: space-between; align-items: center;
	flex-wrap: wrap; gap: 10px; margin-bottom: 16px;
}
.adz-calc-results-head h2 { margin: 0; }
.adz-calc-dl { display: flex; gap: 8px; }
.adz-calc-dl button {
	display: inline-flex; align-items: center; gap: 6px;
	font-family: var(--adz-font-b); font-size: .82rem; font-weight: 600;
	cursor: pointer; border: 1px solid var(--adz-border); background: #fff;
	color: var(--adz-ink); padding: 8px 14px; border-radius: 9px;
	transition: all .2s ease; text-transform: none; letter-spacing: 0;
}
.adz-calc-dl button:hover { border-color: var(--adz-gold); color: var(--adz-gold); background: #fff; }
.adz-calc-dl button i { font-size: .95rem; }

.adz-calc-sumrow { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 18px; }
.adz-calc-sum {
	background: var(--c-soft); border: 1px solid var(--adz-border);
	border-radius: 12px; padding: 15px; text-align: center;
}
.adz-calc-sum .adz-cs-lbl {
	font-size: .72rem; color: var(--adz-muted);
	text-transform: uppercase; letter-spacing: .03em; line-height: 1.4;
}
.adz-calc-sum .adz-cs-val {
	font-family: var(--adz-font-d); font-weight: 800; font-size: 1.15rem;
	color: var(--adz-gold); margin-top: 5px;
}
.adz-calc-sum.is-big .adz-cs-val { color: var(--adz-ink); }

.adz-calc-note { font-size: .82rem; color: var(--adz-muted); margin: 4px 0 16px; max-width: none; }

.adz-calc-table-wrap {
	overflow: auto; max-height: 72vh;
	border: 1px solid var(--adz-border); border-radius: 12px;
	-webkit-overflow-scrolling: touch;
}
table.adz-calc-t { width: 100%; border-collapse: collapse; font-size: .84rem; margin: 0; }
table.adz-calc-t th, table.adz-calc-t td {
	padding: 9px 10px; text-align: right; white-space: nowrap; border-right: none;
}
table.adz-calc-t thead th { position: sticky; top: 0; z-index: 2; }
table.adz-calc-t th {
	background: var(--c-soft); color: var(--adz-ink); font-weight: 700;
	border-bottom: 2px solid var(--adz-border);
	/* Flatsome đặt th in HOA – trả lại chữ thường như mẫu */
	text-transform: none; letter-spacing: 0; font-size: inherit;
}
table.adz-calc-t th:first-child, table.adz-calc-t td:first-child { text-align: left; }
table.adz-calc-t td { border-bottom: 1px solid var(--adz-border); color: var(--adz-ink-2); }
table.adz-calc-t tbody tr:last-child td {
	border-bottom: none; font-weight: 700; background: rgba(209, 167, 101, .08);
}
table.adz-calc-t tbody tr:nth-child(even) td { background: rgba(6, 31, 56, .015); }
table.adz-calc-t tbody tr:last-child td { background: rgba(209, 167, 101, .08); }

/* ============ RESPONSIVE ============ */
@media (max-width: 900px) {
	.adz-calc-top { grid-template-columns: 1fr; }
}
@media (max-width: 768px), (pointer: coarse) {
	/* 16px để iOS không tự zoom khi focus vào ô nhập */
	.adz-calc-field input[type=text],
	.adz-calc-field input[type=number] { font-size: 16px; padding: 12px 14px; }
}
@media (max-width: 640px) {
	.adz-calc-card { padding: 16px; }
	.adz-calc-results-head { flex-direction: column; align-items: stretch; }
	.adz-calc-dl button { flex: 1; justify-content: center; }
	/* 3 ô số liệu -> hàng ngang nhãn · giá trị cho gọn chiều cao */
	.adz-calc-sumrow { grid-template-columns: 1fr; gap: 10px; margin-bottom: 14px; }
	.adz-calc-sum {
		display: flex; align-items: center; justify-content: space-between;
		text-align: left; padding: 11px 14px; gap: 12px;
	}
	.adz-calc-sum .adz-cs-val { margin-top: 0; font-size: 1.02rem; }
	.adz-donut svg { width: 168px; height: 168px; }
	/* % đứng ngay sau số thay vì đẩy sát mép phải – nếu đẩy sát mép sẽ bị
	   nút liên hệ nổi (plugin, góc phải) che mất trên màn hẹp. */
	.adz-donut-legend .adz-pct { margin-left: 6px; }
	.adz-calc-table-wrap { max-height: 60vh; }
	table.adz-calc-t { font-size: .72rem; }
	table.adz-calc-t th, table.adz-calc-t td { padding: 7px 5px; }
	table.adz-calc-t th:first-child, table.adz-calc-t td:first-child { padding-left: 8px; }
	/* Ẩn cột "Dư nợ cuối kỳ" + dòng Tổng (đã có ở ô tổng phía trên) để bảng khỏi kéo ngang */
	table.adz-calc-t th:nth-child(5),
	table.adz-calc-t td:nth-child(5) { display: none; }
	table.adz-calc-t tbody tr:last-child { display: none; }
}

/* ============ IN / XUẤT PDF ============ */
@media print {
	.header, .header-wrapper, .footer-wrapper, #adz-particles, .adz-noise,
	.adz-cur-dot, .adz-cur-ring, .adz-calc-dl, .adzio-svc-cta, .adz-calc-extra,
	.adz-toc, #top-link, .adz-hero-actions { display: none !important; }
	body { background: #fff !important; }
	.adz-tool-hero { padding: 0 !important; min-height: 0 !important; }
	.adz-article-wrap {
		box-shadow: none !important; border: none !important;
		padding: 0 !important; max-width: 100% !important; margin: 0 !important;
	}
	.adz-calc { max-width: 100% !important; margin: 8px 0 0 !important; }
	.adz-calc-card { box-shadow: none !important; border-color: #ccc !important; break-inside: avoid; }
	.adz-calc-table-wrap { max-height: none !important; overflow: visible !important; }
	table.adz-calc-t { font-size: 11px; }
	table.adz-calc-t thead th { position: static; }
}
