/**
 * 聊天室樣式。
 * 品牌色用實際 logo 取樣的 #2A3B59（深藍）與 #CEA685（褐），
 * 不要用品牌手冊上那兩組換算錯誤的值（見 BRAND.md）。
 */

.bwc {
	--bwc-navy: #2a3b59;
	--bwc-tan: #cea685;
	--bwc-bg: #fff;
	--bwc-line: #e6e3de;
	--bwc-text: #26241f;
	--bwc-muted: #6b6760;
	position: fixed;
	right: 16px;
	bottom: 16px;
	z-index: 99990;
	font-family: inherit;
	font-size: 15px;
	line-height: 1.6;
	color: var(--bwc-text);
}

/* ---------- 啟動鈕 ---------- */

.bwc-launch {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 12px 20px;
	border: 0;
	border-radius: 999px;
	background: var(--bwc-navy);
	color: #fff;
	font-size: 15px;
	font-weight: 600;
	cursor: pointer;
	box-shadow: 0 6px 24px rgba(0, 0, 0, .18);
}

.bwc-launch:hover { background: #22304a; }
.bwc-launch:focus-visible { outline: 3px solid var(--bwc-tan); outline-offset: 2px; }
.bwc.is-open .bwc-launch { display: none; }

.bwc-launch-dot {
	width: 9px;
	height: 9px;
	border-radius: 50%;
	background: var(--bwc-tan);
}

/* ---------- 面板 ---------- */

/**
 * **`hidden` 必須贏過底下任何 display 規則。**
 *
 * 瀏覽器預設的 `[hidden] { display: none }` 是 UA 樣式，作者樣式一律蓋得過它。
 * `.bwc-panel { display: flex }` 就是這樣把 `panel.hidden = true` 蓋掉的
 * ——2026-11-26 把浮動鈕修好（B135）之後才看得見後果：
 * 對話框在每一頁都是**強制展開**的，362×522 蓋住首頁主圖（B138）。
 *
 * 這條要放在所有元件規則前面，而且要 !important：
 * `hidden` 在這個元件裡是 JS 控制開關的唯一方式（panel、未讀點、綁定鈕、保存連結都用它）。
 */
.bwc[hidden],
.bwc [hidden] {
	display: none !important;
}

.bwc-panel {
	display: flex;
	flex-direction: column;
	width: 360px;
	max-width: calc(100vw - 32px);
	height: 520px;
	max-height: calc(100vh - 32px);
	background: var(--bwc-bg);
	border: 1px solid var(--bwc-line);
	border-radius: 14px;
	overflow: hidden;
	box-shadow: 0 16px 48px rgba(0, 0, 0, .22);
}

.bwc-head {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 12px 14px;
	background: var(--bwc-navy);
	color: #fff;
}

.bwc-title { font-weight: 700; }

.bwc-status {
	margin-left: auto;
	font-size: 12px;
	color: var(--bwc-tan);
}

.bwc-x {
	margin-left: 4px;
	border: 0;
	background: transparent;
	color: #fff;
	font-size: 24px;
	line-height: 1;
	cursor: pointer;
	padding: 0 4px;
}

/* ---------- 訊息 ---------- */

.bwc-log {
	flex: 1 1 auto;
	overflow-y: auto;
	padding: 14px;
	display: flex;
	flex-direction: column;
	gap: 10px;
	background: #faf9f7;
	overscroll-behavior: contain;
}

.bwc-msg { max-width: 85%; }
.bwc-msg.is-mine { align-self: flex-end; }

.bwc-who {
	display: block;
	font-size: 12px;
	color: var(--bwc-muted);
	margin-bottom: 2px;
}

.bwc-body {
	margin: 0;
	padding: 9px 13px;
	border-radius: 14px;
	background: #fff;
	border: 1px solid var(--bwc-line);
	white-space: pre-wrap;
	overflow-wrap: anywhere;
}

.bwc-msg.is-mine .bwc-body {
	background: var(--bwc-navy);
	border-color: var(--bwc-navy);
	color: #fff;
}

.bwc-msg.is-bot .bwc-body { background: #f3efe9; }

.bwc-img {
	display: block;
	margin-top: 6px;
	max-width: 100%;
	height: auto;
	border-radius: 10px;
	border: 1px solid var(--bwc-line);
}

.bwc-note {
	align-self: center;
	max-width: 95%;
	font-size: 13px;
	color: var(--bwc-muted);
	text-align: center;
}

.bwc-note.is-greeting {
	align-self: flex-start;
	text-align: left;
	max-width: 85%;
	padding: 9px 13px;
	border-radius: 14px;
	background: #f3efe9;
	color: var(--bwc-text);
}

.bwc-note.is-error { color: #a3341f; }

.bwc-savedlink {
	align-self: center;
	font-size: 12px;
	overflow-wrap: anywhere;
	color: var(--bwc-navy);
}

/* ---------- 工具列與輸入 ---------- */

.bwc-tools {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	padding: 0 14px;
}

.bwc-tools:empty { display: none; }

.bwc-link {
	border: 0;
	background: transparent;
	padding: 6px 0;
	font-size: 13px;
	color: var(--bwc-navy);
	text-decoration: underline;
	cursor: pointer;
}

.bwc-form {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	padding: 10px 14px;
	border-top: 1px solid var(--bwc-line);
}

/**
 * 傳圖片的鈕。
 *
 * **手機上要夠大而且看得出是「加照片」**：原本是 34px 的「＋」，
 * 在手機上既小又不知道是做什麼的（Edwin 2026-11-26 反映找不到）。
 * 44px 是可觸控目標的常見下限，並且在窄螢幕補上「照片」兩個字。
 */
.bwc-file {
	flex: 0 0 auto;
	min-width: 44px;
	height: 44px;
	padding: 0 10px;
	display: flex;
	align-items: center;
	gap: 4px;
	border: 1px solid var(--bwc-line);
	border-radius: 9px;
	font-size: 19px;
	line-height: 1;
	color: var(--bwc-muted);
	cursor: pointer;
	background: #fff;
}
.bwc-file:hover { border-color: var(--bwc-navy); color: var(--bwc-navy); }
.bwc-file-label {
	font-size: 12px;
	letter-spacing: .02em;
}

/**
 * 把照片拖進對話框時的提示。
 *
 * 蓋在整個對話框上，而且 `pointer-events: none`——不然這層會把 `drop` 事件
 * 接走，放開的瞬間就什麼都不會發生。
 */
.bwc-panel { position: relative; }
.bwc-panel.is-drop::after {
	content: "放開就把這張照片傳上來";
	position: absolute;
	inset: 0;
	z-index: 5;
	display: grid;
	place-items: center;
	border: 2px dashed var(--bwc-tan);
	border-radius: 14px;
	background: rgba(42, 59, 89, .86);
	color: #fff;
	font-size: 15px;
	font-weight: 700;
	pointer-events: none;
}

.bwc-input {
	flex: 1 1 auto;
	min-height: 34px;
	max-height: 120px;
	padding: 7px 10px;
	border: 1px solid var(--bwc-line);
	border-radius: 9px;
	font: inherit;
	resize: none;
	background: #fff;
	color: var(--bwc-text);
}

.bwc-send {
	flex: 0 0 auto;
	padding: 8px 16px;
	border: 0;
	border-radius: 9px;
	background: var(--bwc-navy);
	color: #fff;
	font-weight: 600;
	cursor: pointer;
}

.bwc-send:disabled { opacity: .55; cursor: default; }

.bwc-privacy {
	margin: 0;
	padding: 0 14px 10px;
	font-size: 11px;
	line-height: 1.5;
	color: var(--bwc-muted);
}

/* ---------- 整頁模式 ---------- */

.bwc[data-mode="page"] {
	position: static;
	right: auto;
	bottom: auto;
}

.bwc[data-mode="page"] .bwc-panel {
	width: 100%;
	max-width: 680px;
	height: 100dvh;
	max-height: none;
	margin: 0 auto;
	border: 0;
	border-radius: 0;
	box-shadow: none;
}

.bwc[data-mode="page"] .bwc-launch,
.bwc[data-mode="page"] .bwc-x { display: none; }

/* ---------- 手機 ---------- */

@media (max-width: 600px) {
	.bwc { right: 12px; bottom: 12px; }

	.bwc.is-open {
		right: 0;
		bottom: 0;
		left: 0;
		top: 0;
	}

	.bwc.is-open .bwc-panel {
		width: 100%;
		max-width: none;
		height: 100%;
		max-height: none;
		border: 0;
		border-radius: 0;
	}
}

/**
 * 站方接手模式（`/line/chat/?staff=<id>`）。
 *
 * **一定要一眼看得出「我現在是站方」**——2026-11-26 Edwin 在手機上打字，
 * 以為自己在以管理員回覆，實際上被記成客人、還另開了一段新對話。
 * 那是因為當時根本沒有這個模式，手機上看到的就是訪客畫面，
 * 而訪客畫面跟站方畫面長得一模一樣。
 */
.bwc.is-staff .bwc-head {
	background: #6b4f1d;
}
.bwc.is-staff .bwc-head::after {
	content: "站方";
	margin-left: auto;
	font-size: 11px;
	font-weight: 700;
	letter-spacing: .08em;
	padding: 2px 7px;
	border-radius: 999px;
	background: var(--bwc-tan);
	color: #2a2a2a;
}
.bwc.is-staff .bwc-send {
	background: #6b4f1d;
}
