/* Visitor Interact — frontend styles */

:root { --vi-accent: #2271b1; }

.vi-btn {
	background: var(--vi-accent);
	color: #fff;
	border: 0;
	padding: 10px 16px;
	border-radius: 6px;
	cursor: pointer;
	font-size: 14px;
	line-height: 1;
}
.vi-btn:hover { filter: brightness(0.95); }
.vi-btn[disabled] { opacity: 0.6; cursor: not-allowed; }

/* Contact form */
.vi-form-wrap { max-width: 560px; margin: 1em 0; }
.vi-form-title { margin: 0 0 0.6em; font-size: 1.25rem; }
.vi-form label { display: block; font-size: 0.9rem; margin-bottom: 6px; }
.vi-form input[type="text"],
.vi-form input[type="email"],
.vi-form textarea {
	width: 100%;
	padding: 9px 10px;
	border: 1px solid #c3c4c7;
	border-radius: 6px;
	font: inherit;
	box-sizing: border-box;
}
.vi-form-status { margin-top: 8px; font-size: 0.95rem; }
.vi-form-status.vi-ok { color: #1a7f37; }
.vi-form-status.vi-err { color: #b32d2e; }

/* Floating contact widget (bottom-right) */
.vi-contact {
	position: fixed;
	right: 20px;
	bottom: 20px;
	z-index: 99998;
	display: flex;
	flex-direction: column;
	align-items: flex-end;
	gap: 10px;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
.vi-contact-toggle {
	width: 58px; height: 58px;
	border-radius: 50%;
	border: 0;
	background: var(--vi-accent);
	color: #fff;
	box-shadow: 0 6px 16px rgba(0,0,0,0.22);
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: transform 0.15s ease;
	position: relative;
}
.vi-contact-toggle:hover { transform: scale(1.05); }
.vi-contact-toggle .vi-contact-icon { display: flex; align-items: center; justify-content: center; }
.vi-contact-toggle .vi-icon-close { font-size: 28px; line-height: 1; display: none; }
.vi-contact[aria-expanded="true"] .vi-icon-open  { display: none; }
.vi-contact[aria-expanded="true"] .vi-icon-close { display: flex; }

.vi-contact-actions {
	display: flex;
	flex-direction: column;
	align-items: flex-end;
	gap: 10px;
}
.vi-contact-actions[hidden] { display: none; }

.vi-action {
	display: inline-flex;
	align-items: center;
	gap: 10px;
	padding: 10px 16px 10px 12px;
	background: #ffffff;
	color: #111;
	border-radius: 999px;
	text-decoration: none;
	font-size: 14px;
	font-weight: 600;
	box-shadow: 0 6px 18px rgba(0,0,0,0.18);
	transform: translateY(6px);
	opacity: 0;
	transition: transform 0.2s ease, opacity 0.2s ease, background 0.15s ease;
	white-space: nowrap;
}
.vi-contact[aria-expanded="true"] .vi-action { transform: translateY(0); opacity: 1; }
.vi-action:hover { background: #f3f4f6; }
.vi-action-icon {
	width: 36px; height: 36px;
	border-radius: 50%;
	display: flex; align-items: center; justify-content: center;
	color: #fff;
}
.vi-action--wa   .vi-action-icon { background: #25D366; }
.vi-action--call .vi-action-icon { background: var(--vi-accent); }

@media (max-width: 480px) {
	.vi-contact { right: 14px; bottom: 14px; }
	.vi-action-label { display: inline; }
}

/* Chat panel */
.vi-chatbox {
	width: 340px;
	max-width: calc(100vw - 28px);
	height: 460px;
	max-height: calc(100vh - 120px);
	background: #fff;
	border-radius: 14px;
	box-shadow: 0 20px 50px rgba(0,0,0,0.22);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	border: 1px solid #e5e7eb;
}
.vi-chatbox[hidden] { display: none; }
.vi-chat-header {
	background: var(--vi-accent);
	color: #fff;
	padding: 12px 14px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	font-weight: 600;
}
.vi-chat-x {
	background: transparent; border: 0; color: #fff; font-size: 22px; line-height: 1; cursor: pointer;
}
.vi-chat-intro { padding: 16px; display: flex; flex-direction: column; gap: 10px; overflow-y: auto; }
.vi-chat-intro h4 { margin: 0; font-size: 1.05rem; }
.vi-chat-intro p { margin: 0; color: #555; font-size: 0.92rem; }
.vi-chat-start { display: grid; gap: 8px; }
.vi-chat-start input,
.vi-chat-start textarea {
	width: 100%;
	padding: 9px 10px;
	border: 1px solid #d1d5db;
	border-radius: 8px;
	font: inherit;
	box-sizing: border-box;
}
.vi-chat-start-status { font-size: 0.85rem; }
.vi-chat-start-status.vi-ok  { color: #1a7f37; }
.vi-chat-start-status.vi-err { color: #b32d2e; }
.vi-chat-offline { font-size: 0.8rem; color: #6b7280; margin: 4px 0 0; }

.vi-chat-thread { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.vi-chat-messages {
	flex: 1;
	overflow-y: auto;
	padding: 12px;
	background: #f6f7f8;
	display: flex;
	flex-direction: column;
	gap: 8px;
}
.vi-msg { display: flex; flex-direction: column; max-width: 80%; }
.vi-msg--visitor { align-self: flex-end; align-items: flex-end; }
.vi-msg--staff   { align-self: flex-start; align-items: flex-start; }
.vi-msg-bubble {
	padding: 8px 12px;
	border-radius: 14px;
	font-size: 0.92rem;
	line-height: 1.35;
	white-space: pre-wrap;
	word-wrap: break-word;
}
.vi-msg--visitor .vi-msg-bubble { background: var(--vi-accent); color: #fff; border-bottom-right-radius: 4px; }
.vi-msg--staff   .vi-msg-bubble { background: #fff; color: #111; border: 1px solid #e5e7eb; border-bottom-left-radius: 4px; }
.vi-msg-time { font-size: 0.72rem; color: #6b7280; margin-top: 2px; }

.vi-chat-reply {
	display: flex; gap: 6px; align-items: flex-end;
	padding: 8px 10px; border-top: 1px solid #e5e7eb; background: #fff;
}
.vi-chat-reply textarea {
	flex: 1;
	resize: none;
	padding: 9px 10px;
	border: 1px solid #d1d5db;
	border-radius: 8px;
	font: inherit;
	max-height: 100px;
	min-height: 38px;
	box-sizing: border-box;
}
.vi-chat-send {
	background: var(--vi-accent); color: #fff; border: 0;
	width: 38px; height: 38px; border-radius: 50%;
	display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.vi-chat-status { font-size: 0.8rem; padding: 4px 12px 8px; color: #6b7280; }
.vi-chat-status.vi-err { color: #b32d2e; }

/* Unread badge on the toggle */
.vi-contact-toggle { position: relative; }
.vi-badge {
	position: absolute;
	top: -4px; right: -4px;
	min-width: 14px; height: 14px;
	background: #e11d48;
	border: 2px solid #fff;
	border-radius: 50%;
}
.vi-badge[hidden] { display: none; }


/* Popup */
.vi-popup { position: fixed; inset: 0; z-index: 99999; display: flex; align-items: center; justify-content: center; }
.vi-popup[hidden] { display: none; }
.vi-popup-overlay { position: absolute; inset: 0; background: rgba(0,0,0,0.55); }
.vi-popup-card {
	position: relative;
	background: #fff;
	border-radius: 12px;
	padding: 24px;
	max-width: 420px;
	width: calc(100% - 40px);
	box-shadow: 0 20px 60px rgba(0,0,0,0.3);
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
.vi-popup-card h3 { margin: 0 0 0.4em; }
.vi-popup-close { position: absolute; top: 8px; right: 10px; background: transparent; border: 0; font-size: 24px; cursor: pointer; color: #6b7280; }
.vi-popup-form { display: grid; gap: 8px; margin-top: 10px; }
.vi-popup-form input,
.vi-popup-form textarea {
	width: 100%;
	padding: 9px 10px;
	border: 1px solid #c3c4c7;
	border-radius: 6px;
	font: inherit;
	box-sizing: border-box;
}
.vi-popup-status { font-size: 0.9rem; }
.vi-popup-status.vi-ok { color: #1a7f37; }
.vi-popup-status.vi-err { color: #b32d2e; }
