/**
 * WorkDo Live Cart Assist — Public Chat Popup Styles
 *
 * @package WorkDo_Live_Cart_Assist
 */

/* ---- Launcher Button (bottom-right chat bubble) ---- */
#wlca-pub-launcher {
	position: fixed;
	bottom: 24px;
	right: 24px;
	z-index: 999998;
	width: 56px;
	height: 56px;
	border-radius: 50%;
	background: var(--dark-green);
	border: 1px solid var(--border-color);
	cursor: pointer;
	display: none; /* hidden until a session exists */
	align-items: center;
	justify-content: center;
	padding: 0;
}

/* Shown only when a cart session is active */
#wlca-pub-launcher.wlca-launcher-visible {
	display: flex;
}

#wlca-pub-launcher:hover {
	transform: scale( 1.08 );
	box-shadow: 0 6px 20px rgba( 0, 0, 0, .32 );
}

#wlca-pub-launcher svg {
	display: block;
}

/* Icon states — chat icon shown when closed, X shown when open */
#wlca-pub-launcher .wlca-launcher-icon-chat {
	display: block;
}

#wlca-pub-launcher .wlca-launcher-icon-close {
	display: none;
}

#wlca-pub-launcher.wlca-launcher-open .wlca-launcher-icon-chat {
	display: none;
}

#wlca-pub-launcher.wlca-launcher-open .wlca-launcher-icon-close {
	display: block;
}

/* ---- Chat Widget (sits above launcher) ---- */
#wlca-pub-modal {
	position: fixed;
	bottom: 76px;
	right: 76px;
	z-index: 999999;
	width: 360px;
	max-width: calc( 100vw - 32px );
	display: flex;
	flex-direction: column;
	pointer-events: none;
	transform: translateY( 16px );
	opacity: 0;
	transition: transform .2s ease, opacity .2s ease;
}

#wlca-pub-modal.wlca-pub-modal-open {
	pointer-events: auto;
	transform: translateY( 0 );
	opacity: 1;
}

#wlca-pub-modal.wlca-pub-modal-hidden {
	display: none;
}

/* No overlay — widget floats freely */
.wlca-pub-overlay {
	display: none;
}

/* ---- Chat Box ---- */
.wlca-pub-box {
	background: var(--white);
	border-radius: 12px;
	width: 100%;
	height: 550px;
	max-height: calc( 100vh - 120px );
	display: flex;
	flex-direction: column;
	box-shadow: 0 8px 32px rgba( 0, 0, 0, .18 );
	overflow: hidden;
	font-size: 14px;
}

/* ---- Header ---- */
.wlca-pub-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 15px;
	flex-shrink: 0;
	color: var(--black);
	border-bottom: 1px solid var(--border-color);
}

.wlca-pub-header-info {
	display: flex;
	align-items: center;
	gap: 10px;
	min-width: 0;
}

/* ---- Avatar with status dot ---- */
.wlca-pub-header-avatar {
	position: relative;
	flex-shrink: 0;
	width: 38px;
	height: 38px;
	background: rgba( 255, 255, 255, .2 );
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
}

.wlca-pub-avatar {
	border-radius: 50%;
}

.wlca-pub-status-dot {
	position: absolute;
	bottom: 1px;
	right: 1px;
	width: 10px;
	height: 10px;
	border-radius: 50%;
	border: 2px solid var(--dark-green);
}

.wlca-pub-status-dot.wlca-pub-status-online {
	background: var(--theme-color);
}

.wlca-pub-status-dot.wlca-pub-status-offline {
	background: #94a3b8;
}

/* ---- Header text block ---- */

.wlca-pub-header-name {
	font-size: 14px;
	font-weight: 700;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	line-height: 1.2;
}

.wlca-pub-header-status {
	font-size: 11px;
	font-weight: 500;
	line-height: 1.2;
}

.wlca-pub-header-status.wlca-pub-status-online {
	color: #008000;
}

.wlca-pub-header-status.wlca-pub-status-offline {
	color: #6c6f74;
}

#wlca-pub-modal-title {
	font-size: 14px;
	font-weight: 700;
}

.wlca-pub-close {
	background: none;
	border: none;
	cursor: pointer;
	font-size: 18px;
	color: #6c6f74;
	padding: 4px 8px;
	line-height: 1;
	border-radius: 4px;
	min-width: 36px;
	min-height: 36px;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
}

.wlca-pub-close:hover {
	background-color: rgb(9 14 21 / 10%);
	color: #6c6f74;
}

/* ---- Messages Area ---- */
.wlca-pub-messages {
	flex: 1;
	overflow-y: auto;
	padding: 14px 16px;
	display: flex;
	flex-direction: column;
	gap: 10px;
	-webkit-overflow-scrolling: touch;
}

/* ---- Message Bubbles ---- */
.wlca-pub-msg {
	max-width: 80%;
	padding: 9px 13px;
	border-radius: 10px;
	font-size: 13px;
	line-height: 1.5;
	word-break: break-word;
	display: flex;
	flex-direction: column;
}

.wlca-pub-msg.admin {
	align-self: flex-start;
	background: #f5f5f5;
	color: #1a1a1a;
	border-bottom-left-radius: 3px;
}

.wlca-pub-msg.visitor {
	align-self: flex-end;
	background: var(--dark-green);
	color: var(--white);
	border-bottom-right-radius: 3px;
}

.wlca-pub-msg.system {
	align-self: center;
	background: #e9e9e9;
	font-style: italic;
	font-size: 11px;
	padding: 8px 12px;
	border-radius: 10px;
	max-width: 90%;
	text-align: center;
}

.wlca-pub-msg .wlca-pub-text {
	display: block;
	word-break: break-word;
	margin: 0;
	line-height: 1.5;
	white-space: pre-wrap;
}

.wlca-pub-msg .wlca-pub-time {
	font-size: 10px;
	opacity: .55;
	margin-top: 5px;
	align-self: flex-end;
	line-height: 1;
}

.wlca-pub-empty {
	color: #aaa;
	font-size: 13px;
	text-align: center;
	margin: auto;
	font-style: italic;
}

/* ---- Typing Indicator ---- */
.wlca-pub-typing {
	display: none;
	align-self: flex-start;
	background: #f5f5f5;
	border-radius: 10px;
	border-bottom-left-radius: 3px;
	padding: 7px 13px;
	font-size: 12px;
	font-style: italic;
	color: #888;
	line-height: 1.4;
}

.wlca-pub-typing.wlca-typing-visible {
	display: block;
}

/* ---- Auto-linked URLs in chat ---- */
.wlca-chat-link {
	color: inherit;
	text-decoration: underline;
	word-break: break-all;
}

/* ---- Quick Replies ---- */
#wlca-pub-quick-replies {
	display: flex;
	flex-wrap: nowrap;
	gap: 8px;
	padding: 10px 15px;
	background: var(--white);
	border-top: 1px solid var(--border-color);
	flex-shrink: 0;
	overflow-x: auto;
}

#wlca-pub-quick-replies.wlca-pub-qr-hidden {
	display: none;
}

.wlca-pub-qr {
	padding: 6px 12px;
	border-radius: 16px;
	border: 1px solid var(--dark-green);
	color: var(--dark-green);
	font-size: 12px;
	cursor: pointer;
	white-space: nowrap;
	line-height: 1.4;
	background: transparent;
}

.wlca-pub-qr:hover {
	background: var(--dark-green);
	color: var(--white);
}

/* ---- Input Row ---- */
.wlca-pub-input-wrap {
	display: flex;
	gap: 8px;
	padding: 15px;
	border-top: 1px solid var(--border-color);
	background: var(--white);
	flex-shrink: 0;
	border-radius: 0 0 12px 12px;
	align-items: flex-end;
}

#wlca-pub-input {
	resize: none;
	min-height: 38px;
	max-height: 120px;
	overflow-y: auto;
	line-height: 1.4;
	padding: 8px 12px;
}

#wlca-pub-input:focus {
	border-color: var(--dark-green);
	outline: none;
}

#wlca-pub-input,
#wlca-pub-input::placeholder {
	color: var(--black);
}

#wlca-pub-send {
	height: 38px;
}

/* ---- Mobile: full-width sheet from bottom ---- */
@media ( max-width: 480px ) {
	#wlca-pub-modal {
		bottom: 0;
		right: 0;
		left: 0;
		width: 100%;
		max-width: 100%;
	}

	.wlca-pub-box {
		max-height: calc(100vh - 30px);
	}

	.wlca-pub-header {
		border-radius: 16px 16px 0 0;
	}

	.wlca-pub-input-wrap {
		border-radius: 0;
	}

	#wlca-pub-launcher {
		bottom: 16px;
		right: 16px;
	}

	#wlca-pub-modal {
		right: 15px;
		bottom: 15px;
		width: 100%;
		margin: 0 15px;
		max-width: calc(100% - 30px);
	}
}
