/* Trình Giải Toán — thanh chia sẻ, bảng chia sẻ bật lên, nút dưới kết quả và kiểu khi in. */

.tgt-share {
	--tgt-share-ink: #23314d;
	--tgt-share-muted: #5d6b86;
	--tgt-share-line: #e3e8f4;
	--tgt-share-bg: #ffffff;
	display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px;
	margin: 28px 0 8px; padding: 14px 0; border-top: 1px dashed var(--tgt-share-line);
	font-family: inherit; clear: both;
}
.tgt-share--top { margin: 0 0 22px; border-top: 0; border-bottom: 1px dashed var(--tgt-share-line); }
.tgt-share--inline { border: 0; padding: 0; margin: 16px 0; }
.tgt-share__label { font-weight: 800; color: var(--tgt-share-muted); font-size: .95rem; }
.tgt-share__btns { display: flex; flex-wrap: wrap; gap: 8px; }
.tgt-share__btn {
	--tgt-share-c: #5d6b86;
	display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 14px 0 10px;
	border-radius: 999px; border: 0; background: var(--tgt-share-c); color: #fff !important;
	font: inherit; font-weight: 700; font-size: .92rem; line-height: 1; text-decoration: none !important;
	cursor: pointer; transition: transform .1s ease, filter .15s ease, box-shadow .15s ease;
	box-shadow: 0 3px 10px rgba(35, 49, 77, .12);
}
.tgt-share__btn:hover { filter: brightness(1.08); transform: translateY(-1px); }
.tgt-share__btn:active { transform: scale(.96); }
.tgt-share__btn:focus-visible { outline: 3px solid #3d7bfd; outline-offset: 2px; }
.tgt-share__btn[hidden] { display: none; }
.tgt-share__icon { width: 20px; height: 20px; flex: none; }
.tgt-share__btn--zalo .tgt-share__icon { width: 26px; margin: 0 -2px; }
.tgt-share__btn--instagram { background: linear-gradient(45deg, #f9a825 0%, #e1306c 45%, #833ab4 100%); }
.tgt-share__btn--copy, .tgt-share__btn--print, .tgt-share__btn--email {
	background: #eef1f8; color: var(--tgt-share-ink) !important; box-shadow: none;
}

/* Màn hình hẹp: chỉ còn biểu tượng tròn cho gọn một hàng. */
@media (max-width: 600px) {
	.tgt-share .tgt-share__btns { gap: 6px; }
	.tgt-share .tgt-share__btn { width: 38px; height: 38px; padding: 0; justify-content: center; }
	.tgt-share .tgt-share__btn .tgt-share__text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
	.tgt-share .tgt-share__label { width: 100%; }
}

/* ---------- Bảng chia sẻ bật lên ---------- */
.tgt-share-sheet { position: fixed; inset: 0; z-index: 100000; display: flex; align-items: center; justify-content: center; padding: 16px; font-family: "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
.tgt-share-sheet__backdrop { position: absolute; inset: 0; background: rgba(15, 23, 42, .5); opacity: 0; transition: opacity .2s ease; }
.tgt-share-sheet__box {
	position: relative; width: min(460px, 100%); background: #fff; color: #23314d; border-radius: 22px;
	padding: 18px 18px 16px; box-shadow: 0 24px 60px rgba(0, 0, 0, .3);
	transform: translateY(16px) scale(.98); opacity: 0; transition: transform .2s ease, opacity .2s ease;
}
.tgt-share-sheet.is-open .tgt-share-sheet__backdrop { opacity: 1; }
.tgt-share-sheet.is-open .tgt-share-sheet__box { transform: none; opacity: 1; }
.tgt-share-sheet__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.tgt-share-sheet__head strong { font-size: 1.15rem; font-weight: 800; }
.tgt-share-sheet__x { width: 36px; height: 36px; border-radius: 50%; border: 0; background: #eef1f8; color: #23314d; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.tgt-share-sheet__x svg { width: 18px; height: 18px; }
.tgt-share-sheet__desc { margin: 0 0 12px; color: #5d6b86; font-size: .95rem; }
.tgt-share__btns--grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px; margin: 10px 0 12px; }
.tgt-share__btns--grid .tgt-share__btn { justify-content: flex-start; height: 44px; }
.tgt-share-sheet__link input {
	width: 100%; box-sizing: border-box; border: 2px solid #e3e8f4; border-radius: 12px; padding: 9px 12px;
	font: inherit; font-size: .88rem; color: #5d6b86; background: #f6f8ff;
}
.tgt-share-sheet .screen-reader-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
@media (max-width: 600px) {
	.tgt-share-sheet { align-items: flex-end; padding: 0; }
	.tgt-share-sheet__box { border-radius: 22px 22px 0 0; width: 100%; padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
	.tgt-share__btns--grid { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- Thông báo nhỏ ---------- */
.tgt-share-toast {
	position: fixed; left: 50%; bottom: 24px; z-index: 100001; max-width: min(440px, calc(100vw - 32px));
	transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
	background: #23314d; color: #fff; padding: 12px 18px; border-radius: 14px; font-weight: 700; font-size: .95rem;
	box-shadow: 0 12px 30px rgba(0, 0, 0, .25); transition: transform .2s ease, opacity .2s ease; text-align: center;
	font-family: "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
.tgt-share-toast.is-show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Nút dưới kết quả công cụ / điểm bộ đề ---------- */
.tgt-share-result { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.tgt-share-result__btn {
	display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 8px 16px;
	border-radius: 999px; border: 2px solid #e3e8f4; background: #fff; color: #23314d;
	font: inherit; font-weight: 800; font-size: .95rem; cursor: pointer;
}
.tgt-share-result__btn svg { width: 18px; height: 18px; }
.tgt-share-result__btn:hover { border-color: #3d7bfd; color: #2563eb; }
.tgt-share-result__btn.is-main { background: #3d7bfd; border-color: #3d7bfd; color: #fff; }
.tgt-share-result__btn.is-main:hover { background: #2563eb; color: #fff; }
.tgt-share-result__btn:focus-visible { outline: 3px solid #3d7bfd; outline-offset: 2px; }

.tgt-score .tgt-share-result { margin-top: 12px; }
@media (max-width: 600px) { .tgt-score .tgt-share-result { justify-content: center; } }

/* ---------- Chế độ tối của theme ---------- */
:root[data-mode="dark"] .tgt-share { --tgt-share-ink: #e9edf8; --tgt-share-muted: #a5b0cc; --tgt-share-line: #2a365e; }
:root[data-mode="dark"] .tgt-share__btn--copy,
:root[data-mode="dark"] .tgt-share__btn--print,
:root[data-mode="dark"] .tgt-share__btn--email { background: #233059; }
:root[data-mode="dark"] .tgt-share-sheet__box { background: #121a35; color: #e9edf8; }
:root[data-mode="dark"] .tgt-share-sheet__x { background: #233059; color: #e9edf8; }
:root[data-mode="dark"] .tgt-share-sheet__desc { color: #a5b0cc; }
:root[data-mode="dark"] .tgt-share-sheet__link input { background: #1b2547; border-color: #2a365e; color: #a5b0cc; }
:root[data-mode="dark"] .tgt-share-sheet .tgt-share__btn--copy,
:root[data-mode="dark"] .tgt-share-sheet .tgt-share__btn--print,
:root[data-mode="dark"] .tgt-share-sheet .tgt-share__btn--email { background: #233059; color: #e9edf8 !important; }

/* ---------- In ---------- */
.tgt-print-head { display: none; }
@media print {
	.tgt-share, .tgt-share-result, .tgt-share-sheet, .tgt-share-toast,
	.tgtt-topbar, .tgtt-header, .tgtt-footer, .tgtt-skip, .tgtt-comments-wrap, #comments, .comments-area,
	.tgt-form__actions, .tgt-examples, .tgt-quiz__top, .tgt-graph__controls, .tgt-stage__close, .tgt-quiz__actions, .tgt-score button {
		display: none !important;
	}
	body { background: #fff !important; }
	.tgt, .tgt * { box-shadow: none !important; }
	.tgt-q, .tgt-answer, .tgt-steps-wrap, .tgt-score { break-inside: avoid; }

	/* In riêng một khối (bài làm, lời giải): JS gắn .tgt-print-hide cho mọi khối khác. */
	html.tgt-printing .tgt-print-hide { display: none !important; }
	html.tgt-printing .tgt-print-scope { margin: 0 !important; }
	html.tgt-printing .tgt-print-head { display: flex; flex-direction: column; gap: 2px; margin: 0 0 14px; padding-bottom: 8px; border-bottom: 1px solid #ccc; }
	html.tgt-printing .tgt-print-head strong { font-size: 18px; }
	html.tgt-printing .tgt-print-head span { font-size: 11px; color: #555; word-break: break-all; }
}
