/* ================================================================
   チャットボット UI
   ================================================================ */

/* === トグルボタン === */
/* チャットトグル — 目立つデザイン */
.chat-toggle {
  position: fixed; bottom: 24px; right: 24px; z-index: 150;
  display: flex; align-items: center; gap: 10px;
  padding: 14px 22px 14px 18px;
  background: var(--accent, #b8963e);
  border: none; border-radius: 60px;
  color: var(--navy, #0c1420);
  box-shadow: 0 6px 28px rgba(184,150,62,.35);
  transition: all .3s cubic-bezier(.22,1,.36,1);
  cursor: pointer;
  animation: chat-attention 3s ease-in-out infinite;
}
@keyframes chat-attention {
  0%,100% { box-shadow: 0 6px 28px rgba(184,150,62,.35); }
  50% { box-shadow: 0 8px 36px rgba(184,150,62,.55), 0 0 0 6px rgba(184,150,62,.1); }
}
.chat-toggle:hover {
  transform: scale(1.05);
  box-shadow: 0 10px 40px rgba(184,150,62,.5);
  background: var(--accent-light, #d4b96a);
}
.chat-toggle svg { width: 22px; height: 22px; flex-shrink: 0; }
.chat-toggle-label {
  font-size: 12px; font-weight: 700; letter-spacing: 1px;
  white-space: nowrap; font-family: var(--sans, sans-serif);
}
.chat-toggle .badge {
  position: absolute; top: -4px; right: -4px;
  width: 20px; height: 20px; border-radius: 50%;
  background: #e74c3c; color: #fff;
  font-size: 10px; font-weight: 900;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid #fff;
}

/* === ウィジェット本体 === */
.chat-widget {
  position: fixed; bottom: 96px; right: 24px; z-index: 150;
  width: 380px; max-height: calc(100vh - 130px);
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 12px 48px rgba(0,0,0,.15);
  display: flex; flex-direction: column;
  transform: translateY(20px) scale(.95);
  opacity: 0; visibility: hidden;
  transition: all .3s cubic-bezier(.22,1,.36,1);
  overflow: hidden;
}
.chat-widget.open {
  transform: translateY(0) scale(1);
  opacity: 1; visibility: visible;
}

/* === ヘッダー === */
.chat-header {
  background: var(--navy, #0c1420);
  padding: 16px 18px;
  display: flex; align-items: center; gap: 12px;
  flex-shrink: 0;
  position: relative;
  border-radius: 16px 16px 0 0;
}
.chat-header-icon {
  width: 36px; height: 36px;
  background: rgba(255,255,255,.1);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--gold-light);
}
.chat-header-icon svg { width: 18px; height: 18px; }
.chat-header-text h4 {
  font-family: var(--serif);
  font-size: 14px; color: #fff; letter-spacing: 1px; margin-bottom: 1px;
}
.chat-header-text p { font-size: 10px; color: rgba(255,255,255,.45); letter-spacing: .5px; }
.chat-close-btn {
  position: absolute; top: 12px; right: 14px;
  background: none; border: none; color: rgba(255,255,255,.5);
  width: 24px; height: 24px; display: flex; align-items: center; justify-content: center;
  transition: color .2s; cursor: pointer;
}
.chat-close-btn:hover { color: #fff; }
.chat-close-btn svg { width: 16px; height: 16px; }

/* === メッセージエリア === */
.chat-messages {
  flex: 1; overflow-y: auto; padding: 18px;
  display: flex; flex-direction: column; gap: 16px;
  min-height: 200px;
  scroll-behavior: smooth;
  background: var(--bg-light, #f5f4f1);
}
.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.chat-msg { display: flex; animation: msg-in .3s ease; }
@keyframes msg-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.chat-bot { justify-content: flex-start; }
.chat-user { justify-content: flex-end; }

.chat-bubble {
  max-width: 85%; padding: 12px 16px;
  border-radius: 12px;
  font-size: 13.5px; line-height: 1.8;
  word-break: break-word;
}
.chat-bubble strong {
  font-weight: 700; color: var(--navy, #0c1420);
}
.chat-bot .chat-bubble {
  background: #fff;
  border: 1px solid var(--border, #e5e5e0);
  border-radius: 2px 12px 12px 12px;
  color: var(--text, #1a1a1a);
  max-width: 92%;
  box-shadow: 0 1px 4px rgba(0,0,0,.04);
}
.chat-user .chat-bubble {
  background: var(--navy, #0c1420);
  color: #fff;
  border-radius: 12px 2px 12px 12px;
}

/* === 選択肢ボタン === */
.chat-options {
  display: flex; flex-direction: column; gap: 6px;
  padding: 6px 0;
  animation: msg-in .3s ease;
}
.chat-option-btn {
  padding: 10px 14px;
  background: #fff;
  border: 1px solid var(--accent, #b8963e);
  border-radius: 6px;
  font-size: 12px; font-weight: 500;
  color: var(--navy, #0c1420);
  text-align: left;
  transition: all .2s;
  cursor: pointer;
  line-height: 1.4;
}
.chat-option-btn:hover {
  background: var(--accent, #b8963e);
  color: #fff;
  border-color: var(--accent, #b8963e);
}
.chat-option-btn:disabled {
  opacity: .35; pointer-events: none;
  background: var(--bg-light, #f5f4f1); border-color: var(--border, #e5e5e0); color: var(--text-muted, #999);
}

/* === 入力エリア === */
.chat-input-area {
  display: none;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  gap: 8px;
  background: #fff;
  flex-shrink: 0;
}
.chat-input-area input {
  flex: 1; padding: 9px 14px;
  border: 1px solid var(--border); border-radius: 8px;
  font-size: 13px; font-family: var(--sans);
  outline: none; background: var(--green-bg);
}
.chat-input-area input:focus { border-color: var(--green-main); background: #fff; }
.chat-send-btn {
  padding: 9px 14px;
  background: var(--navy, #0c1420); color: #fff;
  border: none; border-radius: 8px;
  display: flex; align-items: center;
  transition: background .2s; cursor: pointer;
}
.chat-send-btn:hover { background: var(--navy-mid, #1c2e44); }
.chat-send-btn svg { width: 16px; height: 16px; }

/* === タイピングインジケーター === */
.chat-typing {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 12px 18px;
}
.chat-typing .typing-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent, #b8963e);
  animation: typing-bounce 1.4s ease-in-out infinite;
}
.chat-typing .typing-dot:nth-child(2) { animation-delay: .2s; }
.chat-typing .typing-dot:nth-child(3) { animation-delay: .4s; }
@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: .4; }
  30% { transform: translateY(-8px); opacity: 1; }
}

/* === レスポンシブ === */
@media (max-width: 480px) {
  .chat-widget {
    width: calc(100vw - 16px);
    right: 8px; bottom: 72px;
    max-height: calc(100vh - 90px);
    border-radius: 12px;
  }
  .chat-toggle { bottom: 12px; right: 12px; padding: 12px 16px 12px 14px; }
  .chat-toggle svg { width: 20px; height: 20px; }
  .chat-toggle-label { font-size: 11px; }
}
@media (max-width: 380px) {
  .chat-widget {
    width: 100vw;
    right: 0; bottom: 0;
    max-height: 100vh;
    border-radius: 0;
  }
  .chat-header { border-radius: 0; }
  .chat-toggle-label { display: none; }
}

/* === ダークモード === */
@media (prefers-color-scheme: dark) {
  .chat-widget {
    background: #1a1a2e;
    box-shadow: 0 12px 48px rgba(0,0,0,.4);
  }
  .chat-messages {
    background: #12121e;
  }
  .chat-bot .chat-bubble {
    background: #222240;
    border-color: #333355;
    color: #e0e0e8;
  }
  .chat-bot .chat-bubble strong {
    color: var(--accent-light, #d4b96a);
  }
  .chat-user .chat-bubble {
    background: var(--accent, #b8963e);
    color: #0c1420;
  }
  .chat-option-btn {
    background: #222240;
    border-color: var(--accent, #b8963e);
    color: #e0e0e8;
  }
  .chat-option-btn:hover {
    background: var(--accent, #b8963e);
    color: #0c1420;
  }
  .chat-option-btn:disabled {
    background: #1a1a2e;
    border-color: #333;
    color: #666;
  }
  .chat-input-area {
    background: #1a1a2e;
    border-top-color: #333355;
  }
  .chat-input-area input {
    background: #222240;
    border-color: #333355;
    color: #e0e0e8;
  }
  .chat-input-area input:focus {
    border-color: var(--accent, #b8963e);
    background: #2a2a48;
  }
  .chat-messages::-webkit-scrollbar-thumb {
    background: #444;
  }
}
