/* RE/MAX BASE サイト内チャット
   ============================================================================
   5ページで使うため、このサイトでは例外的に共通ファイルに切り出している
   （他は各HTMLに直接書く方針。同じ300行を5枚に複製するのは避けた）。

   色はサイトのトークン（--accent など）を参照せず、この中で完結させている。
   ページごとに変数名が違うため、依存すると1ページだけ色が外れる。
   ============================================================================ */

.rbc {
  --rbc-navy: #1e2d45;
  --rbc-gold: #b8966e;
  --rbc-ink: #1a1a1a;
  --rbc-line: #e6e0d6;
  --rbc-paper: #ffffff;
  --rbc-soft: #f7f6f4;
  font-family: 'Noto Sans JP', 'Hiragino Kaku Gothic ProN', sans-serif;
}

/* ---- 開くボタン ---- */
.rbc-launch {
  position: fixed; right: 24px; bottom: 96px; z-index: 9990;
  display: flex; align-items: center; gap: 10px;
  height: 52px; padding: 0 20px 0 18px;
  border: 0; border-radius: 26px;
  background: var(--rbc-navy); color: #fff;
  font-size: 0.86rem; letter-spacing: 0.06em; font-family: inherit;
  cursor: pointer;
  box-shadow: 0 6px 22px rgba(30,45,69,0.28);
  transition: transform .25s ease, box-shadow .25s ease, opacity .25s ease;
}
.rbc-launch:hover { transform: translateY(-2px); box-shadow: 0 10px 28px rgba(30,45,69,0.34); }
.rbc-launch svg { width: 19px; height: 19px; fill: currentColor; flex: none; }
.rbc-launch.is-hidden { opacity: 0; pointer-events: none; transform: translateY(8px); }

/* ---- 本体 ---- */
/* 大きさは左辺・上辺・左上の角をつまんで自由に変えられる。
   変えた値は widget.js が --rbc-w / --rbc-h に直接書き込み、ブラウザに覚えさせる */
.rbc { --rbc-w: 380px; --rbc-h: 540px; }

.rbc-panel {
  position: fixed; right: 24px; bottom: 96px; z-index: 9991;
  width: var(--rbc-w); max-width: calc(100vw - 32px);
  height: var(--rbc-h); max-height: calc(100vh - 140px);
  display: flex; flex-direction: column;
  background: var(--rbc-paper);
  border: 1px solid var(--rbc-line); border-radius: 10px;
  box-shadow: 0 18px 50px rgba(20,25,35,0.22);
  overflow: hidden;
  opacity: 0; transform: translateY(12px) scale(0.98);
  pointer-events: none;
  transition: opacity .25s ease, transform .25s ease;
}
.rbc-panel.is-open { opacity: 1; transform: none; pointer-events: auto; }

.rbc-head {
  flex: none; display: flex; align-items: center; gap: 12px;
  padding: 15px 14px 15px 18px;
  background: var(--rbc-navy); color: #fff;
}
.rbc-head-title { font-size: 0.9rem; letter-spacing: 0.06em; font-weight: 500; }
.rbc-head-sub { font-size: 0.7rem; color: rgba(255,255,255,0.66); margin-top: 2px; }
.rbc-close {
  margin-left: auto; flex: none;
  width: 40px; height: 40px; margin-right: -8px;
  border: 0; background: none; color: rgba(255,255,255,0.82);
  font-size: 1.2rem; line-height: 1; cursor: pointer; border-radius: 50%;
}
.rbc-close:hover { background: rgba(255,255,255,0.12); color: #fff; }

/* ---- 枠をつまんで大きさを変える ---- */
/* パネルは右下に貼り付いているので、広がるのは左と上。つまめるのはその2辺と左上の角 */
.rbc-edge {
  position: absolute; z-index: 6;
  touch-action: none;              /* つまんで動かす間、画面ごとスクロールさせない */
}
.rbc-edge-l { left: 0; top: 0; bottom: 0; width: 7px; cursor: ew-resize; }
.rbc-edge-t { left: 0; right: 0; top: 0; height: 7px; cursor: ns-resize; }

.rbc-grip {
  position: absolute; left: 0; top: 0; z-index: 7;
  width: 22px; height: 22px; padding: 0;
  border: 0; background: none; cursor: nwse-resize;
  touch-action: none;
}
/* 角に斜めの線を2本。押せる場所だと分かる程度に、控えめに */
.rbc-grip::before, .rbc-grip::after {
  content: ""; position: absolute;
  border-top: 1px solid rgba(255,255,255,0.42);
  transform: rotate(45deg); transform-origin: 0 0;
}
.rbc-grip::before { left: 6px;  top: 6px;  width: 9px; }
.rbc-grip::after  { left: 6px;  top: 11px; width: 5px; }
.rbc-grip:hover::before, .rbc-grip:hover::after,
.rbc-grip:focus-visible::before, .rbc-grip:focus-visible::after { border-top-color: rgba(255,255,255,0.9); }
.rbc-grip:focus-visible { outline: 2px solid var(--rbc-gold); outline-offset: -2px; border-radius: 10px 0 0 0; }

/* つまんでいる間は、文字が選ばれたり吹き出しが動いたりしないようにする */
.rbc.is-resizing .rbc-panel { transition: none; }
.rbc.is-resizing { user-select: none; -webkit-user-select: none; }

/* ---- 会話 ---- */
.rbc-log {
  flex: 1; min-height: 0; overflow-y: auto;
  padding: 18px 16px; background: var(--rbc-soft);
  display: flex; flex-direction: column; gap: 12px;
  overscroll-behavior: contain;   /* 端まで来てもページ側をスクロールさせない */
}
.rbc-msg { max-width: 84%; font-size: 0.86rem; line-height: 1.85; white-space: pre-wrap; word-break: auto-phrase; }
.rbc-msg.bot {
  align-self: flex-start;
  background: var(--rbc-paper); color: var(--rbc-ink);
  border: 1px solid var(--rbc-line); border-radius: 3px 12px 12px 12px;
  padding: 11px 14px;
}
.rbc-msg.me {
  align-self: flex-end;
  background: var(--rbc-navy); color: #fff;
  border-radius: 12px 3px 12px 12px;
  padding: 11px 14px;
}
.rbc-msg a { color: var(--rbc-gold); text-decoration: underline; text-underline-offset: 2px; }
.rbc-msg.me a { color: #e8ddd0; }

/* 応答待ちの三点 */
.rbc-typing { align-self: flex-start; display: flex; gap: 5px; padding: 13px 15px;
  background: var(--rbc-paper); border: 1px solid var(--rbc-line); border-radius: 3px 12px 12px 12px; }
.rbc-typing i { width: 6px; height: 6px; border-radius: 50%; background: #b9b4ab; animation: rbcDot 1.2s infinite ease-in-out; }
.rbc-typing i:nth-child(2) { animation-delay: .15s; }
.rbc-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes rbcDot { 0%,60%,100% { opacity: .3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

/* ---- ご相談内容の帯 ---- */
/* いま何の話をしているかを、会話の上にずっと出しておく。
   途中で用件が変わる人がいるので「変更」を添える */
.rbc-ctx {
  flex: none; display: flex; align-items: center; gap: 8px;
  padding: 9px 14px;
  background: #fbf9f6; border-bottom: 1px solid var(--rbc-line);
  font-size: 0.74rem; line-height: 1.5;
}
.rbc-ctx[hidden] { display: none; }
.rbc-ctx-label { color: #8b8b8b; letter-spacing: 0.04em; }
.rbc-ctx-name { color: var(--rbc-navy); font-weight: 500; }
.rbc-ctx-change {
  margin-left: auto; flex: none;
  border: 1px solid var(--rbc-line); background: var(--rbc-paper);
  color: #6b7280; font-family: inherit; font-size: 0.7rem;
  padding: 4px 10px; border-radius: 12px; cursor: pointer;
  transition: border-color .2s, color .2s;
}
.rbc-ctx-change:hover { border-color: var(--rbc-gold); color: var(--rbc-navy); }

/* 会話に挟む細い注記。誰の発言でもないので、吹き出しにしない */
.rbc-meta {
  align-self: center; max-width: 92%;
  font-size: 0.7rem; color: #9a9a9a; letter-spacing: 0.02em; text-align: center;
}

/* ---- よくある質問・ご相談内容（選んでもらう） ---- */
.rbc-chips { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 2px; }
.rbc-chip {
  border: 1px solid var(--rbc-line); background: var(--rbc-paper);
  color: #46505e; font-family: inherit; font-size: 0.76rem;
  padding: 8px 13px; border-radius: 16px; cursor: pointer;
  transition: border-color .2s, color .2s, background .2s;
}
.rbc-chip:hover { border-color: var(--rbc-gold); color: var(--rbc-navy); background: #fffdf9; }

/* ご相談内容は、質問例より先に選んでもらうもの。少し大きく、押す対象だと分かる形に */
.rbc-topics { gap: 8px; margin-top: 4px; }
.rbc-topic {
  font-size: 0.79rem; padding: 9px 15px;
  color: var(--rbc-navy); border-color: #dcd3c6;
}
.rbc-topic:hover { background: var(--rbc-navy); border-color: var(--rbc-navy); color: #fff; }
.rbc-topic.is-cur { border-color: var(--rbc-gold); background: #fffdf9; }

/* ---- 担当者へ引き継ぐ ---- */
.rbc-handoff { border-color: var(--rbc-gold); color: var(--rbc-navy); background: #fffdf9; }
.rbc-handoff:hover { background: var(--rbc-navy); border-color: var(--rbc-navy); color: #fff; }

.rbc-handoff-box {
  background: var(--rbc-paper); border: 1px solid var(--rbc-line); border-radius: 8px;
  padding: 12px; display: flex; flex-direction: column; gap: 9px;
}
.rbc-handoff-note {
  width: 100%; box-sizing: border-box; resize: none;
  border: 1px solid var(--rbc-line); border-radius: 6px;
  padding: 9px 10px; font-family: inherit; font-size: 0.82rem; line-height: 1.7;
  color: var(--rbc-ink); background: #fff;
}
.rbc-handoff-note:focus { outline: none; border-color: var(--rbc-gold); }
.rbc-handoff-row { display: flex; gap: 8px; }
.rbc-handoff-send, .rbc-handoff-cancel {
  font-family: inherit; font-size: 0.78rem; padding: 9px 14px;
  border-radius: 6px; cursor: pointer; border: 1px solid transparent;
}
.rbc-handoff-send { flex: 1; background: var(--rbc-navy); color: #fff; }
.rbc-handoff-send:hover { background: #16233a; }
.rbc-handoff-cancel { background: var(--rbc-paper); border-color: var(--rbc-line); color: #6b7280; }
.rbc-handoff-cancel:hover { border-color: var(--rbc-gold); color: var(--rbc-navy); }
.rbc-handoff-help { margin: 0; font-size: 0.7rem; color: #9a9a9a; line-height: 1.7; }

/* ---- 入力 ---- */
.rbc-form { flex: none; display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--rbc-line); background: var(--rbc-paper); }
.rbc-input {
  flex: 1; min-width: 0; resize: none;
  border: 1px solid var(--rbc-line); border-radius: 6px;
  padding: 11px 12px; font-family: inherit; font-size: 0.86rem; line-height: 1.6;
  max-height: 96px; color: var(--rbc-ink); background: #fff;
}
.rbc-input:focus { outline: none; border-color: var(--rbc-gold); }
.rbc-send {
  flex: none; width: 44px; height: 44px; align-self: flex-end;
  border: 0; border-radius: 6px; background: var(--rbc-navy); color: #fff;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.rbc-send:disabled { opacity: .45; cursor: default; }
.rbc-send svg { width: 17px; height: 17px; fill: currentColor; }

.rbc-note {
  flex: none; padding: 0 14px 11px; background: var(--rbc-paper);
  font-size: 0.68rem; color: #8b8b8b; line-height: 1.7;
}
.rbc-note a { color: #8a6b45; text-decoration: underline; text-underline-offset: 2px; }

/* ---- スマホ ---- */
@media (max-width: 600px) {
  .rbc-launch { right: 16px; bottom: 80px; height: 48px; padding: 0 17px 0 15px; font-size: 0.8rem; }
  /* 横幅は画面いっぱいなので、変えられるのは高さだけ。上辺を指でつまむ */
  .rbc { --rbc-h: 72vh; }
  .rbc-grip, .rbc-edge-l { display: none; }
  .rbc-edge-t { height: 16px; }
  /* 指でつまむ場所が分かるように、上辺に短い横棒を出す */
  .rbc-edge-t::before {
    content: ""; position: absolute; left: 50%; top: 6px;
    width: 38px; height: 3px; margin-left: -19px; border-radius: 2px;
    background: rgba(255,255,255,0.4);
  }
  .rbc-panel {
    right: 0; left: 0; bottom: 0;
    width: auto; max-width: none;
    height: var(--rbc-h); max-height: none;
    border-radius: 12px 12px 0 0; border-left: 0; border-right: 0; border-bottom: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .rbc-launch, .rbc-panel { transition: none; }
  .rbc-panel { transition: none !important; }
  .rbc-typing i { animation: none; }
}
