/* Blueky Support – cổng hỗ trợ độc lập (không dùng CSS theme), bố cục dashboard: sidebar trái + nội dung. Luôn nền sáng.
   --bks-accent in từ PHP (Cài đặt hỗ trợ hoặc màu chính trong Hồ sơ thương hiệu). */
:root {
	--bks-accent: #2563eb;
	--bks-on-accent: #fff;
	--bks-bg: #f5f6f8;
	--bks-card: #fff;
	--bks-text: #1d2327;
	--bks-muted: #646970;
	--bks-line: #e4e6ea;
	--bks-soft: #f3f4f6;
	--bks-ok: #00703c;
	--bks-ok-bg: #e6f4ea;
	--bks-warn: #8a5300;
	--bks-warn-bg: #fcf3e3;
	--bks-bad: #b32d2e;
	--bks-bad-bg: #fbeaea;
	--bks-radius: 10px;
	--bks-side: 256px;
	color-scheme: light;
}
*, *::before, *::after { box-sizing: border-box; }
body.bks-page {
	margin: 0;
	min-height: 100vh;
	background: var(--bks-bg);
	color: var(--bks-text);
	font: 15px/1.6 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	-webkit-font-smoothing: antialiased;
}
.bks-page a { color: var(--bks-accent); }
.bks-brand { display: inline-flex; align-items: center; text-decoration: none; color: var(--bks-text) !important; font-weight: 700; font-size: 1.15em; }
.bks-brand img { max-height: 40px; max-width: 180px; width: auto; height: auto; display: block; }

/* Khung ứng dụng */
.bks-app { display: flex; min-height: 100vh; }
.bks-side {
	position: sticky; top: 0; height: 100vh; width: var(--bks-side); flex: 0 0 var(--bks-side);
	display: flex; flex-direction: column;
	background: var(--bks-card); border-right: 1px solid var(--bks-line);
}
.bks-side__head { padding: 20px 20px 12px; }
.bks-side__nav { flex: 1; overflow-y: auto; padding: 4px 12px 12px; }
.bks-side__label { margin: 16px 10px 6px; font-size: .72em; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--bks-muted); }
.bks-side__link {
	display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px;
	color: var(--bks-text) !important; text-decoration: none; font-weight: 500;
}
.bks-side__link svg { flex: 0 0 auto; color: var(--bks-muted); }
.bks-side__link span { flex: 1; min-width: 0; }
.bks-side__link:hover { background: var(--bks-soft); }
.bks-side__link.is-active { background: color-mix(in srgb, var(--bks-accent) 10%, var(--bks-card)); color: color-mix(in srgb, var(--bks-accent) 80%, #000) !important; }
.bks-side__link.is-active svg { color: var(--bks-accent); }
.bks-side__count { font-size: .75em; min-width: 22px; padding: 1px 7px; border-radius: 999px; background: var(--bks-accent); color: var(--bks-on-accent); text-align: center; }
.bks-side__user { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-top: 1px solid var(--bks-line); }
.bks-side__user img { border-radius: 50%; flex: 0 0 auto; }
.bks-side__user > div { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.bks-side__user strong, .bks-side__user small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bks-side__user small { color: var(--bks-muted); font-size: .8em; }
.bks-side__out { color: var(--bks-muted) !important; display: inline-flex; padding: 6px; border-radius: 6px; }
.bks-side__out:hover { background: var(--bks-soft); color: var(--bks-bad) !important; }

.bks-body-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.bks-head-bar {
	display: flex; align-items: center; gap: 16px; padding: 22px 32px 18px;
	background: var(--bks-card); border-bottom: 1px solid var(--bks-line);
}
.bks-head-bar__title { flex: 1; min-width: 0; }
.bks-head-bar h1 { margin: 2px 0 0; font-size: 1.45em; line-height: 1.25; }
.bks-crumbs { font-size: .85em; color: var(--bks-muted); }
.bks-crumbs a { color: var(--bks-muted) !important; text-decoration: none; }
.bks-crumbs a:hover { color: var(--bks-accent) !important; }
.bks-menu-btn { display: none; background: none; border: 1px solid var(--bks-line); border-radius: 8px; padding: 6px; color: var(--bks-text); cursor: pointer; }
.bks-main { flex: 1; width: 100%; max-width: 1100px; padding: 28px 32px 48px; }
.bks-foot { padding: 16px 32px; color: var(--bks-muted); font-size: .85em; border-top: 1px solid var(--bks-line); }
.bks-btn.bks-side__new { display: flex; width: 100%; justify-content: center; margin: 8px 0 4px; box-sizing: border-box; }
.bks-side__new svg { color: currentColor; }
.bks-btn.bks-head-new { display: none; } /* màn rộng: nút nằm trong sidebar */
.bks-scrim { position: fixed; inset: 0; background: rgb(0 0 0 / .35); z-index: 40; }

@media (max-width: 900px) {
	.bks-side { position: fixed; z-index: 50; left: 0; top: 0; transform: translateX(-100%); visibility: hidden; transition: transform .2s ease, visibility 0s .2s; box-shadow: 0 0 40px rgb(0 0 0 / .15); }
	.bks-page.is-menu-open .bks-side { transform: none; visibility: visible; transition-delay: 0s; }
	.bks-menu-btn { display: inline-flex; }
	.bks-head-bar { padding: 14px 16px; flex-wrap: wrap; }
	.bks-head-bar .bks-btn { order: 3; width: 100%; }
	.bks-btn.bks-head-new { display: inline-flex; } /* sidebar thu vào menu: giữ nút ở đầu trang */
	.bks-main { padding: 20px 16px 40px; }
	.bks-foot { padding: 14px 16px; }
}

/* Đăng nhập (chưa có sidebar) */
.bks-auth { max-width: 460px; margin: 0 auto; padding: 56px 16px; }
.bks-auth__brand { text-align: center; margin-bottom: 24px; }
.bks-auth__foot { text-align: center; font-size: .9em; }

/* Thành phần */
.bks-card {
	background: var(--bks-card);
	border: 1px solid var(--bks-line);
	border-radius: var(--bks-radius);
	padding: 22px;
	margin: 0 0 20px;
	box-shadow: 0 1px 3px rgb(0 0 0 / .04);
}
.bks-card--flush { padding: 0; overflow: hidden; }
.bks-section { font-size: 1.15em; font-weight: 400; margin: 8px 0 12px; }
.bks-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px 20px; }
@media (max-width: 680px) { .bks-grid { grid-template-columns: 1fr; } }

.bks-field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.bks-grid .bks-field { margin-bottom: 0; }
.bks-label { font-weight: 600; font-size: .95em; }
.bks-field input[type="text"],
.bks-field input[type="password"],
.bks-field select,
.bks-field textarea {
	width: 100%;
	min-height: 44px;
	padding: 10px 12px;
	border: 1px solid #8c8f94; /* viền ô nhập đủ tương phản (≥3:1, WCAG 1.4.11); --bks-line quá nhạt cho ô nhập */
	border-radius: 6px;
	background: var(--bks-card);
	color: inherit;
	font: inherit;
	line-height: 1.4;
}
.bks-field textarea { min-height: 150px; resize: vertical; line-height: 1.55; }
.bks-field :is(input, select, textarea):focus {
	outline: 2px solid color-mix(in srgb, var(--bks-accent) 30%, transparent);
	border-color: var(--bks-accent);
}
.bks-static { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border-radius: 6px; background: var(--bks-soft); min-height: 44px; }
.bks-static small, .bks-hint { color: var(--bks-muted); font-size: .85em; }
.bks-hint { margin: 0; }
.bks-check { display: inline-flex; gap: 8px; align-items: center; margin-bottom: 16px; }

.bks-files-input { margin: 4px 0 20px; }
.bks-files-input .bks-hint { margin-top: 8px; }
.bks-field input, .bks-field select, .bks-field textarea, .bks-btn { font-family: inherit; }
.bks-drop {
	position: relative; display: flex; align-items: center; gap: 10px; cursor: pointer;
	padding: 12px 14px; border: 1px dashed #8c8f94; border-radius: 6px; color: var(--bks-muted);
}
.bks-drop:hover, .bks-drop.is-over { border-color: var(--bks-accent); color: var(--bks-accent); }
.bks-drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.bks-drop:focus-within { outline: 2px solid var(--bks-accent); outline-offset: 2px; }
.bks-drop span::before { content: ""; display: inline-block; width: 16px; height: 16px; margin-right: 6px; vertical-align: -3px; background: currentColor; -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m21.44 11.05-9.19 9.19a6 6 0 0 1-8.49-8.49l8.57-8.57A4 4 0 1 1 18 8.84l-8.59 8.57a2 2 0 0 1-2.83-2.83l8.49-8.48'/%3E%3C/svg%3E") center / contain no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m21.44 11.05-9.19 9.19a6 6 0 0 1-8.49-8.49l8.57-8.57A4 4 0 1 1 18 8.84l-8.59 8.57a2 2 0 0 1-2.83-2.83l8.49-8.48'/%3E%3C/svg%3E") center / contain no-repeat; }
.bks-previews { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.bks-previews:empty { display: none; }
.bks-chip { display: inline-flex; align-items: center; gap: 6px; max-width: 220px; padding: 4px 8px; border: 1px solid var(--bks-line); border-radius: 6px; font-size: .85em; }
.bks-chip img { width: 40px; height: 40px; object-fit: cover; border-radius: 4px; }
.bks-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bks-chip.is-bad { border-color: var(--bks-bad); color: var(--bks-bad); }

.bks-actions { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.bks-btn {
	display: inline-flex; align-items: center; justify-content: center; gap: 8px;
	min-height: 44px; padding: 0 18px; border-radius: 6px; border: 1px solid var(--bks-accent);
	background: var(--bks-accent); color: var(--bks-on-accent) !important; font: inherit; font-weight: 600;
	text-decoration: none; cursor: pointer;
}
.bks-btn:hover { filter: brightness(.94); }
.bks-btn:focus-visible { outline: 2px solid var(--bks-accent); outline-offset: 2px; }
.bks-btn:disabled { opacity: .7; cursor: progress; }
.bks-btn--ghost { background: transparent; color: var(--bks-text) !important; border-color: var(--bks-line); }
.bks-link { background: none; border: 0; padding: 0; color: var(--bks-muted); text-decoration: underline; cursor: pointer; font: inherit; font-size: .9em; }
.bks-close { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 0 0 20px; padding: 16px 22px; background: var(--bks-card); border: 1px solid var(--bks-line); border-radius: var(--bks-radius); }
.bks-close span { font-weight: 500; }

.bks-notice { padding: 12px 16px; border-radius: 8px; margin-bottom: 20px; }
.bks-notice--ok { background: var(--bks-ok-bg); color: var(--bks-ok); }
.bks-notice--error { background: var(--bks-bad-bg); color: var(--bks-bad); }

.bks-login { max-width: 460px; margin: 0 auto 20px; }
.bks-login h1, .bks-login h2 { margin: 0 0 4px; font-size: 1.3em; line-height: 1.3; }
.bks-login .bks-hint { margin-bottom: 18px; }
.bks-google { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; min-height: 46px; padding: 0 16px; border: 1px solid var(--bks-line); border-radius: 999px; background: var(--bks-card); color: var(--bks-text) !important; font-weight: 600; text-decoration: none !important; box-sizing: border-box; }
.bks-google:hover { background: var(--bks-soft); border-color: #cfd3da; }
.bks-google:focus-visible { outline: 2px solid var(--bks-accent); outline-offset: 2px; }
.bks-google__g { flex: none; }
.bks-or { display: flex; align-items: center; gap: 12px; margin: 18px 0; color: var(--bks-muted); font-size: .85em; }
.bks-or::before, .bks-or::after { content: ""; flex: 1; height: 1px; background: var(--bks-line); }

.bks-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.bks-tabs a { padding: 6px 14px; border-radius: 999px; text-decoration: none; color: var(--bks-text); border: 1px solid transparent; }
.bks-tabs a span { color: var(--bks-muted); font-size: .85em; }
.bks-tabs a.is-active { border-color: var(--bks-line); background: var(--bks-card); font-weight: 600; }
.bks-table { width: 100%; border-collapse: collapse; }
.bks-table th, .bks-table td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--bks-line); }
.bks-table th { font-size: .85em; color: var(--bks-muted); font-weight: 600; background: var(--bks-soft); }
.bks-table tr:last-child td { border-bottom: 0; }
.bks-table td a { text-decoration: none; }
.bks-table tr.is-new td:first-child a { font-weight: 700; }
@media (max-width: 680px) {
	.bks-table thead { display: none; }
	.bks-table tr { display: block; padding: 10px 0; border-bottom: 1px solid var(--bks-line); }
	.bks-table td { display: flex; justify-content: space-between; gap: 12px; padding: 4px 16px; border: 0; }
	.bks-table td::before { content: attr(data-title); color: var(--bks-muted); font-size: .85em; }
}
.bks-empty { display: flex; align-items: center; gap: 12px; color: var(--bks-muted); padding: 18px 22px; }
.bks-empty p { margin: 0; }
.bks-empty__ico { display: inline-flex; color: var(--bks-ok); }

/* Trang chính của khách: lời chào, ô số = bộ lọc, đầu danh sách */
.bks-hello {
	display: flex; align-items: center; justify-content: space-between; gap: 16px 24px; flex-wrap: wrap;
	margin: 0 0 20px; padding: 22px 24px; border: 1px solid var(--bks-line); border-radius: var(--bks-radius);
	background: linear-gradient(135deg, color-mix(in srgb, var(--bks-accent) 7%, #fff), #fff 60%);
}
.bks-hello__text { flex: 1 1 320px; min-width: 0; }
.bks-hello h2 { margin: 0 0 4px; font-size: 1.25em; line-height: 1.3; }
.bks-hello p { margin: 0; color: var(--bks-muted); }
.bks-hello__acts { display: flex; gap: 10px; flex-wrap: wrap; }
.bks-hello__acts .bks-btn { gap: 8px; }
.bks-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 0 0 28px; }
.bks-stat {
	display: flex; align-items: center; gap: 14px; padding: 16px 18px; border: 1px solid var(--bks-line); border-radius: var(--bks-radius);
	background: var(--bks-card); color: var(--bks-text) !important; text-decoration: none; transition: border-color .15s, box-shadow .15s;
}
.bks-stat:hover { border-color: color-mix(in srgb, var(--bks-accent) 40%, var(--bks-line)); }
.bks-stat.is-active { border-color: var(--bks-accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--bks-accent) 14%, transparent); }
.bks-stat__ico { display: grid; place-items: center; flex: none; width: 40px; height: 40px; border-radius: 10px; background: var(--bks-soft); color: var(--bks-muted); }
.bks-stat--open .bks-stat__ico { background: var(--bks-warn-bg); color: var(--bks-warn); }
.bks-stat--answered .bks-stat__ico { background: color-mix(in srgb, var(--bks-accent) 12%, #fff); color: var(--bks-accent); }
.bks-stat--closed .bks-stat__ico { background: var(--bks-ok-bg); color: var(--bks-ok); }
.bks-stat__body { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.bks-stat__body b { font-size: 1.5em; font-weight: 700; }
.bks-stat__body span { color: var(--bks-muted); font-size: .9em; }
.bks-listhead { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 0 0 12px; }
.bks-listhead__title { margin: 0; font-size: 1.05em; }
.bks-listhead__all { font-size: .9em; color: var(--bks-accent) !important; text-decoration: none; font-weight: 500; }
.bks-listhead__sub { margin: 24px 0 12px; font-size: 1em; color: var(--bks-muted); font-weight: 600; }
.bks-side__user small.bks-role {
	align-self: flex-start; margin-top: 2px; padding: 1px 8px; border-radius: 999px;
	background: color-mix(in srgb, var(--bks-accent) 12%, #fff); color: var(--bks-accent); font-size: .74em; font-weight: 600;
}
@media (max-width: 680px) {
	.bks-stats { grid-template-columns: 1fr; gap: 8px; }
	.bks-stat { padding: 12px 14px; }
	.bks-hello { padding: 18px; }
	.bks-hello__acts, .bks-hello__acts .bks-btn { width: 100%; justify-content: center; }
}
.bks-pages { display: flex; gap: 10px; }

.bks-pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .8em; font-weight: 600; white-space: nowrap; background: var(--bks-soft); color: var(--bks-muted); }
.bks-pill--open, .bks-pill--customer_reply { background: var(--bks-warn-bg); color: var(--bks-warn); }
.bks-pill--in_progress { background: color-mix(in srgb, var(--bks-accent) 14%, var(--bks-card)); color: color-mix(in srgb, var(--bks-accent) 80%, #000); }
.bks-pill--answered { background: var(--bks-ok-bg); color: var(--bks-ok); }

.bks-head { display: grid; grid-template-columns: 1fr auto; gap: 8px 16px; align-items: start; }
.bks-number { margin: 0; color: var(--bks-muted); font-size: .9em; }
.bks-subject { margin: 2px 0 0; font-size: 1.3em; }
.bks-meta { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px 32px; margin: 8px 0 0; }
.bks-meta dt { color: var(--bks-muted); font-size: .8em; }
.bks-meta dd { margin: 0; font-weight: 500; }

.bks-thread { display: flex; flex-direction: column; gap: 14px; margin-bottom: 20px; }
.bks-msg { border: 1px solid var(--bks-line); border-radius: var(--bks-radius); padding: 16px 18px; background: var(--bks-card); }
.bks-msg--staff { background: color-mix(in srgb, var(--bks-accent) 4%, var(--bks-card)); }
.bks-msg header { display: flex; gap: 10px; align-items: center; margin-bottom: 8px; }
.bks-msg header > div { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; }
.bks-avatar { border-radius: 50%; }
.bks-role { font-size: .75em; padding: 1px 8px; border-radius: 999px; background: color-mix(in srgb, var(--bks-accent) 14%, transparent); color: color-mix(in srgb, var(--bks-accent) 80%, #000); font-weight: 600; }
.bks-msg time { color: var(--bks-muted); font-size: .85em; }
.bks-body { overflow-wrap: anywhere; }
.bks-body p { margin: 0 0 .8em; }
.bks-body p:last-child { margin-bottom: 0; }
.bks-body code { padding: 1px 4px; border-radius: 4px; background: var(--bks-soft); }

.bks-files { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.bks-files li { font-size: .9em; }
.bks-files__img img { display: block; width: 120px; height: 90px; object-fit: cover; border-radius: 6px; border: 1px solid var(--bks-line); }

@media (max-width: 680px) {
	.bks-card { padding: 16px; }
}
/* Tiêu đề / giá trị dài không tràn khung trên điện thoại */
.bks-subject, .bks-meta dd, .bks-table td { overflow-wrap: anywhere; min-width: 0; }
/* Màn cảm ứng: mục menu, nút thoát/menu, liên kết dưới form và trang số đạt 44px */
@media (hover: none) and (pointer: coarse) {
	.bks-side__link, .bks-side__out, .bks-menu-btn { min-height: 44px; min-width: 44px; box-sizing: border-box; }
	.bks-actions a:not(.bks-btn) { display: inline-flex; align-items: center; min-height: 44px; }
	.bks-pages a { display: inline-flex; align-items: center; justify-content: center; min-width: 44px; min-height: 44px; }
}

.bks-pwd { display: flex; gap: 8px; align-items: stretch; }
.bks-pwd input { flex: 1; min-width: 0; }
.bks-pwd__t { flex: none; min-width: 64px; min-height: 44px; padding: 0 12px; border: 1px solid var(--bks-line); border-radius: 6px; background: var(--bks-card); color: var(--bks-text); font: inherit; cursor: pointer; }
.bks-pwd__t:focus-visible { outline: 2px solid var(--bks-accent); outline-offset: 2px; }
.bks-notice:focus-visible { outline: 2px solid currentColor; outline-offset: 2px; }
.bks-form input[aria-invalid="true"] { border-color: var(--bks-bad); }
