/* ===== Base Reset ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Hiragino Kaku Gothic Pro', 'メイリオ', Meiryo, sans-serif;
  background: #f0f2f5;
  min-height: 100vh;
}

/* ===== Chat Toggle Button ===== */
.chat-toggle {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(135deg, #4a90d9, #5ba0e9);
  color: #fff;
  border: none;
  border-radius: 50px;
  padding: 12px 24px 12px 12px;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(74, 144, 217, 0.4);
  transition: all 0.3s ease;
  z-index: 9999;
  font-size: 15px;
  font-weight: bold;
}

.chat-toggle:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 25px rgba(74, 144, 217, 0.5);
}

.toggle-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  background: #fff;
  padding: 2px;
}

.toggle-text {
  white-space: nowrap;
}

/* ===== Chat Window ===== */
.chat-window {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 420px;
  height: 650px;
  max-height: 85vh;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.15);
  display: flex;
  flex-direction: column;
  z-index: 10000;
  overflow: hidden;
  animation: slideUp 0.3s ease-out;
}

.chat-window.hidden {
  display: none;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===== Header ===== */
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(135deg, #4a90d9, #5ba0e9);
  padding: 12px 16px;
  min-height: 52px;
}

.header-btn {
  background: rgba(255,255,255,0.9);
  border: none;
  border-radius: 6px;
  padding: 6px 14px;
  font-size: 12px;
  cursor: pointer;
  color: #333;
  font-weight: 500;
  transition: background 0.2s;
}

.header-btn:hover {
  background: #fff;
}

.header-title {
  font-size: 16px;
  font-weight: bold;
  color: #333;
}

.header-close {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: #333;
  padding: 4px 8px;
  border-radius: 4px;
  transition: background 0.2s;
}

.header-close:hover {
  background: rgba(0,0,0,0.1);
}

/* ===== Chat Content (character + messages layout) ===== */
.chat-content {
  flex: 1;
  display: flex;
  flex-direction: row;
  overflow: hidden;
  background: #f8f9fa;
}

/* ===== Character ===== */
.character-container {
  width: 180px;
  flex-shrink: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0 4px 16px 8px;
  background: #f8f9fa;
}

.character-img {
  width: 170px;
  height: auto;
  animation: float 3s ease-in-out infinite;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.1));
  transition: transform 0.3s ease;
}

/* ===== Chat Body (scrollable messages) ===== */
.chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 16px 16px 8px;
  position: relative;
}

.chat-body::-webkit-scrollbar {
  width: 6px;
}

.chat-body::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 3px;
}

/* ===== Character Animations ===== */
@keyframes float {
  0%, 100% {
    transform: translateY(0px);
  }
  50% {
    transform: translateY(-8px);
  }
}

@keyframes bounce {
  0%, 100% {
    transform: translateY(0) scale(1);
  }
  30% {
    transform: translateY(-12px) scale(1.05);
  }
  50% {
    transform: translateY(0) scale(0.98);
  }
  70% {
    transform: translateY(-5px) scale(1.02);
  }
}

@keyframes wave {
  0%, 100% {
    transform: rotate(0deg);
  }
  25% {
    transform: rotate(5deg);
  }
  75% {
    transform: rotate(-5deg);
  }
}

.character-bounce {
  animation: bounce 0.6s ease-in-out !important;
}

.character-wave {
  animation: wave 0.5s ease-in-out 2 !important;
}

/* ===== Messages ===== */
#messages {
}

.message {
  margin-bottom: 16px;
  animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.message-time {
  font-size: 11px;
  color: #999;
  margin-top: 4px;
}

/* Bot message */
.bot-message {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.bot-bubble {
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 0 16px 16px 16px;
  padding: 14px 18px;
  max-width: 92%;
  font-size: 14px;
  line-height: 1.7;
  color: #333;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  white-space: pre-wrap;
  word-break: break-word;
}

/* User message */
.user-message {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.user-bubble {
  background: linear-gradient(135deg, #4a90d9, #357abd);
  color: #fff;
  border-radius: 16px 0 16px 16px;
  padding: 12px 18px;
  max-width: 80%;
  font-size: 14px;
  line-height: 1.6;
  box-shadow: 0 2px 6px rgba(74, 144, 217, 0.3);
  word-break: break-word;
}

/* ===== Category Toggle Button ===== */
.category-toggle-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, #4a90d9, #5ba0e9);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 12px 18px;
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-top: 10px;
  margin-bottom: 4px;
}

.category-toggle-btn:hover {
  background: linear-gradient(135deg, #e6951a, #e8ba3e);
  transform: scale(1.02);
}

.category-toggle-btn .toggle-icon {
  font-size: 16px;
}

.category-toggle-btn .toggle-arrow {
  margin-left: auto;
  font-size: 12px;
  transition: transform 0.2s ease;
}

/* ===== Category Buttons ===== */
.category-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
  max-width: 92%;
  max-height: 1000px;
  overflow: hidden;
  transition: max-height 0.3s ease, opacity 0.3s ease, margin 0.3s ease;
  opacity: 1;
}

.category-buttons.collapsed {
  max-height: 0;
  opacity: 0;
  margin-top: 0;
  margin-bottom: 0;
}

.category-btn {
  background: #fff;
  border: 1.5px solid #e0e0e0;
  border-radius: 10px;
  padding: 12px 16px;
  text-align: left;
  font-size: 14px;
  color: #333;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 8px;
}

.category-btn:hover {
  border-color: #4a90d9;
  background: #fff8ee;
  transform: translateX(4px);
}

.category-btn .cat-icon {
  font-size: 16px;
  flex-shrink: 0;
}

/* ===== Suggestion Buttons ===== */
.suggestion-buttons {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 10px;
  max-width: 92%;
}

.suggestion-btn {
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 10px 14px;
  text-align: left;
  font-size: 13px;
  color: #555;
  cursor: pointer;
  transition: all 0.2s ease;
  line-height: 1.5;
}

.suggestion-btn:hover {
  border-color: #4a90d9;
  background: #fffcf5;
  color: #333;
}

/* 折りたたみ式関連質問 */
.suggestion-container {
  margin-top: 4px;
}

.suggestion-toggle-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #f8f9fa;
  border: 1px solid #e0e0e0;
  border-radius: 16px;
  padding: 6px 12px;
  font-size: 12px;
  color: #666;
  cursor: pointer;
  transition: all 0.2s ease;
}

.suggestion-toggle-btn:hover {
  background: #fffcf5;
  border-color: #4a90d9;
}

.suggestion-toggle-btn .toggle-icon {
  font-size: 14px;
}

.suggestion-toggle-btn .toggle-arrow {
  font-size: 10px;
  margin-left: auto;
}

.suggestion-buttons.collapsed {
  display: none;
}

/* ===== Typing Indicator ===== */
.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 12px 18px;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 0 16px 16px 16px;
  width: fit-content;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.typing-dot {
  width: 8px;
  height: 8px;
  background: #ccc;
  border-radius: 50%;
  animation: typingBounce 1.4s ease-in-out infinite;
}

.typing-dot:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typingBounce {
  0%, 60%, 100% {
    transform: translateY(0);
    background: #ccc;
  }
  30% {
    transform: translateY(-6px);
    background: #4a90d9;
  }
}

/* ===== Input Area ===== */
.chat-input-area {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  background: #fff;
  border-top: 1px solid #e8e8e8;
  gap: 10px;
}

#user-input {
  flex: 1;
  border: 1.5px solid #e0e0e0;
  border-radius: 24px;
  padding: 10px 18px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
  font-family: inherit;
}

#user-input:focus {
  border-color: #4a90d9;
}

#user-input::placeholder {
  color: #aaa;
}

.send-btn {
  background: linear-gradient(135deg, #4a90d9, #357abd);
  color: #fff;
  border: none;
  border-radius: 24px;
  padding: 10px 22px;
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.send-btn:hover {
  background: linear-gradient(135deg, #e6991a, #e08b0a);
  transform: scale(1.02);
}

.send-btn:active {
  transform: scale(0.98);
}

/* ===== Source Badge ===== */
.source-badge {
  display: inline-block;
  background: #f0f0f0;
  color: #888;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  margin-top: 6px;
}

/* ===== Embed Mode ===== */
.embed-mode .chat-window {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  right: 0;
  width: 100%;
  height: 100%;
  max-height: 100%;
  border-radius: 0;
  box-shadow: none;
}

/* ===== Responsive ===== */
@media (max-width: 480px) {
  .chat-window {
    width: 100%;
    height: 100%;
    max-height: 100vh;
    bottom: 0;
    right: 0;
    border-radius: 0;
  }

  .chat-toggle {
    bottom: 16px;
    right: 16px;
    padding: 10px 18px 10px 10px;
  }

  .character-container {
    display: none;
  }

  .chat-body {
    padding: 12px;
  }

  .bot-bubble, .user-bubble {
    max-width: 100%;
  }
}

/* ===== Contact Links ===== */
.contact-link {
  display: inline-block;
  color: #fff;
  background: linear-gradient(135deg, #4a90d9, #357abd);
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 16px;
  font-size: 13px;
  margin: 4px 2px;
  transition: all 0.2s ease;
  box-shadow: 0 2px 4px rgba(74, 144, 217, 0.3);
}

.contact-link:hover {
  text-decoration: none;
  background: linear-gradient(135deg, #357abd, #2868a8);
  transform: translateY(-1px);
  box-shadow: 0 3px 6px rgba(74, 144, 217, 0.4);
}

/* ===== Feedback Bar ===== */
.feedback-bar {
  background: #fffbf0;
  border-top: 1px solid #f0e6d0;
  padding: 8px 16px;
  text-align: center;
}

.feedback-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: #c67600;
  text-decoration: none;
  font-size: 12px;
  transition: color 0.2s;
}

.feedback-link:hover {
  color: #e08b0a;
  text-decoration: underline;
}

.feedback-link strong {
  color: #e08b0a;
}

.feedback-gift {
  font-size: 14px;
}

/* ===== Staff Reply Bubble ===== */
.staff-bubble {
  background: linear-gradient(135deg, #fff3e0, #ffe0b2) !important;
  border: 1px solid #ffcc80;
}

.staff-badge {
  display: inline-block;
  background: #ff6b00;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  margin-bottom: 4px;
}

/* ===== Email Prompt ===== */
.email-prompt-bubble {
  background: linear-gradient(135deg, #fff8e8, #fff3d6) !important;
  border: 1px solid #f0c060 !important;
  padding: 14px 16px !important;
}

.email-prompt-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: #333;
  cursor: pointer;
  user-select: none;
}

.email-prompt-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: #ff6b00;
}

.email-input-group {
  margin-top: 10px;
  display: none;
}

.email-input-group.visible {
  display: block;
}

.email-input-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 6px;
}

.email-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #ccc;
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  box-sizing: border-box;
}

.email-input:focus {
  border-color: #ff6b00;
}

.email-submit-btn {
  width: 100%;
  background: #ff6b00;
  color: #fff;
  border: none;
  padding: 10px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}

.email-submit-btn:hover {
  background: #e55a00;
}

.email-skip-btn {
  background: none;
  border: none;
  color: #bbb;
  font-size: 11px;
  cursor: pointer;
  margin-top: 8px;
  text-decoration: underline;
  display: block;
}
