/* ==========================================================================
   Chatbot Form Styles
   ========================================================================== */

/* Variables */
:root {
  --chatbot-primary: #0895c2;
  --chatbot-primary-hover: #0dade2;
  --chatbot-bg: #ffffff;
  --chatbot-message-bg: #f0f4f8;
  --chatbot-user-bg: #15a7d8;
  --chatbot-text: #333333;
  --chatbot-text-light: #666666;
  --chatbot-border: #e0e0e0;
  --chatbot-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  --chatbot-radius: 12px;
  --chatbot-avatar-size: 40px;
}

/* ==========================================================================
   Toggle Button - Horizontal with Avatar
   ========================================================================== */
.chatbot-toggle {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 30px 5px 5px;
  background: var(--chatbot-primary);
  border: none;
  border-radius: 50px;
  cursor: pointer;
  box-shadow: var(--chatbot-shadow);
  z-index: 9998;
  transition: transform 0.3s ease, background-color 0.3s ease, opacity 0.3s ease;
}
@media (min-width: 768px) and (max-width: 1600px) {
  .chatbot-toggle {
    bottom:95px;
  }
}
.chatbot-toggle:hover {
  background: var(--chatbot-primary-hover);
  transform: scale(1.02);
}

.chatbot-toggle__avatar {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  object-fit: cover;
}

.chatbot-toggle__text {
  color: #ffffff;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}

.chatbot-toggle.is-hidden {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.8) translateY(20px);
}

/* ==========================================================================
   Chatbot Container
   ========================================================================== */
.chatbot {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 400px;
  max-width: calc(100vw - 40px);
  height: 600px;
  max-height: calc(100vh - 40px);
  background: var(--chatbot-bg);
  border-radius: var(--chatbot-radius);
  box-shadow: var(--chatbot-shadow);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform-origin: bottom right;
  transform: scale(0) translateY(20px);
  opacity: 0;
  visibility: hidden;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
              opacity 0.3s ease,
              visibility 0.3s ease;
}

.chatbot.is-open {
  transform: scale(1) translateY(0);
  opacity: 1;
  visibility: visible;
}

/* ==========================================================================
   Header
   ========================================================================== */
.chatbot__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--chatbot-primary);
  color: #ffffff;
  flex-shrink: 0;
}

.chatbot__header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.chatbot__header-avatar {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  object-fit: cover;
}

.chatbot__title {
  font-size: 15px;
  font-weight: 600;
  margin: 0;
}

.chatbot__remaining {
  font-size: 12px;
  background: rgba(255, 255, 255, 0.2);
  padding: 4px 10px;
  border-radius: 12px;
  margin-left: auto;
  margin-right: 12px;
}

.chatbot__minimize {
  width: 32px;
  height: 32px;
  border: none;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s ease;
  flex-shrink: 0;
}

.chatbot__minimize:hover {
  background: rgba(255, 255, 255, 0.3);
}

.chatbot__minimize-icon {
  width: 16px;
  height: 16px;
  fill: #ffffff;
}

/* ==========================================================================
   Body / Messages Area - Conversation Style
   ========================================================================== */
.chatbot__body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
}

/* ==========================================================================
   Conversation Item (Bot message + User input/answer)
   ========================================================================== */
.chatbot__conversation-item {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chatbot__conversation-item.is-completed .chatbot__input-area {
  display: none;
}

.chatbot__conversation-item.is-completed .chatbot__user-answer {
  display: flex;
}

/* ==========================================================================
   Bot Message with Avatar
   ========================================================================== */
.chatbot__bot-message {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.chatbot__avatar {
  width: var(--chatbot-avatar-size);
  height: var(--chatbot-avatar-size);
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.chatbot__message {
  background: var(--chatbot-message-bg);
  padding: 12px 16px;
  border-radius: 4px 18px 18px 18px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--chatbot-text);
  max-width: calc(100% - 50px);
  animation: fadeInUp 0.3s ease forwards;
}

.chatbot__message p {
  margin: 0;
}

/* ==========================================================================
   User Answer Bubble (Right-aligned)
   ========================================================================== */
.chatbot__user-answer {
  display: none;
  justify-content: flex-end;
  animation: fadeInUp 0.3s ease forwards;
}

.chatbot__user-bubble {
  background: var(--chatbot-user-bg);
  color: #ffffff;
  padding: 10px 16px;
  border-radius: 18px 18px 4px 18px;
  font-size: 14px;
  line-height: 1.5;
  max-width: 80%;
  word-break: break-word;
}

.chatbot__user-bubble--editable {
  cursor: pointer;
  position: relative;
}

.chatbot__user-bubble--editable:hover {
  opacity: 0.9;
}

.chatbot__user-bubble--editable::after {
  content: "クリックで編集";
  position: absolute;
  bottom: -20px;
  right: 0;
  font-size: 10px;
  color: var(--chatbot-text-light);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.chatbot__user-bubble--editable:hover::after {
  opacity: 1;
}

/* ==========================================================================
   Input Area
   ========================================================================== */
.chatbot__input-area {
  padding-left: 50px;
}

.chatbot__form-group {
  margin-bottom: 12px;
}

.chatbot__label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--chatbot-text-light);
  margin-bottom: 6px;
}

.chatbot__input,
.chatbot__textarea,
.chatbot__select {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--chatbot-border);
  border-radius: 8px;
  font-size: 14px;
  color: var(--chatbot-text);
  background: #ffffff;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  box-sizing: border-box;
}

.chatbot__input:focus,
.chatbot__textarea:focus,
.chatbot__select:focus {
  outline: none;
  border-color: var(--chatbot-primary);
  box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.1);
}

.chatbot__input::placeholder,
.chatbot__textarea::placeholder {
  color: #aaaaaa;
}

.chatbot__input.is-invalid,
.chatbot__textarea.is-invalid {
  border-color: #dc3545;
}

.chatbot__textarea {
  min-height: 80px;
  resize: vertical;
}

.chatbot__error {
  color: #dc3545;
  font-size: 12px;
  margin-top: 4px;
  display: none;
}

.chatbot__error.is-visible {
  display: block;
}

/* Amount Input with Yen Symbol */
.chatbot__amount-wrapper {
  position: relative;
}

.chatbot__amount-wrapper .chatbot__input {
  padding-right: 40px;
}

.chatbot__amount-suffix {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--chatbot-text-light);
  font-size: 14px;
}

/* ==========================================================================
   Navigation Buttons
   ========================================================================== */
.chatbot__nav {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.chatbot__btn {
  flex: 1;
  padding: 10px 16px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s ease, transform 0.1s ease;
}

.chatbot__btn:active {
  transform: scale(0.98);
}

.chatbot__btn--primary {
  background: var(--chatbot-primary);
  color: #ffffff;
}

.chatbot__btn--primary:hover {
  background: var(--chatbot-primary-hover);
}

.chatbot__btn--primary:disabled {
  background: #cccccc;
  cursor: not-allowed;
}

.chatbot__btn--submit {
  background: #28a745;
  color: #ffffff;
}

.chatbot__btn--submit:hover {
  background: #218838;
}

.chatbot__btn--submit:disabled {
  background: #cccccc;
  cursor: not-allowed;
}

/* ==========================================================================
   Confirmation Section
   ========================================================================== */
.chatbot__confirmation {
  background: #f8f9fa;
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 12px;
}

.chatbot__confirmation-item {
  display: flex;
  flex-direction: column;
  padding: 8px 0;
  border-bottom: 1px solid var(--chatbot-border);
}

.chatbot__confirmation-item:last-child {
  border-bottom: none;
}

.chatbot__confirmation-label {
  font-size: 11px;
  color: var(--chatbot-text-light);
  margin-bottom: 2px;
}

.chatbot__confirmation-value {
  font-size: 13px;
  color: var(--chatbot-text);
  word-break: break-word;
}

/* Privacy Policy Link */
.chatbot__privacy-link {
  color: var(--chatbot-primary);
  text-decoration: underline;
}

.chatbot__privacy-link:hover {
  text-decoration: none;
}

/* Consent Checkbox */
.chatbot__consent {
  margin: 12px 0;
}

.chatbot__consent-label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  font-size: 13px;
  line-height: 1.5;
  color: var(--chatbot-text);
}

.chatbot__consent-label input {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  flex-shrink: 0;
  cursor: pointer;
  accent-color: var(--chatbot-primary);
}

/* ==========================================================================
   Success Message
   ========================================================================== */
.chatbot__success {
  text-align: center;
  padding: 30px 20px;
}

.chatbot__success-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 16px;
  background: var(--chatbot-primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chatbot__success-icon svg {
  width: 28px;
  height: 28px;
  fill: #ffffff;
}

.chatbot__success-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--chatbot-text);
  margin-bottom: 8px;
}

.chatbot__success-text {
  font-size: 13px;
  color: var(--chatbot-text-light);
  line-height: 1.6;
}

/* ==========================================================================
   Typing Indicator (Loading dots)
   ========================================================================== */
.chatbot__typing {
  display: none;
  align-items: flex-start;
  gap: 10px;
  animation: fadeInUp 0.3s ease forwards;
}

.chatbot__typing.is-visible {
  display: flex;
}

.chatbot__typing-bubble {
  background: var(--chatbot-message-bg);
  padding: 14px 20px;
  border-radius: 4px 18px 18px 18px;
  display: flex;
  align-items: center;
  gap: 4px;
}

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

.chatbot__typing-dot:nth-child(1) {
  animation-delay: 0s;
}

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

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

@keyframes typingBounce {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.4;
  }
  30% {
    transform: translateY(-6px);
    opacity: 1;
  }
}

/* ==========================================================================
   Confirmation Modal
   ========================================================================== */
.chatbot__modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 10;
  display: none;
  align-items: center;
  justify-content: center;
  border-radius: var(--chatbot-radius);
  animation: fadeIn 0.2s ease;
}

.chatbot__modal-overlay.is-visible {
  display: flex;
}

.chatbot__modal {
  background: #ffffff;
  border-radius: 12px;
  padding: 24px;
  max-width: 320px;
  width: 90%;
  text-align: center;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  animation: scaleIn 0.2s ease;
}

.chatbot__modal-text {
  font-size: 15px;
  color: var(--chatbot-text);
  margin-bottom: 20px;
  line-height: 1.6;
}

.chatbot__modal-buttons {
  display: flex;
  gap: 10px;
}

.chatbot__modal-btn {
  flex: 1;
  padding: 12px 16px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.chatbot__modal-btn--cancel {
  background: #e9ecef;
  color: var(--chatbot-text);
}

.chatbot__modal-btn--cancel:hover {
  background: #dee2e6;
}

.chatbot__modal-btn--confirm {
  background: #dc3545;
  color: #ffffff;
}

.chatbot__modal-btn--confirm:hover {
  background: #c82333;
}

/* ==========================================================================
   Animations
   ========================================================================== */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

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

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* ==========================================================================
   Mobile Responsive
   ========================================================================== */
@media (max-width: 767px) {
  .chatbot-toggle {
    bottom: 90px;
    right: 15px;
    padding: 8px 16px 8px 8px;
    opacity: 0;
    pointer-events: none;
    transform: scale(0.8) translateY(20px);
  }

  .chatbot-toggle.is-active {
    opacity: 1;
    pointer-events: auto;
    transform: scale(1) translateY(0);
  }

  .chatbot-toggle__avatar {
    width: 32px;
    height: 32px;
  }

  .chatbot-toggle__text {
    font-size: 13px;
  }

  .chatbot {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    max-width: 100%;
    height: 85vh;
    max-height: 85vh;
    border-radius: var(--chatbot-radius) var(--chatbot-radius) 0 0;
    transform-origin: bottom center;
  }

  .chatbot__header {
    padding: 12px 14px;
  }

  .chatbot__body {
    padding: 14px;
  }

  .chatbot__avatar {
    width: 32px;
    height: 32px;
  }

  .chatbot__input-area {
    padding-left: 42px;
  }

  .chatbot__message {
    max-width: calc(100% - 42px);
    padding: 10px 14px;
    font-size: 13px;
  }

  .chatbot__user-bubble {
    font-size: 13px;
    padding: 8px 14px;
  }

  .chatbot__modal {
    max-width: 280px;
    padding: 20px;
  }
}
