/* チャットボット共通スタイル */
.chatbot-widget {
	position: fixed;
	bottom: 20px;
	right: 90px;
	/* LiveChatとの競合を避けるため右側に余裕を持たせる */
	z-index: 9998;
	/* LiveChatより少し低く設定 */
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* チャットボタン */
.chatbot-toggle {
	width: 60px;
	height: 60px;
	background-color: #FAA200;
	border-radius: 50%;
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: all 0.3s ease;
	border: none;
	outline: none;
}

.chatbot-toggle:hover {
	background-color: #e89200;
	transform: translateY(-2px);
	box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.chatbot-toggle svg {
	width: 34px;
	height: 34px;
	fill: #fff;
}

/* チャットウィンドウ */
.chatbot-window {
	position: absolute;
	bottom: 80px;
	right: 0;
	width: 380px;
	height: 500px;
	background-color: #fff;
	border-radius: 12px;
	box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
	display: none;
	flex-direction: column;
	overflow: hidden;
	border: 1px solid #e0e0e0;
}

.chatbot-window.active {
	display: flex;
}

/* ヘッダー */
.chatbot-header {
	background: linear-gradient(135deg, #393869 0%, #0381D5 100%);
	color: #fff;
	padding: 16px 20px;
	display: flex;
	align-items: center;
	justify-content: space-between;
}

.chatbot-header h3 {
	margin: 0;
	font-size: 16px;
	font-weight: 600;
}

.chatbot-close {
	background: none;
	border: none;
	color: #fff;
	cursor: pointer;
	padding: 4px;
	display: flex;
	align-items: center;
	justify-content: center;
}

.chatbot-close:hover {
	opacity: 0.8;
}

.chatbot-close svg {
	width: 16px;
	height: 16px;
	fill: #fff;
}

/* メッセージエリア */
.chatbot-messages {
	flex: 1;
	padding: 20px;
	overflow-y: auto;
	display: flex;
	flex-direction: column;
	gap: 16px;
	background-color: #f8f9fa;
}

.chatbot-messages::-webkit-scrollbar {
	width: 6px;
}

.chatbot-messages::-webkit-scrollbar-track {
	background: #f1f1f1;
}

.chatbot-messages::-webkit-scrollbar-thumb {
	background: #c1c1c1;
	border-radius: 3px;
}

.chatbot-messages::-webkit-scrollbar-thumb:hover {
	background: #a8a8a8;
}

/* メッセージ */
.message {
	display: flex;
	gap: 12px;
	max-width: 85%;
}

.message.user {
	align-self: flex-end;
	flex-direction: row-reverse;
}

.message-avatar {
	width: 32px;
	height: 32px;
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
}

.message.bot .message-avatar {
	background-color: #0381D5;
}

.message.user .message-avatar {
	background-color: #393869;
}

.message-avatar svg {
	width: 16px;
	height: 16px;
	fill: #fff;
}

.message-content {
	background-color: #fff;
	padding: 12px 16px;
	border-radius: 12px;
	border: 1px solid #e0e0e0;
	font-size: 14px;
	line-height: 1.4;
	word-wrap: break-word;
	overflow-wrap: break-word;
	word-break: break-word;
	max-width: 100%;
	overflow: hidden;
}

.message.user .message-content {
	background-color: #0381D5;
	color: #fff;
	border-color: #0381D5;
}

/* 入力エリア */
.chatbot-input-area {
	padding: 16px 20px;
	border-top: 1px solid #e0e0e0;
	background-color: #fff;
	display: flex;
	flex-direction: row;
	align-items: flex-end;
	gap: 8px;
}

.chatbot-input-wrapper {
	flex: 1;
	display: flex;
	flex-direction: column;
}

.chatbot-controls {
	display: flex;
	gap: 8px;
	align-items: flex-end;
	flex-shrink: 0;
}

.chatbot-input {
	flex: 1;
	border: 1px solid #d0d0d0;
	border-radius: 12px;
	padding: 10px 16px;
	font-size: 14px;
	outline: none;
	resize: none;
	min-height: 60px;
	max-height: 120px;
	line-height: 1.4;
}

.chatbot-input:focus {
	border-color: #0381D5;
}

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

.chatbot-attach {
	background-color: #393869;
}

.chatbot-attach:hover:not(:disabled) {
	background-color: #2a2a50;
}

.chatbot-send {
	background-color: #0381D5;
}

.chatbot-send:hover:not(:disabled) {
	background-color: #026bb3;
}

.chatbot-send:disabled {
	background-color: #ccc;
	cursor: not-allowed;
}

.chatbot-attach svg,
.chatbot-send svg {
	width: 16px;
	height: 16px;
	fill: #fff;
}

/* 添付プレビュー */
.chatbot-attachment-preview {
	display: none;
	margin-top: 8px;
}

.attachment-item {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 8px;
	background-color: #f8f9fa;
	border-radius: 8px;
	border: 1px solid #e0e0e0;
}

.attachment-preview-image {
	width: 40px;
	height: 40px;
	object-fit: cover;
	border-radius: 4px;
}

.attachment-info {
	flex: 1;
	display: flex;
	justify-content: space-between;
	align-items: center;
}

.attachment-name {
	font-size: 12px;
	color: #666;
	max-width: 150px;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.attachment-remove {
	background-color: #FAA200;
	border: none;
	border-radius: 50%;
	width: 20px;
	height: 20px;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	color: #fff;
	font-weight: bold;
	font-size: 12px;
	transition: background-color 0.2s ease;
}

.attachment-remove:hover {
	background-color: #e6920a;
}

/* メッセージ内の画像 */
.message-image {
	margin-bottom: 8px;
}

.message-image img {
	max-width: 200px;
	max-height: 200px;
	border-radius: 8px;
	object-fit: cover;
}

.message-text {
	margin-top: 8px;
}

/* ローディング表示 */
.typing-indicator {
	display: flex;
	gap: 4px;
	padding: 12px 16px;
}

.typing-dot {
	width: 8px;
	height: 8px;
	background-color: #ccc;
	border-radius: 50%;
	animation: typing 1.4s infinite;
}

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

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

@keyframes typing {

	0%,
	60%,
	100% {
		transform: scale(1);
		opacity: 0.6;
	}

	30% {
		transform: scale(1.2);
		opacity: 1;
	}
}

/* モバイル対応 */
@media (max-width: 480px) {
	.chatbot-widget {
		bottom: 16px;
		right: 16px;
		/* モバイルではLiveChatがない場合が多いので通常位置 */
	}

	.chatbot-window {
		width: calc(100vw - 32px);
		height: calc(100vh - 120px);
		max-width: 380px;
		max-height: 500px;
	}

	.chatbot-toggle {
		width: 56px;
		height: 56px;
	}

	.chatbot-toggle svg {
		width: 20px;
		height: 20px;
	}
}

@media (max-width: 320px) {
	.chatbot-window {
		width: calc(100vw - 20px);
		right: -6px;
	}
}

/* マークダウン要素のスタイル */
.message-content p {
	margin: 0 0 8px 0;
}

.message-content p:last-child {
	margin-bottom: 0;
}

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

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

.message-content code {
	background-color: rgba(0, 0, 0, 0.05);
	padding: 2px 6px;
	border-radius: 4px;
	font-family: 'Courier New', Courier, monospace;
	font-size: 13px;
}

.message.user .message-content code {
	background-color: rgba(255, 255, 255, 0.2);
}

.message-content pre {
	background-color: #f5f5f5;
	padding: 12px;
	border-radius: 6px;
	overflow-x: auto;
	margin: 8px 0;
	max-width: 100%;
	white-space: pre-wrap;
	word-wrap: break-word;
}

.message-content pre code {
	background-color: transparent;
	padding: 0;
	font-size: 12px;
	line-height: 1.5;
}

.message.user .message-content pre {
	background-color: rgba(255, 255, 255, 0.15);
}

.message-content ul,
.message-content ol {
	margin: 8px 0;
	padding-left: 20px;
}

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

.message-content a {
	color: #0381D5;
	text-decoration: none;
	border-bottom: 1px solid #0381D5;
	word-wrap: break-word;
	overflow-wrap: break-word;
}

.message-content a:hover {
	color: #026bb3;
	border-bottom-color: #026bb3;
}

.message.user .message-content a {
	color: #fff;
	border-bottom-color: rgba(255, 255, 255, 0.6);
}

.message.user .message-content a:hover {
	border-bottom-color: #fff;
}

.message-content blockquote {
	border-left: 3px solid #0381D5;
	padding-left: 12px;
	margin: 8px 0;
	color: #666;
}

.message.user .message-content blockquote {
	border-left-color: rgba(255, 255, 255, 0.6);
	color: rgba(255, 255, 255, 0.9);
}

.message-content h1,
.message-content h2,
.message-content h3,
.message-content h4,
.message-content h5,
.message-content h6 {
	margin: 12px 0 8px 0;
	font-weight: 600;
	line-height: 1.3;
}

.message-content h1 {
	font-size: 18px;
}

.message-content h2 {
	font-size: 16px;
}

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

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

.message-content hr {
	border: none;
	border-top: 1px solid #e0e0e0;
	margin: 12px 0;
}

.message.user .message-content hr {
	border-top-color: rgba(255, 255, 255, 0.3);
}

.message-content table {
	border-collapse: collapse;
	width: 100%;
	margin: 8px 0;
	font-size: 13px;
	display: block;
	overflow-x: auto;
	max-width: 100%;
}

.message-content th,
.message-content td {
	border: 1px solid #e0e0e0;
	padding: 6px 8px;
	text-align: left;
}

.message-content th {
	background-color: #f5f5f5;
	font-weight: 600;
}

.message.user .message-content th,
.message.user .message-content td {
	border-color: rgba(255, 255, 255, 0.3);
}

.message.user .message-content th {
	background-color: rgba(255, 255, 255, 0.15);
}

/* メッセージ内の画像・要素がはみ出さないように */
.message-content img {
	max-width: 100%;
	height: auto;
}

.message-content * {
	max-width: 100%;
}