/* ===== AIチャットウィジェット ===== */

/* --- フローティングボタン --- */
.chat-toggle {
  position: fixed;
  bottom: 60px;
  right: 24px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #00d4ff, #7c3aed);
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(0, 212, 255, 0.3);
  z-index: 9998;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s, box-shadow 0.3s;
}
.chat-toggle:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 28px rgba(0, 212, 255, 0.45);
}
.chat-toggle svg {
  width: 28px;
  height: 28px;
  fill: #fff;
  transition: transform 0.3s;
}
.chat-toggle.open svg.icon-chat { display: none; }
.chat-toggle:not(.open) svg.icon-close { display: none; }

/* 非表示リンク（フッター） */
.chat-footer {
  text-align: center;
  padding: 6px 16px 10px;
  border-top: 1px solid rgba(255,255,255,0.04);
}
.chat-footer a {
  color: rgba(255,255,255,0.3);
  font-size: 11px;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}
.chat-footer a:hover {
  color: rgba(255,255,255,0.6);
}
.chat-footer-sep {
  color: rgba(255,255,255,0.15);
  font-size: 11px;
  margin: 0 8px;
}

/* 再表示ミニボタン */
.chat-mini {
  position: fixed;
  bottom: 60px;
  right: 24px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(0,212,255,0.4), rgba(124,58,237,0.4));
  border: none;
  cursor: pointer;
  z-index: 9998;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s, transform 0.2s;
  opacity: 0.7;
  -webkit-tap-highlight-color: transparent;
}
.chat-mini:hover {
  opacity: 1;
  transform: scale(1.1);
}
.chat-mini svg {
  width: 22px;
  height: 22px;
  fill: #fff;
}

/* バッジ（未読） */
.chat-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 16px;
  height: 16px;
  background: #ef4444;
  border-radius: 50%;
  border: 2px solid #0a0a1a;
  display: none;
}
.chat-badge.show { display: block; }

/* --- チャットウィンドウ --- */
.chat-window {
  position: fixed;
  bottom: 132px;
  right: 24px;
  width: 380px;
  max-height: 520px;
  background: #0a0a1a;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 16px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.5);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  pointer-events: none;
  transition: opacity 0.3s, transform 0.3s;
}
.chat-window.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* ヘッダー */
.chat-header {
  padding: 16px 20px;
  background: linear-gradient(135deg, rgba(0,212,255,0.08), rgba(124,58,237,0.08));
  border-bottom: 1px solid rgba(255,255,255,0.06);
  display: flex;
  align-items: center;
  gap: 12px;
}
.chat-header-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #00d4ff, #7c3aed);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.chat-header-icon svg {
  width: 18px;
  height: 18px;
  fill: #fff;
}
.chat-header-text h3 {
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  margin: 0;
  line-height: 1.3;
}
.chat-header-text p {
  color: rgba(255,255,255,0.5);
  font-size: 11px;
  margin: 0;
  line-height: 1.3;
}

/* ヘッダー閉じるボタン */
.chat-header-close {
  margin-left: auto;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255,255,255,0.08);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  line-height: 1;
  color: rgba(255,255,255,0.5);
  padding: 0;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.2s, color 0.2s;
}
.chat-header-close:hover {
  background: rgba(255,255,255,0.15);
  color: #fff;
}

/* メッセージエリア */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 200px;
  max-height: 340px;
}
.chat-messages::-webkit-scrollbar {
  width: 4px;
}
.chat-messages::-webkit-scrollbar-track {
  background: transparent;
}
.chat-messages::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.1);
  border-radius: 2px;
}

/* メッセージバブル */
.chat-msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.6;
  word-break: break-word;
}
.chat-msg.user {
  align-self: flex-end;
  background: linear-gradient(135deg, #7c3aed, #6d28d9);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.chat-msg.assistant {
  align-self: flex-start;
  background: #141432;
  color: rgba(255,255,255,0.85);
  border: 1px solid rgba(255,255,255,0.06);
  border-bottom-left-radius: 4px;
}

/* ウェルカムメッセージ */
.chat-welcome {
  text-align: center;
  padding: 20px 10px;
}
.chat-welcome p {
  color: rgba(255,255,255,0.5);
  font-size: 12px;
  line-height: 1.6;
}
.chat-welcome .suggestions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 12px;
}
.chat-welcome .suggestion-btn {
  background: rgba(0,212,255,0.06);
  border: 1px solid rgba(0,212,255,0.15);
  color: #00d4ff;
  font-size: 12px;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s;
  text-align: left;
}
.chat-welcome .suggestion-btn:hover {
  background: rgba(0,212,255,0.12);
}

/* タイピングインジケーター */
.chat-typing {
  align-self: flex-start;
  display: flex;
  gap: 4px;
  padding: 12px 16px;
  background: #141432;
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  border: 1px solid rgba(255,255,255,0.06);
}
.chat-typing span {
  width: 6px;
  height: 6px;
  background: rgba(255,255,255,0.3);
  border-radius: 50%;
  animation: typing 1.4s infinite;
}
.chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.3; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* 入力エリア */
.chat-input-area {
  padding: 12px 16px;
  border-top: 1px solid rgba(255,255,255,0.06);
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.chat-input {
  flex: 1;
  background: #111128;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  padding: 10px 14px;
  color: #fff;
  font-size: 13px;
  font-family: inherit;
  resize: none;
  outline: none;
  max-height: 80px;
  line-height: 1.4;
  transition: border-color 0.2s;
}
.chat-input::placeholder {
  color: rgba(255,255,255,0.25);
}
.chat-input:focus {
  border-color: rgba(0,212,255,0.3);
}
.chat-send {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, #00d4ff, #7c3aed);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s;
  flex-shrink: 0;
}
.chat-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.chat-send svg {
  width: 18px;
  height: 18px;
  fill: #fff;
}

/* エラー */
.chat-error {
  align-self: center;
  background: rgba(239,68,68,0.1);
  border: 1px solid rgba(239,68,68,0.2);
  color: #fca5a5;
  font-size: 12px;
  padding: 8px 12px;
  border-radius: 8px;
  text-align: center;
}

/* --- モバイル対応 --- */
@media (max-width: 480px) {
  .chat-window {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    max-height: 100vh;
    max-height: 100dvh;
    border-radius: 16px 16px 0 0;
  }
  .chat-messages {
    max-height: calc(100vh - 160px);
    max-height: calc(100dvh - 160px);
  }
  .chat-toggle {
    bottom: 16px;
    right: 16px;
  }
  .chat-mini {
    bottom: 16px;
    right: 16px;
  }
}
