/* =========================
	Memberpress_Chat - Floating Side Button + Modal Chat UI
========================= */

/* ---------- Floating side box (right side) ---------- */
.mpchat-floatbox {
	position: fixed;
	right: 0;
	right: constant(safe-area-inset-right);
	right: env(safe-area-inset-right, 0px);
	top: 45%;
	transform: translateY(-50%);
	z-index: 99999;

	border: 1px solid rgba(0,0,0,0.12);
	border-right: none;
	background: #ffffff;
	box-shadow: 0 10px 26px rgba(0,0,0,0.14);
	border-radius: 12px 0 0 12px;

	padding: 0;
	cursor: pointer;
}

.mpchat-floatbox-text {
	display: block;
	width: 45px;
	padding: 14px 12px;
	font-size: 14px;
	font-weight: 600;
	letter-spacing: 0.02em;
	font-family: system-ui, -apple-system, Segoe UI, Roboto, "Hiragino Kaku Gothic ProN", "Noto Sans JP", sans-serif;

	/* Vertical label (desktop) */
	writing-mode: vertical-rl;
	text-orientation: mixed;
}

.mpchat-floatbox:hover {
	box-shadow: 0 14px 34px rgba(0,0,0,0.18);
}

.mpchat-floatbox:focus {
	outline: 3px solid rgba(0,0,0,0.18);
	outline-offset: 2px;
}

/* ---------- Modal base ---------- */
.mpchat-modal {
	position: fixed;
	inset: 0;
	z-index: 100000;
	display: none;
}

.mpchat-modal.is-open {
	display: block;
}

.mpchat-modal-backdrop {
	position: absolute;
	inset: 0;
	background: rgba(0,0,0,0.45);
}

/* Default: open panel from bottom-right */
.mpchat-modal-panel {
	position: fixed;	 /* absolute でも動くが fixed の方が自然 */
	left: 16px;
	top: 16px;

	/* 初期表示：画面ほぼ最大 */
	width: calc(100vw - 32px);
	height: calc(100vh - 32px);

	max-width: calc(100vw - 32px);
	max-height: calc(100vh - 32px);

	background: #fff;
	border-radius: 12px;
	box-shadow: 0 18px 40px rgba(0,0,0,0.22);
	border: 1px solid rgba(0,0,0,0.08);

	display: flex;
	flex-direction: column;

	resize: both;
	overflow: auto;

	min-width: 360px;
	min-height: 320px;

	font-size: 15px;
}

/* ---------- Header ---------- */
.mpchat-header {
	padding: 10px 12px;
	border-bottom: 1px solid #eee;
	background: #fafafa;
	display: flex;
	align-items: center;
	justify-content: space-between;
	cursor: move;
	user-select: none;
	-webkit-user-select: none;
	touch-action: none; /* スマホ/タブレットでのドラッグを安定させる */
}


.mpchat-title {
	font-weight: 600;
}

.mpchat-close {
	border: 1px solid #ddd;
	background: #fff;
	border-radius: 8px;
	width: 34px;
	height: 34px;
	line-height: 32px;
	cursor: pointer;
}

/* ---------- Messages ---------- */
.mpchat-messages {
	flex: 1;
	overflow: auto;
	padding: 12px;
	background: #fff;
}

/* ---------- Membership row ---------- */
.mpchat-membership-row {
	padding: 10px 12px;
	border-top: 1px solid #eee;
	background: #fff;
	display: flex;
	gap: 8px;
	align-items: center;
}

.mpchat-membership-label {
	font-size: 12px;
	opacity: 0.8;
	white-space: nowrap;
}

.mpchat-membership {
	flex: 1;
	padding: 8px;
	border: 1px solid #ddd;
	border-radius: 8px;
}

/* ---------- Form ---------- */
.mpchat-form {
	display: flex;
	gap: 8px;
	padding: 10px;
	border-top: 1px solid #eee;
	background: #fafafa;
}

.mpchat-input {
	flex: 1;
	padding: 10px;
	border: 1px solid #ddd;
	border-radius: 8px;
}

.mpchat-send {
	padding: 10px 14px;
	border: 1px solid #ddd;
	border-radius: 8px;
	background: #fff;
	cursor: pointer;
}

/* ---------- Message bubbles ---------- */
.mpchat-msg {
	display: flex;
	margin: 10px 0;
}

.mpchat-bubble-box {
	padding: 10px 12px;
	border-radius: 10px;
	border: 1px solid #eee;
	width: 70%;
	max-width: 70%;
	line-height: 1.5;
	background: #f8f8f8;
}

.mpchat-user {
	justify-content: flex-end;
}

.mpchat-user .mpchat-bubble-box {
	background: #f3f7ff;
}

.mpchat-assistant {
	justify-content: flex-start;
}

.mpchat-system {
	justify-content: center;
}

.mpchat-system .mpchat-bubble-box {
	background: #fffbe6;
	border-color: #ffe58f;
}

/* ---------- Markdown basics ---------- */
.mpchat-bubble-box pre {
	overflow: auto;
	padding: 10px;
	border-radius: 8px;
	background: #111;
	color: #fff;
	font-size: 14px;
}

.mpchat-bubble-box code {
	font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
	font-size: 14px;
}

/* Mermaid container */
.mpchat-bubble-box .mermaid {
	overflow: auto;
}

/* ---------- Responsive (mobile) ---------- */
@media (max-width: 600px) {
	.mpchat-modal-panel {
		left: 10px;
		top: 10px;
		right: 10px;
		bottom: 10px;
		max-width: calc(100vw - 20px);
		max-height: calc(100vh - 20px);
		min-width: auto;
		min-height: auto;
	}
	.mpchat-bubble-box {
		max-width: 90%;
	}
}