/* AIpage WP — Chatbot widget styles (Young Tech / AI vibe) */

.aipw-chat {
	position: fixed;
	z-index: 99998;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Be Vietnam Pro", Helvetica, Arial, sans-serif;
	--aipw-c-primary:   #0866FF;
	--aipw-c-accent:    #5C39E5;
	--aipw-c-grad:      linear-gradient(135deg, #0866FF 0%, #5C39E5 100%);
	--aipw-c-text:      #0F1729;
	--aipw-c-muted:     #65676B;
	--aipw-c-border:    #E2E8F0;
	--aipw-c-bg:        #F4F6F9;
	--aipw-c-radius:    18px;
	--aipw-c-radius-sm: 10px;
}

.aipw-chat-pos-bottom-right { right: 20px; bottom: 20px; }
.aipw-chat-pos-bottom-left  { left: 20px;  bottom: 20px; }

/* QUAN TRỌNG: tôn trọng thuộc tính [hidden].
   Nếu không có rule này, .aipw-chat-window { display:flex } sẽ ĐÈ lên [hidden]
   (do UA style [hidden]{display:none} có độ ưu tiên thấp hơn), khiến khung chat
   LUÔN mở khi tải trang. Rule dưới đây bảo đảm khi có [hidden] thì thực sự ẩn. */
.aipw-chat[hidden],
.aipw-chat-window[hidden] { display: none !important; }

/* Launcher button */

.aipw-chat-launcher {
	width: 60px;
	height: 60px;
	border-radius: 50%;
	border: 0;
	color: #fff;
	cursor: pointer;
	background: var(--aipw-c-grad) !important;
	box-shadow: 0 8px 24px rgba(8,102,255,0.32), 0 2px 6px rgba(92,57,229,0.20);
	display: flex;
	align-items: center;
	justify-content: center;
	transition: transform 0.2s cubic-bezier(.4,0,.2,1), box-shadow 0.2s ease;
	position: relative;
}
.aipw-chat-launcher::after {
	content: "";
	position: absolute;
	inset: -4px;
	border-radius: 50%;
	background: var(--aipw-c-grad);
	opacity: 0.35;
	z-index: -1;
	filter: blur(10px);
	animation: aipw-chat-glow 2.4s ease-in-out infinite;
}
@keyframes aipw-chat-glow {
	0%, 100% { opacity: 0.25; transform: scale(1); }
	50%      { opacity: 0.45; transform: scale(1.08); }
}

.aipw-chat-launcher:hover {
	transform: scale(1.06);
	box-shadow: 0 12px 32px rgba(8,102,255,0.40), 0 4px 8px rgba(92,57,229,0.28);
}

/* Window */

.aipw-chat-window {
	position: absolute;
	bottom: 76px;
	width: 380px;
	max-width: calc(100vw - 40px);
	height: 540px;
	max-height: calc(100vh - 100px);
	background: #fff;
	border: 1px solid var(--aipw-c-border);
	border-radius: var(--aipw-c-radius);
	box-shadow: 0 16px 48px rgba(15,23,41,0.18), 0 4px 12px rgba(15,23,41,0.10);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	animation: aipw-chat-pop 0.22s cubic-bezier(.4,0,.2,1);
}

.aipw-chat-pos-bottom-right .aipw-chat-window { right: 0; }
.aipw-chat-pos-bottom-left  .aipw-chat-window { left: 0; }

@keyframes aipw-chat-pop {
	from { opacity: 0; transform: translateY(8px); }
	to   { opacity: 1; transform: translateY(0); }
}

/* Header */

.aipw-chat-header {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 14px 16px;
	color: #fff;
	background: var(--aipw-c-grad) !important;
	position: relative;
}
.aipw-chat-header::after {
	content: "";
	position: absolute;
	left: 0; right: 0; bottom: -1px;
	height: 1px;
	background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
}

.aipw-chat-avatar {
	width: 38px;
	height: 38px;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.2);
	color: #fff;
	display: flex;
	align-items: center;
	justify-content: center;
	font-weight: 700;
	font-size: 14px;
	flex-shrink: 0;
}

.aipw-chat-name-block { flex: 1; min-width: 0; }
.aipw-chat-name { font-weight: 600; font-size: 15px; line-height: 1.2; }
.aipw-chat-role { font-size: 12px; opacity: 0.85; line-height: 1.3; }

.aipw-chat-close {
	background: transparent;
	border: 0;
	color: rgba(255, 255, 255, 0.85);
	font-size: 24px;
	line-height: 1;
	cursor: pointer;
	padding: 4px 8px;
	margin-right: -6px;
}

.aipw-chat-close:hover { color: #fff; }
.aipw-chat-close svg { display: block; }
.aipw-chat-input button svg { display: block; }
.aipw-chat-launcher svg { display: block; }

/* Messages */

.aipw-chat-messages {
	flex: 1;
	overflow-y: auto;
	padding: 14px;
	background: #f7f9fc;
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.aipw-chat-msg {
	max-width: 80%;
	display: flex;
}

.aipw-chat-msg-bot { align-self: flex-start; }
.aipw-chat-msg-me  { align-self: flex-end; }

.aipw-chat-bubble {
	padding: 10px 14px;
	border-radius: 16px;
	line-height: 1.5;
	font-size: 14px;
	white-space: pre-wrap;
	word-wrap: break-word;
}

.aipw-chat-msg-bot .aipw-chat-bubble {
	background: #fff;
	color: #1d2327;
	border-bottom-left-radius: 4px;
	box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.aipw-chat-msg-me .aipw-chat-bubble {
	background: var(--aipw-c-grad);
	color: #fff;
	border-bottom-right-radius: 4px;
	box-shadow: 0 2px 8px rgba(8,102,255,0.20);
}

.aipw-chat-msg-bot .aipw-chat-bubble {
	border: 1px solid var(--aipw-c-border);
}

/* Typing indicator */

.aipw-chat-typing {
	display: inline-flex;
	gap: 3px;
	padding: 12px 14px;
}

.aipw-chat-typing span {
	width: 6px; height: 6px; border-radius: 50%;
	background: #c0c4ca;
	animation: aipw-chat-blink 1.4s infinite;
}

.aipw-chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.aipw-chat-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes aipw-chat-blink {
	0%, 60%, 100% { opacity: 0.2; }
	30% { opacity: 1; }
}

/* Input */

.aipw-chat-input {
	display: flex;
	gap: 8px;
	padding: 10px 12px;
	border-top: 1px solid #e0e4eb;
	background: #fff;
}

.aipw-chat-input input {
	flex: 1;
	border: 1px solid #d0d4db;
	border-radius: 999px;
	padding: 10px 16px;
	font-size: 14px;
	outline: none;
	transition: border-color 0.15s;
}

.aipw-chat-input input:focus {
	border-color: var(--aipw-c-primary);
	box-shadow: 0 0 0 3px rgba(8,102,255,0.15);
}

.aipw-chat-input button {
	width: 40px;
	height: 40px;
	border: 0;
	border-radius: 50%;
	color: #fff;
	cursor: pointer;
	font-size: 18px;
	font-weight: 700;
	display: flex;
	align-items: center;
	justify-content: center;
	background: var(--aipw-c-grad) !important;
	box-shadow: 0 2px 6px rgba(8,102,255,0.25);
	transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.aipw-chat-input button:hover {
	transform: scale(1.05);
	box-shadow: 0 4px 12px rgba(8,102,255,0.35);
}

.aipw-chat-input button:disabled { opacity: 0.5; cursor: wait; }

.aipw-chat-footer-note {
	margin: 0;
	padding: 6px 12px;
	font-size: 10.5px;
	color: #999;
	text-align: center;
	background: #fff;
	border-top: 1px solid #f0f2f5;
}
.aipw-chat-footer-note a {
	color: var(--aipw-c-primary);
	text-decoration: none;
	font-weight: 600;
}
.aipw-chat-footer-note a:hover { text-decoration: underline; }

/* Mobile */

@media (max-width: 480px) {
	.aipw-chat-pos-bottom-right { right: 12px; bottom: 12px; }
	.aipw-chat-pos-bottom-left  { left: 12px;  bottom: 12px; }
	.aipw-chat-window {
		width: calc(100vw - 24px);
		height: calc(100vh - 100px);
		bottom: 76px;
	}
}

.aipw-chat-lead-strip {
	margin: 4px 0;
	padding: 8px 12px;
	background: linear-gradient(135deg, #e9f1ff 0%, #ede5ff 100%);
	border: 1px solid rgba(8,102,255,0.18);
	color: #044bba;
	font-size: 12px;
	border-radius: var(--aipw-c-radius-sm);
	text-align: center;
	font-weight: 500;
	animation: aipw-chat-pop 0.2s ease;
}
.aipw-chat-lead-strip strong {
	color: var(--aipw-c-accent);
}
