/**
 * Premium Chat Styles for Peterwolf AI Content Assistant
 */

.pw-chat-widget {
	--pw-primary: #050308;
	--pw-primary-gradient: linear-gradient(135deg, rgba(7, 4, 12, 0.98) 0%, rgba(25, 10, 35, 0.96) 52%, rgba(54, 14, 74, 0.94) 100%);
	--pw-accent: #d16bff;
	--pw-accent-hover: #e1a0ff;
	--pw-bg-light: linear-gradient(180deg, rgba(8, 5, 13, 0.98) 0%, rgba(18, 9, 25, 0.98) 58%, rgba(32, 12, 46, 0.98) 100%);
	--pw-text-dark: #f7f2ff;
	--pw-text-light: #ffffff;
	--pw-bubble-user: linear-gradient(135deg, #d16bff 0%, #8f18d5 100%);
	--pw-bubble-agent: rgba(255, 255, 255, 0.08);
	--pw-shadow: 0 28px 60px rgba(0, 0, 0, 0.46), 0 0 48px rgba(209, 107, 255, 0.2);
	--pw-border: rgba(209, 107, 255, 0.38);

	display: flex;
	flex-direction: column;
	width: 100%;
	max-width: 480px;
	height: 600px;
	background: radial-gradient(circle at 82% 0%, rgba(209, 107, 255, 0.22), transparent 38%), var(--pw-bg-light);
	border: 1px solid var(--pw-border);
	border-radius: 14px;
	box-shadow: var(--pw-shadow);
	overflow: hidden;
	font-family: "Montserrat", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
	margin: 20px auto;
	box-sizing: border-box;
	color: var(--pw-text-light);
	backdrop-filter: blur(16px);
}

.pw-chat-widget * {
	box-sizing: border-box;
}

/* Header */
.pw-chat-header {
	background: var(--pw-primary-gradient);
	padding: 15px 18px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	color: var(--pw-text-light);
	border-bottom: 1px solid rgba(209, 107, 255, 0.25);
}

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

.pw-chat-avatar {
	position: relative;
	width: 42px;
	height: 42px;
	background: linear-gradient(135deg, rgba(209, 107, 255, 0.32), rgba(255, 255, 255, 0.08));
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	border: 1px solid rgba(209, 107, 255, 0.55);
	box-shadow: 0 0 22px rgba(209, 107, 255, 0.25);
}

.pw-avatar-icon {
	font-size: 22px;
	line-height: 1;
}

.pw-avatar-status {
	position: absolute;
	bottom: 0;
	right: 0;
	width: 11px;
	height: 11px;
	background: #6bffb4;
	border: 2px solid #100718;
	border-radius: 50%;
	animation: pulseStatus 2s infinite;
}

.pw-chat-title {
	margin: 0;
	font-size: 16px;
	font-weight: 700;
	letter-spacing: 0;
	color: #fff;
}

.pw-chat-subtitle {
	margin: 2px 0 0 0;
	font-size: 12px;
	color: rgba(255, 255, 255, 0.72);
	font-weight: 500;
}

.pw-chat-reset-btn {
	background: none;
	border: none;
	color: rgba(255, 255, 255, 0.74);
	cursor: pointer;
	padding: 6px;
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: all 0.2s ease;
}

.pw-chat-reset-btn:hover {
	color: var(--pw-text-light);
	background: rgba(209, 107, 255, 0.16);
}

.pw-chat-reset-btn svg {
	width: 18px;
	height: 18px;
}

/* Messages Area */
.pw-chat-messages {
	flex: 1;
	padding: 24px 20px;
	overflow-y: auto;
	background: var(--pw-bg-light);
	display: flex;
	flex-direction: column;
	gap: 16px;
	scroll-behavior: smooth;
}

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

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

.pw-chat-messages::-webkit-scrollbar-thumb {
	background: rgba(209, 107, 255, 0.42);
	border-radius: 3px;
}

.pw-chat-messages::-webkit-scrollbar-thumb:hover {
	background: rgba(209, 107, 255, 0.62);
}

/* Chat Bubbles */
.pw-msg-row {
	display: flex;
	width: 100%;
	animation: popBubble 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.pw-msg-row.pw-msg-user {
	justify-content: flex-end;
}

.pw-msg-row.pw-msg-agent {
	justify-content: flex-start;
}

.pw-chat-bubble {
	max-width: 80%;
	padding: 13px 16px;
	border-radius: 16px;
	font-size: 14px;
	line-height: 1.5;
	word-wrap: break-word;
	box-shadow: 0 12px 26px rgba(0, 0, 0, 0.2);
}

.pw-msg-user .pw-chat-bubble {
	background: var(--pw-bubble-user);
	color: var(--pw-text-light);
	border: 1px solid rgba(255, 255, 255, 0.22);
	border-bottom-right-radius: 5px;
	box-shadow: 0 12px 28px rgba(143, 24, 213, 0.34);
}

.pw-msg-agent .pw-chat-bubble {
	background: var(--pw-bubble-agent);
	color: var(--pw-text-dark);
	border-bottom-left-radius: 5px;
	border: 1px solid rgba(209, 107, 255, 0.2);
	backdrop-filter: blur(10px);
}

.pw-msg-debug .pw-chat-bubble {
	background: #fff7ed;
	color: #7c2d12;
	border: 1px solid #fed7aa;
	font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;
	font-size: 12px;
	max-width: 100%;
}

.pw-chat-bubble p {
	margin: 0 0 10px 0;
}

.pw-chat-bubble p:last-child {
	margin-bottom: 0;
}

.pw-chat-bubble a {
	color: var(--pw-accent);
	text-decoration: underline;
	font-weight: 600;
}

.pw-chat-bubble a:hover {
	color: var(--pw-accent-hover);
}

/* Typing Indicator */
.pw-typing-indicator {
	display: flex;
	align-items: center;
	gap: 4px;
	padding: 8px 4px;
}

.pw-typing-indicator span {
	width: 7px;
	height: 7px;
	background: #d16bff;
	border-radius: 50%;
	display: inline-block;
	animation: bounceDot 1.4s infinite ease-in-out both;
}

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

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

/* Input Area */
.pw-chat-input-area {
	display: flex;
	padding: 16px 20px;
	background: rgba(5, 3, 8, 0.96);
	border-top: 1px solid rgba(209, 107, 255, 0.22);
	gap: 12px;
	align-items: center;
}

#pw-chat-input {
	flex: 1;
	height: 44px;
	border: 1px solid rgba(255, 255, 255, 0.58);
	border-radius: 22px;
	padding: 0 18px;
	font-size: 14px;
	outline: none;
	background: rgba(255, 255, 255, 0.05);
	color: #ffffff;
	transition: all 0.2s ease;
}

#pw-chat-input::placeholder {
	color: rgba(255, 255, 255, 0.62);
}

#pw-chat-input:focus {
	border-color: var(--pw-accent);
	background: rgba(255, 255, 255, 0.08);
	box-shadow: 0 0 0 2px rgba(209, 107, 255, 0.18), 0 0 24px rgba(209, 107, 255, 0.18);
}

.pw-chat-send-btn {
	width: 44px;
	height: 44px;
	background: linear-gradient(135deg, #d16bff 0%, #9e19dc 100%);
	color: #ffffff;
	border: none;
	border-radius: 50%;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: all 0.2s ease;
	box-shadow: 0 10px 22px rgba(209, 107, 255, 0.35);
}

.pw-chat-send-btn:hover {
	background: linear-gradient(135deg, #e1a0ff 0%, #b52bf0 100%);
	transform: scale(1.05);
}

.pw-chat-send-btn svg {
	width: 18px;
	height: 18px;
	margin-left: 2px;
}

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

/* Floating launcher */
.pw-chat-floating {
	position: fixed;
	right: 24px;
	bottom: 24px;
	z-index: 99999;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

.pw-chat-floating-panel {
	position: absolute;
	right: 0;
	bottom: 76px;
	width: min(420px, calc(100vw - 32px));
	transform-origin: bottom right;
	opacity: 0;
	pointer-events: none;
	transform: translateY(12px) scale(0.98);
	transition: opacity 0.18s ease, transform 0.18s ease;
}

.pw-chat-floating.is-open .pw-chat-floating-panel {
	opacity: 1;
	pointer-events: auto;
	transform: translateY(0) scale(1);
}

.pw-chat-floating.is-closed .pw-chat-floating-panel {
	visibility: hidden;
}

.pw-chat-floating .pw-chat-widget {
	width: 100%;
	height: min(620px, calc(100vh - 124px));
	margin: 0;
}

.pw-chat-floating-toggle {
	position: relative;
	z-index: 100001;
	width: 62px;
	height: 62px;
	border: none;
	border-radius: 50%;
	background: radial-gradient(circle at 35% 28%, #e5b3ff 0%, #d16bff 34%, #7c10be 100%);
	color: #ffffff;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	box-shadow: 0 18px 38px rgba(0, 0, 0, 0.34), 0 0 36px rgba(209, 107, 255, 0.45);
	transition: transform 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}

.pw-chat-floating-toggle:hover {
	background: radial-gradient(circle at 35% 28%, #f0ccff 0%, #d16bff 40%, #9418d8 100%);
	transform: translateY(-2px);
	box-shadow: 0 22px 42px rgba(0, 0, 0, 0.4), 0 0 44px rgba(209, 107, 255, 0.58);
}

.pw-chat-floating-toggle:focus-visible {
	outline: 3px solid rgba(209, 107, 255, 0.44);
	outline-offset: 4px;
}

.pw-chat-floating-icon {
	position: absolute;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: opacity 0.16s ease, transform 0.16s ease;
}

.pw-chat-floating-icon svg {
	width: 27px;
	height: 27px;
}

.pw-chat-floating-icon-close {
	opacity: 0;
	transform: scale(0.75) rotate(-45deg);
}

.pw-chat-floating.is-open .pw-chat-floating-icon-open {
	opacity: 0;
	transform: scale(0.75) rotate(45deg);
}

.pw-chat-floating.is-open .pw-chat-floating-icon-close {
	opacity: 1;
	transform: scale(1) rotate(0);
}

/* Animations */
@keyframes popBubble {
	0% {
		opacity: 0;
		transform: scale(0.9) translateY(15px);
	}
	100% {
		opacity: 1;
		transform: scale(1) translateY(0);
	}
}

@keyframes bounceDot {
	0%, 80%, 100% { 
		transform: scale(0);
	} 40% { 
		transform: scale(1.0);
	}
}

@keyframes pulseStatus {
	0% {
		box-shadow: 0 0 0 0 rgba(107, 255, 180, 0.72);
	}
	70% {
		box-shadow: 0 0 0 6px rgba(107, 255, 180, 0);
	}
	100% {
		box-shadow: 0 0 0 0 rgba(72, 187, 120, 0);
	}
}

/* Responsive adjustment */
@media (max-width: 480px) {
	.pw-chat-widget {
		height: 100vh;
		max-height: 100%;
		border-radius: 0;
		margin: 0;
		position: fixed;
		top: 0;
		left: 0;
		right: 0;
		bottom: 0;
		z-index: 99999;
	}

	.pw-chat-floating {
		right: 16px;
		bottom: 16px;
	}

	.pw-chat-floating-panel {
		position: fixed;
		inset: 0;
		width: auto;
		bottom: auto;
		right: auto;
		transform: none;
	}

	.pw-chat-floating.is-open .pw-chat-floating-panel {
		transform: none;
	}

	.pw-chat-floating .pw-chat-widget {
		height: 100vh;
		max-height: 100%;
		border-radius: 0;
	}

	.pw-chat-floating-toggle {
		width: 56px;
		height: 56px;
	}
}
