/* ===================================================================
 * Chatbot VNDC widget — hoàn toàn isolated khỏi theme/Elementor.
 *
 * Chiến lược chống đè CSS:
 *   1. Mọi selector đều bọc trong #gau-chatbot-vndc-root  →  specificity 0,1,X
 *      (vẫn thua selector !important của theme, nhưng thắng selector
 *       element thường như `button {}` hoặc `.content button`).
 *   2. Trên các property visual mà theme HAY đè (background, border,
 *      box-shadow, outline, color, text-shadow, text-transform), ta nhét
 *      !important để khoá cứng.
 *   3. all: revert ở khối reset để xoá các property kế thừa mà theme set
 *      trên ancestor — vd theme set `body * { letter-spacing: 2px }`.
 *
 * Class prefix: .gau-chatbot-* (BEM với __ và --).
 * CSS variable prefix: --gau-chatbot-* (JS inject color từ config.php).
 * =================================================================== */

#gau-chatbot-vndc-root {
	--gau-chatbot-color: #1e88e5;
	--gau-chatbot-color-fg: #fff;
	--gau-chatbot-color-text: #222;
	--gau-chatbot-color-bg: #fff;
	--gau-chatbot-color-bg-soft: #f7f8fa;
	--gau-chatbot-color-border: #e7e9ee;
	--gau-chatbot-color-error: #b00020;
	--gau-chatbot-color-error-bg: #ffe9e9;
	--gau-chatbot-radius: 14px;
	--gau-chatbot-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
	--gau-chatbot-margin: 20px;   /* override bởi admin Settings → widget margin */
	--gau-chatbot-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

	font-family: var(--gau-chatbot-font) !important;
	font-size: 14px !important;
	line-height: 1.45 !important;
	color: var(--gau-chatbot-color-text) !important;
}

/* ===== RESET — chống theme đè vào button/input/svg/textarea ===== */

#gau-chatbot-vndc-root,
#gau-chatbot-vndc-root *,
#gau-chatbot-vndc-root *::before,
#gau-chatbot-vndc-root *::after {
	box-sizing: border-box !important;
	letter-spacing: normal !important;
	text-transform: none !important;
	text-shadow: none !important;
}

#gau-chatbot-vndc-root button {
	-webkit-appearance: none !important;
	-moz-appearance: none !important;
	appearance: none !important;
	margin: 0 !important;
	padding: 0;
	border: 0 !important;
	outline: 0 !important;
	background: transparent !important;
	background-image: none !important;
	box-shadow: none !important;
	color: inherit;
	font-family: inherit !important;
	font-size: inherit !important;
	cursor: pointer;
}
#gau-chatbot-vndc-root button:focus,
#gau-chatbot-vndc-root button:focus-visible,
#gau-chatbot-vndc-root button:hover,
#gau-chatbot-vndc-root button:active {
	outline: 0 !important;
	box-shadow: none !important;
}

#gau-chatbot-vndc-root input,
#gau-chatbot-vndc-root textarea {
	-webkit-appearance: none !important;
	-moz-appearance: none !important;
	appearance: none !important;
	margin: 0 !important;
	background: var(--gau-chatbot-color-bg) !important;
	background-image: none !important;
	color: var(--gau-chatbot-color-text) !important;
	font-family: inherit !important;
	font-size: 14px !important;
	line-height: 1.4 !important;
	box-shadow: none !important;
	text-shadow: none !important;
}
#gau-chatbot-vndc-root input:focus,
#gau-chatbot-vndc-root textarea:focus {
	outline: 0 !important;
	box-shadow: none !important;
}
#gau-chatbot-vndc-root input::-webkit-outer-spin-button,
#gau-chatbot-vndc-root input::-webkit-inner-spin-button {
	-webkit-appearance: none !important;
	margin: 0 !important;
}
#gau-chatbot-vndc-root textarea {
	resize: none !important;
	overflow-y: auto !important;
}

#gau-chatbot-vndc-root svg {
	display: inline-block;
	vertical-align: middle;
	fill: currentColor;
	color: inherit;
}

#gau-chatbot-vndc-root a {
	text-decoration: none !important;
	color: inherit !important;
	box-shadow: none !important;
}


/* ===== LAUNCHER (bubble góc dưới) ===== */

#gau-chatbot-vndc-root .gau-chatbot-launcher {
	position: fixed;
	bottom: var(--gau-chatbot-margin, 20px);
	z-index: 2147483600;
	display: inline-flex !important;
	align-items: center;
	gap: 8px;
	padding: 12px 18px 12px 14px !important;
	border-radius: 999px !important;
	background: var(--gau-chatbot-color) !important;
	color: var(--gau-chatbot-color-fg) !important;
	font-size: 15px !important;
	font-weight: 600 !important;
	box-shadow: var(--gau-chatbot-shadow) !important;
	transition: transform 0.15s ease, box-shadow 0.15s ease;
}
#gau-chatbot-vndc-root .gau-chatbot-launcher:hover {
	transform: translateY(-2px);
	box-shadow: 0 16px 48px rgba(0, 0, 0, 0.22) !important;
}
#gau-chatbot-vndc-root .gau-chatbot-launcher--right { right: var(--gau-chatbot-margin, 20px); }
#gau-chatbot-vndc-root .gau-chatbot-launcher--left  { left:  var(--gau-chatbot-margin, 20px); }

#gau-chatbot-vndc-root .gau-chatbot-launcher__icon {
	width: 22px;
	height: 22px;
	flex: none;
	color: var(--gau-chatbot-color-fg) !important;
	fill: currentColor !important;
}


/* ===== PANEL (khung chat) ===== */

#gau-chatbot-vndc-root .gau-chatbot-panel {
	position: fixed;
	/* Panel ngồi cách launcher 1 đoạn = margin + chiều cao launcher (~66px gồm padding) */
	bottom: calc(var(--gau-chatbot-margin, 20px) + 66px);
	width: 380px;
	max-width: calc(100vw - 32px);
	height: 560px;
	max-height: calc(100vh - 120px);
	z-index: 2147483601;
	display: flex !important;
	flex-direction: column;
	background: var(--gau-chatbot-color-bg) !important;
	border-radius: var(--gau-chatbot-radius) !important;
	box-shadow: var(--gau-chatbot-shadow) !important;
	overflow: hidden;
	opacity: 0;
	transform: translateY(10px);
	pointer-events: none;
	transition: opacity 0.18s ease, transform 0.18s ease;
}
#gau-chatbot-vndc-root .gau-chatbot-panel--right { right: var(--gau-chatbot-margin, 20px); }
#gau-chatbot-vndc-root .gau-chatbot-panel--left  { left:  var(--gau-chatbot-margin, 20px); }
#gau-chatbot-vndc-root .gau-chatbot-panel--open {
	opacity: 1;
	transform: translateY(0);
	pointer-events: auto;
}


/* ===== HEADER ===== */

#gau-chatbot-vndc-root .gau-chatbot-header {
	padding: 14px 16px;
	background: var(--gau-chatbot-color) !important;
	color: var(--gau-chatbot-color-fg) !important;
	display: flex !important;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
}
#gau-chatbot-vndc-root .gau-chatbot-header__title {
	font-weight: 700 !important;
	font-size: 16px !important;
	line-height: 1.2 !important;
	color: var(--gau-chatbot-color-fg) !important;
}
#gau-chatbot-vndc-root .gau-chatbot-header__subtitle {
	font-size: 12px !important;
	opacity: 0.85;
	margin-top: 2px;
	color: var(--gau-chatbot-color-fg) !important;
}
#gau-chatbot-vndc-root .gau-chatbot-header__close {
	width: 32px;
	height: 32px;
	display: inline-flex !important;
	align-items: center;
	justify-content: center;
	border-radius: 8px !important;
	background: transparent !important;
	color: var(--gau-chatbot-color-fg) !important;
	opacity: 0.85;
}
#gau-chatbot-vndc-root .gau-chatbot-header__close:hover {
	background: rgba(255, 255, 255, 0.15) !important;
	opacity: 1;
}
#gau-chatbot-vndc-root .gau-chatbot-header__close svg {
	color: var(--gau-chatbot-color-fg) !important;
	stroke: currentColor !important;
}


/* ===== BODY (vùng tin nhắn) ===== */

#gau-chatbot-vndc-root .gau-chatbot-body {
	flex: 1;
	overflow-y: auto;
	padding: 14px;
	background: var(--gau-chatbot-color-bg-soft) !important;
	display: flex !important;
	flex-direction: column;
	gap: 8px;
}
#gau-chatbot-vndc-root .gau-chatbot-body::-webkit-scrollbar { width: 6px; }
#gau-chatbot-vndc-root .gau-chatbot-body::-webkit-scrollbar-thumb {
	background: #c5cad3 !important;
	border-radius: 3px;
}


/* ===== TIN NHẮN ===== */

#gau-chatbot-vndc-root .gau-chatbot-msg {
	max-width: 80%;
	padding: 9px 13px !important;
	border-radius: 14px !important;
	font-size: 14px !important;
	line-height: 1.45 !important;
	white-space: pre-wrap;
	word-wrap: break-word;
}
#gau-chatbot-vndc-root .gau-chatbot-msg--bot {
	align-self: flex-start;
	background: var(--gau-chatbot-color-bg) !important;
	color: var(--gau-chatbot-color-text) !important;
	border-bottom-left-radius: 4px !important;
	box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05) !important;
}
#gau-chatbot-vndc-root .gau-chatbot-msg--user {
	align-self: flex-end;
	background: var(--gau-chatbot-color) !important;
	color: var(--gau-chatbot-color-fg) !important;
	border-bottom-right-radius: 4px !important;
}
#gau-chatbot-vndc-root .gau-chatbot-msg--error {
	align-self: flex-start;
	background: var(--gau-chatbot-color-error-bg) !important;
	color: var(--gau-chatbot-color-error) !important;
	font-size: 13px !important;
}

/* Bubble greeting do TinyMCE xuất HTML (p, ul, ol, a, strong…) */
#gau-chatbot-vndc-root .gau-chatbot-msg--html p {
	margin: 0 0 8px !important;
}
#gau-chatbot-vndc-root .gau-chatbot-msg--html p:last-child { margin-bottom: 0 !important; }
#gau-chatbot-vndc-root .gau-chatbot-msg--html ul,
#gau-chatbot-vndc-root .gau-chatbot-msg--html ol {
	margin: 4px 0 8px !important;
	padding-left: 20px !important;
}
#gau-chatbot-vndc-root .gau-chatbot-msg--html a {
	color: var(--gau-chatbot-color) !important;
	text-decoration: underline !important;
}
#gau-chatbot-vndc-root .gau-chatbot-msg--html strong { font-weight: 700 !important; }
#gau-chatbot-vndc-root .gau-chatbot-msg--html em     { font-style: italic !important; }
#gau-chatbot-vndc-root .gau-chatbot-msg--html del    { text-decoration: line-through !important; opacity: 0.7; }

#gau-chatbot-vndc-root .gau-chatbot-msg--html code {
	background: rgba(0, 0, 0, 0.06) !important;
	padding: 1px 5px !important;
	border-radius: 3px !important;
	font-family: Consolas, Monaco, "Courier New", monospace !important;
	font-size: 12px !important;
}
#gau-chatbot-vndc-root .gau-chatbot-msg--html pre {
	background: rgba(0, 0, 0, 0.06) !important;
	padding: 8px 10px !important;
	border-radius: 6px !important;
	overflow-x: auto !important;
	margin: 6px 0 !important;
	font-family: Consolas, Monaco, "Courier New", monospace !important;
	font-size: 12px !important;
	line-height: 1.4 !important;
}
#gau-chatbot-vndc-root .gau-chatbot-msg--html pre code {
	background: transparent !important;
	padding: 0 !important;
	font-size: inherit !important;
}
#gau-chatbot-vndc-root .gau-chatbot-msg--bot.gau-chatbot-msg--html strong {
	color: var(--gau-chatbot-color-text) !important;
}


/* ===== TYPING ===== */

#gau-chatbot-vndc-root .gau-chatbot-typing {
	align-self: flex-start;
	padding: 10px 14px;
	background: var(--gau-chatbot-color-bg) !important;
	border-radius: 14px;
	border-bottom-left-radius: 4px;
	box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05) !important;
	display: flex !important;
	gap: 4px;
}
#gau-chatbot-vndc-root .gau-chatbot-typing span {
	width: 7px;
	height: 7px;
	background: #b8bcc4 !important;
	border-radius: 50%;
	animation: gau-chatbot-blink 1.2s infinite both;
}
#gau-chatbot-vndc-root .gau-chatbot-typing span:nth-child(2) { animation-delay: 0.2s; }
#gau-chatbot-vndc-root .gau-chatbot-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes gau-chatbot-blink {
	0%, 80%, 100% { opacity: 0.25; }
	40%           { opacity: 1; }
}


/* ===== FOOTER chung (2 mode: chat & phone) ===== */

#gau-chatbot-vndc-root .gau-chatbot-footer {
	border-top: 1px solid var(--gau-chatbot-color-border) !important;
	background: var(--gau-chatbot-color-bg) !important;
	padding: 10px 12px;
}

/* Mode switching: hiện chat-form khi panel ở mode-chat, hiện phone-form khi mode-phone */
#gau-chatbot-vndc-root .gau-chatbot-chat-form,
#gau-chatbot-vndc-root .gau-chatbot-phone-form {
	display: none;
}
#gau-chatbot-vndc-root .gau-chatbot-panel--mode-chat .gau-chatbot-chat-form {
	display: flex !important;
	gap: 8px;
	align-items: flex-end;
}
#gau-chatbot-vndc-root .gau-chatbot-panel--mode-phone .gau-chatbot-phone-form {
	display: flex !important;
	flex-direction: column;
	gap: 8px;
}

/* CHAT mode: textarea + send */
#gau-chatbot-vndc-root .gau-chatbot-input {
	flex: 1;
	border: 1px solid #d8dbe2 !important;
	border-radius: 10px !important;
	padding: 9px 12px !important;
	max-height: 120px;
}
#gau-chatbot-vndc-root .gau-chatbot-input:focus {
	border-color: var(--gau-chatbot-color) !important;
}
#gau-chatbot-vndc-root .gau-chatbot-input::-webkit-scrollbar { width: 6px; }
#gau-chatbot-vndc-root .gau-chatbot-input::-webkit-scrollbar-thumb {
	background: #c5cad3 !important;
	border-radius: 3px;
}

/* PHONE mode: caption + tel input + send + skip */
#gau-chatbot-vndc-root .gau-chatbot-phone-caption {
	font-size: 13px !important;
	line-height: 1.4 !important;
	color: #555 !important;
	padding: 2px 2px 0;
}
#gau-chatbot-vndc-root .gau-chatbot-phone-row {
	display: flex !important;
	gap: 8px;
	align-items: stretch;
}
#gau-chatbot-vndc-root .gau-chatbot-phone-input {
	flex: 1;
	height: 40px !important;
	border: 1.5px solid var(--gau-chatbot-color) !important;
	border-radius: 10px !important;
	padding: 0 12px !important;
	font-size: 15px !important;
	font-weight: 600 !important;
	letter-spacing: 0.5px !important;
}
#gau-chatbot-vndc-root .gau-chatbot-phone-input:focus {
	border-color: var(--gau-chatbot-color) !important;
	box-shadow: 0 0 0 3px rgba(30, 136, 229, 0.15) !important;
}
#gau-chatbot-vndc-root .gau-chatbot-phone-skip {
	align-self: center;
	font-size: 12px !important;
	color: #888 !important;
	text-decoration: underline !important;
	cursor: pointer;
	padding: 2px 4px;
}
#gau-chatbot-vndc-root .gau-chatbot-phone-skip:hover {
	color: #555 !important;
}

/* SEND button (dùng chung cho cả chat-send và phone-submit) */
#gau-chatbot-vndc-root .gau-chatbot-send {
	background: var(--gau-chatbot-color) !important;
	color: var(--gau-chatbot-color-fg) !important;
	border-radius: 10px !important;
	padding: 0 14px !important;
	height: 38px !important;
	font-weight: 600 !important;
	font-size: 14px !important;
	display: inline-flex !important;
	align-items: center;
	justify-content: center;
	white-space: nowrap;
}
#gau-chatbot-vndc-root .gau-chatbot-phone-submit {
	height: 40px !important;
}
#gau-chatbot-vndc-root .gau-chatbot-send:hover {
	filter: brightness(0.95);
}
#gau-chatbot-vndc-root .gau-chatbot-send:disabled {
	opacity: 0.5 !important;
	cursor: not-allowed !important;
}


/* ===== RESPONSIVE MOBILE ===== */

@media (max-width: 480px) {
	#gau-chatbot-vndc-root .gau-chatbot-panel {
		width: calc(100vw - 16px);
		height: calc(100vh - 100px);
		bottom: 80px;
	}
	#gau-chatbot-vndc-root .gau-chatbot-panel--right { right: 8px; }
	#gau-chatbot-vndc-root .gau-chatbot-panel--left  { left: 8px;  }
	#gau-chatbot-vndc-root .gau-chatbot-launcher--right { right: 16px; bottom: 16px; }
	#gau-chatbot-vndc-root .gau-chatbot-launcher--left  { left: 16px;  bottom: 16px; }
}
