/* ============================================================
   NTG チャットボット ウィジェットスタイル
   - 全て .ntg-chatbot- プレフィックスで既存CSS競合回避
   - カラー：オレンジ基調（#e8763a メイン / #d4692e ダーク）
   ============================================================ */

/* ── FABラッパー ────────────────────────────────────── */
.ntg-chatbot-fab-wrap {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 99998;
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.ntg-chatbot-fab-wrap--hidden {
  opacity: 0;
  pointer-events: none;
  transform: scale(0);
}

/* ── フローティングボタン ───────────────────────────── */
.ntg-chatbot-fab {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: #e8763a;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  outline: none;
  position: relative;
  -webkit-tap-highlight-color: transparent;
}
.ntg-chatbot-fab:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 24px rgba(0,0,0,0.35);
}
.ntg-chatbot-fab:active {
  transform: scale(0.96);
}
.ntg-chatbot-fab img {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  pointer-events: none;
}

/* ── FAB ×ボタン（ワンクリック非表示） ──────────────── */
.ntg-chatbot-fab-dismiss {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(60,60,60,0.75);
  border: 2px solid #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  outline: none;
  opacity: 0;
  transform: scale(0.5);
  transition: opacity 0.15s ease, transform 0.15s ease, background 0.15s ease;
  z-index: 1;
  -webkit-tap-highlight-color: transparent;
}
.ntg-chatbot-fab-wrap:hover .ntg-chatbot-fab-dismiss,
.ntg-chatbot-fab-dismiss:focus {
  opacity: 1;
  transform: scale(1);
}
.ntg-chatbot-fab-dismiss:hover {
  background: rgba(200,50,50,0.9);
}
.ntg-chatbot-fab-dismiss svg {
  width: 10px;
  height: 10px;
  stroke: #fff;
  stroke-width: 2.5;
  stroke-linecap: round;
  fill: none;
}

/* ── 再表示ボタン（右端の極小タブ） ──────────────── */
.ntg-chatbot-restore {
  position: fixed;
  bottom: 50%;
  right: 0;
  width: 24px;
  height: 48px;
  border-radius: 8px 0 0 8px;
  background: rgba(232,118,58,0.6);
  border: none;
  cursor: pointer;
  z-index: 99997;
  box-shadow: -1px 1px 4px rgba(0,0,0,0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  outline: none;
  transition: width 0.2s ease, background 0.2s ease, opacity 0.3s ease, transform 0.3s ease;
  opacity: 0;
  pointer-events: none;
  transform: translateX(100%);
  -webkit-tap-highlight-color: transparent;
}
.ntg-chatbot-restore--visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(0);
}
.ntg-chatbot-restore:hover {
  width: 32px;
  background: rgba(232,118,58,0.9);
}
.ntg-chatbot-restore svg {
  width: 14px;
  height: 14px;
  fill: #fff;
}

/* ── オーバーレイ（全デバイス共通、デフォルト非表示） ── */
.ntg-chatbot-overlay {
  display: none;
}

/* ── チャットウィンドウ ────────────────────────────── */
.ntg-chatbot-window {
  position: fixed;
  bottom: 100px;
  right: 24px;
  width: 380px;
  height: 520px;
  max-height: calc(100vh - 130px);
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.2);
  z-index: 99999;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.ntg-chatbot-window--open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* ── ヘッダー ──────────────────────────────────────── */
.ntg-chatbot-header {
  background: linear-gradient(135deg, #e8763a 0%, #d4692e 100%);
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.ntg-chatbot-header-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  flex-shrink: 0;
  background: #fff;
}
.ntg-chatbot-header-info {
  flex: 1;
  min-width: 0;
}
.ntg-chatbot-header-title {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.3;
}
.ntg-chatbot-header-sub {
  font-size: 11px;
  opacity: 0.9;
  line-height: 1.3;
}

/* ヘッダーボタン群 */
.ntg-chatbot-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
.ntg-chatbot-btn-minimize,
.ntg-chatbot-btn-hide,
.ntg-chatbot-btn-close {
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}
.ntg-chatbot-btn-minimize:hover,
.ntg-chatbot-btn-hide:hover,
.ntg-chatbot-btn-close:hover {
  background: rgba(255,255,255,0.25);
}
.ntg-chatbot-btn-minimize svg,
.ntg-chatbot-btn-hide svg,
.ntg-chatbot-btn-close svg {
  width: 18px;
  height: 18px;
  stroke: #fff;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ── メッセージエリア ──────────────────────────────── */
.ntg-chatbot-messages {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #faf8f5;
  scroll-behavior: smooth;
  overscroll-behavior: contain;
}
.ntg-chatbot-messages::-webkit-scrollbar {
  width: 6px;
}
.ntg-chatbot-messages::-webkit-scrollbar-track {
  background: transparent;
}
.ntg-chatbot-messages::-webkit-scrollbar-thumb {
  background: #d0c8be;
  border-radius: 3px;
}

/* ── メッセージバブル ──────────────────────────────── */
.ntg-chatbot-msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.65;
  word-break: break-word;
}
.ntg-chatbot-msg--bot {
  background: #fff;
  color: #333;
  align-self: flex-start;
  border-bottom-left-radius: 4px;
  border: 1px solid #ebe5dd;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.ntg-chatbot-msg--user {
  background: #e8763a;
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.ntg-chatbot-msg--bot a {
  color: #d4692e;
  text-decoration: underline;
  font-weight: 500;
}
.ntg-chatbot-msg--bot a:hover {
  color: #b85520;
}

/* ── タイピングインジケーター ──────────────────────── */
.ntg-chatbot-typing {
  display: flex;
  gap: 4px;
  padding: 10px 14px;
  align-self: flex-start;
}
.ntg-chatbot-typing span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #d4a87a;
  animation: ntg-chatbot-bounce 1.2s infinite;
}
.ntg-chatbot-typing span:nth-child(2) { animation-delay: 0.15s; }
.ntg-chatbot-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes ntg-chatbot-bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-6px); }
}

/* ── クイック返信ボタン ────────────────────────────── */
.ntg-chatbot-quickreplies {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 16px 8px;
  background: #faf8f5;
  flex-shrink: 0;
}
.ntg-chatbot-quickreply {
  background: #fff;
  color: #d4692e;
  border: 1.5px solid #e8763a;
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  outline: none;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.ntg-chatbot-quickreply:hover,
.ntg-chatbot-quickreply:active {
  background: #e8763a;
  color: #fff;
}
/* 火災保険引受回答ボタン（特別スタイル） */
.ntg-chatbot-quickreply--fire {
  background: #e8763a;
  color: #fff;
  border-color: #e8763a;
  font-weight: 700;
}
.ntg-chatbot-quickreply--fire:hover,
.ntg-chatbot-quickreply--fire:active {
  background: #d4692e;
  border-color: #d4692e;
}
/* フロー内の業種選択ボタン（控えめスタイル） */
.ntg-chatbot-quickreply--flow {
  background: #fff;
  color: #555;
  border-color: #ccc;
  font-weight: 400;
  font-size: 12px;
}
.ntg-chatbot-quickreply--flow:hover,
.ntg-chatbot-quickreply--flow:active {
  background: #f5f0eb;
  color: #333;
  border-color: #ccc;
}

/* ── 入力エリア ────────────────────────────────────── */
.ntg-chatbot-input-area {
  display: flex;
  align-items: center;
  padding: 10px 12px;
  border-top: 1px solid #ebe5dd;
  background: #fff;
  flex-shrink: 0;
  gap: 8px;
}
.ntg-chatbot-input {
  flex: 1;
  border: 1.5px solid #d8d0c8;
  border-radius: 20px;
  padding: 8px 14px;
  font-size: 16px; /* 16px以上でiOS自動ズーム防止 */
  outline: none;
  background: #fff;
  color: #333;
  font-family: inherit;
  resize: none;
  max-height: 80px;
  min-height: 36px;
  line-height: 1.4;
  -webkit-appearance: none;
  appearance: none;
}
.ntg-chatbot-input::placeholder {
  color: #a09080;
}
.ntg-chatbot-input:focus {
  border-color: #e8763a;
  box-shadow: 0 0 0 2px rgba(232,118,58,0.15);
}
.ntg-chatbot-send {
  width: 40px;
  height: 40px;
  min-width: 40px;
  border-radius: 50%;
  background: #e8763a;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.1s;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}
.ntg-chatbot-send:hover {
  background: #d4692e;
}
.ntg-chatbot-send:active {
  transform: scale(0.92);
}
.ntg-chatbot-send:disabled {
  background: #c8b8a8;
  cursor: not-allowed;
}
.ntg-chatbot-send svg {
  width: 18px;
  height: 18px;
  fill: #fff;
}

/* ── フッター ──────────────────────────────────────── */
.ntg-chatbot-footer {
  text-align: center;
  padding: 4px;
  font-size: 10px;
  color: #b0a090;
  background: #fff;
  border-top: 1px solid #f0ebe5;
  flex-shrink: 0;
}

/* ── body scroll lock ──────────────────────────────── */
.ntg-chatbot-body-locked {
  overflow: hidden !important;
  position: fixed !important;
  width: 100% !important;
  touch-action: none;
}

/* ══════════════════════════════════════════════════════
   モバイル対応 (≤768px)
   ══════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  /* ── FAB ────────────────────────────────────────── */
  .ntg-chatbot-fab-wrap {
    bottom: 76px; /* sp_agent_reg_sticky の上 */
    right: 16px;
  }
  .ntg-chatbot-fab {
    width: 56px;
    height: 56px;
  }
  .ntg-chatbot-fab img {
    width: 48px;
    height: 48px;
  }
  .ntg-chatbot-fab-dismiss {
    opacity: 1;
    transform: scale(1);
  }

  /* ── 再表示 ──────────────────────────────────── */
  .ntg-chatbot-restore {
    bottom: 50%;
    right: 0;
  }

  /* ── オーバーレイ ─────────────────────────────── */
  .ntg-chatbot-overlay {
    display: block;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.35);
    z-index: 99998;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    -webkit-tap-highlight-color: transparent;
  }
  .ntg-chatbot-overlay--visible {
    opacity: 1;
    pointer-events: auto;
  }

  /* ── ボトムシート型ウィンドウ ─────────────────── */
  .ntg-chatbot-window {
    /* topで上端を固定、bottomで下端を固定 → 高さは自動 */
    top: 44px;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: auto;
    max-height: none;
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -4px 30px rgba(0,0,0,0.15);
    opacity: 1;
    transform: translateY(100%);
    pointer-events: none;
    transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1);
  }
  .ntg-chatbot-window--open {
    transform: translateY(0);
    pointer-events: auto;
  }

  /* つまみハンドル */
  .ntg-chatbot-header {
    border-radius: 20px 20px 0 0;
    position: relative;
    padding-top: 20px;
  }
  .ntg-chatbot-header::before {
    content: '';
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 36px;
    height: 4px;
    border-radius: 2px;
    background: rgba(255,255,255,0.4);
  }

  /* ── メッセージ ──────────────────────────────── */
  .ntg-chatbot-msg {
    max-width: 90%;
    font-size: 14px;
  }

  /* ── クイック返信（折り返し表示） ────────────── */
  .ntg-chatbot-quickreplies {
    flex-wrap: wrap;
    padding: 8px 12px;
    gap: 6px;
  }
  .ntg-chatbot-quickreply {
    padding: 6px 12px;
    font-size: 12px;
  }

  /* ── 入力エリア（safe area対応） ─────────────── */
  .ntg-chatbot-input-area {
    padding: 10px 12px;
    padding-bottom: max(10px, env(safe-area-inset-bottom, 0px));
  }
  .ntg-chatbot-send {
    width: 44px;
    height: 44px;
    min-width: 44px;
  }

  /* ── フッター非表示 ────────────────────────── */
  .ntg-chatbot-footer {
    display: none;
  }
}
