/**
 * HNG Commerce - Live Chat Frontend Styles
 *
 * @package HNG_Commerce
 * @since 1.3.0
 */

/* Variables */
:root {
	--hng-chat-primary: #0073aa;
	--hng-chat-btn-text-color: #ffffff;
	--hng-chat-header-color: var(--hng-chat-primary);
	--hng-chat-header-text-color: #ffffff;
	--hng-chat-text: #333;
	--hng-chat-text-light: #666;
	--hng-chat-message-text-color: #333333;
	--hng-chat-bg: #fff;
	--hng-chat-bg-light: #f7f7f7;
	--hng-chat-border: #e0e0e0;
	--hng-chat-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
	--hng-chat-radius: 12px;
}

/* Reset styles inside widget to avoid theme conflicts */
.hng-live-chat-widget,
.hng-live-chat-widget *,
.hng-live-chat-widget *::before,
.hng-live-chat-widget *::after {
	box-sizing: border-box;
}

.hng-live-chat-widget input,
.hng-live-chat-widget textarea,
.hng-live-chat-widget select {
	color: #333 !important;
	background-color: #fff !important;
	font-family: inherit;
	font-size: 14px;
	line-height: 1.5;
}

.hng-live-chat-widget button {
	color: inherit;
	background-color: inherit;
	font-family: inherit;
	font-size: 14px;
	line-height: 1.5;
}

.hng-live-chat-widget input::placeholder,
.hng-live-chat-widget textarea::placeholder {
	color: #999 !important;
	opacity: 1;
}

/* Widget container */
.hng-live-chat-widget {
	position: fixed;
	z-index: 999999;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
	font-size: 14px;
	line-height: 1.5;
	color: #333;
}

.hng-chat-bottom-right {
	right: 20px;
	bottom: 20px;
}

.hng-chat-bottom-left {
	left: 20px;
	bottom: 20px;
}

/* Chat bubble button */
.hng-chat-bubble {
	width: 60px !important;
	height: 60px !important;
	border-radius: 50% !important;
	background: var(--hng-chat-primary) !important;
	background-color: var(--hng-chat-primary) !important;
	border: none !important;
	cursor: pointer;
	display: flex !important;
	align-items: center;
	justify-content: center;
	box-shadow: var(--hng-chat-shadow) !important;
	transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
	position: relative;
	padding: 0 !important;
	margin: 0 !important;
	/* Reset browser default effects */
	outline: none !important;
	-webkit-tap-highlight-color: transparent !important;
	-webkit-appearance: none !important;
	-moz-appearance: none !important;
	appearance: none !important;
}

/* Reset focus/hover browser defaults */
.hng-chat-bubble:focus,
.hng-chat-bubble:focus-visible,
.hng-chat-bubble:active {
	outline: none !important;
	box-shadow: var(--hng-chat-shadow) !important;
}

/* Override global theme/Tailwind ::before ripple effect */
.hng-chat-bubble::before,
.hng-chat-bubble::after {
	content: none !important;
	display: none !important;
	width: 0 !important;
	height: 0 !important;
	background: none !important;
	transition: none !important;
}

/* Sem efeito hover padrão - use classes hng-hover-effect-* */
.hng-chat-bubble:hover {
	transform: none !important;
}

/* Otimizações de performance para mobile */
@media (prefers-reduced-motion: reduce) {
	.hng-chat-bubble,
	.hng-chat-window {
		animation: none !important;
		transition: opacity 0.2s ease !important;
	}
}

@media (max-width: 768px) {
	.hng-chat-bubble {
		/* Transições mais leves no mobile */
		transition: opacity 0.2s ease;
	}
}

/* Hover text support for chat */
.hng-chat-bubble .hng-chat-label {
	display: none;
	white-space: nowrap;
	font-weight: 600;
	font-size: 14px;
	color: var(--hng-chat-btn-text-color, #fff);
}

.hng-chat-bubble.hng-chat-hover-text-enabled:hover {
	width: auto !important;
	min-width: 100px;
	max-width: 160px;
	border-radius: 28px !important;
	justify-content: flex-start;
	padding-left: 14px !important;
	padding-right: 18px !important;
	gap: 10px;
}

.hng-chat-bubble.hng-chat-hover-text-enabled:hover .hng-chat-label {
	display: inline-block;
}

.hng-chat-bubble-icon {
	width: 28px;
	height: 28px;
	display: flex;
	align-items: center;
	justify-content: center;
}

.hng-chat-bubble-icon svg {
	width: 28px;
	height: 28px;
	fill: var(--hng-chat-btn-text-color, white);
}

/* Icon: Chat (default) */
.hng-chat-icon-chat .hng-chat-bubble-icon svg {
	fill: var(--hng-chat-btn-text-color, white);
}

/* Icon: Message */
.hng-chat-icon-message .hng-chat-bubble-icon svg {
	fill: var(--hng-chat-btn-text-color, white);
}

/* Icon: Support */
.hng-chat-icon-support .hng-chat-bubble-icon svg {
	fill: var(--hng-chat-btn-text-color, white);
}

/* Icon: Headset */
.hng-chat-icon-headset .hng-chat-bubble-icon svg {
	fill: var(--hng-chat-btn-text-color, white);
}

/* Icon: WhatsApp */
.hng-chat-icon-whatsapp .hng-chat-bubble-icon svg {
	fill: var(--hng-chat-btn-text-color, white);
}

.hng-chat-badge {
	position: absolute;
	top: -5px;
	right: -5px;
	background: #e53935;
	color: white;
	font-size: 12px;
	font-weight: bold;
	min-width: 20px;
	height: 20px;
	border-radius: 10px;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0 5px;
}

/* Chat window */
.hng-chat-window {
	position: absolute;
	bottom: 80px;
	width: 380px;
	max-width: calc(100vw - 40px);
	height: 520px;
	max-height: calc(100vh - 120px);
	background: var(--hng-chat-bg);
	border-radius: var(--hng-chat-radius);
	box-shadow: var(--hng-chat-shadow);
	display: flex;
	flex-direction: column;
	overflow: hidden;
}

.hng-chat-bottom-right .hng-chat-window {
	right: 0;
}

.hng-chat-bottom-left .hng-chat-window {
	left: 0;
}

/* Header */
.hng-chat-header {
	background: var(--hng-chat-header-color, var(--hng-chat-primary));
	color: var(--hng-chat-header-text-color, white);
	padding: 16px;
	display: flex;
	align-items: center;
	justify-content: space-between;
}

.hng-chat-header-info {
	display: flex;
	flex-direction: column;
}

.hng-chat-title {
	font-weight: 600;
	font-size: 16px;
}

.hng-chat-status {
	font-size: 12px;
	opacity: 0.9;
}

.hng-chat-header-actions {
	display: flex;
	gap: 8px;
}

.hng-chat-header-actions button {
	background: transparent;
	border: none;
	color: var(--hng-chat-header-text-color, white);
	font-size: 20px;
	cursor: pointer;
	width: 30px;
	height: 30px;
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: 50%;
	transition: background 0.2s;
}

.hng-chat-header-actions button:hover {
	background: rgba(255, 255, 255, 0.2);
}

/* Sound toggle button */
.hng-chat-sound-toggle {
	opacity: 0.6;
}

.hng-chat-sound-toggle.sound-active {
	opacity: 1;
	color: #2AFFA3 !important;
}

.hng-chat-sound-toggle svg {
	width: 16px;
	height: 16px;
}

.hng-chat-sound-toggle:not(.sound-active) .sound-on {
	display: none;
}

/* Body */
.hng-chat-body {
	flex: 1;
	overflow-y: auto;
	padding: 16px;
	background: var(--hng-chat-bg-light);
}

/* Pre-chat form */
.hng-chat-prechat {
	display: flex;
	flex-direction: column;
	height: 100%;
}

.hng-chat-welcome {
	text-align: center;
	margin-bottom: 20px;
	color: var(--hng-chat-text);
}

.hng-chat-prechat-form {
	display: flex;
	flex-direction: column;
	gap: 12px;
}

.hng-chat-field input,
.hng-chat-field textarea {
	width: 100%;
	padding: 12px;
	border: 1px solid var(--hng-chat-border);
	border-radius: 8px;
	font-size: 14px;
	font-family: inherit;
	transition: border-color 0.2s;
	box-sizing: border-box;
	color: #333 !important;
	background-color: #fff !important;
}

.hng-chat-field input:focus,
.hng-chat-field textarea:focus {
	outline: none;
	border-color: var(--hng-chat-primary);
}

.hng-chat-field textarea {
	resize: none;
}

.hng-chat-start-btn {
	background: var(--hng-chat-start-btn-color, var(--hng-chat-primary)) !important;
	color: white !important;
	border: none !important;
	padding: 14px;
	border-radius: 8px;
	font-size: 15px;
	font-weight: 600;
	cursor: pointer;
	transition: background 0.2s, filter 0.2s;
}

.hng-chat-start-btn:hover {
	filter: brightness(1.1);
}

.hng-chat-start-btn:disabled {
	opacity: 0.7;
	cursor: not-allowed;
}

/* Messages area */
.hng-chat-messages {
	display: flex;
	flex-direction: column;
	gap: 12px;
	padding-bottom: 8px;
}

.hng-chat-message {
	max-width: 85%;
	padding: 10px 14px;
	border-radius: 16px;
	word-wrap: break-word;
}

.hng-chat-message.customer {
	background: var(--hng-chat-primary);
	color: white;
	margin-left: auto;
	border-bottom-right-radius: 4px;
}

.hng-chat-message.operator {
	background: var(--hng-chat-bg, white);
	color: var(--hng-chat-message-text-color, var(--hng-chat-text));
	margin-right: auto;
	border-bottom-left-radius: 4px;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.hng-chat-message.system {
	background: transparent;
	color: var(--hng-chat-text-light);
	font-size: 12px;
	text-align: center;
	max-width: 100%;
	padding: 8px;
	margin: 8px 0;
}

.hng-chat-message-header {
	display: flex;
	align-items: center;
	gap: 8px;
	margin-bottom: 4px;
}

.hng-chat-sender-name {
	font-weight: 600;
	font-size: 12px;
}

.hng-chat-message.customer .hng-chat-sender-name {
	display: none;
}

.hng-chat-message-time {
	font-size: 11px;
	opacity: 0.7;
}

.hng-chat-message-content {
	line-height: 1.4;
}

/* File/Image messages */
.hng-chat-attachment {
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.hng-chat-attachment img {
	max-width: 100%;
	border-radius: 8px;
	cursor: pointer;
}

.hng-chat-file-preview {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 8px;
	background: rgba(0, 0, 0, 0.05);
	border-radius: 8px;
	text-decoration: none;
	color: inherit;
}

.hng-chat-message.customer .hng-chat-file-preview {
	background: rgba(255, 255, 255, 0.2);
	color: white;
}

.hng-chat-file-icon {
	width: 32px;
	height: 32px;
	display: flex;
	align-items: center;
	justify-content: center;
	background: rgba(0, 0, 0, 0.1);
	border-radius: 4px;
}

.hng-chat-file-info {
	flex: 1;
	overflow: hidden;
}

.hng-chat-file-name {
	font-weight: 500;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.hng-chat-file-size {
	font-size: 11px;
	opacity: 0.7;
}

/* Typing indicator */
.hng-chat-typing {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 8px 16px;
	color: var(--hng-chat-text-light);
	font-size: 13px;
}

.hng-typing-dots {
	display: flex;
	gap: 3px;
}

.hng-typing-dots span {
	width: 6px;
	height: 6px;
	background: var(--hng-chat-text-light);
	border-radius: 50%;
	animation: hng-typing 1.4s infinite;
}

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

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

@keyframes hng-typing {
	0%, 60%, 100% {
		transform: translateY(0);
	}
	30% {
		transform: translateY(-4px);
	}
}

/* Footer */
.hng-chat-footer {
	padding: 12px;
	background: var(--hng-chat-bg);
	border-top: 1px solid var(--hng-chat-border);
}

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

.hng-chat-attach,
.hng-chat-send {
	width: 40px;
	height: 40px;
	border: none;
	background: transparent;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: 50%;
	transition: background 0.2s;
	flex-shrink: 0;
}

.hng-chat-attach:hover {
	background: var(--hng-chat-bg-light);
}

.hng-chat-attach svg,
.hng-chat-send svg {
	color: var(--hng-chat-text-light);
}

.hng-chat-send {
	background: var(--hng-chat-primary);
}

.hng-chat-send svg {
	color: white;
}

.hng-chat-send:hover {
	filter: brightness(1.1);
}

.hng-chat-input {
	flex: 1;
	border: 1px solid var(--hng-chat-border);
	border-radius: 20px;
	padding: 10px 16px;
	font-size: 14px;
	font-family: inherit;
	resize: none;
	max-height: 100px;
	line-height: 1.4;
	color: #333 !important;
	background-color: #fff !important;
	overflow-y: auto;
	overflow-x: hidden;
	min-height: 40px;
	height: auto;
}

.hng-chat-input:focus {
	outline: none;
	border-color: var(--hng-chat-primary);
}

/* ===== End Chat / Restart Containers ===== */
.hng-chat-end-container {
	margin-top: 8px;
	text-align: center;
	padding: 4px 0 2px;
}

.hng-chat-end-btn {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	background: transparent;
	border: 1px solid var(--hng-chat-border, #e0e0e0);
	color: var(--hng-chat-text-light, #666);
	font-size: 12px;
	font-family: var(--hng-chat-font-family, inherit);
	padding: 6px 16px;
	border-radius: calc(var(--hng-chat-radius, 12px) / 2);
	cursor: pointer;
	transition: all 0.25s ease;
	text-decoration: none;
	letter-spacing: 0.02em;
}

.hng-chat-end-btn:hover {
	color: #ef4444;
	border-color: #ef4444;
	background: rgba(239, 68, 68, 0.08);
}

.hng-chat-end-btn svg {
	width: 14px;
	height: 14px;
	flex-shrink: 0;
}

.hng-chat-end-btn.hng-confirm-active {
	color: #ef4444 !important;
	border-color: #ef4444 !important;
	background: rgba(239, 68, 68, 0.08) !important;
	font-weight: 600;
	animation: hng-confirm-pulse 1s ease infinite;
}

@keyframes hng-confirm-pulse {
	0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.3); }
	50%      { box-shadow: 0 0 0 4px rgba(239, 68, 68, 0); }
}

/* Restart button */
.hng-chat-restart-container {
	margin-top: 8px;
	text-align: center;
	padding: 4px 0 2px;
}

.hng-chat-restart-btn {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	background: var(--hng-chat-primary, #0073aa);
	color: var(--hng-chat-btn-text-color, #ffffff);
	border: none;
	font-size: 13px;
	font-weight: 600;
	font-family: var(--hng-chat-font-family, inherit);
	padding: 8px 20px;
	border-radius: calc(var(--hng-chat-radius, 12px) / 2);
	cursor: pointer;
	transition: all 0.25s ease;
	letter-spacing: 0.02em;
}

.hng-chat-restart-btn:hover {
	opacity: 0.88;
	transform: translateY(-1px);
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* ===== Rating Overlay ===== */
.hng-chat-rating {
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background: var(--hng-chat-bg, #fff);
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	padding: 28px 24px;
	text-align: center;
	z-index: 10;
	animation: hng-rating-fade-in 0.35s ease;
}

@keyframes hng-rating-fade-in {
	from { opacity: 0; transform: scale(0.95); }
	to   { opacity: 1; transform: scale(1); }
}

.hng-chat-rating h4 {
	margin: 0 0 8px;
	font-size: 18px;
	font-weight: 700;
	color: var(--hng-chat-text, #333);
	letter-spacing: -0.01em;
}

.hng-chat-rating-subtitle {
	margin: 0 0 18px;
	font-size: 13px;
	color: var(--hng-chat-text-light, #666);
	line-height: 1.4;
}

/* Stars */
.hng-chat-stars {
	display: flex;
	gap: 6px;
	margin-bottom: 20px;
}

.hng-chat-stars button {
	background: transparent;
	border: 2px solid transparent;
	font-size: 30px;
	color: var(--hng-chat-border, #ddd);
	cursor: pointer;
	transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
	padding: 4px 6px;
	border-radius: 8px;
	line-height: 1;
}

.hng-chat-stars button:hover {
	color: #fbbf24;
	transform: scale(1.18);
	background: rgba(251, 191, 36, 0.1);
}

.hng-chat-stars button.active {
	color: #f59e0b;
	transform: scale(1.12);
	border-color: rgba(245, 158, 11, 0.3);
	background: rgba(245, 158, 11, 0.08);
}

/* Comment textarea */
.hng-chat-rating-comment {
	width: 100%;
	padding: 12px 14px;
	border: 1px solid var(--hng-chat-border, #e0e0e0);
	border-radius: calc(var(--hng-chat-radius, 12px) / 2);
	font-size: 13px;
	font-family: var(--hng-chat-font-family, inherit);
	color: var(--hng-chat-text, #333);
	background: var(--hng-chat-bg-light, #f7f7f7);
	resize: none;
	margin-bottom: 16px;
	min-height: 72px;
	transition: border-color 0.2s ease;
}

.hng-chat-rating-comment:focus {
	outline: none;
	border-color: var(--hng-chat-primary, #0073aa);
	box-shadow: 0 0 0 3px rgba(41, 132, 241, 0.12);
}

.hng-chat-rating-comment::placeholder {
	color: var(--hng-chat-text-light, #666);
	opacity: 0.7;
}

/* Submit button - prominent */
.hng-chat-rating-submit {
	width: 100%;
	background: var(--hng-chat-primary, #0073aa);
	color: var(--hng-chat-btn-text-color, #ffffff);
	border: none;
	padding: 12px 28px;
	border-radius: calc(var(--hng-chat-radius, 12px) / 2);
	font-size: 14px;
	font-weight: 600;
	font-family: var(--hng-chat-font-family, inherit);
	cursor: pointer;
	margin-bottom: 10px;
	transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
	letter-spacing: 0.02em;
	position: relative;
	overflow: hidden;
}

.hng-chat-rating-submit:hover {
	opacity: 0.92;
	transform: translateY(-1px);
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
}

.hng-chat-rating-submit:active {
	transform: translateY(0);
}

.hng-chat-rating-submit:disabled {
	opacity: 0.5;
	cursor: not-allowed;
	transform: none;
	box-shadow: none;
}

/* Skip button - ghost style */
.hng-chat-rating-skip {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	background: transparent;
	border: 1px solid var(--hng-chat-border, #e0e0e0);
	color: var(--hng-chat-text-light, #666);
	font-size: 13px;
	font-family: var(--hng-chat-font-family, inherit);
	padding: 8px 24px;
	border-radius: calc(var(--hng-chat-radius, 12px) / 2);
	cursor: pointer;
	transition: all 0.2s ease;
	text-decoration: none;
}

.hng-chat-rating-skip:hover {
	background: var(--hng-chat-bg-light, #f7f7f7);
	border-color: var(--hng-chat-text-light, #999);
	color: var(--hng-chat-text, #333);
}

/* Rating thanks animation */
.hng-chat-rating-thanks {
	text-align: center;
	padding: 32px 20px;
	animation: hng-rating-fade-in 0.4s ease;
}

.hng-chat-rating-thanks .hng-thanks-icon {
	font-size: 48px;
	margin-bottom: 12px;
	display: block;
	animation: hng-thanks-bounce 0.6s ease;
}

@keyframes hng-thanks-bounce {
	0%   { transform: scale(0); opacity: 0; }
	50%  { transform: scale(1.2); }
	100% { transform: scale(1); opacity: 1; }
}

.hng-chat-rating-thanks .hng-thanks-text {
	font-size: 16px;
	font-weight: 600;
	color: var(--hng-chat-text, #333);
	margin-bottom: 4px;
}

.hng-chat-rating-thanks .hng-thanks-sub {
	font-size: 13px;
	color: var(--hng-chat-text-light, #666);
}

/* Upload progress */
.hng-chat-upload-progress {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 8px 12px;
	background: var(--hng-chat-bg-light);
	border-radius: 8px;
	margin-bottom: 8px;
}

.hng-chat-upload-progress-bar {
	flex: 1;
	height: 4px;
	background: var(--hng-chat-border);
	border-radius: 2px;
	overflow: hidden;
}

.hng-chat-upload-progress-bar span {
	display: block;
	height: 100%;
	background: var(--hng-chat-primary);
	width: 0;
	transition: width 0.3s;
}

/* Animations */
.hng-chat-window {
	animation: hng-chat-slide-up 0.3s ease;
}

@keyframes hng-chat-slide-up {
	from {
		opacity: 0;
		transform: translateY(20px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

.hng-chat-message {
	animation: hng-chat-fade-in 0.3s ease;
}

@keyframes hng-chat-fade-in {
	from {
		opacity: 0;
		transform: translateY(10px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

/* Responsive */
@media (max-width: 480px) {
	/* Respeitar posição configurada em mobile */
	.hng-live-chat-widget.hng-chat-bottom-right {
		right: 10px;
		left: auto;
		bottom: 10px;
	}

	.hng-live-chat-widget.hng-chat-bottom-left {
		left: 10px;
		right: auto;
		bottom: 10px;
	}

	.hng-chat-window {
		width: calc(100vw - 20px);
		max-width: 380px;
		height: calc(100vh - 80px);
		max-height: calc(100vh - 80px);
		border-radius: var(--hng-chat-radius) var(--hng-chat-radius) 0 0;
		bottom: 70px;
	}

	/* Posicionar janela corretamente com base na posição do botão */
	.hng-chat-bottom-right .hng-chat-window {
		right: 0;
		left: auto;
	}

	.hng-chat-bottom-left .hng-chat-window {
		left: 0;
		right: auto;
	}

	.hng-chat-bubble {
		width: 56px !important;
		height: 56px !important;
	}
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
	.hng-live-chat-widget {
		--hng-chat-text: #e0e0e0;
		--hng-chat-text-light: #999;
		--hng-chat-bg: #1e1e1e;
		--hng-chat-bg-light: #2d2d2d;
		--hng-chat-border: #444;
	}

	.hng-chat-message.operator {
		background: #333;
	}

	.hng-chat-rating {
		background: var(--hng-chat-bg, rgba(30, 30, 30, 0.98));
	}

	.hng-chat-rating-comment {
		background: var(--hng-chat-bg-light, #2d2d2d);
	}
}

/* Minimized state */
.hng-live-chat-widget.minimized .hng-chat-window {
	height: auto;
}

.hng-live-chat-widget.minimized .hng-chat-body,
.hng-live-chat-widget.minimized .hng-chat-footer {
	display: none !important;
}

/* Print hide */
@media print {
	.hng-live-chat-widget {
		display: none !important;
	}
}
