/* ===================================================================
   AIチャット相談ページ専用スタイル（ブランド準拠リデザイン）
   ※ SCSSパイプラインとは独立した単体CSS（再コンパイル不要）
   配色トークン:
     blue #2490a4 / dark_blue #3ebfd6 / white #f6f3ec
     light_brown #f4eddd / black #1a313f / green #2ecc71
   フォントは body 継承（fot-tsukuardgothic-std）
   =================================================================== */

.yuzu_ai_page {
  --yuzu-blue: #2490a4;
  --yuzu-blue-deep: #1d7d8e;
  --yuzu-dark-blue: #3ebfd6;
  --yuzu-white: #f6f3ec;
  --yuzu-light-brown: #f4eddd;
  --yuzu-black: #1a313f;
  --yuzu-ink: #323232;
  --yuzu-green: #2ecc71;
  --yuzu-line: #e7e1d3;
  --yuzu-muted: #7c8790;
}

.yuzu_ai_page * { box-sizing: border-box; }

/* ============================ 全画面アプリ（LINEトーク画面風） ============================ */
/* サイトヘッダー(高さ70px・fixed)の直下からビューポート最下部までを占有 */
body.yuzu-ai-fullscreen { overflow: hidden; }
body.yuzu-ai-fullscreen .bl_footer { display: none; }
body.yuzu-ai-fullscreen .bl_cta_fixed_section { display: none; }

.yuzu_ai_page {
  position: fixed;
  top: 70px;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  background: var(--yuzu-light-brown);
}

/* ============================ チャットカード ============================ */
.yuzu_ai_window {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  background: #fff;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

@media screen and (min-width: 768px) {
  .yuzu_ai_page { padding: 22px; }
  .yuzu_ai_window {
    max-width: 880px;
    margin: 0 auto;
    border: 1px solid var(--yuzu-line);
    border-radius: 20px;
    box-shadow: 0 18px 50px rgba(26, 49, 63, 0.12);
  }
}

/* カード上部のヘッダー帯 */
.yuzu_ai_winhead {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: #ecd03c;
  color: #2490a4;
}

/* 戻るボタン（トーク画面のヘッダー左） */
.yuzu_ai_winhead_back {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #2490a4;
  background: rgba(36, 144, 164, 0.12);
  transition: background 0.18s;
}
.yuzu_ai_winhead_back:hover { background: rgba(36, 144, 164, 0.22); }
.yuzu_ai_winhead_back svg { width: 20px; height: 20px; display: block; }

.yuzu_ai_winhead_avatar {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--yuzu-white) url("../images/ai-chat/yuzu_chan_avatar.png") center / cover no-repeat;
  border: 1.5px solid rgba(255, 255, 255, 0.7);
  font-size: 0;
}

.yuzu_ai_winhead_text { display: flex; flex-direction: column; line-height: 1.35; }
.yuzu_ai_winhead_title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 1.02rem;
  font-weight: 700;
}
/* オンライン状態を示す点滅ドット（タイトル横） */
.yuzu_ai_winhead_dot {
  flex: 0 0 auto;
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--yuzu-green);
  box-shadow: 0 0 0 0 rgba(46, 204, 113, 0.7);
  animation: yuzuAiPulse 2s infinite;
}
@keyframes yuzuAiPulse {
  0% { box-shadow: 0 0 0 0 rgba(111, 240, 166, 0.6); }
  70% { box-shadow: 0 0 0 7px rgba(111, 240, 166, 0); }
  100% { box-shadow: 0 0 0 0 rgba(111, 240, 166, 0); }
}

/* メッセージ領域 */
.yuzu_ai_messages {
  flex: 1 1 auto;
  min-height: 0;
  padding: 18px clamp(14px, 3vw, 24px);
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
  background:
    radial-gradient(circle at 12% 0%, rgba(62, 191, 214, 0.05), transparent 38%),
    #fcfbf7;
}

.yuzu_ai_messages::-webkit-scrollbar { width: 8px; }
.yuzu_ai_messages::-webkit-scrollbar-thumb { background: #e0dac9; border-radius: 8px; }

/* システムノート（注意書き・同意文をトーク冒頭にまとめて表示） */
.yuzu_ai_sysnote {
  align-self: center;
  max-width: 92%;
  text-align: center;
  background: rgba(244, 237, 221, 0.85);
  border: 1px solid var(--yuzu-line);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 0.74rem;
  line-height: 1.7;
  color: #6a6256;
}
.yuzu_ai_sysnote p { margin: 0 0 0.4rem; }
.yuzu_ai_sysnote p:last-child { margin-bottom: 0; }
.yuzu_ai_sysnote_privacy { padding-top: 0.4rem; border-top: 1px dashed var(--yuzu-line); }

/* メッセージ行 */
.yuzu_ai_msg {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  max-width: 88%;
  animation: yuzuAiIn 0.32s ease both;
}
@keyframes yuzuAiIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.yuzu_ai_avatar {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 0.78rem;
  font-weight: 700;
  margin-top: 2px;
}

/* ボット = ゆずちゃん（背景透過） */
.yuzu_ai_msg_bot .yuzu_ai_avatar {
  font-size: 0;
  color: transparent;
  background: transparent url("../images/ai-chat/yuzu_chan_avatar.png") center / contain no-repeat;
  box-shadow: none;
}

/* ユーザー = 薄色丸に人型アイコン（テキストは隠す） */
.yuzu_ai_msg_user .yuzu_ai_avatar {
  font-size: 0;
  background: var(--yuzu-light-brown) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%232490a4'%3E%3Cpath d='M12 12a5 5 0 1 0 0-10 5 5 0 0 0 0 10Zm0 2c-4.42 0-8 2.69-8 6v2h16v-2c0-3.31-3.58-6-8-6Z'/%3E%3C/svg%3E") center / 20px no-repeat;
  border: 1px solid var(--yuzu-line);
}

.yuzu_ai_bubble {
  background: #fff;
  border: 1px solid var(--yuzu-line);
  border-radius: 16px 16px 16px 5px;
  padding: 13px 16px;
  font-size: 0.95rem;
  line-height: 1.9;
  color: var(--yuzu-black);
  word-break: break-word;
  box-shadow: 0 4px 14px rgba(26, 49, 63, 0.05);
}

.yuzu_ai_bubble p { margin: 0 0 0.55rem; }
.yuzu_ai_bubble p:last-child { margin-bottom: 0; }
.yuzu_ai_bubble ul { margin: 0.35rem 0 0.6rem; padding-left: 1.25rem; }
.yuzu_ai_bubble li { margin-bottom: 0.3rem; }
.yuzu_ai_bubble li::marker { color: var(--yuzu-blue); }
.yuzu_ai_bubble strong { font-weight: 700; color: var(--yuzu-blue-deep); }

/* 回答内の表（診療時間・料金など） */
.yuzu_ai_table_wrap { overflow-x: auto; margin: 0.5rem 0 0.7rem; }
.yuzu_ai_table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.88rem;
  background: #fff;
  border-radius: 10px;
  overflow: hidden;
}
.yuzu_ai_table th,
.yuzu_ai_table td {
  border: 1px solid var(--yuzu-line);
  padding: 7px 10px;
  text-align: left;
  vertical-align: top;
  line-height: 1.6;
}
.yuzu_ai_table th {
  background: rgba(36, 144, 164, 0.1);
  color: var(--yuzu-blue-deep);
  font-weight: 700;
  white-space: nowrap;
}
.yuzu_ai_table tbody tr:nth-child(even) td { background: #fbfaf6; }

/* ユーザー側 */
.yuzu_ai_msg_user {
  align-self: flex-end;
  flex-direction: row-reverse;
}
.yuzu_ai_msg_user .yuzu_ai_bubble {
  background: linear-gradient(135deg, var(--yuzu-blue), var(--yuzu-dark-blue));
  border-color: transparent;
  color: #fff;
  border-radius: 16px 16px 5px 16px;
  box-shadow: 0 6px 16px rgba(36, 144, 164, 0.22);
}

/* 参照情報 */
.yuzu_ai_refs {
  margin-top: 12px;
  padding: 12px 14px;
  background: rgba(36, 144, 164, 0.06);
  border: 1px solid rgba(36, 144, 164, 0.16);
  border-radius: 12px;
}
.yuzu_ai_refs_title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--yuzu-blue-deep);
  margin: 0 0 8px;
  letter-spacing: 0.06em;
}
.yuzu_ai_refs_title::before {
  content: "";
  width: 14px; height: 14px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%231d7d8e'%3E%3Cpath d='M6 2h9l5 5v15a1 1 0 0 1-1 1H6a1 1 0 0 1-1-1V3a1 1 0 0 1 1-1Zm8 1.5V8h4.5L14 3.5Z'/%3E%3C/svg%3E") center / contain no-repeat;
}
.yuzu_ai_refs ol { margin: 0; padding-left: 1.15rem; }
.yuzu_ai_refs li { font-size: 0.84rem; line-height: 1.6; margin-bottom: 0.4rem; }
.yuzu_ai_refs li:last-child { margin-bottom: 0; }
.yuzu_ai_refs a { color: var(--yuzu-blue-deep); text-decoration: none; border-bottom: 1px solid rgba(29, 125, 142, 0.4); }
.yuzu_ai_refs a:hover { border-bottom-color: var(--yuzu-blue-deep); }
.yuzu_ai_ref_snip { display: block; color: var(--yuzu-muted); font-size: 0.76rem; margin-top: 0.15rem; }

/* タイピングインジケータ */
.yuzu_ai_typing .yuzu_ai_bubble {
  display: inline-flex; gap: 5px; align-items: center; padding: 14px 16px;
}
.yuzu_ai_typing .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--yuzu-blue); opacity: 0.4;
  animation: yuzuAiBlink 1.2s infinite ease-in-out;
}
.yuzu_ai_typing .dot:nth-child(2) { animation-delay: 0.18s; }
.yuzu_ai_typing .dot:nth-child(3) { animation-delay: 0.36s; }
@keyframes yuzuAiBlink {
  0%, 80%, 100% { opacity: 0.3; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-4px); }
}

/* ============================ 入力エリア ============================ */
.yuzu_ai_footarea {
  flex: 0 0 auto;
  border-top: 1px solid var(--yuzu-line);
  background: var(--yuzu-white);
  padding: 12px clamp(14px, 3vw, 22px) calc(12px + env(safe-area-inset-bottom, 0px));
}

.yuzu_ai_suggestions {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  margin-bottom: 12px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 2px;
  scrollbar-width: none;
}
.yuzu_ai_suggestions::-webkit-scrollbar { display: none; }
.yuzu_ai_suggest_btn {
  flex: 0 0 auto;
  white-space: nowrap;
  background: #fff;
  border: 1px solid rgba(36, 144, 164, 0.4);
  color: var(--yuzu-blue-deep);
  border-radius: 999px;
  padding: 7px 15px;
  font-size: 0.82rem;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.18s, color 0.18s, box-shadow 0.18s;
}
.yuzu_ai_suggest_btn:hover {
  background: var(--yuzu-blue);
  color: #fff;
  box-shadow: 0 4px 12px rgba(36, 144, 164, 0.28);
}

.yuzu_ai_form {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  background: #fff;
  border: 1px solid var(--yuzu-line);
  border-radius: 18px;
  padding: 8px 8px 8px 16px;
  transition: border-color 0.18s, box-shadow 0.18s;
}
.yuzu_ai_form:focus-within {
  border-color: var(--yuzu-blue);
  box-shadow: 0 0 0 3px rgba(36, 144, 164, 0.14);
}

.yuzu_ai_input {
  flex: 1 1 auto;
  resize: none;
  border: none;
  background: transparent;
  padding: 8px 0;
  font-size: 0.97rem;
  line-height: 1.7;
  font-family: inherit;
  color: var(--yuzu-black);
  max-height: 140px;
}
.yuzu_ai_input:focus { outline: none; }
.yuzu_ai_input::placeholder { color: #aeb6bc; }

.yuzu_ai_send {
  flex: 0 0 auto;
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--yuzu-blue), var(--yuzu-dark-blue));
  color: #fff;
  border: none;
  border-radius: 14px;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.18s, opacity 0.18s;
  box-shadow: 0 6px 16px rgba(36, 144, 164, 0.3);
}
.yuzu_ai_send svg { width: 20px; height: 20px; display: block; }
.yuzu_ai_send:hover { transform: translateY(-1px); }
.yuzu_ai_send:active { transform: translateY(0); }
.yuzu_ai_send:disabled { opacity: 0.45; cursor: not-allowed; box-shadow: none; transform: none; }

/* 準備中表示 */
.yuzu_ai_notready_wrap {
  flex: 1 1 auto;
  display: grid;
  place-items: center;
  padding: 20px;
}
.yuzu_ai_notready {
  max-width: 520px;
  background: #fff;
  border: 1px solid var(--yuzu-line);
  border-radius: 18px;
  box-shadow: 0 18px 50px rgba(26, 49, 63, 0.08);
  padding: 2.5rem 1.5rem;
  text-align: center;
  line-height: 2;
  color: var(--yuzu-black);
}
.yuzu_ai_notready a { color: var(--yuzu-blue-deep); font-weight: 700; }

/* 注意書き・同意文 */
.yuzu_ai_disclaimer {
  margin: 16px auto 0;
  max-width: 760px;
  font-size: 0.78rem;
  line-height: 1.8;
  color: var(--yuzu-muted);
  text-align: center;
}
.yuzu_ai_privacy {
  margin-top: 18px;
  padding: 12px 16px;
  background: rgba(244, 237, 221, 0.7);
  border: 1px solid var(--yuzu-line);
  border-radius: 12px;
  color: #6a6256;
}
.yuzu_ai_error_inline { color: #b32d2e; }

@media (max-width: 600px) {
  .yuzu_ai_msg { max-width: 96%; }
  .yuzu_ai_winhead_title { font-size: 0.96rem; }
}
