/* ========================================
   チャットボット UI スタイル
   ======================================== */

:root {
	/* カラー定義 */
	--cb-color-primary: #0A1464;
	--cb-color-secondary: #071872;
	--cb-bg-gray: #F2F2F2;
	--cb-bg-white: #FFFFFF;
	--cb-border-gray: #CDCDCD;
	--cb-text-main: #333333;
	--cb-text-black: #000000;

	/* レイアウト */
	--cb-z-floating: 100002;
	--cb-z-window: 100003;
	--cb-z-pagetop: 100001;

	/* アニメーション */
	--cb-transition-base: opacity 0.3s ease, visibility 0.3s ease, transform 0.3s ease;
	--cb-transition-fast: 0.2s ease;
}

/* ========================================
   インラインエリア（AIチャット導線）
   ======================================== */

/* postdate の padding-top 調整 */
#main .postdate {
	padding-top: 12px;
}

/* 外側コンテナ（ラッパー） */
.chatbot-inline-wrapper {
	display: flex;
	width: 100%;
	margin-top: 16px;
	padding-top: 16px;
	flex-direction: column;
	align-items: center;
	background: var(--cb-bg-gray);
	box-sizing: border-box;
}

/* 内側コンテナ */
.chatbot-inline-inner {
	display: flex;
	padding: 12px 0 16px 0;
	align-items: center;
	gap: 24px;
	align-self: stretch;
	flex-wrap: wrap; /* 折り返しを許可 */
	justify-content: center;
}

/* 左右カラム共通レイアウト */
.chatbot-inline-column {
	display: flex;
	justify-content: center;
	align-items: flex-start;
	gap: 8px;
	flex: 1 0 0;
}

/* 左側：AIチャット説明部 */
.chatbot-inline-left {
	flex-direction: column;
	align-items: center;
	gap: 24px;
	align-self: stretch;
	max-width: 550px;
}

.chatbot-inline-content {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 24px;
	flex: 1 0 0;
	align-self: stretch;
	padding: 0 24px; /* ここで一括管理 */
}

/* タイトルエリア */
.chatbot-inline-title-area {
	display: flex;
	padding: 0; /* paddingをリセット */
	align-items: center;
	justify-content: center; /* 中央寄せに追加 */
	gap: 8px;
	align-self: stretch;
}

.chatbot-inline-qa-icon {
	width: 32px;
	height: 32px;
	aspect-ratio: 1 / 1;
	flex-shrink: 0;
}

.chatbot-inline-title {
	color: var(--cb-color-primary);
	text-align: center;
	font-family: Arial, sans-serif;
	font-size: 16px;
	font-weight: 700;
	line-height: 1.4; /* line-heightを調整して中央に合わせやすく */
	letter-spacing: 0.7px;
}

/* リード文エリア */
.chatbot-inline-lead-area {
	display: flex;
	padding: 0; /* paddingをリセット */
	align-items: center;
	justify-content: center; /* 中央寄せに追加 */
	gap: 10px;
	align-self: stretch;
}

.chatbot-inline-lead-text {
	color: var(--cb-text-black);
	text-align: center;
	font-family: Arial, sans-serif;
	font-size: 16px;
	font-weight: 700;
	line-height: 140%;
	letter-spacing: 0.7px;
	margin: 0;
}

/* チャットボタンエリア */
.chatbot-inline-btn-area {
	display: flex;
	padding: 0; /* paddingをリセット */
	flex-direction: column;
	justify-content: center;
	align-items: center;
	gap: 10px;
	width: 100%;
	box-sizing: border-box;
}

/* ボタン外枠 */
.chatbot-inline-btn-outer {
	display: flex;
	padding: 1px;
	flex-direction: column;
	align-items: flex-start;
	gap: 10px;
	border-radius: 5px;
	border: 1px solid var(--cb-text-main);
	background: transparent;
	cursor: pointer;
	transition: opacity var(--cb-transition-fast);
}

.chatbot-inline-btn-outer:hover {
	opacity: 0.5;
}

/* ボタン内部 */
.chatbot-inline-btn-inner {
	display: flex;
	padding: 8px 16px;
	justify-content: center;
	align-items: center;
	gap: 10px;
	align-self: stretch;
	border-radius: 5px;
	background: var(--cb-bg-white);
}

.chatbot-inline-mevico-icon {
	width: 24px;
	height: 24px;
	aspect-ratio: 1 / 1;
	flex-shrink: 0;
}

.chatbot-inline-btn-text {
	color: var(--cb-color-primary);
	text-align: center;
	font-family: Arial, sans-serif;
	font-size: 14px;
	font-weight: 700;
}

/* 右側：グラフィックエリア */
.chatbot-inline-right {
	flex-direction: column;
	justify-content: center;
	align-items: flex-start;
	align-self: stretch;
	max-width: 450px;
}

.chatbot-inline-graphic {
	max-width: 100%;
	height: auto;
	max-height: 174px;
	margin: 0 auto;
}

/* ========================================
   フローティングボタン（右下固定）
   ======================================== */

#chatbot-wrapper {
	position: fixed;
	bottom: 76px; /* ページトップボタン(50px) + gap(16px) + 余白(10px) */
	right: 10px;
	z-index: var(--cb-z-floating);
	font-family: "Noto Sans JP", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.toPageTop {
	z-index: var(--cb-z-pagetop) !important;
}

/* フローティングコンテナ（外側ラッパー） */
.chatbot-floating-container {
	display: inline-flex;
	padding-bottom: 16px;
	flex-direction: column;
	align-items: flex-end;
	gap: 8px;
	position: relative;
	opacity: 0;
	visibility: hidden;
	transform: translateY(20px) scale(0.9);
	transition: var(--cb-transition-base);
	pointer-events: none;
}

.chatbot-floating-container.is-visible {
	opacity: 1;
	visibility: visible;
	transform: translateY(0) scale(1);
	pointer-events: auto;
}

/* ホバーメッセージ（ツールチップ）- ボタンの上に絶対配置 */
.chatbot-floating-tooltip {
	display: flex;
	width: 540px;
	padding-bottom: 10px;
	flex-direction: column;
	justify-content: center;
	align-items: flex-end;
	gap: -2px;
	position: absolute;
	bottom: 100%;
	right: 0;
	opacity: 0;
	visibility: hidden;
	transform: translateY(10px);
	transition: opacity var(--cb-transition-fast), visibility var(--cb-transition-fast), transform var(--cb-transition-fast);
	pointer-events: none;
}

/* ボタンにホバーしたときのみツールチップを表示 */
.chatbot-floating-btn:hover + .chatbot-floating-tooltip {
	opacity: 1;
	visibility: visible;
	transform: translateY(0);
}

.chatbot-floating-tooltip-inner {
	display: flex;
	padding: 16px;
	flex-direction: column;
	justify-content: center;
	align-items: center;
	gap: 16px;
	border-radius: 3px;
	border: 0.4px solid var(--cb-color-secondary);
	background: var(--cb-bg-white);
	box-shadow: 0 0 10px 0 rgba(0, 0, 0, 0.25);
}

.chatbot-floating-tooltip-content {
	display: flex;
	align-items: center;
	gap: 8px;
}

.chatbot-floating-tooltip-text {
	color: var(--cb-text-black);
	font-family: "Noto Sans JP", sans-serif;
	font-size: 20px;
	font-style: normal;
	font-weight: 400;
	line-height: 140%;
}

.chatbot-floating-tooltip-icon {
	width: 60px;
	height: 60px;
	flex-shrink: 0;
}

/* 指差しマーク（三角矢印） */
.chatbot-floating-tooltip-arrow {
	position: absolute;
	bottom: 4px;
	right: 80px;
	width: 17px;
	height: 9px;
}

/* フローティングボタン本体 */
.chatbot-floating-btn {
	display: flex;
	padding: 16px 24px;
	justify-content: center;
	align-items: center;
	gap: 8px;
	border-radius: 40px;
	border: 0.4px solid var(--cb-color-primary);
	background: var(--cb-bg-white);
	box-shadow: 0 5px 24px 0 rgba(0, 0, 0, 0.20);
	cursor: pointer;
	transition: opacity var(--cb-transition-fast);
}

.chatbot-floating-btn:hover {
	opacity: 0.5;
}

.chatbot-floating-btn-inner {
	display: flex;
	justify-content: center;
	align-items: center;
	gap: 8px;
}

.chatbot-floating-mevico-icon {
	width: 48px;
	height: 48px;
	flex-shrink: 0;
}

.chatbot-floating-btn-text {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
}

.chatbot-floating-btn-title {
	color: var(--cb-color-primary);
	font-family: "Noto Sans JP", sans-serif;
	font-size: 20px;
	font-style: normal;
	font-weight: 700;
	line-height: 160%;
	letter-spacing: 0.7px;
}

.chatbot-floating-btn-subtitle {
	color: var(--cb-color-primary);
	font-family: "Noto Sans JP", sans-serif;
	font-size: 16px;
	font-style: normal;
	font-weight: 700;
	line-height: 160%;
	letter-spacing: 0.7px;
}

/* ========================================
   チャットウィンドウ
   ======================================== */

.chatbot-window {
	position: fixed;
	bottom: 16px;
	right: 8px;
	width: 40%;
	height: 88%;
	min-width: 300px;
	min-height: 400px;
	max-width: calc(100vw - 16px);
	max-height: calc(100vh - 32px);
	background: var(--cb-bg-white);
	border: 1px solid var(--cb-border-gray);
	border-radius: 6px;
	box-shadow: 0 0 10px rgba(0, 0, 0, 0.25);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	opacity: 0;
	visibility: hidden;
	transform: translateY(20px) scale(0.95);
	transition: var(--cb-transition-base);
	z-index: var(--cb-z-window);
	pointer-events: none;
	box-sizing: border-box;
}

.chatbot-window.is-open {
	opacity: 1;
	visibility: visible;
	transform: translateY(0) scale(1);
	pointer-events: auto;
}

/* ドラッグ中・リサイズ中はトランジション無効 */
.chatbot-window.is-dragging,
.chatbot-window.is-resizing {
	transition: none;
	user-select: none;
}

/* チャットヘッダー（ドラッグハンドル） */
.chatbot-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 12px 16px;
	background: #f5f5f5;
	color: var(--cb-text-main);
	flex-shrink: 0;
	cursor: move;
	user-select: none;
	border-radius: 5px 5px 0 0;
	position: relative;
	z-index: 1;
	touch-action: none; /* Pointer Events 用 */
}

.chatbot-header:active {
	cursor: grabbing;
}

.chatbot-title {
	font-size: 15px;
	font-weight: 600;
	pointer-events: none;
}

/* 閉じるボタン */
.chatbot-close-btn {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	background: rgba(255, 255, 255, 0.1);
	border: none;
	border-radius: 50%;
	color: var(--cb-text-main);
	cursor: pointer;
	transition: background var(--cb-transition-fast);
	position: relative;
	z-index: 5;
}

.chatbot-close-btn:hover {
	background: rgba(255, 255, 255, 0.25);
}

/* チャット本体 */
.chatbot-body {
	flex: 1;
	overflow: hidden;
	background: var(--cb-bg-white);
	border-radius: 0 0 5px 5px;
	position: relative;
	z-index: 1;
}

.chatbot-body chat-bot-element {
	display: block;
	width: 100%;
	height: 100%;
}

/* ========================================
   リサイズハンドル
   ======================================== */

/* リサイズハンドル共通 */
.chatbot-resize-handle {
	position: absolute;
	z-index: 100;
	background: transparent;
	touch-action: none; /* Pointer Events 用 */
}

.chatbot-resize-handle:hover {
	background: rgba(0, 102, 204, 0.1);
}

/* 四隅のリサイズハンドル */
.chatbot-resize-handle-nw {
	top: -4px;
	left: -4px;
	width: 20px;
	height: 20px;
	cursor: nw-resize;
	border-radius: 12px 0 0 0;
}

.chatbot-resize-handle-ne {
	top: -4px;
	right: -4px;
	width: 20px;
	height: 20px;
	cursor: ne-resize;
	border-radius: 0 12px 0 0;
}

.chatbot-resize-handle-sw {
	bottom: -4px;
	left: -4px;
	width: 20px;
	height: 20px;
	cursor: sw-resize;
	border-radius: 0 0 0 12px;
}

.chatbot-resize-handle-se {
	bottom: -4px;
	right: -4px;
	width: 20px;
	height: 20px;
	cursor: se-resize;
	border-radius: 0 0 12px 0;
}

/* 辺のリサイズハンドル */
.chatbot-resize-handle-n {
	top: -4px;
	left: 20px;
	right: 20px;
	height: 8px;
	cursor: n-resize;
}

.chatbot-resize-handle-s {
	bottom: -4px;
	left: 20px;
	right: 20px;
	height: 8px;
	cursor: s-resize;
}

.chatbot-resize-handle-w {
	top: 20px;
	bottom: 20px;
	left: -4px;
	width: 8px;
	cursor: w-resize;
}

.chatbot-resize-handle-e {
	top: 20px;
	bottom: 20px;
	right: -4px;
	width: 8px;
	cursor: e-resize;
}

/* ========================================
   レスポンシブ（スマホ・タブレット）
   ======================================== */
@media screen and (max-width: 959px) {
	.chatbot-inline-inner {
		flex-direction: column; /* 縦並びに変更 */
		gap: 32px;
	}

	.chatbot-inline-right {
		align-items: center;
		order: -1; /* 画像を上に持ってくる */
		margin: 0 auto;
	}

	.chatbot-inline-left {
		margin: 0 auto;
	}
}

@media screen and (max-width: 767px) {
	#chatbot-wrapper {
		bottom: 70px;
		right: 10px;
	}

	.chatbot-inline-wrapper {
		display: none;
	}

	/* スマホではツールチップ非表示 */
	.chatbot-floating-tooltip {
		display: none;
	}

	/* スマホではボタンを小さく */
	.chatbot-floating-btn {
		padding: 12px 16px;
	}

	.chatbot-floating-mevico-icon {
		width: 32px;
		height: 32px;
	}

	.chatbot-floating-btn-title {
		font-size: 14px;
	}

	.chatbot-floating-btn-subtitle {
		font-size: 12px;
	}

	/* スマホではフルスクリーン表示（リサイズ・移動無効） */
	.chatbot-window {
		bottom: 0;
		right: 0;
		left: 0;
		top: 0;
		width: 100%;
		height: 100%;
		max-width: 100%;
		max-height: 100%;
		border-radius: 0;
	}

	.chatbot-header {
		cursor: default;
		border-radius: 0;
	}

	.chatbot-body {
		border-radius: 0;
	}

	.chatbot-resize-handle,
	.chatbot-resize-icon {
		display: none;
	}
}

/* 印刷時は非表示 */
@media print {
	#chatbot-wrapper,
	.chatbot-inline-wrapper {
		display: none;
	}
}
