/**
 * WP AI Chat public styles.
 *
 * テーマのスタイルと衝突しにくいよう、すべて.wp-ai-chat配下に限定します。
 */

.wp-ai-chat,
.wp-ai-chat * {
	box-sizing: border-box;
}

.wp-ai-chat {
	display: flex;
	flex-direction: column;
	width: 100%;
	max-width: 760px;
	height: min(620px, 75vh);
	min-height: 420px;
	margin: 24px auto;
	overflow: hidden;
	color: #1f2937;
	background: #fff;
	border: 1px solid #d9dde3;
	border-radius: 16px;
	box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.wp-ai-chat .screen-reader-text {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

.wp-ai-chat__history {
	flex: 1;
	padding: 24px;
	overflow-y: auto;
	background: #f7f7f8;
	scroll-behavior: smooth;
}

.wp-ai-chat__message {
	display: flex;
	width: 100%;
	height: auto !important;
	min-height: 0 !important;
	max-height: none !important;
	margin: 0 0 18px;
	overflow: visible !important;
}

.wp-ai-chat__message--user {
	justify-content: flex-end;
}

.wp-ai-chat__message--assistant {
	justify-content: flex-start;
}

.wp-ai-chat__bubble {
	display: block !important;
	max-width: min(82%, 620px);
	height: auto !important;
	min-height: 0 !important;
	max-height: none !important;
	padding: 11px 15px;
	overflow: visible !important;
	border-radius: 16px;
	font-size: 15px;
	line-height: 1.65;
	white-space: pre-wrap !important;
	overflow-wrap: anywhere;
	text-overflow: clip !important;
	-webkit-line-clamp: unset !important;
}

.wp-ai-chat__message--assistant .wp-ai-chat__bubble {
	background: #fff;
	border: 1px solid #e3e5e8;
	border-bottom-left-radius: 5px;
}

.wp-ai-chat [hidden] {
	display: none !important;
}

.wp-ai-chat__message--guide .wp-ai-chat__bubble {
	width: 100%;
	max-width: 100%;
	white-space: normal !important;
}

.wp-ai-chat__guide-title,
.wp-ai-chat__guide-heading,
.wp-ai-chat__guide-empty {
	margin: 0 0 12px;
}

.wp-ai-chat__guide-heading {
	font-weight: 700;
}

.wp-ai-chat__guide-empty {
	color: #6b7280;
}

.wp-ai-chat__choices {
	display: grid;
	gap: 8px;
}

.wp-ai-chat .wp-ai-chat__choice {
	display: block;
	width: 100%;
	margin: 0;
	padding: 10px 12px;
	color: #1d4ed8;
	background: #eff6ff;
	border: 1px solid #bfdbfe;
	border-radius: 10px;
	cursor: pointer;
	font: inherit;
	font-weight: 600;
	line-height: 1.45;
	text-align: left;
	text-decoration: none;
}

.wp-ai-chat .wp-ai-chat__choice:hover,
.wp-ai-chat .wp-ai-chat__choice:focus {
	color: #1e40af;
	background: #dbeafe;
	border-color: #93c5fd;
	outline: none;
}

.wp-ai-chat .wp-ai-chat__choice.wp-ai-chat__choice--link {
	color: #1d4ed8;
	text-decoration: none;
}

.wp-ai-chat__guide-nav {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin-top: 14px;
}

.wp-ai-chat .wp-ai-chat__guide-nav-button,
.wp-ai-chat__context button {
	margin: 0;
	padding: 5px 8px;
	color: #475569;
	background: transparent;
	border: 0;
	cursor: pointer;
	font: inherit;
	font-size: 12px;
	text-decoration: underline;
}

.wp-ai-chat__message--assistant .wp-ai-chat__bubble a {
	color: #1d4ed8;
	font-weight: 600;
	text-decoration: underline;
	text-underline-offset: 2px;
}

.wp-ai-chat__message--assistant .wp-ai-chat__bubble a:hover,
.wp-ai-chat__message--assistant .wp-ai-chat__bubble a:focus {
	color: #1e40af;
}

.wp-ai-chat__message--loading .wp-ai-chat__bubble {
	color: #6b7280;
	font-style: italic;
}

.wp-ai-chat__message--error .wp-ai-chat__bubble {
	color: #991b1b;
	background: #fff1f2;
	border-color: #fecdd3;
}

.wp-ai-chat__message--user .wp-ai-chat__bubble {
	color: #fff;
	background: #2563eb;
	border-bottom-right-radius: 5px;
}

.wp-ai-chat__composer {
	background: #fff;
	border-top: 1px solid #e5e7eb;
}

.wp-ai-chat__context {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	padding: 8px 16px 0;
	color: #475569;
	font-size: 12px;
	line-height: 1.4;
}

.wp-ai-chat__toolbar {
	display: flex;
	justify-content: flex-end;
	padding: 6px 12px 0;
	margin-bottom: 6px;
}

.wp-ai-chat .wp-ai-chat__new-question {
	padding: 3px 8px;
	border: 0;
	background: transparent;
	color: #315b91;
	font-size: 12px;
	text-decoration: underline;
	cursor: pointer;
}

.wp-ai-chat__feedback {
	display: flex;
	gap: 6px;
	align-items: center;
	margin: 5px 0 0 12px;
	font-size: 12px;
	color: #5f6b7a;
}

.wp-ai-chat__feedback button {
	padding: 2px 8px;
	border: 1px solid #c8d2df;
	border-radius: 12px;
	background: #fff;
	color: #315b91;
	cursor: pointer;
}

.wp-ai-chat__feedback button:disabled {
	opacity: 0.6;
	cursor: default;
}

.wp-ai-chat__compatibility-gate {
	display: grid;
	gap: 9px;
	max-width: 440px;
	margin: 12px 0 0;
	padding: 12px;
	border: 1px solid #bfdbfe;
	border-radius: 10px;
	background: #eff6ff;
	font-size: 13px;
}

.wp-ai-chat__compatibility-faq {
	font-weight: 700;
}

.wp-ai-chat__compatibility-check {
	display: flex;
	gap: 7px;
	align-items: center;
	cursor: pointer;
}

.wp-ai-chat__compatibility-check input {
	width: 16px;
	height: 16px;
	margin: 0;
}

.wp-ai-chat .wp-ai-chat__compatibility-proceed {
	justify-self: start;
	padding: 8px 12px;
	border: 0;
	border-radius: 7px;
	background: #2563eb;
	color: #fff;
	font-weight: 700;
	cursor: pointer;
}

.wp-ai-chat .wp-ai-chat__compatibility-proceed:disabled {
	opacity: 0.45;
	cursor: default;
}

.wp-ai-chat__compatibility-status {
	min-height: 1.4em;
	color: #475569;
	font-size: 12px;
}

.wp-ai-chat__form {
	display: flex;
	align-items: flex-end;
	gap: 10px;
	padding: 16px 16px 4px;
}

.wp-ai-chat__input-hint {
	margin: 0;
	padding: 0 16px 10px;
	color: #6b7280;
	font-size: 12px;
	line-height: 1.4;
	text-align: right;
}

.wp-ai-chat__inquiry-handoff {
	margin-top: 12px;
	padding-top: 12px;
	border-top: 1px solid #d8e2ef;
}

.wp-ai-chat__inquiry-link {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 42px;
	padding: 8px 16px;
	border-radius: 7px;
	background: #1769c2;
	color: #fff !important;
	font-weight: 700;
	line-height: 1.4;
	text-decoration: none !important;
}

.wp-ai-chat__inquiry-link:hover,
.wp-ai-chat__inquiry-link:focus-visible {
	background: #0f4f96;
}

.wp-ai-chat__handoff-notice {
	margin: 0 0 16px;
	padding: 12px 14px;
	border-left: 4px solid #1769c2;
	background: #eef6ff;
	color: #07325d;
	font-weight: 700;
}

.wp-ai-chat__log-notice {
	margin: 0;
	padding: 0 16px 10px;
	color: #64748b;
	font-size: 11px;
	line-height: 1.4;
	text-align: left;
}

.wp-ai-chat .wp-ai-chat__input {
	flex: 1;
	width: auto;
	min-height: 46px;
	max-height: 140px;
	margin: 0;
	padding: 11px 14px;
	resize: none;
	color: #111827;
	background: #fff;
	border: 1px solid #cbd0d8;
	border-radius: 12px;
	box-shadow: none;
	font: inherit;
	font-size: 16px;
	line-height: 1.4;
}

.wp-ai-chat .wp-ai-chat__input:focus {
	border-color: #2563eb;
	box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
	outline: none;
}

.wp-ai-chat .wp-ai-chat__submit {
	min-width: 78px;
	height: 46px;
	margin: 0;
	padding: 0 18px;
	color: #fff;
	background: #2563eb;
	border: 0;
	border-radius: 12px;
	cursor: pointer;
	font: inherit;
	font-weight: 600;
	line-height: 1;
	transition: background-color 0.15s ease, transform 0.15s ease;
}

.wp-ai-chat .wp-ai-chat__submit:hover,
.wp-ai-chat .wp-ai-chat__submit:focus {
	color: #fff;
	background: #1d4ed8;
}

.wp-ai-chat .wp-ai-chat__submit:focus-visible {
	box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.22);
	outline: none;
}

.wp-ai-chat .wp-ai-chat__submit:active {
	transform: translateY(1px);
}

.wp-ai-chat .wp-ai-chat__input:disabled,
.wp-ai-chat .wp-ai-chat__submit:disabled {
	cursor: not-allowed;
	opacity: 0.6;
}

@media (max-width: 600px) {
	.wp-ai-chat {
		height: min(560px, 78vh);
		min-height: 380px;
		margin: 16px auto;
		border-radius: 12px;
	}

	.wp-ai-chat__history {
		padding: 16px;
	}

	.wp-ai-chat__bubble {
		max-width: 90%;
	}

	.wp-ai-chat__form {
		gap: 8px;
		padding: 12px 12px 4px;
	}

	.wp-ai-chat__input-hint {
		padding: 0 12px 8px;
	}

	.wp-ai-chat .wp-ai-chat__submit {
		min-width: 64px;
		padding: 0 12px;
	}
}
