/* =====================================================
   共通スタイル — このファイルは直接編集しないでください
   カスタマイズは theme.css で行ってください
   ===================================================== */

:root {
  /* --- デフォルト値（theme.css で上書き可能） --- */
  --color-primary:        #2563eb;
  --color-primary-hover:  #1d4ed8;
  --color-user-bubble:    #111827;
  --color-link-btn:       #2563eb;
  --color-link-btn-hover: #1d4ed8;
  --color-bg:             #f6f7f9;
  --color-surface:        #ffffff;
  --color-border:         #e6e8ee;
  --color-text-muted:     #6b7280;
  --color-notes-text:     #6b7280;

  --font-family:    system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-size-base: 15px;

  --radius-bubble:  14px;
  --radius-input:   10px;
  --radius-btn:     10px;

  --spacing-chat:   12px;
  --spacing-header: 14px 16px;
  --max-width:      720px;
}

:root { font-family: var(--font-family); font-size: var(--font-size-base); }
body  { margin: 0; background: transparent; }

.app {
  max-width: var(--max-width);
  margin: 0 auto;
  height: 100vh;
  height: 100dvh;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--color-bg);
  box-shadow: 0 8px 32px rgba(0,0,0,0.15);
}

/* ヘッダー */
.header {
  padding: var(--spacing-header);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  user-select: none;
}
.title { font-weight: 700; flex: 1; }
.meta  { font-size: 12px; color: var(--color-text-muted); margin-top: 4px; }

/* 最小化ボタン */
.minimize-btn {
  background: none;
  border: none;
  font-size: 20px;
  line-height: 1;
  color: var(--color-text-muted);
  cursor: pointer;
  padding: 0 4px;
}
.minimize-btn:hover { color: #374151; }

/* 最小化状態 */
.app.is-minimized { display: none; }

/* ランチャーボタン */
.chat-launcher {
  display: none;
  position: fixed;
  bottom: var(--launcher-bottom, 20px);
  right:  var(--launcher-right,  20px);
  align-items: center;
  gap: 8px;
  padding: 12px 18px;
  background: var(--color-primary);
  color: #fff;
  border: none;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0,0,0,0.18);
  animation: btnFloat 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  z-index: 9999;
}
.chat-launcher.is-visible { display: flex; }
.chat-launcher:hover { background: var(--color-primary-hover); }

@media (max-width: 768px) {
  .chat-launcher {
    bottom: var(--launcher-mobile-bottom, 75px);
  }
}

/* チャットエリア */
.chat {
  flex: 1;
  min-height: 0;
  padding: var(--spacing-chat);
  overflow: auto;
}

.msg       { display: flex; margin: 8px 0; animation: msgFadeIn 0.3s ease; }
.msg.user  { justify-content: flex-end; }
.msg.bot   { justify-content: flex-start; }

@keyframes msgFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.bubble {
  max-width: 88%;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-bubble);
  padding: 10px 12px;
  line-height: 1.5;
  font-size: var(--font-size-base);
}
.msg.user .bubble {
  background: var(--color-user-bubble);
  color: white;
  border-color: var(--color-user-bubble);
  white-space: pre-wrap;
}
.bubble.muted { color: var(--color-text-muted); }

/* クイック返信ボタン */
.quick {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 0 var(--spacing-chat) 10px;
}
.quick-btn {
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  border-radius: 999px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 14px;
}

/* 入力エリア */
.composer {
  display: flex;
  gap: 8px;
  padding: var(--spacing-chat);
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
}
.composer input {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-input);
  outline: none;
  font-size: var(--font-size-base);
}
.composer button {
  padding: 10px 16px;
  border: none;
  border-radius: var(--radius-btn);
  background: var(--color-primary);
  color: white;
  cursor: pointer;
  font-size: var(--font-size-base);
}
.composer button:hover    { background: var(--color-primary-hover); }
.composer button:disabled { opacity: 0.6; cursor: not-allowed; }

/* フッター */
.footer {
  padding: 8px var(--spacing-chat);
  color: var(--color-text-muted);
  font-size: 12px;
}
.footer-links {
  display: flex;
  gap: 12px;
  margin-top: 4px;
}
.footer-links a {
  color: var(--color-text-muted);
  font-size: 11px;
  text-decoration: underline;
}
.footer-links a:hover { color: var(--color-primary); }
.tools { display: flex; gap: 8px; margin-top: 8px; }
.tools button {
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  border-radius: var(--radius-btn);
  padding: 6px 10px;
  cursor: pointer;
  font-size: 12px;
}

/* ボットメッセージ内の構造 */
.bot-heading    { font-weight: bold; margin: 0 0 4px; font-size: calc(var(--font-size-base) + 1px); }
.bot-conclusion {
  font-weight: 600;
  margin: 0 0 6px;
  color: var(--color-primary);
}
.bot-section-label {
  font-size: 12px;
  font-weight: 700;
  color: #374151;
  margin: 8px 0 2px;
  border-bottom: 1px solid var(--color-border);
  padding-bottom: 2px;
}
.bot-content-details { margin: 4px 0; }
.bot-content-details .bot-content { margin-top: 4px; }
.bot-content-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  font-size: 12px;
  color: var(--color-primary);
  user-select: none;
  list-style: none;
}
.bot-content-toggle::-webkit-details-marker { display: none; }
.bot-content-toggle::after  { content: "＋"; font-weight: bold; }
details[open] .bot-content-toggle::after { content: "ー"; }
.bot-content         { padding-left: 16px; margin: 2px 0 4px; }
.bot-content li      { margin: 2px 0; }
.bot-notes           { list-style: none; padding-left: 0; margin: 4px 0 4px; font-size: 13px; color: var(--color-notes-text); }
.bot-notes li        { margin: 2px 0; padding-left: 1.4em; text-indent: -1.4em; }
.bot-notes li::before { content: "※ "; }
.bot-note-block      { animation: msgFadeIn 0.4s ease 1s both; margin: 1.5rem 0; }
.bot-links-block     { animation: msgFadeIn 0.3s ease 1.8s both; }
.bot-links-block .chat-btn {
  animation: btnFloat 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
.bot-links-block .chat-btn:nth-child(1) { animation-delay: 2.0s; }
.bot-links-block .chat-btn:nth-child(2) { animation-delay: 2.15s; }
.bot-links-block .chat-btn:nth-child(3) { animation-delay: 2.3s; }
.bot-links-block .chat-btn:nth-child(4) { animation-delay: 2.45s; }

@keyframes btnFloat {
  0%   { opacity: 0; transform: translateY(14px) scale(0.95); }
  70%  { opacity: 1; transform: translateY(-4px) scale(1.02); }
  100% { opacity: 1; transform: translateY(0)   scale(1); }
}

/* content 内インラインリンク */
.content-link {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  font-size: 12px;
  color: var(--color-primary);
  border: 1px solid var(--color-primary);
  border-radius: 4px;
  text-decoration: none;
  vertical-align: middle;
  line-height: 1.6;
}
.content-link:hover {
  background: var(--color-primary);
  color: #fff;
}

/* ローディングインジケーター */
.loading-bubble {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.loading-dots {
  display: flex;
  gap: 5px;
  align-items: center;
  height: 20px;
}
.loading-dots span {
  display: block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--color-text-muted);
  animation: dotBounce 1.2s infinite ease-in-out;
}
.loading-dots span:nth-child(1) { animation-delay: 0s; }
.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes dotBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30%            { transform: translateY(-6px); opacity: 1; }
}

.loading-status {
  font-size: 12px;
  color: var(--color-text-muted);
}

/* リンクボタン */
.chat-links {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.chat-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  font-size: 14px;
  font-weight: 600;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255,255,255,0.25) 0%, rgba(255,255,255,0) 100%) var(--color-link-btn);
  color: #fff;
  text-decoration: none;
  transition: filter 0.2s ease, transform 0.1s ease;
}
.chat-btn::after {
  content: "›";
  font-size: 16px;
  line-height: 1;
  opacity: 0.8;
}
.chat-btn:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
}
.chat-btn:active { transform: translateY(0); filter: brightness(0.96); }

/* ─── サブタイトル（clinicLabel 下の補足テキスト） ──── */
.subtitle {
  font-weight: 400;
  margin-top: 4px;
  display: block;
}

/* ─── ユーティリティ ─────────────────────────────── */
.chat-btn--no-link {
  opacity: 0.6;
  cursor: default;
  pointer-events: none;
}

/* ─── モバイルモード基本（html.mobile-mode 付与時） ── */
html.mobile-mode .composer button {
  white-space: nowrap;
  min-width: 44px;
}
