/*!
 * pages.css — style riêng của từng trang.
 *
 *   Trang Đăng nhập  (Bước 7) — scope .xh-auth
 *   Trang Tổng quan  (Bước 8) — scope .xh-app
 *
 * Mọi màu lấy từ token. Phần quầng sáng và lưới của cột thương hiệu dùng nhóm
 * token --xh-login-* khai báo ở tokens.css, không viết rgba() trực tiếp ở đây.
 */

/* ================================================================== *
 * Tổng quan
 * ================================================================== */

.xh-app .xh-page__notice { margin-bottom: var(--xh-space-6); }

.xh-app .xh-page__head {
	display: flex;
	align-items: flex-start;
	gap: var(--xh-space-4);
	margin-bottom: var(--xh-space-8);
}

.xh-app .xh-page__titles { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: var(--xh-space-2); }

.xh-app .xh-page__cta { flex: none; }

.xh-app .xh-section { margin-bottom: var(--xh-space-8); }

.xh-app .xh-section__head {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: var(--xh-space-3);
	margin-bottom: var(--xh-space-4);
}

.xh-app .xh-section > .xh-t-section-title { display: block; margin-bottom: var(--xh-space-4); }
.xh-app .xh-section__head > .xh-t-section-title { margin-bottom: 0; }

.xh-app .xh-chips { display: flex; flex-wrap: wrap; gap: var(--xh-space-2); margin-left: auto; }

/* Chip đang chọn — bám aria-current chứ không dùng class riêng, để trạng thái
   thị giác không thể lệch khỏi trạng thái ngữ nghĩa. */
.xh-app .xh-chip[aria-current="true"] {
	background: var(--xh-primary-soft);
	color: var(--xh-primary-hover);
	border-color: var(--xh-primary-line);
}

.xh-app .xh-chip { text-decoration: none; }
.xh-app .xh-chip:hover { text-decoration: none; background: var(--xh-app-bg); }
.xh-app .xh-chip[aria-current="true"]:hover { background: var(--xh-primary-soft); }

/* --- Truy cập nhanh --- */

.xh-app .xh-quick {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
	gap: var(--xh-space-4);
	align-items: stretch;
}

/* Xếp DỌC theo prototype: ô vuông icon ở trên, rồi tên, rồi mô tả. */
.xh-app .xh-quick__item {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: var(--xh-space-3);
	padding: 18px;
	border: 1px solid var(--xh-line);
	border-radius: var(--xh-r-md);
	background: var(--xh-surface);
	color: var(--xh-ink);
	text-decoration: none;
	transition: border-color .12s ease, box-shadow .12s ease;
}

.xh-app .xh-quick__item:hover {
	border-color: var(--xh-card-line-hover);
	box-shadow: var(--xh-sh-md);
	text-decoration: none;
}

.xh-app .xh-quick__item:hover .xh-tile {
	background: var(--xh-primary-soft);
	border-color: var(--xh-tile-line-soft);
	color: var(--xh-primary);
}

.xh-app .xh-quick__body  { display: block; }
.xh-app .xh-quick__label { display: block; font-size: 15px; line-height: 22px; margin-bottom: 4px; }
.xh-app .xh-quick__desc  { display: block; font-size: 12.5px; line-height: 19px; color: var(--xh-ink-muted); }

/* --- Bố cục hai cột: lưới công cụ | thẻ Truy cập gần đây --- */

.xh-app .xh-dash {
	display: grid;
	grid-template-columns: 1fr 328px;
	gap: var(--xh-space-6);
	align-items: start;   /* cột phải không bị kéo cao theo cột trái */
}

/* Khoảng cách giữa hai cột do `gap` của lưới lo. Bỏ margin-bottom mà .xh-section tự
   mang, nếu không cột trái sẽ thừa 32px dưới đáy so với cột phải. */
.xh-app .xh-dash__main,
.xh-app .xh-dash__side { min-width: 0; margin-bottom: 0; }

/* --- Thẻ panel (cột phải) --- */

.xh-app .xh-panel {
	display: flex;
	flex-direction: column;
	gap: 14px;
	padding: 18px;
	background: var(--xh-surface);
	border: 1px solid var(--xh-line);
	border-radius: var(--xh-r-md);
}

.xh-app .xh-panel__head { display: flex; align-items: center; gap: var(--xh-space-2); }

.xh-app .xh-panel__action {
	margin-left: auto;
	padding: 4px var(--xh-space-2);
	border-radius: var(--xh-r-sm);
	font-size: 12.5px;
	line-height: 19px;
	color: var(--xh-ink-3);
	background: none;
	border: 0;
	cursor: pointer;
}

.xh-app .xh-panel__action:hover { background: var(--xh-app-bg); color: var(--xh-primary); }
.xh-app .xh-panel__action:focus-visible { outline: none; box-shadow: var(--xh-focus-ring); }

/* --- Hàng "Truy cập gần đây" --- */

.xh-app .xh-recent { display: flex; flex-direction: column; gap: var(--xh-space-1); }

.xh-app .xh-recent__item {
	display: flex;
	align-items: center;
	gap: var(--xh-space-3);
	padding: 9px var(--xh-space-2);
	border-radius: var(--xh-r-sm);
	color: inherit;
	text-decoration: none;
	transition: background .12s ease;
}

.xh-app .xh-recent__item:hover { background: var(--xh-surface-2); text-decoration: none; }
.xh-app .xh-recent__item:focus-visible { outline: none; box-shadow: var(--xh-focus-ring); }

.xh-app .xh-recent__body { flex: 1; min-width: 0; }

.xh-app .xh-recent__name {
	display: block;
	font-size: 13.5px;
	line-height: 20px;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.xh-app .xh-recent__time { display: block; font-size: 11.5px; line-height: 17px; color: var(--xh-ink-muted); }

/*
 * "Mở lại" là <span> trong lòng thẻ <a> của cả hàng, không phải <button>.
 * Nhìn như nút, nhưng không phải control thứ hai — xem lý do trong shell.js.
 */
.xh-app .xh-recent__open {
	flex: none;
	padding: 5px 9px;
	border: 1px solid var(--xh-primary-line);
	border-radius: var(--xh-r-sm);
	font-size: 12.5px;
	line-height: 18px;
	color: var(--xh-primary);
}

.xh-app .xh-recent__item:hover .xh-recent__open { background: var(--xh-primary-soft); }

/* Empty state trong panel: đã có viền của panel rồi, không lồng thêm khung nữa. */
.xh-app .xh-empty--panel {
	padding: 26px var(--xh-space-3) 22px;
	background: none;
	border: 0;
}

/* --- Lưới công cụ --- */

.xh-app .xh-tools {
	display: grid;
	grid-template-columns: repeat(2, 1fr);
	gap: 14px;
}

.xh-app .xh-tools > [hidden] { display: none; }

/*
 * Chiều cao bằng nhau theo từng hàng.
 *
 * Ô lưới vốn đã kéo giãn (`align-items:stretch` là mặc định của grid), nhưng thẻ <a>
 * nằm TRONG ô lại tự co theo nội dung, nên mô tả dài ngắn khác nhau là thẻ cao thấp
 * khác nhau. Cho ô làm flex container rồi bảo thẻ lấp đầy — không dùng chiều cao cố
 * định, vì mô tả có thể xuống hai dòng ở màn hình hẹp.
 */
.xh-app .xh-tools > * { display: flex; }
.xh-app .xh-tools > * > .xh-app-card { flex: 1; }

/*
 * Dưới 1200px cột phải 328px làm lưới công cụ hẹp tới mức thẻ vỡ chữ ⇒ xếp chồng,
 * thẻ Truy cập gần đây xuống dưới. Mốc này rộng hơn 1024px của sidebar vì ở đây
 * còn phải trừ đi bề rộng sidebar.
 */
@media (max-width: 1199px) {
	.xh-app .xh-dash { grid-template-columns: 1fr; }
	/* Xếp chồng rồi thì cột trái cần lại khoảng cách dưới — gap của lưới đã lo, giữ nguyên 0. */
}

@media (max-width: 1023px) {
	.xh-app .xh-tools { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
}

@media (max-width: 767px) {
	.xh-app .xh-page__head { flex-direction: column; align-items: stretch; }
	.xh-app .xh-page__cta { width: 100%; }
	.xh-app .xh-chips { margin-left: 0; width: 100%; }
	.xh-app .xh-quick { grid-template-columns: 1fr 1fr; }
	.xh-app .xh-tools { grid-template-columns: 1fr; }
}

/* ================================================================== *
 * Đăng nhập
 * ================================================================== */

.xh-auth .xh-login {
	display: flex;
	min-height: 100vh;
	min-height: 100dvh;
	background: var(--xh-surface);
}

/* --- Cột thương hiệu --- */

.xh-auth .xh-login__brand {
	position: relative;
	display: flex;
	flex-direction: column;
	justify-content: space-between;
	gap: var(--xh-space-8);
	width: 55%;
	padding: 56px 64px;
	overflow: hidden;
	background: var(--xh-sidebar);
}

/* Hai quầng sáng — cùng một lớp nền, không thêm phần tử trống vào DOM. */
.xh-auth .xh-login__brand::before {
	content: "";
	position: absolute;
	inset: 0;
	background:
		radial-gradient(760px 420px at 12% 8%, var(--xh-login-glow-1), transparent 62%),
		radial-gradient(620px 380px at 88% 92%, var(--xh-login-glow-2), transparent 60%);
}

/* Lưới ô 64px. */
.xh-auth .xh-login__brand::after {
	content: "";
	position: absolute;
	inset: 0;
	background-image:
		linear-gradient(var(--xh-login-grid) 1px, transparent 1px),
		linear-gradient(90deg, var(--xh-login-grid) 1px, transparent 1px);
	background-size: 64px 64px;
}

.xh-auth .xh-login__brand > * { position: relative; }

.xh-auth .xh-login__logo-box {
	align-self: flex-start;
	padding: 14px 18px;
	border-radius: var(--xh-r-md);
	background: var(--xh-surface);
	box-shadow: var(--xh-login-shadow);
}

.xh-auth .xh-login__logo { height: 44px; width: auto; }

.xh-auth .xh-login__pitch {
	display: flex;
	flex-direction: column;
	gap: var(--xh-space-5);
	max-width: 520px;
}

.xh-auth .xh-login__headline { color: var(--xh-on-dark); text-wrap: pretty; }

.xh-auth .xh-login__lead {
	font-size: 16px;
	line-height: 26px;
	color: var(--xh-sidebar-ink);
	text-wrap: pretty;
}

.xh-auth .xh-login__points {
	display: flex;
	flex-direction: column;
	gap: 14px;
	margin-top: var(--xh-space-3);
}

.xh-auth .xh-login__point {
	display: flex;
	align-items: center;
	gap: var(--xh-space-3);
	font-size: 15px;
	line-height: 22px;
	color: var(--xh-tooltip-ink);
}

.xh-auth .xh-login__point-icon {
	display: flex;
	align-items: center;
	justify-content: center;
	flex: none;
	width: 38px;
	height: 38px;
	border: 1px solid var(--xh-login-tile-line);
	border-radius: var(--xh-r-sm);
	background: var(--xh-login-tile);
	color: var(--xh-login-tile-ink);
}

.xh-auth .xh-login__footnote {
	font-size: 12px;
	line-height: 18px;
	color: var(--xh-login-foot);
}

/* --- Cột form --- */

.xh-auth .xh-login__panel {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 45%;
	padding: var(--xh-space-12);
	background: var(--xh-surface);
}

.xh-auth .xh-login__form {
	display: flex;
	flex-direction: column;
	gap: var(--xh-space-6);
	width: 420px;
	max-width: 100%;
}

.xh-auth .xh-login__intro { display: flex; flex-direction: column; gap: var(--xh-space-2); }

.xh-auth .xh-login__fields { display: flex; flex-direction: column; gap: var(--xh-space-4); }

.xh-auth .xh-login__note {
	margin-top: var(--xh-space-1);
	font-size: 12px;
	line-height: 18px;
	color: var(--xh-ink-muted);
	text-align: center;
}

/* Nút hiện/ẩn mật khẩu — chỉ một icon hiển thị tại mỗi trạng thái. */
.xh-auth .xh-login__pw-toggle[aria-pressed="false"] .xh-login__pw-hide,
.xh-auth .xh-login__pw-toggle[aria-pressed="true"] .xh-login__pw-show { display: none; }

/* ================================================================== *
 * Đăng nhập — tablet và mobile
 * ================================================================== */

@media (max-width: 1023px) {
	.xh-auth .xh-login__brand { padding: var(--xh-space-8); }
	.xh-auth .xh-login__panel { padding: var(--xh-space-8); }
}

@media (max-width: 767px) {

	.xh-auth .xh-login { flex-direction: column; }

	/* Cột thương hiệu thu thành dải đầu trang: giữ nhận diện, nhường chỗ cho form. */
	.xh-auth .xh-login__brand {
		width: auto;
		gap: var(--xh-space-4);
		padding: var(--xh-space-6) var(--xh-space-4);
	}

	.xh-auth .xh-login__logo { height: 34px; }
	.xh-auth .xh-login__logo-box { padding: 10px 14px; }

	.xh-auth .xh-login__headline { font-size: 22px; line-height: 30px; letter-spacing: -0.2px; }
	.xh-auth .xh-login__lead { font-size: 14px; line-height: 22px; }

	/* Ba gạch đầu dòng và dòng chân là trang trí — bỏ để form lên trên màn hình đầu tiên. */
	.xh-auth .xh-login__points,
	.xh-auth .xh-login__footnote { display: none; }

	.xh-auth .xh-login__panel {
		width: auto;
		padding: var(--xh-space-6) var(--xh-space-4) var(--xh-space-10);
	}

	.xh-auth .xh-login__form { width: 100%; gap: var(--xh-space-5); }

	/* A51 — nút gửi cao 52px trên mobile. */
	.xh-auth .xh-login__form .xh-btn--form { height: 52px; }

	/* 46px là chuẩn desktop; trên mobile nâng lên cho vừa ngón tay. */
	.xh-auth .xh-login__form .xh-input { height: 48px; }
}
