

/* CSS Variables for Design System */
:root {
	/* Colors */
	--background: 0 0% 100%;
	--foreground: 222.2 84% 4.9%;
	--card: 0 0% 100%;
	--card-foreground: 222.2 84% 4.9%;
	--popover: 0 0% 100%;
	--popover-foreground: 222.2 84% 4.9%;
	--primary: 221.2 83.2% 53.3%;
	--primary-foreground: 210 40% 98%;
	--secondary: 210 40% 96%;
	--secondary-foreground: 222.2 84% 4.9%;
	--muted: 210 40% 96%;
	--muted-foreground: 215.4 16.3% 46.9%;
	--accent: 210 40% 96%;
	--accent-foreground: 222.2 84% 4.9%;
	--destructive: 0 84.2% 60.2%;
	--destructive-foreground: 210 40% 98%;
	--border: 214.3 31.8% 91.4%;
	--input: 214.3 31.8% 91.4%;
	--ring: 221.2 83.2% 53.3%;
	--radius: 0.5rem;
}

/* Dark mode */
.dark {
	--background: 222.2 84% 4.9%;
	--foreground: 210 40% 98%;
	--card: 222.2 84% 4.9%;
	--card-foreground: 210 40% 98%;
	--popover: 222.2 84% 4.9%;
	--popover-foreground: 210 40% 98%;
	--primary: 217.2 91.2% 59.8%;
	--primary-foreground: 222.2 84% 4.9%;
	--secondary: 217.2 32.6% 17.5%;
	--secondary-foreground: 210 40% 98%;
	--muted: 217.2 32.6% 17.5%;
	--muted-foreground: 215 20.2% 65.1%;
	--accent: 217.2 32.6% 17.5%;
	--accent-foreground: 210 40% 98%;
	--destructive: 0 62.8% 30.6%;
	--destructive-foreground: 210 40% 98%;
	--border: 217.2 32.6% 17.5%;
	--input: 217.2 32.6% 17.5%;
	--ring: 224.3 76.3% 94.1%;
}

body {
	margin: 0;
	padding: 0;
	height: 100vh;
	background: linear-gradient(135deg, hsl(var(--primary)), hsl(var(--primary) / 0.8));
}

.demo-info {
	position: fixed;
	top: 1rem;
	left: 1rem;
	right: 1rem;
	z-index: 9999;
	pointer-events: none;
}

.demo-card {
	background-color: hsl(var(--card));
	border: 1px solid hsl(var(--border));
	border-radius: calc(var(--radius) + 2px);
	padding: 1rem;
	box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
	pointer-events: auto;
	max-width: 400px;
	margin: 0 auto;
}

.demo-title {
	font-size: 1.125rem;
	font-weight: 600;
	color: hsl(var(--foreground));
	margin-bottom: 0.5rem;
}

.demo-description {
	font-size: 0.875rem;
	color: hsl(var(--muted-foreground));
	line-height: 1.5;
}

.demo-badge {
	display: inline-block;
	background-color: hsl(var(--primary));
	color: hsl(var(--primary-foreground));
	padding: 0.25rem 0.5rem;
	border-radius: var(--radius);
	font-size: 0.75rem;
	font-weight: 500;
	margin-bottom: 0.5rem;
}

@media (max-width: 768px) {
	.demo-info {
		display: none;
	}
}

/* Reset */
* {
	border: 0;
	box-sizing: border-box;
	margin: 0;
	padding: 0;
}

/* Base */
body {
	background-color: hsl(var(--background));
	color: hsl(var(--foreground));
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	font-feature-settings: "rlig" 1, "calt" 1;
	line-height: 1.5;
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
}

/* Demo page specific styles */
.demo-info {
	position: fixed;
	top: 1rem;
	left: 1rem;
	right: 1rem;
	z-index: 9999;
	pointer-events: none;
}

.demo-card {
	background-color: hsl(var(--card));
	border: 1px solid hsl(var(--border));
	border-radius: calc(var(--radius) + 2px);
	padding: 1rem;
	box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
	pointer-events: auto;
	max-width: 400px;
	margin: 0 auto;
}

.demo-title {
	font-size: 1.125rem;
	font-weight: 600;
	color: hsl(var(--foreground));
	margin-bottom: 0.5rem;
}

.demo-description {
	font-size: 0.875rem;
	color: hsl(var(--muted-foreground));
	line-height: 1.5;
}

.demo-badge {
	display: inline-block;
	background-color: hsl(var(--primary));
	color: hsl(var(--primary-foreground));
	padding: 0.25rem 0.5rem;
	border-radius: var(--radius);
	font-size: 0.75rem;
	font-weight: 500;
	margin-bottom: 0.5rem;
}

@media (max-width: 768px) {
	.demo-info {
		display: none;
	}
}

/* Widget-specific CSS Variables */
:root {
	--primary-color: #667eea;
	--secondary-color: #6c757d;
	--success-color: #28a745;
	--danger-color: #dc3545;
	--warning-color: #ffc107;
	--info-color: #17a2b8;

	--text-primary: #212529;
	--text-secondary: #6c757d;
	--text-muted: #adb5bd;
	--text-white: #ffffff;

	--bg-white: #ffffff;
	--bg-light: #f8f9fa;
	--bg-dark: #343a40;
	--bg-overlay: rgba(0, 0, 0, 0.5);

	--border-color: #dee2e6;
	--border-radius: 12px;
	--border-radius-sm: 8px;
	--border-radius-lg: 16px;

	--shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.1);
	--shadow-md: 0 4px 12px rgba(0, 0, 0, 0.15);
	--shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.2);

	--button-size: 60px;
	--z-index-widget: 2147483647;
	--z-index-window: 2147483646;

	--transition-default: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
	--transition-bounce: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

/* 위젯 컨테이너 */
.chat-widget-container {
	position: fixed;
	z-index: var(--z-index-widget);
	font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
	font-size: 14px;
	line-height: 1.5;
	color: var(--text-primary);

	/* 다른 사이트 스타일 격리 */
	all: initial;
	font-family: inherit;
}

/* 채널 목록 스타일 */
.chat-channel-list {
	padding: 1rem;
	max-height: 400px;
	overflow-y: auto;
}

.channel-list-header h3 {
	margin: 0 0 1rem 0;
	font-size: 1.2rem;
	color: var(--text-primary);
	text-align: center;
}

.channel-item {
	display: flex;
	align-items: center;
	padding: 0.75rem;
	margin-bottom: 0.5rem;
	background: var(--bg-secondary);
	border-radius: var(--border-radius);
	border: 1px solid var(--border-color);
	cursor: pointer;
	transition: all 0.2s ease;
}

.channel-item:hover {
	background: var(--bg-hover);
	border-color: var(--primary-color);
	transform: translateY(-1px);
}

.channel-info {
	flex: 1;
}

.channel-name {
	margin: 0 0 0.25rem 0;
	font-size: 1rem;
	font-weight: 600;
	color: var(--text-primary);
}

.channel-description {
	margin: 0;
	font-size: 0.875rem;
	color: var(--text-secondary);
}

.channel-meta {
	text-align: right;
	font-size: 0.75rem;
	color: var(--text-muted);
}

/* 플로팅 버튼 */
.chat-floating-button {
	position: fixed;
	width: var(--button-size);
	height: var(--button-size);
	border-radius: 50%;
	background: var(--primary-color);
	color: white;
	border: none;
	cursor: pointer;
	box-shadow: var(--shadow-lg);
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 24px;
	transition: var(--transition-bounce);
	z-index: var(--z-index-widget);
}

.chat-floating-button:hover {
	transform: scale(1.1);
	box-shadow: 0 12px 32px rgba(0, 0, 0, 0.25);
}

.chat-floating-button.pulse {
	animation: pulse 2s infinite;
}

@keyframes pulse {
	0% {
		transform: scale(1);
		box-shadow: 0 0 0 0 rgba(var(--primary-color), 0.7);
	}

	70% {
		transform: scale(1.05);
		box-shadow: 0 0 0 10px rgba(var(--primary-color), 0);
	}

	100% {
		transform: scale(1);
		box-shadow: 0 0 0 0 rgba(var(--primary-color), 0);
	}
}

/* 위치별 스타일 */
.chat-floating-button.position-bottom-right {
	bottom: 20px;
	right: 20px;
}

.chat-floating-button.position-bottom-left {
	bottom: 20px;
	left: 20px;
}

.chat-floating-button.position-center {
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	width: 80px;
	height: 80px;
	font-size: 32px;
}

.chat-floating-button.position-center:hover {
	transform: translate(-50%, -50%) scale(1.1);
}

/* 채팅 윈도우 */
.chat-window {
	position: fixed;
	z-index: var(--z-index-window);
	background: white;
	border-radius: var(--border-radius-lg);
	box-shadow: var(--shadow-lg);
	overflow: hidden;
	transition: var(--transition-default);
}

.chat-window.position-bottom-right {
	bottom: 90px;
	right: 20px;
	width: 380px;
	height: 600px;
}

.chat-window.position-bottom-left {
	bottom: 90px;
	left: 20px;
	width: 380px;
	height: 600px;
}

.chat-window.position-center {
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	width: min(90vw, 400px);
	height: min(80vh, 600px);
}

/* 반응형 */
@media (max-width: 768px) {
	.chat-window {
		position: fixed !important;
		top: 0 !important;
		left: 0 !important;
		right: 0 !important;
		bottom: 0 !important;
		width: 100% !important;
		height: 100% !important;
		border-radius: 0 !important;
		transform: none !important;
	}

	.chat-floating-button.position-center {
		position: fixed;
		top: 50%;
		left: 50%;
		transform: translate(-50%, -50%);
	}
}

/* 채팅 헤더 */
.chat-header {
	background: var(--primary-color);
	color: white;
	padding: 1rem 1.5rem;
	display: flex;
	align-items: center;
	justify-content: space-between;
}

.chat-title {
	font-size: 1.1rem;
	font-weight: 600;
	margin: 0;
}

.chat-close-button {
	background: none;
	border: none;
	color: white;
	font-size: 1.5rem;
	cursor: pointer;
	padding: 0.25rem;
	border-radius: 4px;
	transition: background 0.2s ease;
}

.chat-close-button:hover {
	background: rgba(255, 255, 255, 0.1);
}

/* 채팅 내용 */
.chat-content {
	height: calc(100% - 120px);
	display: flex;
	flex-direction: column;
}

/* 메시지 목록 */
.chat-messages {
	flex: 1;
	overflow-y: auto;
	padding: 1rem;
	background: #f8f9fa;
}

.message-group {
	margin-bottom: 1rem;
}

.message-sender {
	font-size: 0.875rem;
	font-weight: 600;
	color: var(--primary-color);
	margin-bottom: 0.5rem;
}

.message-bubble {
	max-width: 80%;
	padding: 0.75rem 1rem;
	border-radius: var(--border-radius);
	word-wrap: break-word;
	font-size: 0.9rem;
	line-height: 1.4;
}

.message-bubble.user {
	background: var(--primary-color);
	color: white;
	margin-left: auto;
	border-bottom-right-radius: 4px;
}

.message-bubble.assistant {
	background: white;
	color: var(--text-primary);
	border: 1px solid var(--border-color);
	border-bottom-left-radius: 4px;
}

.message-time {
	font-size: 0.75rem;
	color: var(--text-muted);
	margin-top: 0.25rem;
	text-align: right;
}

.message-bubble.assistant+.message-time {
	text-align: left;
}

/* 메시지 입력 */
.chat-input-container {
	padding: 1rem;
	background: white;
	border-top: 1px solid var(--border-color);
}

.chat-input-wrapper {
	display: flex;
	align-items: flex-end;
	gap: 0.75rem;
}

.chat-input {
	flex: 1;
	border: 1px solid var(--border-color);
	border-radius: var(--border-radius);
	padding: 0.75rem;
	font-size: 0.9rem;
	resize: none;
	min-height: 44px;
	max-height: 120px;
	line-height: 1.4;
	font-family: inherit;
}

.chat-input:focus {
	outline: none;
	border-color: var(--primary-color);
	box-shadow: 0 0 0 3px rgba(var(--primary-color), 0.1);
}

.chat-send-button {
	background: var(--primary-color);
	color: white;
	border: none;
	border-radius: var(--border-radius);
	padding: 0.75rem;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	min-width: 44px;
	height: 44px;
	transition: background 0.2s ease;
}

.chat-send-button:hover {
	background: var(--primary-color);
	filter: brightness(1.1);
}

.chat-send-button:disabled {
	opacity: 0.5;
	cursor: not-allowed;
}

/* 로딩 상태 */
.loading-dots {
	display: flex;
	align-items: center;
	gap: 4px;
	padding: 1rem;
}

.loading-dot {
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: var(--text-muted);
	animation: loading 1.4s infinite ease-in-out both;
}

.loading-dot:nth-child(1) {
	animation-delay: -0.32s;
}

.loading-dot:nth-child(2) {
	animation-delay: -0.16s;
}

@keyframes loading {

	0%,
	80%,
	100% {
		transform: scale(0);
	}

	40% {
		transform: scale(1);
	}
}

/* 빈 상태 */
.empty-state {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	padding: 2rem;
	text-align: center;
	color: var(--text-muted);
}

.empty-state-icon {
	font-size: 3rem;
	margin-bottom: 1rem;
	opacity: 0.5;
}

.empty-state-text {
	font-size: 1rem;
	line-height: 1.5;
}

/* 에러 상태 */
.error-state {
	padding: 1rem;
	margin: 1rem;
	background: #fff3cd;
	border: 1px solid #ffeaa7;
	border-radius: var(--border-radius);
	color: #856404;
	text-align: center;
}

/* 유틸리티 클래스 */
.hidden {
	display: none !important;
}

.fade-in {
	animation: fadeIn 0.3s ease-in-out;
}

.fade-out {
	animation: fadeOut 0.3s ease-in-out;
}

@keyframes fadeIn {
	from {
		opacity: 0;
		transform: translateY(10px);
	}

	to {
		opacity: 1;
		transform: translateY(0);
	}
}

@keyframes fadeOut {
	from {
		opacity: 1;
		transform: translateY(0);
	}

	to {
		opacity: 0;
		transform: translateY(-10px);
	}
}

.slide-up {
	animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
	from {
		transform: translateY(100%);
	}

	to {
		transform: translateY(0);
	}
}

/* 스크롤바 스타일 */
.chat-messages::-webkit-scrollbar,
.chat-channel-list::-webkit-scrollbar {
	width: 6px;
}

.chat-messages::-webkit-scrollbar-track,
.chat-channel-list::-webkit-scrollbar-track {
	background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb,
.chat-channel-list::-webkit-scrollbar-thumb {
	background: var(--border-color);
	border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover,
.chat-channel-list::-webkit-scrollbar-thumb:hover {
	background: var(--text-muted);
}

/* 접근성 */
.sr-only {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

/* 포커스 스타일 */
button:focus-visible,
input:focus-visible,
textarea:focus-visible {
	outline: 2px solid var(--primary-color);
	outline-offset: 2px;
}