/* =========================================================================
   Solution Advisor — trang Gợi ý giải pháp theo brief
   Template: template-solution-advisor.php
   ========================================================================= */

.at-sa {
	--sa-orange: #f26522;
	--sa-orange-dark: #e04f16;
	--sa-orange-soft: #fff4ed;
	--sa-orange-line: #fed7c3;
	--sa-text: #1e293b;
	--sa-muted: #64748b;
	--sa-line: #e2e8f0;
	--sa-bg: #f8fafc;
	--sa-card: #ffffff;
	--sa-radius: 14px;
	--g-awareness: #2563eb;
	--g-awareness-bg: #eff6ff;
	--g-conversion: #ea580c;
	--g-conversion-bg: #fff7ed;
	--g-retention: #16a34a;
	--g-retention-bg: #f0fdf4;
	--g-referral: #7c3aed;
	--g-referral-bg: #f5f3ff;

	font-family: 'Be Vietnam Pro', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
	color: var(--sa-text);
	background: var(--sa-bg);
	padding: 24px 16px 48px;
}

.at-sa *,
.at-sa *::before,
.at-sa *::after { box-sizing: border-box; }

.at-sa h1, .at-sa h2, .at-sa h3, .at-sa h4 {
	font-family: inherit;
	color: var(--sa-text);
	margin: 0;
	letter-spacing: -0.01em;
}
.at-sa p { margin: 0; }
.at-sa ul, .at-sa ol { margin: 0; padding: 0; list-style: none; }
.at-sa button { font-family: inherit; text-transform: none; letter-spacing: normal; margin: 0; min-height: 0; line-height: 1.3; }
.at-sa .at-sa-ico { flex-shrink: 0; }

.at-sa-layout {
	max-width: 1440px;
	margin: 0 auto;
	display: grid;
	grid-template-columns: 290px minmax(0, 1fr);
	gap: 20px;
	align-items: start;
}
.at-sa.has-detail .at-sa-layout { grid-template-columns: 270px minmax(0, 1fr) 330px; }

.at-sa-card {
	background: var(--sa-card);
	border: 1px solid var(--sa-line);
	border-radius: var(--sa-radius);
	padding: 22px;
	box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
}

/* ---------- Brief ---------- */

.at-sa-brief { position: sticky; top: 90px; }

/* Thẻ brief cao tối đa bằng màn hình: phần câu hỏi cuộn bên trong, nút "Xem giải pháp" luôn ghim ở đáy thẻ */
.at-sa-brief .at-sa-card {
	display: flex;
	flex-direction: column;
	max-height: calc(100vh - 110px);
	padding: 0;
	overflow: hidden;
}
.at-sa-brief-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 22px 22px 6px; overscroll-behavior: contain; }
.at-sa-brief-foot {
	flex: 0 0 auto;
	padding: 12px 22px 14px;
	background: #fff;
	border-top: 1px solid var(--sa-line);
	box-shadow: 0 -6px 14px rgba(15, 23, 42, .05);
}
.at-sa-brief-title { font-size: 19px; font-weight: 800; }
.at-sa-brief-sub { font-size: 13px; color: var(--sa-muted); margin: 4px 0 18px !important; }

.at-sa-field { border: 0; padding: 0; margin: 0 0 16px; min-width: 0; }
.at-sa-label {
	display: block;
	font-size: 13.5px;
	font-weight: 700;
	margin-bottom: 8px;
	padding: 0;
	color: var(--sa-text);
}
.at-sa-req { color: var(--sa-orange); }
.at-sa-hint { font-weight: 500; color: var(--sa-muted); font-size: 12px; }

.at-sa .at-sa-select {
	width: 100%;
	height: 42px;
	margin: 0;
	padding: 0 12px;
	font-size: 14px;
	border: 1px solid var(--sa-line);
	border-radius: 10px;
	background-color: #fff;
	color: var(--sa-text);
	box-shadow: none;
}
.at-sa .at-sa-select:focus { border-color: var(--sa-orange); outline: 0; box-shadow: 0 0 0 3px rgba(242, 101, 34, .15); }

.at-sa-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.at-sa-chip { position: relative; margin: 0; cursor: pointer; font-weight: 500; }
.at-sa-chip input { position: absolute; opacity: 0; pointer-events: none; }
.at-sa-chip span {
	display: inline-block;
	padding: 7px 11px;
	font-size: 12.5px;
	line-height: 1.3;
	border: 1px solid var(--sa-line);
	border-radius: 999px;
	background: #fff;
	color: #334155;
	transition: all .15s ease;
}
.at-sa-chip:hover span { border-color: var(--sa-orange-line); }
.at-sa-chip input:checked + span { background: var(--sa-orange-soft); border-color: var(--sa-orange); color: var(--sa-orange-dark); font-weight: 600; }
.at-sa-chip input:focus-visible + span { box-shadow: 0 0 0 3px rgba(242, 101, 34, .25); }
.at-sa-chip.is-disabled { cursor: not-allowed; opacity: .45; }

.at-sa-more { margin: 0 0 16px; border-top: 1px dashed var(--sa-line); padding-top: 12px; }
.at-sa-more summary { font-size: 13px; font-weight: 600; color: var(--sa-orange-dark); cursor: pointer; margin-bottom: 12px; }

.at-sa-segment { display: flex; border: 1px solid var(--sa-line); border-radius: 10px; overflow: hidden; }
.at-sa-segment label { flex: 1; margin: 0; cursor: pointer; }
.at-sa-segment input { position: absolute; opacity: 0; pointer-events: none; }
.at-sa-segment span { display: block; text-align: center; font-size: 12px; font-weight: 500; padding: 8px 4px; color: #475569; }
.at-sa-segment label + label span { border-left: 1px solid var(--sa-line); }
.at-sa-segment input:checked + span { background: var(--sa-orange-soft); color: var(--sa-orange-dark); font-weight: 700; }

.at-sa-error { font-size: 13px; color: #dc2626; margin-bottom: 10px; }
.at-sa legend.at-sa-label { text-transform: none; }
.at-sa-note { font-size: 11.5px; color: var(--sa-muted); margin-top: 8px; text-align: center; line-height: 1.4; }

/* ---------- Buttons ---------- */

.at-sa .at-sa-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	padding: 12px 18px;
	font-size: 14.5px;
	font-weight: 700;
	border-radius: 10px;
	border: 1px solid transparent;
	cursor: pointer;
	text-decoration: none;
	transition: all .15s ease;
}
.at-sa .at-sa-btn-block { width: 100%; }
/* Nút trong cột brief luôn 1 dòng, kể cả khi hiển thị đủ 3 cột */
.at-sa .at-sa-brief-foot .at-sa-btn { white-space: nowrap; font-size: 14px; padding: 12px 10px; gap: 6px; }
.at-sa .at-sa-btn-primary { background: linear-gradient(135deg, #f97316, var(--sa-orange-dark)); color: #fff; box-shadow: 0 6px 16px rgba(242, 101, 34, .28); }
.at-sa .at-sa-btn-primary:hover { filter: brightness(1.05); color: #fff; }
.at-sa .at-sa-btn-outline { background: #fff; color: var(--sa-orange-dark); border-color: var(--sa-orange); }
.at-sa .at-sa-btn-outline:hover { background: var(--sa-orange-soft); }
.at-sa .at-sa-btn-ghost { background: transparent; color: var(--sa-text); border-color: var(--sa-line); margin-top: 8px; font-weight: 600; }
.at-sa .at-sa-btn-ghost:hover { border-color: var(--sa-orange); color: var(--sa-orange-dark); }
.at-sa .at-sa-link { background: none; border: 0; padding: 0; color: var(--sa-orange-dark); font-weight: 600; text-decoration: underline; cursor: pointer; font-size: inherit; }
.at-sa .at-sa-icon-btn { background: none; border: 0; padding: 4px; color: var(--sa-muted); cursor: pointer; border-radius: 6px; }
.at-sa .at-sa-icon-btn:hover { color: var(--sa-text); background: var(--sa-bg); }

/* ---------- Main ---------- */

.at-sa-head { margin-bottom: 18px; }
.at-sa-title { font-size: 26px; font-weight: 800; line-height: 1.25; }
.at-sa-title em { font-style: normal; color: var(--sa-orange); }
.at-sa-sub { color: var(--sa-muted); font-size: 14px; margin-top: 4px !important; }

.at-sa-section + .at-sa-section { margin-top: 26px; }
.at-sa-section-title {
	display: flex;
	align-items: center;
	gap: 8px;
	font-size: 17px !important;
	font-weight: 800;
	margin-bottom: 14px !important;
}
.at-sa-section-title .at-sa-ico { color: var(--sa-orange); }

/* Journey */
.at-sa-journey { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; margin-bottom: 12px !important; }
.at-sa-journey-step {
	position: relative;
	display: flex;
	flex-direction: column;
	align-items: center;
	padding: 8px 4px 8px 14px;
	background: #eef2f6;
	clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 50%, calc(100% - 12px) 100%, 0 100%, 12px 50%);
	text-align: center;
	transition: background .2s ease, color .2s ease;
}
.at-sa-journey-step:first-child { clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 50%, calc(100% - 12px) 100%, 0 100%); padding-left: 6px; }
.at-sa-journey-num { font-size: 13px; font-weight: 800; }
.at-sa-journey-label { font-size: 11.5px; color: var(--sa-muted); }
/* 2 trạng thái: cam đậm = bước được tác động, xám nhạt = không tác động */
.at-sa-journey.has-active .at-sa-journey-step:not(.is-active) { background: #f1f5f9; color: #a3b1c2; }
.at-sa-journey.has-active .at-sa-journey-step:not(.is-active) .at-sa-journey-label { color: #a3b1c2; }
.at-sa-journey-step.is-active { background: var(--sa-orange); color: #fff; }
.at-sa-journey-step.is-active .at-sa-journey-label { color: #fff; font-weight: 600; }
.at-sa-journey-caption { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--sa-muted); margin: -4px 0 12px; }
.at-sa-journey-caption::before { content: ''; flex: 0 0 18px; height: 8px; border-radius: 3px; background: var(--sa-orange); }
.at-sa-journey-caption strong { color: var(--sa-text); }

/* Groups */
.at-sa-groups { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.at-sa-group { border-radius: 12px; padding: 14px; display: flex; flex-direction: column; }
.at-sa-group-title { display: flex; align-items: center; gap: 6px; font-size: 13.5px !important; font-weight: 800; line-height: 1.25; margin-bottom: 8px !important; }
.at-sa-group-list { flex: 1; }
.at-sa-group-list li { margin: 0 0 2px; }
.at-sa .at-sa-group-item {
	display: block;
	width: 100%;
	text-align: left;
	background: none;
	border: 0;
	padding: 4px 6px 4px 14px;
	font-size: 12.5px;
	font-weight: 500;
	color: #334155;
	border-radius: 6px;
	position: relative;
	cursor: pointer;
}
.at-sa .at-sa-group-item::before { content: ''; position: absolute; left: 4px; top: 11px; width: 4px; height: 4px; border-radius: 50%; background: currentColor; opacity: .5; }
.at-sa .at-sa-group-item:hover { background: rgba(255, 255, 255, .7); }
.at-sa .at-sa-group-item.is-recommended { font-weight: 700; color: var(--sa-text); }
.at-sa .at-sa-group-item.is-recommended::after { content: '★'; margin-left: 4px; color: var(--sa-orange); font-size: 11px; }
.at-sa .at-sa-group-item.is-active { background: #fff; box-shadow: 0 0 0 1px var(--sa-orange-line); }
.at-sa-group-pricing { font-size: 11.5px; font-weight: 600; margin-top: 10px !important; padding-top: 8px; border-top: 1px dashed currentColor; opacity: .85; }

.at-sa-group--awareness  { background: var(--g-awareness-bg); }
.at-sa-group--awareness  .at-sa-group-title, .at-sa-group--awareness  .at-sa-group-pricing { color: var(--g-awareness); }
.at-sa-group--conversion { background: var(--g-conversion-bg); }
.at-sa-group--conversion .at-sa-group-title, .at-sa-group--conversion .at-sa-group-pricing { color: var(--g-conversion); }
.at-sa-group--retention  { background: var(--g-retention-bg); }
.at-sa-group--retention  .at-sa-group-title, .at-sa-group--retention  .at-sa-group-pricing { color: var(--g-retention); }
.at-sa-group--referral   { background: var(--g-referral-bg); }
.at-sa-group--referral   .at-sa-group-title, .at-sa-group--referral   .at-sa-group-pricing { color: var(--g-referral); }

/* Results */
.at-sa-results-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.at-sa-empty {
	grid-column: 1 / -1;
	padding: 28px 20px;
	text-align: center;
	font-size: 14px;
	color: var(--sa-muted);
	border: 1px dashed var(--sa-line);
	border-radius: 12px;
	background: var(--sa-bg);
}
.at-sa-result {
	display: flex;
	flex-direction: column;
	padding: 16px;
	border: 1px solid var(--sa-line);
	border-radius: 12px;
	background: #fff;
	cursor: pointer;
	transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
	animation: at-sa-in .3s ease both;
}
.at-sa-result:nth-child(2) { animation-delay: .05s; }
.at-sa-result:nth-child(3) { animation-delay: .1s; }
.at-sa-result:nth-child(4) { animation-delay: .15s; }
.at-sa-result:hover, .at-sa-result:focus-visible { border-color: var(--sa-orange-line); box-shadow: 0 8px 20px rgba(15, 23, 42, .07); transform: translateY(-2px); outline: 0; }
.at-sa-result.is-active { border: 1.5px solid var(--sa-orange); box-shadow: 0 8px 24px rgba(242, 101, 34, .18); }
.at-sa-result-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.at-sa-result-num {
	display: inline-flex; align-items: center; justify-content: center;
	width: 32px; height: 32px; border-radius: 8px;
	background: var(--sa-orange-soft); color: var(--sa-orange-dark);
	font-size: 13px; font-weight: 800;
}
.at-sa-result-icon { color: var(--sa-orange); }
.at-sa-result-name { font-size: 15.5px !important; font-weight: 800; margin-bottom: 8px !important; }
.at-sa-result-stages { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
.at-sa-stage-chip { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--sa-orange-soft); color: var(--sa-orange-dark); border: 1px solid var(--sa-orange-line); }
.at-sa-result-desc { font-size: 13px; color: #475569; line-height: 1.5; margin-bottom: 10px !important; flex: 1; }
.at-sa-result-why { display: flex; gap: 6px; font-size: 12px; font-weight: 600; color: #15803d; line-height: 1.4; margin-bottom: 12px !important; }
.at-sa-result-why .at-sa-ico { margin-top: 1px; }
.at-sa-result-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-top: 10px; border-top: 1px solid #f1f5f9; }
.at-sa-fit { font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 6px; }
.at-sa-fit--high { background: #dcfce7; color: #15803d; }
.at-sa-fit--mid { background: #f1f5f9; color: #475569; }
.at-sa-result-more { display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; font-weight: 700; color: var(--sa-orange-dark); white-space: nowrap; }

.at-sa-results-cta { margin-top: 14px; text-align: center; }

@keyframes at-sa-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* Case */
.at-sa-case {
	display: flex;
	gap: 18px;
	align-items: center;
	padding: 18px;
	border-radius: 12px;
	background: linear-gradient(135deg, #fff7ed, #fff);
	border: 1px solid var(--sa-orange-line);
	color: inherit;
	text-decoration: none;
}
a.at-sa-case:hover { box-shadow: 0 8px 20px rgba(15, 23, 42, .07); color: inherit; }
.at-sa-case-logo { flex: 0 0 120px; height: 72px; display: flex; align-items: center; justify-content: center; background: #fff; border-radius: 10px; padding: 10px; border: 1px solid var(--sa-line); }
.at-sa-case-logo img { max-width: 100%; max-height: 100%; object-fit: contain; }
.at-sa-case-badge { display: inline-block; font-size: 11px; font-weight: 700; color: var(--sa-orange-dark); background: #fff; border: 1px solid var(--sa-orange-line); padding: 2px 8px; border-radius: 999px; margin-bottom: 6px; }
.at-sa-case-title { font-size: 15px !important; font-weight: 800; line-height: 1.4; margin-bottom: 8px !important; }
.at-sa-case-metrics { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px !important; }
.at-sa-case-metrics li { font-size: 12px; font-weight: 600; padding: 4px 10px; background: #fff; border-radius: 6px; border: 1px solid var(--sa-line); }
.at-sa-case-more { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 700; color: var(--sa-orange-dark); }
.at-sa-case--compact { padding: 12px; gap: 12px; }
.at-sa-case--compact .at-sa-case-logo { flex-basis: 72px; height: 56px; padding: 6px; }
.at-sa-case--compact .at-sa-case-title { font-size: 13px !important; margin-bottom: 4px !important; }

/* ---------- Detail ---------- */

.at-sa-detail { position: sticky; top: 90px; }
.at-sa-detail-card { max-height: calc(100vh - 110px); overflow-y: auto; animation: at-sa-in .25s ease both; }
.at-sa-detail-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.at-sa-detail-kicker { font-size: 14px; font-weight: 800; }
.at-sa-detail-title { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.at-sa-detail-title h3 { font-size: 19px !important; font-weight: 800; color: var(--sa-orange-dark) !important; line-height: 1.3; }
.at-sa-detail-icon {
	flex: 0 0 48px; height: 48px; border-radius: 50%;
	display: flex; align-items: center; justify-content: center;
	background: linear-gradient(135deg, #f97316, var(--sa-orange-dark)); color: #fff;
}
.at-sa-detail-desc { font-size: 14px; color: #334155; line-height: 1.55; margin: 4px 0 16px !important; }
.at-sa-detail-block { margin-bottom: 18px; }
.at-sa-detail-block h4 { font-size: 13.5px !important; font-weight: 800; margin-bottom: 10px !important; }
.at-sa-detail-why ul li { display: flex; gap: 8px; font-size: 13px; line-height: 1.45; margin-bottom: 6px; color: #334155; }
.at-sa-detail-why .at-sa-ico { color: #16a34a; margin-top: 2px; }
.at-sa-detail-caveat { display: flex; gap: 8px; font-size: 12.5px; color: #92400e; background: #fffbeb; border: 1px solid #fde68a; border-radius: 10px; padding: 10px 12px; margin-bottom: 18px; line-height: 1.45; }

.at-sa-steps { counter-reset: sa-step; }
.at-sa-steps li { counter-increment: sa-step; position: relative; padding: 0 0 14px 42px; margin: 0; }
.at-sa-steps li::before {
	content: counter(sa-step);
	position: absolute; left: 0; top: 0;
	width: 30px; height: 30px; border-radius: 50%;
	display: flex; align-items: center; justify-content: center;
	background: var(--sa-orange-soft); color: var(--sa-orange-dark);
	font-size: 13px; font-weight: 800;
}
.at-sa-steps li:not(:last-child)::after { content: ''; position: absolute; left: 14.5px; top: 32px; bottom: 2px; width: 1px; background: var(--sa-orange-line); }
.at-sa-steps strong { display: block; font-size: 13.5px; font-weight: 700; margin-bottom: 2px; }
.at-sa-steps span { display: block; font-size: 12.5px; color: var(--sa-muted); line-height: 1.45; }

.at-sa-detail-meta { margin: 0 0 18px; padding: 12px 14px; background: var(--sa-bg); border-radius: 10px; }
.at-sa-detail-meta div { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; }
.at-sa-detail-meta div + div { margin-top: 6px; }
.at-sa-detail-meta dt { color: var(--sa-muted); font-weight: 500; margin: 0; }
.at-sa-detail-meta dd { font-weight: 700; text-align: right; margin: 0; }

.at-sa-detail-actions { position: sticky; bottom: -22px; background: #fff; padding: 12px 0 0; margin-bottom: -4px; }

/* ---------- Responsive ---------- */

@media (max-width: 1199px) {
	.at-sa.has-detail .at-sa-layout,
	.at-sa-layout { grid-template-columns: 280px minmax(0, 1fr); }

	/* Chi tiết giải pháp chuyển thành bottom sheet */
	.at-sa-detail {
		position: fixed;
		inset: auto 0 0 0;
		top: auto;
		z-index: 9990;
		padding: 0;
	}
	.at-sa-detail::before {
		content: '';
		position: fixed;
		inset: 0;
		background: rgba(15, 23, 42, .45);
		z-index: -1;
	}
	.at-sa-detail-card { max-height: 85vh; border-radius: 18px 18px 0 0; max-width: 640px; margin: 0 auto; }
	body.at-sa-sheet-open { overflow: hidden; }
}

@media (max-width: 849px) {
	.at-sa { padding: 12px 10px 96px; }
	.at-sa.has-detail .at-sa-layout,
	.at-sa-layout { grid-template-columns: minmax(0, 1fr); }
	.at-sa-brief { position: static; }
	.at-sa-card { padding: 16px; }

	/* Mobile: nút ghim ở đáy màn hình, bấm được ở bất kỳ vị trí cuộn nào */
	.at-sa-brief .at-sa-card { max-height: none; overflow: visible; padding: 0; }
	.at-sa-brief-body { overflow: visible; padding: 16px 16px 4px; }
	.at-sa-brief-foot {
		position: fixed;
		left: 0;
		right: 0;
		bottom: 0;
		z-index: 9980;
		padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
		box-shadow: 0 -6px 18px rgba(15, 23, 42, .12);
	}
	.at-sa-brief-foot .at-sa-note { display: none; }
	body.at-sa-sheet-open .at-sa-brief-foot,
	body:has(.mfp-wrap) .at-sa-brief-foot { display: none; } /* không đè lên popup tư vấn / menu (z-index 1043) */
	.at-sa-title { font-size: 21px; }
	.at-sa-journey { grid-template-columns: repeat(3, 1fr); row-gap: 6px; }
	.at-sa-journey-step:nth-child(4) { clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 50%, calc(100% - 12px) 100%, 0 100%); padding-left: 6px; }
	.at-sa-groups { grid-template-columns: repeat(2, 1fr); }
	.at-sa-case { flex-direction: column; align-items: flex-start; }
	.at-sa-case-logo { flex-basis: auto; width: 120px; }
}

@media (max-width: 479px) {
	.at-sa-groups { grid-template-columns: 1fr; }
	.at-sa-results-grid { grid-template-columns: 1fr; }
}
