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

:root {
  --bubble-green: #77CCB5;
  --bubble-green-border: #5db89f;
  --bubble-blue: #7DC1E0;
  --bubble-blue-border: #5aaed1;
  --bubble-yellow: #FCD24F;
  --bubble-yellow-border: #e8bc30;
  --bubble-red: #E8746B;
  --bubble-red-border: #d45c52;
  --bubble-purple: #E8746B;
  --bubble-purple-border: #d45c52;
}

body {
  font-family: "M PLUS Rounded 1c", sans-serif;
  background-color: #F4F4F4;
}

/* --- Speech bubble tail --- */
.speech-bubble { position: relative; }
.speech-bubble::before {
  content: "";
  position: absolute;
  left: -12px; top: 18px;
  width: 0; height: 0;
  border-top: 8px solid transparent;
  border-bottom: 8px solid transparent;
  border-right: 12px solid var(--border-color);
}
.speech-bubble::after {
  content: "";
  position: absolute;
  left: -10px; top: 18px;
  width: 0; height: 0;
  border-top: 8px solid transparent;
  border-bottom: 8px solid transparent;
  border-right: 12px solid var(--bg-color);
}
.bubble-green  { --bg-color: var(--bubble-green);  --border-color: var(--bubble-green-border); }
.bubble-blue   { --bg-color: var(--bubble-blue);   --border-color: var(--bubble-blue-border); }
.bubble-yellow { --bg-color: var(--bubble-yellow); --border-color: var(--bubble-yellow-border); }
.bubble-red    { --bg-color: var(--bubble-red);    --border-color: var(--bubble-red-border); }
.bubble-purple { --bg-color: var(--bubble-purple); --border-color: var(--bubble-purple-border); }

/* --- Select arrow --- */
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%234A4A4A'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
  background-position: right 0.75rem center;
  background-repeat: no-repeat;
  background-size: 1.25em 1.25em;
  padding-right: 2.5rem;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

/* --- Badges --- */
.required-badge {
  display: inline-block;
  background: #FF5A5A;
  color: white;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 2px;
  font-weight: bold;
  margin-left: 6px;
}
.optional-badge {
  display: inline-block;
  background: #9E9E9E;
  color: white;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 2px;
  font-weight: bold;
  margin-left: 6px;
}

/* --- Input card --- */
.input-card {
  background: #F9F9F9;
  padding: 1.5rem;
  border-radius: 20px;
  box-shadow: inset 0 2px 6px rgba(0,0,0,0.06);
}

/* --- Chat step visibility & animation --- */
.chat-step {
  display: none;
}
.chat-step.step-visible {
  display: block;
}
.chat-step .step-bubble { opacity: 0; }
.chat-step .step-input  { opacity: 0; }

.chat-step.step-animate .step-bubble {
  animation: chatSlideIn 0.4s ease forwards;
}
.chat-step.step-animate .step-input {
  animation: chatFadeUp 0.45s ease 0.35s forwards;
}

@keyframes chatSlideIn {
  from { transform: translateX(-16px); opacity: 0; }
  to   { transform: translateX(0);     opacity: 1; }
}
@keyframes chatFadeUp {
  from { transform: translateY(14px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

/* --- Typing indicator --- */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 14px;
  background: #e5e7eb;
  border-radius: 20px;
  margin-left: 60px;
  width: fit-content;
  margin-bottom: 10px;
}
.typing-indicator span {
  width: 7px; height: 7px;
  background: #9ca3af;
  border-radius: 50%;
  animation: typingBounce 1.2s ease-in-out infinite;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

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

/* --- Next / Skip buttons --- */
.next-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  width: 100%;
  margin-top: 1.25rem;
  padding: 0.875rem 2rem;
  background: linear-gradient(135deg, #5AC33B 0%, #4ea833 100%);
  color: white;
  font-weight: bold;
  font-size: 0.9rem;
  border-radius: 0.875rem;
  border: none;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  box-shadow: 0 4px 14px rgba(90,195,59,0.35);
  font-family: inherit;
}
.next-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(90,195,59,0.45);
}
.next-btn:active:not(:disabled) { transform: scale(0.97); }
.next-btn:disabled {
  background: linear-gradient(135deg, #9ca3af 0%, #6b7280 100%);
  box-shadow: none;
  cursor: default;
}
.skip-btn {
  display: block;
  width: 100%;
  margin-top: 0.5rem;
  padding: 0.4rem;
  color: #9ca3af;
  font-size: 0.7rem;
  cursor: pointer;
  background: none;
  border: none;
  text-decoration: underline;
  font-family: inherit;
  text-align: center;
}
.skip-btn:hover { color: #6b7280; }

/* --- Field errors --- */
.field-error {
  color: #FF5A5A;
  font-size: 0.7rem;
  margin-top: 0.25rem;
  display: none;
}
.field-error.show { display: block; }

/* --- Progress dots --- */
.step-progress {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  padding: 1.25rem 1.5rem 0;
}
.step-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #e5e7eb;
  transition: background 0.4s ease, transform 0.3s ease;
}
.step-dot.done    { background: #B8E986; }
.step-dot.current { background: #5AC33B; transform: scale(1.4); }

/* --- Sex select buttons --- */
.sex-btn {
  padding: 0.5rem 1.5rem;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  font-weight: bold;
  border: 2px solid #e5e7eb;
  background: #f3f4f6;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}
.sex-btn.selected  { background: var(--bubble-green); border-color: var(--bubble-green-border); }
.sex-btn:hover:not(.selected) { background: #e5e7eb; }

/* ===== main.css 競合リセット（#chatbot-form スコープで上書き） ===== */

/* フォントサイズ・行高・文字色のリセット（body { font-size:.8em } 対策） */
#chatbot-form {
  font-size: 16px;
  line-height: 1.5;
  color: #4A4A4A;
  font-family: "M PLUS Rounded 1c", sans-serif;
  letter-spacing: normal;
}

/* select の float・height・radius リセット */
#chatbot-form select {
  float: none !important;
  height: auto !important;
  border-radius: 0.75rem !important;
  margin: 0 !important;
  padding: 0.75rem !important;
  padding-right: 2.5rem !important;
  border: 1px solid #e5e7eb !important;
  box-shadow: none !important;
  font-size: 0.875rem !important;
  line-height: 1.5 !important;
  background-color: #fff !important;
  -webkit-appearance: none !important;
  -moz-appearance: none !important;
  appearance: none !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%234A4A4A'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E") !important;
  background-position: right 0.75rem center !important;
  background-repeat: no-repeat !important;
  background-size: 1.25em 1.25em !important;
  width: auto;
}

/* input[type=text/password/email/tel] の radius・height リセット */
#chatbot-form input[type='text'],
#chatbot-form input[type='password'],
#chatbot-form input[type='email'],
#chatbot-form input[type='tel'],
#chatbot-form input[type='number'] {
  border-radius: 0.75rem !important;
  height: auto !important;
  line-height: 1.5 !important;
  padding: 0.75rem !important;
  border: 1px solid #e5e7eb !important;
  box-shadow: none !important;
  font-size: 0.875rem !important;
  font-family: inherit !important;
  color: #4A4A4A !important;
  margin: 0 !important;
  width: 100%;
  box-sizing: border-box;
}

/* checkbox: サイト側CSSの上書きを強制リセット */
#chatbot-form input[type='checkbox'] {
  -webkit-appearance: checkbox !important;
  -moz-appearance: checkbox !important;
  appearance: checkbox !important;
  width: 1rem !important;
  height: 1rem !important;
  min-width: 1rem !important;
  min-height: 1rem !important;
  border-radius: 0.25rem !important;
  padding: 0 !important;
  margin: 0 !important;
  border: 1.5px solid #d1d5db !important;
  background-color: #fff !important;
  cursor: pointer;
  accent-color: #5AC33B;
  flex-shrink: 0;
}

/* button の font-size・line-height リセット */
#chatbot-form button {
  font-family: "M PLUS Rounded 1c", sans-serif !important;
  font-size: inherit !important;
  line-height: inherit !important;
}

/* h1-h5 の font-size リセット（もし使用している場合） */
#chatbot-form h1,
#chatbot-form h2,
#chatbot-form h3 {
  font-size: revert !important;
  line-height: revert !important;
}

/* img の float 防止 */
#chatbot-form img {
  display: inline !important;
  float: none !important;
}

/* フォームラッパー: 幅・余白の正規化 */
.form {
  width: 100%;
  padding: 2rem 1rem;
  box-sizing: border-box;
}

#chatbot-form {
  width: 100% !important;
  max-width: 550px !important;
  margin-left: auto !important;
  margin-right: auto !important;
  box-sizing: border-box;
}

/* フォーム内 p タグの余白リセット（サイトCSS対策） */
#chatbot-form p {
  margin: 0 !important;
  padding: 0 !important;
}

/* フォーム内 label の幅リセット */
#chatbot-form label {
  width: auto !important;
  float: none !important;
  display: block;
}

/* flex/inline-flex ラッパー内の label */
#chatbot-form .flex label,
#chatbot-form .inline-flex label {
  display: inline-flex !important;
}
