/*
 * faq-widget スタイル（Zendesk Guide テーマ埋め込み用）
 * 依存なしのバニラCSS。クラスはすべて faqw- プレフィックスでテーマ既存CSSと衝突しないようにする。
 */

.faqw-launcher {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 2147483000;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 18px;
  border: none;
  border-radius: 999px;
  background: #d81b60;
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.24);
  font-family: inherit;
}
.faqw-launcher:hover { background: #c2185b; }
.faqw-launcher:focus-visible { outline: 3px solid rgba(216, 27, 96, 0.4); }
.faqw-launcher[hidden] { display: none; }

.faqw-panel {
  position: fixed;
  right: 20px;
  bottom: 20px;
  /* 低い画面で上部固定UIにヘッダーが隠れないよう上限値にする。 */
  z-index: 2147483647;
  display: flex;
  flex-direction: column;
  width: 360px;
  max-width: calc(100vw - 32px);
  height: 560px;
  max-height: calc(100vh - 32px);
  /* ※上の vh 行を消さないこと・順序を入れ替えないこと（理由は IMPLEMENTATION.md）。 */
  max-height: calc(100dvh - 32px);
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.28);
  overflow: hidden;
  font-family: inherit;
}
.faqw-panel[hidden] { display: none; }

.faqw-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: #d81b60;
  color: #fff;
}
/* 狭い端末でボタンを押し出さないよう、あふれるのはタイトル側にする。 */
.faqw-title {
  font-size: 15px;
  font-weight: 700;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.faqw-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
/* 会話のリセット。× より弱く見せる（主導線ではないが、いつでも押せる位置に置く）。
   白1pxのゴースト枠はやめ、静止時は面を持たせない（白テキスト＋白アイコンだけ）。
   ※色を重ねるのは hover / 押下のときだけにし、そのとき重ねるのは白ではなく黒。
     濃いピンク(#d81b60)に白を重ねると彩度が 78%→71% に落ちてくすんだピンクになるが、
     黒なら彩度 78% のまま明度だけ下がるので、ブランド色の純度が保たれる。 */
.faqw-reset {
  /* ＋ アイコン。単独使用だが -webkit- と標準の2回書くので変数に逃がす。
     mask で塗り分けるため、SVG 側の stroke 色は不透明でありさえすればよい。 */
  --faqw-icon-plus: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='M12 5v14M5 12h14'/%3E%3C/svg%3E");
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: none;
  background: transparent;
  color: #fff;
  font-family: inherit;
  /* 面が無いぶん、読みやすさは文字そのものが受け持つ。濃い地の白抜きは細いと
     にじんで読みにくいので、12px/400 まで落とさない。タイトルは 15px/700 なので
     13px/600 なら階層は保てる。 */
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  border-radius: 999px;
  /* 面が無いぶん、余白は見た目に響かずタップ領域として使える。ただし × の 30px を
     超えるとヘッダーが太るので、そこが上限（13px + 8px*2 = 29px）。
     アイコン側だけ 1px 詰めて左右の見た目の重さを合わせる。 */
  padding: 8px 8px 8px 7px;
  cursor: pointer;
  white-space: nowrap;
  /* テーマ側の button 指定に素材を持っていかれないようにする。 */
  -webkit-appearance: none;
  appearance: none;
  transition: background-color 140ms ease, transform 140ms ease;
}
/* JS を触らずに済むよう、アイコンは mask で描く（色は currentColor に追従する）。
   ※ @supports を外さないこと。mask 非対応だと 12px の白い四角が出る。 */
@supports ((-webkit-mask: url("")) or (mask: url(""))) {
  .faqw-reset::before {
    content: "";
    flex-shrink: 0;
    /* 文字（13px）とほぼ同じ高さにして、＋ とラベルの重さを揃える。 */
    width: 13px;
    height: 13px;
    background-color: currentColor;
    -webkit-mask: var(--faqw-icon-plus) center / contain no-repeat;
    mask: var(--faqw-icon-plus) center / contain no-repeat;
  }
}
.faqw-reset:hover { background: rgba(0, 0, 0, 0.12); }
/* モバイルには hover が無いので、タップ中のフィードバックはこちらが受け持つ。 */
.faqw-reset:active { background: rgba(0, 0, 0, 0.2); transform: scale(0.96); }
/* 静止時は輪郭が無いので、リングを少し外に出して押せる範囲そのものを示す。 */
.faqw-reset:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.faqw-close {
  border: none;
  background: transparent;
  color: #fff;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
}
.faqw-close:focus-visible { outline: 2px solid rgba(255, 255, 255, 0.7); }

.faqw-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: #f7f7f8;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.faqw-msg {
  max-width: 85%;
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.6;
  white-space: normal;
  word-break: break-word;
  /* 追加と同時に再生させたいので transition ではなく animation を使う。 */
  animation: faqw-msg-in 180ms ease-out both;
}
/* ※ここで高さを変えないこと（transform 以外を使わない）。widget.js の
   scrollToBottom が高さを見てスクロール位置を決めている。 */
@keyframes faqw-msg-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
.faqw-msg-user {
  align-self: flex-end;
  background: #d81b60;
  color: #fff;
  border-bottom-right-radius: 4px;
}
.faqw-msg-bot {
  align-self: flex-start;
  background: #fff;
  color: #222;
  border: 1px solid #e3e3e6;
  border-bottom-left-radius: 4px;
}

.faqw-sources {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed #e0e0e0;
  font-size: 12px;
}
.faqw-sources-label { color: #777; margin-bottom: 4px; }
.faqw-sources a {
  display: block;
  color: #1565c0;
  text-decoration: none;
  word-break: break-all;
  margin-bottom: 2px;
}
.faqw-sources a:hover { text-decoration: underline; }

/* 回答への評価（解決した / 解決しなかった）。出典リンクと同じく bot バブル内にネストする。 */
.faqw-feedback {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed #e0e0e0;
  font-size: 12px;
}
.faqw-feedback-label { color: #777; margin-bottom: 6px; }
.faqw-feedback-btns { display: flex; gap: 8px; }
.faqw-fb-btn {
  flex: 1;
  padding: 6px 8px;
  font-size: 12px;
  font-family: inherit;
  line-height: 1.4;
  cursor: pointer;
  border: 1px solid #d5d5da;
  border-radius: 8px;
  background: #fff;
  color: #333;
}
.faqw-fb-btn:hover:not(:disabled) { border-color: #d81b60; color: #d81b60; }
.faqw-fb-btn:disabled { cursor: default; opacity: 0.55; }
/* 押した側は淡く残す。消すと「押せたのか」が分からず連打を誘発する。
   押下と同時に disabled になる（widget.js の closeRow）ため、:disabled の opacity より
   詳細度を上げておく。単独の .faqw-fb-selected では負けて 0.55 に沈む。 */
.faqw-fb-btn.faqw-fb-selected,
.faqw-fb-btn.faqw-fb-selected:disabled {
  border-color: #d81b60;
  background: #fdeef4;
  color: #d81b60;
  font-weight: 700;
  opacity: 1;
}

/* アプリ内お問い合わせへの導線。ボタンが主導線、サーバが返すテキスト手順が保険。 */
.faqw-applink {
  display: block;
  margin-top: 4px;
  padding: 12px;
  border-radius: 10px;
  background: #d81b60;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  text-align: center;
  text-decoration: none;
}
.faqw-applink:hover { background: #c2185b; }

.faqw-typing { display: inline-flex; gap: 4px; align-items: center; }
.faqw-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #b0b0b6;
  animation: faqw-blink 1.2s infinite both;
}
.faqw-typing span:nth-child(2) { animation-delay: 0.2s; }
.faqw-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes faqw-blink {
  0%, 80%, 100% { opacity: 0.3; }
  40% { opacity: 1; }
}
/* 応答が長引いたときに3点ドットの下へ足す一言。回答本文と紛れないよう控えめにする。 */
.faqw-waiting-hint {
  margin-top: 6px;
  font-size: 12px;
  color: #8a8a90;
}

.faqw-inputarea {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid #ececee;
  background: #fff;
}
.faqw-input {
  flex: 1;
  resize: none;
  border: 1px solid #d5d5da;
  border-radius: 10px;
  padding: 10px 12px;
  /* ※16px 未満にしないこと（理由は IMPLEMENTATION.md）。 */
  font-size: 16px;
  font-family: inherit;
  line-height: 1.4;
  max-height: 96px;
}
.faqw-input:focus { outline: none; border-color: #d81b60; }
.faqw-send {
  border: none;
  background: #d81b60;
  color: #fff;
  border-radius: 10px;
  padding: 0 16px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}
.faqw-send:disabled { background: #e3a7be; cursor: not-allowed; }

.faqw-legal {
  padding: 6px 12px 10px;
  font-size: 10px;
  line-height: 1.4;
  color: #999;
  background: #fff;
  text-align: center;
}
.faqw-legal a { color: #999; text-decoration: underline; }

/* reCAPTCHA バッジは非表示にし、上記 .faqw-legal で法的表記を代替表示する。 */
.grecaptcha-badge { visibility: hidden !important; }

.faqw-hidden { display: none !important; }

/* スマホ（縦・横持ちとも）ではパネルを全画面にする。
   ※条件は widget.js の FULLSCREEN_QUERY と同じにすること（理由は IMPLEMENTATION.md）。 */
@media (max-width: 640px), (max-height: 500px) {
  .faqw-panel {
    top: 0;
    right: 0;
    bottom: auto;
    left: 0;
    width: auto;
    max-width: none;
    /* キーボード表示中は widget.js（fitPanelToViewport）が top / height を上書きする。 */
    height: 100vh;
    height: 100dvh;
    max-height: none;
    border-radius: 0;
    box-shadow: none;
  }
  .faqw-messages { overscroll-behavior: contain; }
}

/* 動きを減らす設定への配慮。回答本文の流し込み（widget.js の streamText）も
   同じメディアクエリを JS 側で見て無効化している。片方だけ直さないこと。 */
@media (prefers-reduced-motion: reduce) {
  .faqw-msg { animation: none; }
  .faqw-typing span { animation: none; opacity: 0.6; }
  /* ［新しい質問］の押下フィードバック。こちらは JS 側と連動していない。 */
  .faqw-reset { transition: none; }
  .faqw-reset:active { transform: none; }
}
