/**
 * Webshop Chat Widget Styles
 */

/* ===== Variables ===== */
:root {
	--webshop-chat-primary: #4f46e5;
	--webshop-chat-primary-hover: #4338ca;
	--webshop-chat-bg: #ffffff;
	--webshop-chat-text: #1f2937;
	--webshop-chat-text-light: #6b7280;
	--webshop-chat-border: #e5e7eb;
	--webshop-chat-user-bg: #4f46e5;
	--webshop-chat-user-text: #ffffff;
	--webshop-chat-assistant-bg: #f3f4f6;
	--webshop-chat-assistant-text: #1f2937;
	--webshop-chat-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
	--webshop-chat-radius: 16px;
	--webshop-chat-bubble-size: 60px;
}

/* Dark theme */
.webshop-chat-widget.theme-dark {
	--webshop-chat-bg: #1f2937;
	--webshop-chat-text: #f9fafb;
	--webshop-chat-text-light: #9ca3af;
	--webshop-chat-border: #374151;
	--webshop-chat-assistant-bg: #374151;
	--webshop-chat-assistant-text: #f9fafb;
}

/* ===== Widget Container ===== */
.webshop-chat-widget {
	position: fixed;
	z-index: 99999;
	font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
	font-size: 14px;
	line-height: 1.5;
}

.webshop-chat-widget.position-bottom-right {
	bottom: 20px;
	right: 20px;
}

.webshop-chat-widget.position-bottom-left {
	bottom: 20px;
	left: 20px;
}

/* ===== Chat Bubble ===== */
.webshop-chat-bubble {
	width: var(--webshop-chat-bubble-size);
	height: var(--webshop-chat-bubble-size);
	border-radius: 50%;
	background: var(--webshop-chat-primary);
	border: none;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	box-shadow: var(--webshop-chat-shadow);
	transition: transform 0.2s ease, background-color 0.2s ease;
}

.webshop-chat-bubble:hover {
	transform: scale(1.05);
	background: var(--webshop-chat-primary-hover);
}

.webshop-chat-bubble:active {
	transform: scale(0.95);
}

.webshop-chat-bubble svg {
	width: 28px;
	height: 28px;
	color: white;
}

.webshop-chat-bubble .hidden {
	display: none;
}

/* ===== Chat Window ===== */
.webshop-chat-window {
	position: absolute;
	bottom: calc(var(--webshop-chat-bubble-size) + 15px);
	width: 380px;
	max-width: calc(100vw - 40px);
	height: 520px;
	max-height: calc(100vh - 120px);
	background: var(--webshop-chat-bg);
	border-radius: var(--webshop-chat-radius);
	box-shadow: var(--webshop-chat-shadow);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	transition: opacity 0.2s ease, transform 0.2s ease;
}

.position-bottom-right .webshop-chat-window {
	right: 0;
}

.position-bottom-left .webshop-chat-window {
	left: 0;
}

.webshop-chat-window.hidden {
	opacity: 0;
	transform: translateY(20px);
	pointer-events: none;
}

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

.chat-header-info {
	display: flex;
	align-items: center;
	gap: 12px;
}

.chat-avatar {
	width: 40px;
	height: 40px;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.2);
	display: flex;
	align-items: center;
	justify-content: center;
}

.chat-avatar svg {
	width: 24px;
	height: 24px;
}

.chat-title-container {
	display: flex;
	flex-direction: column;
}

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

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

.chat-close {
	width: 32px;
	height: 32px;
	border-radius: 50%;
	border: none;
	background: rgba(255, 255, 255, 0.2);
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background-color 0.2s ease;
}

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

.chat-close svg {
	width: 18px;
	height: 18px;
	color: white;
}

/* ===== Chat Messages ===== */
.chat-messages {
	flex: 1;
	overflow-y: auto;
	padding: 16px;
	display: flex;
	flex-direction: column;
	gap: 12px;
}

.chat-message {
	max-width: 85%;
	animation: messageSlide 0.2s ease;
}

@keyframes messageSlide {
	from {
		opacity: 0;
		transform: translateY(10px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

.chat-message.user {
	align-self: flex-end;
}

.chat-message.assistant,
.chat-message.system {
	align-self: flex-start;
}

.message-content {
	padding: 12px 16px;
	border-radius: 18px;
	word-wrap: break-word;
}

.chat-message.user .message-content {
	background: var(--webshop-chat-user-bg);
	color: var(--webshop-chat-user-text);
	border-bottom-right-radius: 4px;
}

.chat-message.assistant .message-content {
	background: var(--webshop-chat-assistant-bg);
	color: var(--webshop-chat-assistant-text);
	border-bottom-left-radius: 4px;
}

.chat-message.system .message-content {
	background: #fef3c7;
	color: #92400e;
	font-size: 13px;
	text-align: center;
	border-radius: 8px;
}

.message-time {
	font-size: 11px;
	color: var(--webshop-chat-text-light);
	margin-top: 4px;
	padding: 0 4px;
}

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

/* ===== Typing Indicator ===== */
.typing-indicator {
	display: flex;
	gap: 4px;
	padding: 4px 0;
}

.typing-indicator span {
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: var(--webshop-chat-text-light);
	animation: typing 1.4s infinite ease-in-out both;
}

.typing-indicator span:nth-child(1) {
	animation-delay: -0.32s;
}

.typing-indicator span:nth-child(2) {
	animation-delay: -0.16s;
}

@keyframes typing {
	0%, 80%, 100% {
		transform: scale(0.6);
		opacity: 0.5;
	}
	40% {
		transform: scale(1);
		opacity: 1;
	}
}

/* ===== Suggestions ===== */
.chat-suggestions {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	padding: 8px 16px;
	border-top: 1px solid var(--webshop-chat-border);
}

.chat-suggestions.hidden {
	display: none;
}

.suggestion-chip {
	padding: 8px 14px;
	border-radius: 20px;
	border: 1px solid var(--webshop-chat-border);
	background: var(--webshop-chat-bg);
	color: var(--webshop-chat-text);
	font-size: 13px;
	cursor: pointer;
	transition: all 0.2s ease;
}

.suggestion-chip:hover {
	background: var(--webshop-chat-primary);
	color: white;
	border-color: var(--webshop-chat-primary);
}

/* ===== Input Container ===== */
.chat-input-container {
	display: flex;
	gap: 8px;
	padding: 12px 16px;
	border-top: 1px solid var(--webshop-chat-border);
	background: var(--webshop-chat-bg);
}

.chat-input {
	flex: 1;
	padding: 12px 16px;
	border-radius: 24px;
	border: 1px solid var(--webshop-chat-border);
	background: var(--webshop-chat-bg);
	color: var(--webshop-chat-text);
	font-size: 14px;
	outline: none;
	transition: border-color 0.2s ease;
}

.chat-input:focus {
	border-color: var(--webshop-chat-primary);
}

.chat-input::placeholder {
	color: var(--webshop-chat-text-light);
}

.chat-send {
	width: 44px;
	height: 44px;
	border-radius: 50%;
	border: none;
	background: var(--webshop-chat-primary);
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background-color 0.2s ease, transform 0.1s ease;
}

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

.chat-send:active {
	transform: scale(0.95);
}

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

.chat-send svg {
	width: 20px;
	height: 20px;
	color: white;
}

/* ===== Login Prompt ===== */
.chat-login-prompt {
	text-align: center;
	padding: 16px;
	background: #f0f9ff;
	border-radius: 12px;
	margin-top: 8px;
}

.chat-login-prompt p {
	margin: 0 0 12px 0;
	color: #0369a1;
	font-size: 13px;
}

.chat-login-prompt .btn {
	display: inline-block;
	padding: 8px 20px;
	background: var(--webshop-chat-primary);
	color: white;
	text-decoration: none;
	border-radius: 20px;
	font-size: 13px;
	font-weight: 500;
}

.chat-login-prompt .btn:hover {
	background: var(--webshop-chat-primary-hover);
}

/* ===== Message Content Formatting ===== */
.message-content ul {
	margin: 8px 0;
	padding-left: 20px;
}

.message-content li {
	margin: 4px 0;
}

.message-content strong {
	font-weight: 600;
}

.message-content em {
	font-style: italic;
}

/* ===== Tables ===== */
.message-content .chat-table {
	width: 100%;
	border-collapse: collapse;
	margin: 8px 0;
	font-size: 12px;
	background: var(--webshop-chat-bg);
	border-radius: 8px;
	overflow: hidden;
	border: 1px solid var(--webshop-chat-border);
}

.message-content .chat-table th,
.message-content .chat-table td {
	padding: 8px 10px;
	text-align: left;
	border-bottom: 1px solid var(--webshop-chat-border);
}

.message-content .chat-table th {
	background: var(--webshop-chat-primary);
	color: white;
	font-weight: 600;
	font-size: 11px;
	text-transform: uppercase;
	letter-spacing: 0.3px;
}

.message-content .chat-table tbody tr:hover {
	background: rgba(79, 70, 229, 0.05);
}

.message-content .chat-table tbody tr:last-child td {
	border-bottom: none;
}

/* ===== Code Blocks ===== */
.message-content code {
	background: rgba(0, 0, 0, 0.05);
	padding: 2px 6px;
	border-radius: 4px;
	font-family: 'Monaco', 'Menlo', monospace;
	font-size: 12px;
}

.message-content pre {
	background: rgba(0, 0, 0, 0.05);
	padding: 12px;
	border-radius: 8px;
	overflow-x: auto;
	margin: 8px 0;
}

.message-content pre code {
	background: none;
	padding: 0;
}

/* ===== Headers ===== */
.message-content h3,
.message-content h4 {
	margin: 12px 0 8px 0;
	font-weight: 600;
}

.message-content h3 {
	font-size: 15px;
}

.message-content h4 {
	font-size: 14px;
}

/* ===== Scrollbar ===== */
.chat-messages::-webkit-scrollbar {
	width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
	background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
	background: var(--webshop-chat-border);
	border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
	background: var(--webshop-chat-text-light);
}

/* ===== Mobile Responsive ===== */
@media (max-width: 480px) {
	.webshop-chat-widget {
		bottom: 10px;
		right: 10px;
	}

	.webshop-chat-widget.position-bottom-left {
		left: 10px;
	}

	.webshop-chat-window {
		width: calc(100vw - 20px);
		height: calc(100vh - 90px);
		max-height: none;
		bottom: calc(var(--webshop-chat-bubble-size) + 10px);
	}

	.position-bottom-right .webshop-chat-window,
	.position-bottom-left .webshop-chat-window {
		left: 0;
		right: 0;
	}

	.webshop-chat-bubble {
		width: 54px;
		height: 54px;
	}

	.webshop-chat-bubble svg {
		width: 24px;
		height: 24px;
	}
}

/* ===== Print ===== */
@media print {
	.webshop-chat-widget {
		display: none !important;
	}
}
