/**
 * BearBox Chatbot - Public Styles
 * Responsive, bilingual chatbot widget for Serbian giftshop
 * Brand Colors: Primary #446084, Secondary #e63a47
 */

/* Widget Container */
#bearbox-chatbot-widget {
	position: fixed;
	z-index: 999999;
	font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

.bearbox-position-bottom-right {
	bottom: 20px;
	right: 20px;
}

.bearbox-position-bottom-left {
	bottom: 20px;
	left: 20px;
}

/* Chat Toggle Button */
.bearbox-chat-toggle {
	width: 60px;
	height: 60px;
	border-radius: 50%;
	background: linear-gradient(135deg, #446084 0%, #2f4460 100%);
	border: none;
	color: white;
	cursor: pointer;
	box-shadow: 0 4px 12px rgba(68, 96, 132, 0.4);
	transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
	display: flex;
	align-items: center;
	justify-content: center;
	position: relative;
}

.bearbox-chat-toggle:hover {
	transform: scale(1.1);
	box-shadow: 0 6px 16px rgba(68, 96, 132, 0.6);
}

.bearbox-chat-toggle:active {
	transform: scale(0.95);
}

/* Toggle button when chat is open - minimize style */
.bearbox-chat-toggle.bearbox-chat-open {
	background: linear-gradient(135deg, #e63a47 0%, #c42f3c 100%);
	box-shadow: 0 4px 12px rgba(230, 58, 71, 0.4);
}

.bearbox-chat-toggle.bearbox-chat-open:hover {
	box-shadow: 0 6px 16px rgba(230, 58, 71, 0.6);
}

.bearbox-chat-toggle.bearbox-chat-open svg {
	transform: rotate(45deg);
}

/* Pulse Notification Message */
.bearbox-pulse-message {
	position: absolute;
	bottom: 70px;
	right: 0;
	background: white;
	color: #333;
	padding: 10px 16px;
	border-radius: 18px;
	border-bottom-right-radius: 4px;
	font-size: 14px;
	font-weight: 500;
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
	white-space: nowrap;
	opacity: 0;
	transform: translateY(10px) scale(0.95);
	transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
	pointer-events: none;
	z-index: 999998;
}

.bearbox-pulse-message.visible {
	opacity: 1;
	transform: translateY(0) scale(1);
}

.bearbox-position-bottom-left .bearbox-pulse-message {
	right: auto;
	left: 0;
	border-bottom-right-radius: 18px;
	border-bottom-left-radius: 4px;
}

/* Chat Window */
.bearbox-chat-window {
	position: absolute;
	bottom: 80px;
	right: 0;
	width: 440px;
	max-width: calc(100vw - 40px);
	height: 680px;
	max-height: calc(100vh - 120px);
	max-height: calc(100dvh - 120px);
	background: white;
	border-radius: 16px;
	box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.bearbox-position-bottom-left .bearbox-chat-window {
	right: auto;
	left: 0;
}

@keyframes slideUp {
	from {
		opacity: 0;
		transform: translateY(20px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

/* Header */
.bearbox-chat-header {
	background: linear-gradient(135deg, #446084 0%, #2f4460 100%);
	color: white;
	padding: 18px 24px;
	display: flex;
	justify-content: space-between;
	align-items: center;
	flex-shrink: 0;
	position: relative;
	z-index: 60;
}

.bearbox-header-left {
	display: flex;
	flex-direction: column;
	gap: 2px;
	min-width: 0;
}

.bearbox-chat-title {
	margin: 0;
	font-size: 18px;
	font-weight: 600;
	color: white;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.bearbox-chat-status {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	font-size: 12px;
	line-height: 1;
	opacity: 0.92;
}

.bearbox-status-dot {
	width: 9px;
	height: 9px;
	border-radius: 999px;
	background: #22c55e;
	box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.22);
	flex: 0 0 auto;
}

.bearbox-status-text {
	white-space: nowrap;
}

.bearbox-header-actions {
	display: flex;
	gap: 8px;
	align-items: center;
}

.bearbox-lang-toggle {
	background: rgba(255, 255, 255, 0.2);
	border: 1px solid rgba(255, 255, 255, 0.3);
	color: white;
	padding: 4px 10px;
	border-radius: 6px;
	cursor: pointer;
	font-size: 13px;
	font-weight: 600;
	transition: all 0.2s;
}

.bearbox-lang-toggle:hover {
	background: rgba(255, 255, 255, 0.3);
}

.bearbox-btn-icon {
	background: transparent;
	border: none;
	color: white;
	cursor: pointer;
	padding: 4px;
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: 4px;
	transition: background 0.2s;
}

.bearbox-btn-icon:hover {
	background: rgba(255, 255, 255, 0.2);
}

/* Messages Container */
.bearbox-chat-messages {
	flex: 1;
	overflow-y: auto;
	padding: 24px;
	background: #F8F9FA;
}

.bearbox-message {
	margin-bottom: 16px;
	animation: messageIn 0.3s ease-out;
}

@keyframes messageIn {
	from {
		opacity: 0;
		transform: translateY(10px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

.bearbox-message-user {
	text-align: right;
}

.bearbox-message-bubble {
	display: inline-block;
	max-width: 80%;
	padding: 12px 16px;
	border-radius: 18px;
	word-wrap: break-word;
}

.bearbox-message-user .bearbox-message-bubble {
	background: linear-gradient(135deg, #446084 0%, #2f4460 100%);
	color: white;
	border-bottom-right-radius: 4px;
}

.bearbox-message-bot .bearbox-message-bubble {
	background: white;
	color: #333;
	border-bottom-left-radius: 4px;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.bearbox-message-bot .bearbox-message-bubble a {
	color: #e63a47;
	text-decoration: none;
	font-weight: 500;
}

.bearbox-message-bot .bearbox-message-bubble a:hover {
	text-decoration: underline;
}

/* Pre-chat contact capture overlay */
.bearbox-contact-overlay {
	position: absolute;
	inset: 0;
	background: rgba(0, 0, 0, 0.55);
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 20px;
	z-index: 50;
}

.bearbox-contact-card {
	width: 100%;
	max-width: 380px;
	background: #fff;
	border-radius: 16px;
	padding: 18px 18px 16px;
	box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}

.bearbox-contact-title {
	margin: 0 0 8px;
	font-size: 16px;
	font-weight: 700;
	color: #111;
}

.bearbox-contact-text {
	margin: 0 0 14px;
	font-size: 13px;
	line-height: 1.4;
	color: #555;
}

.bearbox-contact-fields {
	display: flex;
	flex-direction: column;
	gap: 10px;
	margin-bottom: 12px;
}

.bearbox-contact-input {
	width: 100%;
	padding: 10px 12px;
	border: 1px solid #e5e7eb;
	border-radius: 12px;
	font-size: 14px;
}

.bearbox-contact-input:focus {
	outline: none;
	border-color: #446084;
	box-shadow: 0 0 0 3px rgba(68, 96, 132, 0.15);
}

.bearbox-contact-error {
	margin-bottom: 12px;
	padding: 10px 12px;
	border-radius: 12px;
	border: 1px solid #ffd0d6;
	background: #fff3f5;
	color: #b00020;
	font-size: 13px;
}

.bearbox-contact-actions {
	display: flex;
	gap: 10px;
}

.bearbox-contact-skip,
.bearbox-contact-save {
	flex: 1;
	padding: 10px 12px;
	border-radius: 12px;
	cursor: pointer;
	font-weight: 600;
}

.bearbox-contact-skip {
	background: #f3f4f6;
	border: 1px solid #e5e7eb;
	color: #111;
}

.bearbox-contact-save {
	background: linear-gradient(135deg, #446084 0%, #2f4460 100%);
	border: none;
	color: #fff;
}

.bearbox-contact-skip:hover {
	filter: brightness(0.98);
}

.bearbox-contact-save:hover {
	filter: brightness(1.02);
}

/* Product Card */
.bearbox-product-card-link {
	text-decoration: none;
	display: block;
}

.bearbox-product-card {
	background: white;
	border-radius: 12px;
	padding: 12px;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
	border: 2px solid #446084;
	display: flex;
	gap: 12px;
	max-width: 100%;
	transition: all 0.2s ease;
	cursor: pointer;
}

.bearbox-product-card:hover {
	border-color: #e63a47;
	transform: translateY(-2px);
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.bearbox-product-image {
	width: 80px;
	height: 80px;
	object-fit: cover;
	border-radius: 8px;
	flex-shrink: 0;
}

.bearbox-product-info {
	flex: 1;
	min-width: 0;
}

.bearbox-product-title {
	font-size: 14px;
	font-weight: 600;
	color: #333;
	margin: 0 0 4px 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.bearbox-product-price {
	font-size: 16px;
	font-weight: 700;
	color: #446084;
	margin: 4px 0;
}

.bearbox-product-stock {
	font-size: 12px;
	color: #50C878;
	margin: 4px 0;
}

.bearbox-product-stock.out-of-stock {
	color: #E74C3C;
}

/* Thinking Indicator */
.bearbox-thinking {
	padding: 12px 20px;
	display: flex;
	align-items: center;
	gap: 10px;
	background: #F8F9FA;
}

.bearbox-typing-indicator {
	display: flex;
	gap: 4px;
}

.bearbox-typing-indicator span {
	width: 8px;
	height: 8px;
	background: #446084;
	border-radius: 50%;
	animation: typing 1.4s infinite;
}

.bearbox-typing-indicator span:nth-child(2) {
	animation-delay: 0.2s;
}

.bearbox-typing-indicator span:nth-child(3) {
	animation-delay: 0.4s;
}

@keyframes typing {
	0%, 60%, 100% {
		transform: translateY(0);
	}
	30% {
		transform: translateY(-10px);
	}
}

.bearbox-thinking-text {
	font-size: 14px;
	color: #666;
}

/* Input Area */
.bearbox-chat-input-area {
	padding: 16px 20px;
	padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
	background: white;
	border-top: 1px solid #E5E7EB;
	display: flex;
	gap: 12px;
	align-items: center;
	flex-shrink: 0;
}

.bearbox-chat-input {
	flex: 1;
	border: 2px solid #E5E7EB;
	border-radius: 12px;
	padding: 12px 16px;
	font-size: 15px;
	font-family: inherit;
	height: 48px;
	line-height: 1.2;
	transition: border-color 0.2s;
}

.bearbox-chat-input:focus {
	outline: none;
	border-color: #446084;
}

.bearbox-chat-send {
	background: linear-gradient(135deg, #446084 0%, #2f4460 100%);
	border: none;
	color: white;
	width: 48px;
	height: 48px;
	border-radius: 14px;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
	flex-shrink: 0;
	position: relative;
	overflow: hidden;
}

.bearbox-chat-send::before {
	content: '';
	position: absolute;
	top: 0;
	left: -100%;
	width: 100%;
	height: 100%;
	background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
	transition: left 0.5s;
}

.bearbox-chat-send:hover::before {
	left: 100%;
}

.bearbox-chat-send svg {
	width: 24px;
	height: 24px;
	fill: white;
	transition: transform 0.2s;
}

.bearbox-send-text {
	display: none;
	font-size: 14px;
	font-weight: 700;
	letter-spacing: 0.2px;
}

.bearbox-chat-send:hover {
	transform: translateY(-2px);
	box-shadow: 0 4px 16px rgba(68, 96, 132, 0.5), 0 0 20px rgba(68, 96, 132, 0.3);
	background: linear-gradient(135deg, #4d6d94 0%, #3a5070 100%);
}

.bearbox-chat-send:hover svg {
	transform: translateX(2px);
}

.bearbox-chat-send:active {
	transform: translateY(0) scale(0.95);
	box-shadow: 0 2px 8px rgba(68, 96, 132, 0.4);
}

.bearbox-chat-send:disabled {
	opacity: 0.4;
	cursor: not-allowed;
	transform: none;
	box-shadow: none;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
	/* Lock body scroll when chat is open */
	body.bearbox-chat-active {
		overflow: hidden !important;
		touch-action: none;
		-webkit-overflow-scrolling: none;
	}

	/* Chat opens from bottom, 80% height */
	#bearbox-chatbot-widget.bearbox-widget-open {
		position: fixed;
		top: auto;
		left: 0 !important;
		right: 0 !important;
		bottom: 0 !important;
		width: 100%;
		height: auto;
		margin: 0;
		z-index: 999999;
	}

	#bearbox-chatbot-widget.bearbox-widget-open .bearbox-chat-window {
		position: fixed;
		left: 0 !important;
		right: 0 !important;
		bottom: 0 !important;
		top: auto;
		width: 100vw;
		height: 80vh;
		height: 80dvh;
		max-width: none;
		max-width: 100vw;
		max-height: 80vh;
		max-height: 80dvh;
		margin: 0;
		box-sizing: border-box;
		border-radius: 20px 20px 0 0;
		box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.2);
		animation: slideUpMobile 0.3s cubic-bezier(0.4, 0, 0.2, 1);
	}

	@keyframes slideUpMobile {
		from {
			opacity: 0;
			transform: translateY(100%);
		}
		to {
			opacity: 1;
			transform: translateY(0);
		}
	}

	/* When keyboard is open - JS sets exact height */
	#bearbox-chatbot-widget.bearbox-keyboard-open .bearbox-chat-window {
		border-radius: 0;
		max-height: none;
	}

	/* Drag handle indicator */
	#bearbox-chatbot-widget.bearbox-widget-open .bearbox-chat-window::before {
		content: '';
		position: absolute;
		top: 8px;
		left: 50%;
		transform: translateX(-50%);
		width: 40px;
		height: 4px;
		border-radius: 2px;
		background: rgba(255, 255, 255, 0.4);
		z-index: 10;
	}

	#bearbox-chatbot-widget.bearbox-keyboard-open .bearbox-chat-window::before {
		display: none;
	}

	#bearbox-chatbot-widget.bearbox-widget-open .bearbox-chat-toggle {
		display: none;
	}

	#bearbox-chatbot-widget.bearbox-widget-open .bearbox-chat-header {
		padding: 14px 14px 10px;
	}

	#bearbox-chatbot-widget.bearbox-widget-open .bearbox-chat-title {
		font-size: 15px;
	}

	#bearbox-chatbot-widget.bearbox-widget-open .bearbox-chat-messages {
		padding: 12px;
		flex: 1;
		min-height: 0;
		overflow-y: auto;
		-webkit-overflow-scrolling: touch;
	}

	#bearbox-chatbot-widget.bearbox-widget-open .bearbox-chat-input-area {
		padding: 8px 10px;
		padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
		gap: 10px;
		flex-shrink: 0;
	}

	/* Remove safe area padding when keyboard is open */
	#bearbox-chatbot-widget.bearbox-keyboard-open .bearbox-chat-input-area {
		padding-bottom: 10px;
	}

	#bearbox-chatbot-widget.bearbox-widget-open .bearbox-chat-input {
		height: 40px;
		border-radius: 14px;
		font-size: 16px; /* prevent iOS zoom */
		padding: 9px 12px;
	}

	#bearbox-chatbot-widget.bearbox-widget-open .bearbox-chat-send {
		width: 40px;
		min-width: 40px;
		height: 40px;
		padding: 0;
		border-radius: 14px;
	}

	#bearbox-chatbot-widget.bearbox-widget-open .bearbox-chat-send svg {
		width: 18px;
		height: 18px;
	}
}

@media (max-width: 480px) {
	#bearbox-chatbot-widget:not(.bearbox-widget-open) .bearbox-chat-window {
		width: calc(100vw - 24px);
		height: 500px;
		max-height: calc(100vh - 140px);
		max-height: calc(100dvh - 140px);
		bottom: 75px;
		right: 12px;
		border-radius: 20px;
	}

	.bearbox-chat-toggle {
		width: 56px;
		height: 56px;
	}

	#bearbox-chatbot-widget.bearbox-position-bottom-right:not(.bearbox-widget-open),
	#bearbox-chatbot-widget.bearbox-position-bottom-left:not(.bearbox-widget-open) {
		bottom: 12px;
		right: 12px;
		left: auto;
	}

	#bearbox-chatbot-widget:not(.bearbox-widget-open).bearbox-position-bottom-left .bearbox-chat-window {
		right: 12px;
		left: auto;
	}

	.bearbox-chat-header {
		padding: 14px 18px;
		padding-top: calc(14px + env(safe-area-inset-top, 0px));
	}

	.bearbox-chat-messages {
		padding: 14px;
	}

	.bearbox-chat-input-area {
		padding: 10px 12px;
		padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
		gap: 10px;
	}

	.bearbox-chat-send {
		width: 44px;
		min-width: 44px;
		height: 44px;
		padding: 0;
		border-radius: 14px;
	}

	.bearbox-send-text {
		display: none;
	}

	.bearbox-chat-send svg {
		width: 20px;
		height: 20px;
	}

	.bearbox-chat-input {
		font-size: 16px; /* prevent iOS zoom */
		padding: 10px 12px;
		border-radius: 14px;
		max-height: 84px;
	}

	.bearbox-product-card {
		padding: 10px;
	}

	.bearbox-product-image {
		width: 70px;
		height: 70px;
	}
}

/* Scrollbar Styling */
.bearbox-chat-messages::-webkit-scrollbar {
	width: 6px;
}

.bearbox-chat-messages::-webkit-scrollbar-track {
	background: #F8F9FA;
}

.bearbox-chat-messages::-webkit-scrollbar-thumb {
	background: #CBD5E0;
	border-radius: 3px;
}

.bearbox-chat-messages::-webkit-scrollbar-thumb:hover {
	background: #A0AEC0;
}

/* Suggestion Buttons */
.bearbox-suggestions {
	display: flex;
	flex-direction: column;
	gap: 8px;
	margin-top: 8px;
}

.bearbox-suggestion-btn {
	background: #F7FAFC;
	border: 1px solid #E2E8F0;
	border-radius: 16px;
	padding: 8px 14px;
	color: #2D3748;
	font-size: 13px;
	text-align: left;
	cursor: pointer;
	transition: all 0.2s ease;
	font-family: inherit;
	line-height: 1.4;
	white-space: normal;
	word-wrap: break-word;
}

.bearbox-suggestion-btn:hover {
	background: #e63a47;
	border-color: #e63a47;
	color: white;
	transform: translateY(-1px);
}

.bearbox-suggestion-btn:active {
	transform: scale(0.98);
	background: #c42f3c;
}
