/**
 * 責務: ウィジェットの見た目のみ。JSの状態管理には関与しない
 *       （data-state属性はJS(ui.js)側が付与する）。
 */

.ai-voice-operator-widget {
	max-width: 320px;
	margin: 1.5em auto;
	padding: 1.5em;
	border-radius: 12px;
	background: #f7f7f8;
	text-align: center;
	font-family: inherit;
}

.ai-voice-operator-widget__mic {
	width: 64px;
	height: 64px;
	border-radius: 50%;
	border: none;
	background: #2271b1;
	color: #fff;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	transition: background-color 0.2s ease;
}

.ai-voice-operator-widget__mic-icon {
	pointer-events: none;
}

.ai-voice-operator-widget[data-state="user_speaking"] .ai-voice-operator-widget__mic,
.ai-voice-operator-widget[data-state="listening"] .ai-voice-operator-widget__mic {
	background: #d63638;
}

.ai-voice-operator-widget__status {
	margin: 0.75em 0 0;
	font-size: 0.9em;
	color: #555;
}

.ai-voice-operator-widget__avatar-wrap {
	position: relative;
	width: 240px;
	height: 240px;
	margin: 0.75em auto;
}

.ai-voice-operator-widget__particles {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	pointer-events: none;
}

.ai-voice-operator-widget__avatar {
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	width: 96px;
	height: 96px;
	border-radius: 50%;
	background: #ccc;
	overflow: hidden;
	transition: background-color 0.2s ease;
}

.ai-voice-operator-widget__avatar[data-state="speaking"] {
	background: #2271b1;
}

.ai-voice-operator-widget__avatar-image {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.ai-voice-operator-widget__reply {
	margin: 0.5em 0 0;
	font-size: 0.85em;
	text-align: left;
	
	/* 英語が単語の途中で折り返されないよう、標準の単語区切りを維持します */
	word-break: normal;
	overflow-wrap: break-word;
	
	/* 英語特有の合字（ffやfiなどが繋がる現象）による、文字のチラつき（点滅）を防止します。 */
	font-variant-ligatures: none;
	
	line-height: 1.5;
	/* 5行以上の長文が来た際に枠が上下に揺れるのを防ぐため、高さを固定してスクロール可能にします */
	height: 7.5em; /* 1.5 * 5 lines = 7.5em */
	overflow-y: auto;
	/* スクロールバーが出現した際にテキストの折り返し位置が変わってレイアウトシフトするのを防ぐ */
	scrollbar-gutter: stable;
}

/* オペレーターのセリフを1文字ずつ表示している間、「通話終了」ボタンの代わりに
   表示する点滅カーソル（テキストエディタのカーソルのような縦棒）。 */
.ai-voice-operator-widget__cursor {
	display: inline-block;
	width: 2px;
	height: 1em;
	margin-left: 0.15em;
	background: currentColor;
	/* text-bottomは行のディセンダー分の余白まで含めた最下端に揃うため、
	   文字本体より下にズレて見えていた。baseline（文字のベースライン、
	   ディセンダーの無い文字の下端）に揃えることで、セリフの文字と
	   同じ高さに合わせる（v0.24.15）。 */
	vertical-align: baseline;
	animation: ai-voice-operator-cursor-blink 1s step-start infinite;
}

@keyframes ai-voice-operator-cursor-blink {
	50% {
		opacity: 0;
	}
}

.ai-voice-operator-widget__text-input-wrap {
	position: relative;
	margin: 0.75em 0 0;
}

.ai-voice-operator-widget__text-input {
	width: 100%;
	padding: 0.6em 2.4em 0.6em 0.8em;
	border: 1px solid #ccc;
	border-radius: 999px;
	font-size: 0.9em;
	box-sizing: border-box;
}

.ai-voice-operator-widget__text-send {
	position: absolute;
	top: 50%;
	right: 0.3em;
	transform: translateY( -50% );
	width: 1.9em;
	height: 1.9em;
	padding: 0;
	border: none;
	border-radius: 50%;
	background: #2271b1;
	color: #fff;
	font-size: 0.9em;
	line-height: 1;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
}

.ai-voice-operator-auth__avatar {
	width: 96px;
	height: 96px;
	margin: 0 auto 0.75em;
	border-radius: 50%;
	overflow: hidden;
	background: #ccc;
}

.ai-voice-operator-auth__avatar img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.ai-voice-operator-auth {
	display: flex;
	flex-direction: column;
	gap: 0.75em;
	text-align: left;
}

.ai-voice-operator-auth__notice {
	font-size: 0.8em;
	color: #666;
	white-space: pre-line;
}

.ai-voice-operator-auth__field {
	display: flex;
	flex-direction: column;
	gap: 0.3em;
	font-size: 0.9em;
}

.ai-voice-operator-auth__field input {
	padding: 0.5em;
	border: 1px solid #ccc;
	border-radius: 6px;
}

.ai-voice-operator-auth__remember {
	display: flex;
	align-items: center;
	gap: 0.4em;
	font-size: 0.85em;
}

.ai-voice-operator-auth button {
	padding: 0.6em;
	border: none;
	border-radius: 6px;
	background: #2271b1;
	color: #fff;
	cursor: pointer;
}

.ai-voice-operator-auth__message {
	font-size: 0.85em;
	color: #d63638;
	min-height: 1em;
}

.ai-voice-operator-auth__message:empty {
	display: none;
}

.ai-voice-operator-auth__method-heading {
	margin: 0;
	text-align: center;
	font-size: 0.9em;
	color: #444;
}

.ai-voice-operator-auth__method-choices {
	display: flex;
	gap: 0.75em;
	justify-content: center;
}

/* NOTE: 直上の `.ai-voice-operator-auth button`（クラス+要素＝詳細度0,1,1）より
   詳細度を上げるため、`.ai-voice-operator-auth` を親に付けたセレクタにしている
   （単に `.ai-voice-operator-auth__method-choice` 単体（0,1,0）だと詳細度で
   負けて上記の濃い青背景が優先されてしまい、ロゴが見えにくくなる不具合があった）。*/
.ai-voice-operator-auth .ai-voice-operator-auth__method-choice {
	flex: 1;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 0.4em;
	padding: 1em 0.5em;
	background: #f1f3f4;
	color: #3c4043;
	border: none;
	border-radius: 10px;
	font-size: 0.85em;
	font-weight: 500;
	transition: background-color 0.15s ease, color 0.15s ease;
}

.ai-voice-operator-auth .ai-voice-operator-auth__method-choice:hover {
	background: #2271b1;
	color: #fff;
}

.ai-voice-operator-auth__method-icon {
	display: flex;
	align-items: center;
	justify-content: center;
}

.ai-voice-operator-auth .ai-voice-operator-auth__back-link {
	align-self: flex-start;
	padding: 0;
	background: none;
	color: #2271b1;
	font-size: 0.85em;
	text-decoration: underline;
}

/* オペレーターのセリフ末尾にインラインで表示する「通話終了」ボタン。
   文字の高さと同じ小さめのサイズ・横長・角丸。平常時は塗りつぶし、
   ロールオーバーで枠線のみの反転デザインになる。 */
.ai-voice-operator-widget__end {
	display: inline-block;
	margin-left: 0.5em;
	padding: 0 0.6em;
	border: 1px solid #d63638;
	border-radius: 1em;
	background: #d63638;
	color: #fff;
	font-size: 1em;
	line-height: 1.4;
	white-space: nowrap;
	vertical-align: baseline;
	cursor: pointer;
	transition: background-color 0.15s ease, color 0.15s ease;
}

.ai-voice-operator-widget__end:hover {
	background: none;
	color: #d63638;
}

.ai-voice-operator-widget__close-guidance {
	margin: 1em 0 0.5em;
	font-size: 0.85em;
	color: #555;
}

.ai-voice-operator-widget__rating {
	display: flex;
	justify-content: center;
	gap: 0.3em;
}

.ai-voice-operator-widget__star {
	padding: 0;
	border: none;
	background: none;
	font-size: 1.8em;
	line-height: 1;
	color: #ccc;
	opacity: 0.5;
	cursor: pointer;
	transition: opacity 0.15s ease, color 0.15s ease;
}

.ai-voice-operator-widget__star.is-active {
	color: #f0b429;
	opacity: 1;
}

/* 点滅カーソル・「通話終了」ボタンの表示/非表示専用ユーティリティクラス
   （ui.js::updateEndButtonForState()がclassList.toggle()で付け外しする）。
   display:noneで確実に非表示にするため、他の各要素のスタイル定義より
   後方に置き、詳細度が同じ場合でもソース順でこちらを優先させる（v0.24.13）。 */
.is-hidden {
	display: none;
}

/* TODO: ダークモード対応、アニメーションの追加 */

/* チラつき防止ロジック用：各文字spanにカーソルを絶対配置するための基準 */
.ai-voice-operator-widget__reply [data-role="reply-text"] span {
    position: relative;
}

/* タイピング中の現在文字にカーソルを重ねる（レイアウトシフトなし） */
.ai-voice-operator-widget__reply [data-role="reply-text"] span.is-typing::after {
    content: '';
    position: absolute;
    right: -0.15em;
    top: 50%;
    transform: translateY(-50%);
    width: 2px;
    height: 1.1em;
    background: currentColor;
    animation: ai-voice-operator-cursor-blink 1s step-start infinite;
}
