/**
 * BeBond Chat Widget Styles
 *
 * Scoped to #bebond-chat-* selectors to prevent CSS conflicts with themes.
 * Self-contained: includes own reset within scoped containers.
 *
 * @package BeBond
 */

/* ── Floating Action Button ─────────────────────── */

#bebond-chat-fab {
	position: fixed;
	z-index: 999998;
	width: 56px;
	height: 56px;
	border-radius: 50%;
	border: none;
	background: var(--bebond-primary, #21468B);
	color: #fff;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
	transition: transform 0.2s ease, box-shadow 0.2s ease;
	padding: 0;
	margin: 0;
	outline: none;
	box-sizing: border-box;
	font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
	line-height: 1;
}

#bebond-chat-fab:hover {
	transform: scale(1.08);
	box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

#bebond-chat-fab:active {
	transform: scale(0.95);
}

#bebond-chat-fab.bebond-chat-fab-open {
	transform: rotate(90deg);
}

/* Position variants */
#bebond-chat-fab.bebond-chat-bottom-right {
	bottom: 24px;
	right: 24px;
}

#bebond-chat-fab.bebond-chat-bottom-left {
	bottom: 24px;
	left: 24px;
}

/* ── Chat Panel ─────────────────────────────────── */

#bebond-chat-panel {
	position: fixed;
	z-index: 999999;
	width: 380px;
	height: 560px;
	max-height: calc(100vh - 100px);
	max-width: calc(100vw - 32px);
	border-radius: 16px;
	background: #fff;
	box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.08);
	display: none;
	flex-direction: column;
	overflow: hidden;
	box-sizing: border-box;
	font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
	font-size: 14px;
	line-height: 1.5;
	color: #1a1a1a;
}

#bebond-chat-panel *,
#bebond-chat-panel *::before,
#bebond-chat-panel *::after {
	box-sizing: border-box;
}

/* Position variants */
#bebond-chat-panel.bebond-chat-bottom-right {
	bottom: 90px;
	right: 24px;
}

#bebond-chat-panel.bebond-chat-bottom-left {
	bottom: 90px;
	left: 24px;
}

/* ── Header ─────────────────────────────────────── */

.bebond-chat-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 14px 16px;
	background: var(--bebond-primary, #21468B);
	color: #fff;
	flex-shrink: 0;
}

.bebond-chat-header-left {
	display: flex;
	align-items: center;
	gap: 10px;
	min-width: 0;
}

.bebond-chat-header-right {
	display: flex;
	align-items: center;
	gap: 10px;
	flex-shrink: 0;
	margin-left: 8px;
}

.bebond-chat-logo {
	width: 36px;
	height: 36px;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.2);
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	color: #fff;
	overflow: hidden;
}

.bebond-chat-logo img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	border-radius: 50%;
}

.bebond-chat-title-text {
	min-width: 0;
}

.bebond-chat-title-text h3 {
	font-family: 'Jost', 'Montserrat', sans-serif;
	font-size: 15px;
	font-weight: 600;
	margin: 0;
	line-height: 1.3;
	color: #fff;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.bebond-chat-subtitle {
	font-size: 11px;
	opacity: 0.8;
	line-height: 1.2;
	display: block;
}

.bebond-chat-newchat {
	border: 1px solid rgba(255, 255, 255, 0.4);
	background: rgba(255, 255, 255, 0.1);
	color: #fff;
	border-radius: 6px;
	padding: 4px 10px;
	font-size: 12px;
	font-weight: 500;
	cursor: pointer;
	transition: background 0.15s ease;
	white-space: nowrap;
	font-family: inherit;
	line-height: 1.4;
}

.bebond-chat-newchat:hover {
	background: rgba(255, 255, 255, 0.25);
}

.bebond-chat-close {
	width: 32px;
	height: 32px;
	border: none;
	background: rgba(255, 255, 255, 0.15);
	color: #fff;
	border-radius: 50%;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 16px;
	transition: background 0.15s ease;
	padding: 0;
	line-height: 1;
}

.bebond-chat-close:hover {
	background: rgba(255, 255, 255, 0.3);
}

/* ── Visitor Info Form ─────────────────────────── */

.bebond-chat-info-form {
	flex: 1;
	display: flex;
	flex-direction: column;
	padding: 28px 24px;
	gap: 10px;
	overflow-y: auto;
}

.bebond-chat-info-form h3 {
	font-family: 'Jost', 'Montserrat', sans-serif;
	font-size: 17px;
	font-weight: 600;
	color: #1a1a1a;
	margin: 0 0 2px;
}

.bebond-chat-info-form p {
	font-size: 13px;
	color: #666;
	margin: 0 0 8px;
	line-height: 1.5;
}

.bebond-chat-info-form label {
	font-size: 13px;
	font-weight: 500;
	color: #444;
	display: block;
}

.bebond-chat-info-input {
	width: 100%;
	border: 1px solid #ddd;
	border-radius: 10px;
	padding: 10px 14px;
	font-size: 14px;
	font-family: inherit;
	color: #1a1a1a;
	background: #fafafa;
	outline: none;
	transition: border-color 0.15s ease, background 0.15s ease;
}

.bebond-chat-info-input:focus {
	border-color: var(--bebond-primary, #21468B);
	background: #fff;
}

.bebond-chat-info-input::placeholder {
	color: #aaa;
}

.bebond-chat-info-input.bebond-chat-info-error {
	border-color: #e53e3e;
	background: #fff5f5;
}

.bebond-chat-info-submit {
	width: 100%;
	padding: 11px 16px;
	border: none;
	border-radius: 10px;
	background: var(--bebond-primary, #21468B);
	color: #fff;
	font-size: 14px;
	font-weight: 600;
	font-family: inherit;
	cursor: pointer;
	transition: opacity 0.15s ease, transform 0.15s ease;
	margin-top: 6px;
}

.bebond-chat-info-submit:hover {
	opacity: 0.9;
	transform: translateY(-1px);
}

.bebond-chat-info-submit:active {
	transform: translateY(0);
}

/* ── History Button ───────────────────────────── */

#bebond-chat-panel .bebond-chat-history-btn {
	width: 32px;
	height: 32px;
	border: none;
	background: rgba(255, 255, 255, 0.15);
	color: #fff;
	border-radius: 50%;
	cursor: pointer;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	transition: background 0.15s ease;
	padding: 0;
	line-height: 1;
	margin: 0;
	outline: none;
	box-shadow: none;
}


/* ── History Panel ───────────────────────────── */

.bebond-chat-history {
	flex: 1;
	display: flex;
	flex-direction: column;
	overflow-y: auto;
	padding: 8px;
	gap: 4px;
}

.bebond-chat-history-loading,
.bebond-chat-history-empty {
	display: flex;
	align-items: center;
	justify-content: center;
	flex: 1;
	color: #888;
	font-size: 14px;
	padding: 32px 16px;
	text-align: center;
}

#bebond-chat-panel .bebond-chat-history-item {
	display: flex;
	flex-direction: column;
	gap: 2px;
	padding: 12px 14px;
	border: none;
	border-radius: 10px;
	background: #f8f8f8;
	cursor: pointer;
	text-align: left;
	font-family: inherit;
	transition: background 0.15s ease;
	width: 100%;
	color: inherit;
	line-height: 1.4;
	margin: 0;
	outline: none;
	box-shadow: none;
}


.bebond-chat-history-title {
	font-size: 14px;
	font-weight: 500;
	color: #1a1a1a;
	line-height: 1.4;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.bebond-chat-history-meta {
	font-size: 12px;
	color: #888;
	line-height: 1.3;
}

/* ── Empty State / Welcome Screen ──────────────── */

.bebond-chat-empty {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	text-align: center;
	padding: 32px 24px;
	flex: 1;
	gap: 12px;
}

.bebond-chat-empty-icon {
	width: 56px;
	height: 56px;
	border-radius: 50%;
	background: linear-gradient(135deg, var(--bebond-primary, #21468B), #3b6fc0);
	display: flex;
	align-items: center;
	justify-content: center;
	color: #fff;
	margin-bottom: 4px;
	overflow: hidden;
}

.bebond-chat-empty-icon svg {
	width: 28px;
	height: 28px;
}

.bebond-chat-empty-icon img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	border-radius: 50%;
}

.bebond-chat-empty h2 {
	font-family: 'Jost', 'Montserrat', sans-serif;
	font-size: 18px;
	font-weight: 600;
	color: #1a1a1a;
	margin: 0;
	line-height: 1.3;
}

.bebond-chat-empty p {
	font-size: 13px;
	color: #666;
	margin: 0;
	line-height: 1.5;
	max-width: 260px;
}

/* ── Suggestion Buttons ────────────────────────── */

.bebond-chat-suggestions {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	justify-content: center;
	margin-top: 8px;
	padding: 0 8px;
}

.bebond-chat-suggestions button {
	border: 1px solid #ddd;
	background: #fff;
	color: #444;
	border-radius: 20px;
	padding: 7px 14px;
	font-size: 13px;
	cursor: pointer;
	transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
	font-family: inherit;
	line-height: 1.4;
	white-space: nowrap;
}

.bebond-chat-suggestions button:hover {
	background: var(--bebond-primary, #21468B);
	border-color: var(--bebond-primary, #21468B);
	color: #fff;
}

/* ── Messages ───────────────────────────────────── */

.bebond-chat-messages {
	flex: 1;
	overflow-y: auto;
	padding: 16px 16px 8px;
	display: flex;
	flex-direction: column;
	gap: 16px;
	scroll-behavior: smooth;
}

.bebond-chat-msg {
	display: flex;
	gap: 10px;
	max-width: 85%;
	align-items: flex-start;
}

.bebond-chat-msg-user {
	align-self: flex-end;
	flex-direction: row-reverse;
}

.bebond-chat-msg-assistant {
	align-self: flex-start;
}

/* Message avatars */
.bebond-chat-msg-avatar {
	width: 30px;
	height: 30px;
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	font-size: 12px;
	font-weight: 600;
	margin-top: 2px;
	overflow: hidden;
}

.bebond-chat-msg-avatar-assistant {
	background: linear-gradient(135deg, var(--bebond-primary, #21468B), #3b6fc0);
	color: #fff;
}

.bebond-chat-msg-avatar-assistant svg {
	width: 14px;
	height: 14px;
}

.bebond-chat-msg-avatar-assistant img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	border-radius: 50%;
}

.bebond-chat-msg-avatar-user {
	background: #e8e8e8;
	color: #555;
}

/* Message body (content + time) */
.bebond-chat-msg-body {
	min-width: 0;
	display: flex;
	flex-direction: column;
	gap: 3px;
}

.bebond-chat-msg-content {
	padding: 10px 16px;
	border-radius: 16px;
	font-size: 14px;
	line-height: 1.5;
	word-wrap: break-word;
	overflow-wrap: break-word;
	white-space: pre-wrap;
}

.bebond-chat-msg-user .bebond-chat-msg-content {
	background: var(--bebond-primary, #21468B);
	color: #fff;
	border-bottom-right-radius: 4px;
}

.bebond-chat-msg-assistant .bebond-chat-msg-content {
	background: #f0f0f0;
	color: #1a1a1a;
	border-bottom-left-radius: 4px;
}

.bebond-chat-msg-content a {
	color: var(--bebond-primary, #21468B);
	text-decoration: underline;
	word-break: break-word;
}

.bebond-chat-msg-content a:hover {
	opacity: 0.8;
}

.bebond-chat-msg-user .bebond-chat-msg-content a {
	color: #fff;
}

.bebond-chat-msg-time {
	font-size: 11px;
	color: #999;
	padding: 0 4px;
}

.bebond-chat-msg-user .bebond-chat-msg-time {
	text-align: right;
}

/* ── Typing Indicator ───────────────────────────── */

.bebond-chat-typing {
	display: none;
	align-items: center;
	gap: 8px;
	padding: 8px 16px;
	flex-shrink: 0;
}

.bebond-chat-typing .bebond-chat-msg-avatar {
	width: 30px;
	height: 30px;
}

.bebond-chat-typing-dots {
	display: flex;
	align-items: center;
	gap: 4px;
	padding: 8px 12px;
	background: #f0f0f0;
	border-radius: 16px;
}

.bebond-chat-typing-dots span {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: #bbb;
	animation: bebond-typing 1.4s infinite ease-in-out both;
}

.bebond-chat-typing-dots span:nth-child(1) {
	animation-delay: 0s;
}

.bebond-chat-typing-dots span:nth-child(2) {
	animation-delay: 0.2s;
}

.bebond-chat-typing-dots span:nth-child(3) {
	animation-delay: 0.4s;
}

@keyframes bebond-typing {
	0%, 80%, 100% {
		transform: scale(0.7);
		opacity: 0.4;
	}
	40% {
		transform: scale(1);
		opacity: 1;
	}
}

/* ── Input Area ─────────────────────────────────── */

.bebond-chat-input-area {
	display: flex;
	flex-direction: column;
	padding: 12px 16px;
	border-top: 1px solid #e5e5e5;
	flex-shrink: 0;
	background: #fff;
	gap: 4px;
}

.bebond-chat-input-wrap {
	display: flex;
	align-items: flex-end;
	gap: 8px;
}

.bebond-chat-input {
	flex: 1;
	border: 1px solid #ddd;
	border-radius: 12px;
	padding: 10px 14px;
	font-size: 14px;
	line-height: 1.4;
	resize: none;
	outline: none;
	font-family: inherit;
	color: #1a1a1a;
	background: #fafafa;
	transition: border-color 0.15s ease;
	max-height: 120px;
}

.bebond-chat-input:focus {
	border-color: var(--bebond-primary, #21468B);
	background: #fff;
}

.bebond-chat-input::placeholder {
	color: #999;
}

.bebond-chat-input:disabled {
	opacity: 0.6;
}

.bebond-chat-send {
	width: 38px;
	height: 38px;
	border: none;
	border-radius: 50%;
	background: var(--bebond-primary, #21468B);
	color: #fff;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	transition: opacity 0.15s ease, transform 0.15s ease;
	padding: 0;
}

.bebond-chat-send:hover:not(:disabled) {
	transform: scale(1.05);
}

.bebond-chat-send:disabled {
	opacity: 0.5;
	cursor: not-allowed;
}

.bebond-chat-hint {
	font-size: 11px;
	color: #aaa;
	text-align: center;
}

/* ── Theme Override — Elementor Kit Global Button Hover ── */
/* Elementor's .elementor-kit-* button:hover applies red bg globally.
   We use double-ID or ID+class to guarantee we win specificity. */

#bebond-chat-panel#bebond-chat-panel button:hover,
#bebond-chat-panel#bebond-chat-panel button:focus {
	background-color: inherit;
	color: inherit;
}

#bebond-chat-panel#bebond-chat-panel .bebond-chat-newchat:hover {
	background: rgba(255, 255, 255, 0.25);
	color: #fff;
}

#bebond-chat-panel#bebond-chat-panel .bebond-chat-close:hover {
	background: rgba(255, 255, 255, 0.3);
	color: #fff;
}

#bebond-chat-panel#bebond-chat-panel .bebond-chat-send:hover:not(:disabled) {
	background: var(--bebond-primary, #21468B);
	color: #fff;
	transform: scale(1.05);
}

#bebond-chat-panel#bebond-chat-panel .bebond-chat-suggestions button:hover {
	background: var(--bebond-primary, #21468B);
	border-color: var(--bebond-primary, #21468B);
	color: #fff;
}

#bebond-chat-panel#bebond-chat-panel .bebond-chat-info-submit:hover {
	background: var(--bebond-primary, #21468B);
	color: #fff;
	opacity: 0.9;
}

#bebond-chat-panel#bebond-chat-panel .bebond-chat-history-btn:hover,
#bebond-chat-panel#bebond-chat-panel .bebond-chat-history-btn:focus {
	background: rgba(255, 255, 255, 0.3);
	color: #fff;
}

#bebond-chat-panel#bebond-chat-panel .bebond-chat-history-item:hover {
	background: #eef2f8;
	color: inherit;
}

/* ── Mobile Responsive ──────────────────────────── */

@media (max-width: 480px) {
	#bebond-chat-panel {
		width: 100vw;
		height: 100vh;
		max-height: 100vh;
		max-width: 100vw;
		bottom: 0;
		right: 0;
		left: 0;
		top: 0;
		border-radius: 0;
	}

	#bebond-chat-panel.bebond-chat-bottom-right,
	#bebond-chat-panel.bebond-chat-bottom-left {
		bottom: 0;
		right: 0;
		left: 0;
	}

	.bebond-chat-close {
		width: 40px;
		height: 40px;
		font-size: 20px;
	}

	.bebond-chat-messages {
		padding: 12px;
	}

	.bebond-chat-suggestions button {
		font-size: 12px;
		padding: 6px 12px;
	}

	.bebond-chat-info-form {
		padding: 24px 20px;
	}
}

/* ── RTL Support ────────────────────────────────── */

[dir="rtl"] #bebond-chat-fab.bebond-chat-bottom-right {
	right: auto;
	left: 24px;
}

[dir="rtl"] #bebond-chat-fab.bebond-chat-bottom-left {
	left: auto;
	right: 24px;
}

[dir="rtl"] #bebond-chat-panel.bebond-chat-bottom-right {
	right: auto;
	left: 24px;
}

[dir="rtl"] #bebond-chat-panel.bebond-chat-bottom-left {
	left: auto;
	right: 24px;
}

[dir="rtl"] .bebond-chat-msg-user {
	flex-direction: row;
}

[dir="rtl"] .bebond-chat-msg-assistant {
	flex-direction: row-reverse;
}

[dir="rtl"] .bebond-chat-msg-user .bebond-chat-msg-time {
	text-align: left;
}
