/* ================================================================
 * SOA AI Chat — v1.9.281
 * 雲の上の AI チャット UI
 * ================================================================ */

.soa-ai-chat {
	position: fixed;
	bottom: 24px;
	right: 24px;
	z-index: 9998;
	font-family: 'Shippori Mincho', 'Noto Serif JP', 'Hiragino Mincho ProN', serif;
}

/* ============================================================
 * ランチャーボタン
 * ============================================================ */
.soa-ai-chat__launcher {
	display: inline-flex;
	align-items: center;
	gap: 10px;
	padding: 14px 24px 14px 18px;
	background: linear-gradient(135deg, #0a1628 0%, #0e2138 100%);
	color: #ffffff;
	border: 1px solid rgba(184, 153, 104, 0.5);
	border-radius: 40px;
	cursor: pointer;
	font-family: inherit;
	font-size: 14px;
	letter-spacing: 0.08em;
	font-weight: 500;
	box-shadow:
		0 12px 36px rgba(0, 0, 0, 0.35),
		0 0 24px rgba(184, 153, 104, 0.15),
		inset 0 0 16px rgba(184, 153, 104, 0.08);
	transition: all 0.5s cubic-bezier(0.22, 1, 0.36, 1);
	position: relative;
	overflow: hidden;
}
.soa-ai-chat__launcher::before {
	content: "";
	position: absolute;
	inset: 0;
	background: linear-gradient(135deg, rgba(184, 153, 104, 0.20) 0%, transparent 60%);
	opacity: 0;
	transition: opacity 0.5s ease;
}
.soa-ai-chat__launcher:hover {
	transform: translateY(-3px);
	border-color: #b89968;
	box-shadow:
		0 16px 48px rgba(0, 0, 0, 0.45),
		0 0 40px rgba(184, 153, 104, 0.3);
}
.soa-ai-chat__launcher:hover::before { opacity: 1; }

.soa-ai-chat__launcher-icon {
	width: 20px;
	height: 20px;
	color: #d4c4a0;
	position: relative;
	z-index: 1;
	flex-shrink: 0;
}
.soa-ai-chat__launcher-label {
	position: relative;
	z-index: 1;
	white-space: nowrap;
}

/* 脈動パルス */
.soa-ai-chat__launcher-pulse {
	position: absolute;
	top: 14px;
	right: 16px;
	width: 8px;
	height: 8px;
	background: #b89968;
	border-radius: 50%;
	box-shadow: 0 0 0 0 rgba(184, 153, 104, 0.7);
	animation: soa-aichat-pulse 2.4s ease-out infinite;
}
@keyframes soa-aichat-pulse {
	0%   { box-shadow: 0 0 0 0 rgba(184, 153, 104, 0.7); }
	70%  { box-shadow: 0 0 0 12px rgba(184, 153, 104, 0); }
	100% { box-shadow: 0 0 0 0 rgba(184, 153, 104, 0); }
}

/* 開いている時はランチャー非表示 */
.soa-ai-chat[data-open="true"] .soa-ai-chat__launcher { display: none; }

/* ============================================================
 * パネル本体
 * ============================================================ */
.soa-ai-chat__panel {
	position: fixed;
	bottom: 24px;
	right: 24px;
	width: 380px;
	max-width: calc(100vw - 32px);
	height: 580px;
	max-height: calc(100vh - 48px);
	background: linear-gradient(180deg, #050a16 0%, #0a1628 100%);
	border: 1px solid rgba(184, 153, 104, 0.4);
	border-radius: 16px;
	display: flex;
	flex-direction: column;
	overflow: hidden;
	box-shadow:
		0 30px 80px rgba(0, 0, 0, 0.6),
		0 0 60px rgba(184, 153, 104, 0.2);
	color: #ffffff;
	transform: translateY(20px) scale(0.96);
	opacity: 0;
	transition: transform 0.45s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.45s ease;
}
.soa-ai-chat[data-open="true"] .soa-ai-chat__panel {
	transform: translateY(0) scale(1);
	opacity: 1;
}

/* ============================================================
 * ヘッダー
 * ============================================================ */
.soa-ai-chat__header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 18px 20px;
	border-bottom: 1px solid rgba(184, 153, 104, 0.18);
	background: linear-gradient(180deg, rgba(184, 153, 104, 0.05) 0%, transparent 100%);
}
.soa-ai-chat__brand {
	display: flex;
	align-items: center;
	gap: 12px;
}
.soa-ai-chat__brand-dot {
	width: 10px;
	height: 10px;
	border-radius: 50%;
	background: #6dd28f;
	box-shadow: 0 0 12px rgba(109, 210, 143, 0.6);
	animation: soa-aichat-dot 2s ease-in-out infinite;
}
@keyframes soa-aichat-dot {
	0%, 100% { opacity: 0.7; transform: scale(1); }
	50%      { opacity: 1;   transform: scale(1.15); }
}
.soa-ai-chat__brand-text {
	display: flex;
	flex-direction: column;
	line-height: 1.3;
}
.soa-ai-chat__brand-name {
	font-family: 'JetBrains Mono', monospace;
	font-size: 13px;
	color: #d4c4a0;
	letter-spacing: 0.12em;
	font-weight: 500;
}
.soa-ai-chat__brand-status {
	font-size: 10px;
	color: rgba(255, 255, 255, 0.55);
	letter-spacing: 0.1em;
	margin-top: 2px;
}
.soa-ai-chat__close {
	background: transparent;
	border: 1px solid rgba(184, 153, 104, 0.3);
	border-radius: 50%;
	width: 32px;
	height: 32px;
	cursor: pointer;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	color: #d4c4a0;
	transition: all 0.3s ease;
}
.soa-ai-chat__close:hover {
	background: rgba(184, 153, 104, 0.1);
	border-color: #b89968;
	transform: rotate(90deg);
}
.soa-ai-chat__close svg { width: 14px; height: 14px; }

/* ============================================================
 * メッセージリスト
 * ============================================================ */
.soa-ai-chat__messages {
	flex: 1;
	overflow-y: auto;
	padding: 20px;
	display: flex;
	flex-direction: column;
	gap: 16px;
	scrollbar-width: thin;
	scrollbar-color: rgba(184, 153, 104, 0.3) transparent;
}
.soa-ai-chat__messages::-webkit-scrollbar {
	width: 4px;
}
.soa-ai-chat__messages::-webkit-scrollbar-thumb {
	background: rgba(184, 153, 104, 0.3);
	border-radius: 2px;
}

.soa-ai-chat__msg {
	display: flex;
	gap: 10px;
	animation: soa-aichat-msg-in 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes soa-aichat-msg-in {
	from { opacity: 0; transform: translateY(8px); }
	to   { opacity: 1; transform: translateY(0); }
}

.soa-ai-chat__msg--ai {
	align-self: flex-start;
	max-width: 92%;
}
.soa-ai-chat__msg--user {
	align-self: flex-end;
	max-width: 88%;
	flex-direction: row-reverse;
}

.soa-ai-chat__avatar {
	flex-shrink: 0;
	width: 32px;
	height: 32px;
	border-radius: 50%;
	background: linear-gradient(135deg, #b89968 0%, #d4c4a0 100%);
	display: inline-flex;
	align-items: center;
	justify-content: center;
	font-family: 'JetBrains Mono', monospace;
	font-size: 14px;
	font-weight: 600;
	color: #0a1628;
	letter-spacing: 0;
	box-shadow: 0 4px 12px rgba(184, 153, 104, 0.3);
}
.soa-ai-chat__msg--user .soa-ai-chat__avatar { display: none; }

.soa-ai-chat__bubble {
	padding: 12px 16px;
	border-radius: 14px;
	font-size: 14px;
	line-height: 1.7;
	letter-spacing: 0.02em;
	word-break: break-word;
}
.soa-ai-chat__msg--ai .soa-ai-chat__bubble {
	background: rgba(184, 153, 104, 0.08);
	border: 1px solid rgba(184, 153, 104, 0.18);
	color: rgba(255, 255, 255, 0.92);
	border-top-left-radius: 4px;
}
.soa-ai-chat__msg--user .soa-ai-chat__bubble {
	background: linear-gradient(135deg, #b89968 0%, #9d7f50 100%);
	color: #ffffff;
	border-top-right-radius: 4px;
	box-shadow: 0 4px 12px rgba(184, 153, 104, 0.2);
}

/* タイピングインジケーター */
.soa-ai-chat__typing {
	display: inline-flex;
	gap: 4px;
	padding: 4px 0;
}
.soa-ai-chat__typing-dot {
	width: 6px;
	height: 6px;
	background: #d4c4a0;
	border-radius: 50%;
	animation: soa-aichat-typing 1.2s infinite ease-in-out;
}
.soa-ai-chat__typing-dot:nth-child(2) { animation-delay: 0.2s; }
.soa-ai-chat__typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes soa-aichat-typing {
	0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
	30%           { opacity: 1;   transform: translateY(-4px); }
}

/* フィードバックボタン */
.soa-ai-chat__feedback {
	display: flex;
	gap: 8px;
	margin-top: 8px;
	padding-left: 42px;
	opacity: 0.6;
	transition: opacity 0.3s ease;
}
.soa-ai-chat__feedback:hover { opacity: 1; }
.soa-ai-chat__fb-btn {
	background: transparent;
	border: 1px solid rgba(184, 153, 104, 0.3);
	border-radius: 50%;
	width: 26px;
	height: 26px;
	cursor: pointer;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	color: rgba(212, 196, 160, 0.7);
	font-size: 11px;
	transition: all 0.3s ease;
}
.soa-ai-chat__fb-btn:hover { background: rgba(184, 153, 104, 0.1); color: #d4c4a0; }
.soa-ai-chat__fb-btn[data-active="true"] { background: rgba(184, 153, 104, 0.15); color: #ffffff; border-color: #b89968; }

/* ============================================================
 * 入力フォーム
 * ============================================================ */
.soa-ai-chat__form {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	padding: 14px 16px;
	border-top: 1px solid rgba(184, 153, 104, 0.18);
	background: rgba(8, 18, 35, 0.6);
}
.soa-ai-chat__input {
	flex: 1;
	background: rgba(255, 255, 255, 0.04);
	border: 1px solid rgba(184, 153, 104, 0.25);
	border-radius: 10px;
	padding: 10px 12px;
	font-family: inherit;
	font-size: 14px;
	line-height: 1.6;
	color: #ffffff;
	resize: none;
	max-height: 120px;
	overflow-y: auto;
	transition: border-color 0.3s ease;
}
.soa-ai-chat__input:focus {
	outline: none;
	border-color: #b89968;
	background: rgba(255, 255, 255, 0.06);
}
.soa-ai-chat__input::placeholder {
	color: rgba(255, 255, 255, 0.4);
}

.soa-ai-chat__send {
	flex-shrink: 0;
	width: 38px;
	height: 38px;
	border: 1px solid rgba(184, 153, 104, 0.4);
	background: linear-gradient(135deg, #b89968 0%, #9d7f50 100%);
	border-radius: 10px;
	cursor: pointer;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	color: #0a1628;
	transition: all 0.3s ease;
}
.soa-ai-chat__send:hover:not(:disabled) {
	transform: translateY(-2px);
	box-shadow: 0 6px 16px rgba(184, 153, 104, 0.4);
}
.soa-ai-chat__send:disabled {
	opacity: 0.5;
	cursor: not-allowed;
}
.soa-ai-chat__send svg { width: 16px; height: 16px; }

/* ============================================================
 * フッター
 * ============================================================ */
.soa-ai-chat__footer {
	padding: 8px 16px 12px;
	background: rgba(0, 0, 0, 0.25);
	border-top: 1px solid rgba(184, 153, 104, 0.1);
}
.soa-ai-chat__footer-text {
	font-size: 10px;
	color: rgba(255, 255, 255, 0.45);
	letter-spacing: 0.04em;
	line-height: 1.5;
}
.soa-ai-chat__footer-text a {
	color: #d4c4a0;
	text-decoration: none;
}
.soa-ai-chat__footer-text a:hover { text-decoration: underline; }

/* ============================================================
 * モバイル
 * ============================================================ */
@media (max-width: 480px) {
	.soa-ai-chat { bottom: 16px; right: 16px; left: 16px; }
	.soa-ai-chat__panel {
		bottom: 16px;
		right: 16px;
		left: 16px;
		width: auto;
		height: calc(100vh - 32px);
		max-height: 100vh;
		border-radius: 12px;
	}
	.soa-ai-chat__launcher {
		padding: 12px 18px;
		font-size: 13px;
	}
	.soa-ai-chat__launcher-label {
		display: none;
	}
	.soa-ai-chat__launcher {
		padding: 14px;
		border-radius: 50%;
	}
	.soa-ai-chat__launcher-pulse {
		top: 6px;
		right: 6px;
	}
}

/* 既存「無料相談する」ボタンとの位置調整：
 * 既存ボタンも fixed bottom-right にある場合、AIチャットを上にずらす */
@media (min-width: 481px) {
	body .soa-ai-chat {
		bottom: 24px;
		right: 24px;
	}
	body .soa-ai-chat__panel {
		bottom: 84px;
	}
}
