/* ============================================================
   こじか園チャットボット スタイル
   ============================================================ */

.kjk-root {
  --kjk-blue: #1E4B9C;
  --kjk-blue-dark: #163A7A;
  --kjk-blue-light: #E9EFF9;
  --kjk-orange: #E85D2F;
  --kjk-orange-dark: #C94A20;
  --kjk-dark: #2c3a47;
  --kjk-mid: #596275;
  --kjk-bg: #f4f7f6;
  font-family: "Noto Sans JP", "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
}

/* ---------- フローティングボタン ---------- */
.kjk-toggle {
  position: fixed;
  right: 20px;
  bottom: calc(20px + env(safe-area-inset-bottom));
  height: 56px;
  padding: 0 20px 0 14px;
  border-radius: 30px;
  background: linear-gradient(135deg, var(--kjk-orange), var(--kjk-orange-dark));
  border: none;
  box-shadow: 0 4px 16px rgba(232, 93, 47, 0.4);
  cursor: pointer;
  z-index: 9999;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: transform 0.2s ease;
}
.kjk-toggle:hover {
  transform: scale(1.04);
}
.kjk-toggle-label {
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
}
.kjk-toggle-icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  border-radius: 50%;
  width: 38px;
  height: 38px;
  font-size: 20px;
  line-height: 1;
}
.kjk-icon-img {
  object-fit: contain;
  display: block;
}
.kjk-icon-img-toggle {
  width: 26px;
  height: 26px;
}
.kjk-icon-img-header {
  width: 22px;
  height: 22px;
}
.kjk-icon-img-avatar {
  width: 20px;
  height: 20px;
}

/* ---------- チャットウィンドウ ---------- */
.kjk-window {
  position: fixed;
  right: 20px;
  bottom: calc(92px + env(safe-area-inset-bottom));
  width: 360px;
  max-width: calc(100vw - 40px);
  height: 520px;
  max-height: calc(100vh - 140px);
  background: #ffffff;
  border-radius: 18px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.kjk-window.kjk-hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
}

/* ---------- ヘッダー ---------- */
.kjk-header {
  background: linear-gradient(135deg, var(--kjk-blue), var(--kjk-blue-dark));
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.kjk-header-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 14px;
  min-width: 0; /* flexアイテムの縮小を許可し、はみ出しを防ぐ */
}
.kjk-header-title span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.kjk-header-icon {
  font-size: 20px;
}
.kjk-header-actions {
  display: flex;
  gap: 4px;
}
.kjk-icon-btn {
  background: rgba(255, 255, 255, 0.18);
  border: none;
  color: #fff;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  font-size: 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.kjk-icon-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* ---------- 本文（吹き出し） ---------- */
.kjk-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: var(--kjk-bg);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.kjk-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}
.kjk-row-user {
  flex-direction: row-reverse;
}

.kjk-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--kjk-blue-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}
.kjk-avatar-user {
  background: #eef2f7;
}

.kjk-bubble {
  max-width: 78%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
}
.kjk-bubble-bot {
  background: var(--kjk-blue-light);
  color: var(--kjk-dark);
  border-bottom-left-radius: 4px;
}
.kjk-link {
  color: var(--kjk-blue);
  font-weight: 700;
  text-decoration: underline;
  word-break: break-all;
}
.kjk-link:hover {
  color: var(--kjk-orange);
}
.kjk-bubble-user {
  background: #eef2f7;
  color: var(--kjk-dark);
  border-bottom-right-radius: 4px;
}

/* ---------- 選択肢ボタン ---------- */
.kjk-options {
  flex-shrink: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 14px 14px;
  background: #ffffff;
  border-top: 1px solid #eef2ef;
}
.kjk-option {
  background: #ffffff;
  border: 1.5px solid var(--kjk-blue);
  color: var(--kjk-blue-dark);
  border-radius: 14px;
  padding: 7px 14px;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.kjk-option:hover {
  background: var(--kjk-blue);
  color: #fff;
}

/* ---------- インライン選択肢（2回目以降の質問・会話履歴内に表示） ---------- */
.kjk-inline-options {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-left: 36px; /* アバター幅(28px)+gap(8px)に揃える */
  margin-top: -4px;
}
.kjk-option-inline {
  background: #ffffff;
  border: 1.5px solid var(--kjk-blue);
  color: var(--kjk-blue-dark);
  border-radius: 16px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, opacity 0.15s ease;
}
.kjk-option-inline:hover:not(:disabled) {
  background: var(--kjk-blue);
  color: #fff;
}
.kjk-option-inline:disabled {
  cursor: default;
}
.kjk-option-selected {
  background: var(--kjk-orange);
  border-color: var(--kjk-orange);
  color: #fff;
  opacity: 1;
}
.kjk-option-unselected {
  opacity: 0.4;
}

/* ---------- スクロールバー（任意の見た目調整） ---------- */
.kjk-body::-webkit-scrollbar {
  width: 6px;
}
.kjk-body::-webkit-scrollbar-thumb {
  background: #c3d2e8;
  border-radius: 4px;
}

/* ---------- スマホ対応 ---------- */
@media (max-width: 480px) {
  .kjk-window {
    right: 12px;
    left: 12px;
    bottom: calc(84px + env(safe-area-inset-bottom));
    width: auto;
    max-width: none;
    height: 70vh;
    height: 70dvh; /* 対応ブラウザではアドレスバーの出し引きによる高さのガタつきを防止 */
  }
  .kjk-toggle {
    right: 14px;
    bottom: calc(16px + env(safe-area-inset-bottom));
    /* コンパクトなバッジ型に変更：横幅を抑えてコンテンツへの干渉を減らす */
    height: auto;
    flex-direction: column;
    gap: 2px;
    padding: 6px 8px;
    border-radius: 16px;
  }
  .kjk-toggle-icon {
    width: 30px;
    height: 30px;
  }
  .kjk-icon-img-toggle {
    width: 20px;
    height: 20px;
  }
  .kjk-toggle-label {
    font-size: 9px;
    line-height: 1.2;
    white-space: nowrap;
  }
}
