/* =========================================================
   AI店員アバター アシスタント
   SmartDesigner QR Order System のティールテーマに合わせる
   ========================================================= */

/* ---------- アバター起動ボタン ---------- */
.avatar-button {
  border-radius: 999px;
  white-space: nowrap;
  font-weight: 600;
}

/* ---------- 会話パネル（PC: 右下フローティング） ---------- */
.avatar-panel {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: 360px;
  max-width: calc(100vw - 24px);
  max-height: calc(100vh - 40px);
  background: var(--sd-surface, #fff);
  border: 1px solid var(--sd-border, #e3e9ef);
  border-radius: var(--sd-radius, 14px);
  box-shadow: 0 16px 48px rgba(15, 41, 66, 0.22);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 1080;
  animation: avatar-pop-in 0.18s ease-out;
}

.avatar-panel.d-none {
  display: none !important;
}

@keyframes avatar-pop-in {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ---------- ヘッダー ---------- */
.avatar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 0.9rem;
  background: linear-gradient(90deg, var(--sd-teal, #1bb6a6) 0%, var(--sd-teal-600, #149e90) 100%);
  color: #fff;
  font-weight: 600;
}

.avatar-header .avatar-header-title {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.avatar-close-button {
  background: transparent;
  border: none;
  color: #fff;
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 0.25rem;
  border-radius: 6px;
}

.avatar-close-button:hover {
  background: rgba(255, 255, 255, 0.18);
}

/* ---------- 本体 ---------- */
.avatar-body {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: 0.9rem;
  gap: 0.7rem;
  overflow: hidden;
  min-height: 0;
}

.avatar-image-wrap {
  display: flex;
  justify-content: center;
  position: relative;
}

.avatar-image {
  width: 200px;
  height: 200px;
  object-fit: contain;
  border-radius: 50%;
  background: var(--sd-teal-100, #e2f7f4);
  border: 3px solid var(--sd-teal-100, #e2f7f4);
}

/* 画像が未配置でも崩れないようにするフォールバックの円 */
.avatar-image-wrap.is-missing::after {
  content: "👩‍🍳";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 4rem;
  background: var(--sd-teal-100, #e2f7f4);
  border-radius: 50%;
}

/* listening 状態のパルス。円が大きくなって戻る動き（scale）と、
   外側に広がる輪（box-shadow）を組み合わせて「聞いています」を視覚化する。 */
.avatar-image.is-listening {
  animation: avatar-listening-pulse 1.2s ease-in-out infinite;
}

@keyframes avatar-listening-pulse {
  0% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(27, 182, 166, 0.5);
  }
  50% {
    transform: scale(1.06);
    box-shadow: 0 0 0 14px rgba(27, 182, 166, 0);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(27, 182, 166, 0);
  }
}

/* ---------- ステータス表示 ---------- */
.avatar-status {
  text-align: center;
  font-size: 0.9rem;
  color: var(--sd-muted, #6b7c8f);
  min-height: 1.3em;
}

.avatar-status .avatar-dots span {
  animation: avatar-dot-blink 1.2s infinite both;
}

.avatar-status .avatar-dots span:nth-child(2) { animation-delay: 0.2s; }
.avatar-status .avatar-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes avatar-dot-blink {
  0%, 80%, 100% { opacity: 0.2; }
  40% { opacity: 1; }
}

/* ---------- 会話ログ ---------- */
.avatar-transcript {
  flex: 1 1 auto;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  padding: 0.25rem;
  max-height: 220px;
  min-height: 64px;
}

.avatar-message {
  padding: 0.5rem 0.75rem;
  border-radius: 14px;
  font-size: 0.9rem;
  line-height: 1.45;
  max-width: 85%;
  word-break: break-word;
  white-space: pre-wrap;
}

.avatar-message.user {
  align-self: flex-end;
  background: var(--sd-teal, #1bb6a6);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.avatar-message.assistant {
  align-self: flex-start;
  background: var(--sd-teal-100, #e2f7f4);
  color: var(--sd-ink, #1c2b39);
  border-bottom-left-radius: 4px;
}

/* ---------- 入力エリア ---------- */
.avatar-input-row {
  display: flex;
  gap: 0.4rem;
}

.avatar-input-row .form-control {
  font-size: 0.9rem;
}

.avatar-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.avatar-actions .btn {
  flex: 1 1 auto;
  font-weight: 600;
}

.avatar-mic-button.is-recording {
  animation: avatar-mic-flash 1s ease-in-out infinite;
}

@keyframes avatar-mic-flash {
  0%, 100% { filter: none; }
  50% { filter: brightness(1.25); }
}

/* ---------- スマホ: 下から出るボトムシート風 ---------- */
@media (max-width: 575.98px) {
  .avatar-panel {
    right: 0;
    left: 0;
    bottom: 0;
    width: 100%;
    max-width: 100%;
    max-height: 88vh;
    border-radius: 18px 18px 0 0;
    animation: avatar-slide-up 0.22s ease-out;
  }

  @keyframes avatar-slide-up {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
  }

  .avatar-image {
    width: 160px;
    height: 160px;
  }

  .avatar-transcript {
    max-height: 30vh;
  }
}
