/* TESRA Chatbot - production styles (scoped to .chatbot / #chatbot / .tesra-cta-launcher) */

#chatbot.chatbot[hidden] { display: none !important; }
#chatbot.chatbot {
  position: fixed; inset: 0; z-index: 99999;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", "Noto Sans JP", system-ui, sans-serif;
  color: #1a1f2c;
  line-height: 1.7;
  animation: tesraFadeIn .2s ease;
}
@keyframes tesraFadeIn { from { opacity: 0 } to { opacity: 1 } }

#chatbot .chatbot-mask {
  position: absolute; inset: 0;
  background: rgba(8, 14, 30, 0.65);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}
#chatbot .chatbot-window {
  position: relative;
  width: 100%; max-width: 480px;
  height: 100%; max-height: 720px;
  background: #fff; border-radius: 18px;
  display: flex; flex-direction: column;
  overflow: hidden;
  box-shadow: 0 24px 48px rgba(0,0,0,0.35);
}
@media (max-height: 740px) {
  #chatbot .chatbot-window { max-height: calc(100vh - 32px); }
}
@media (min-width: 720px) {
  #chatbot .chatbot-window { height: 720px; }
}

#chatbot .chatbot-head {
  background: linear-gradient(135deg, #1f3a6b 0%, #0c1b3a 100%);
  color: #fff;
  padding: 14px 16px;
  display: flex; align-items: center; justify-content: space-between;
}
#chatbot .chatbot-head-left { display: flex; align-items: center; gap: 10px; }
#chatbot .chatbot-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: #fff;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}
#chatbot .chatbot-avatar img { width: 100%; height: 100%; object-fit: contain; padding: 4px; box-sizing: border-box; }
#chatbot .chatbot-name { font-weight: 700; font-size: 15px; }
#chatbot .chatbot-status { font-size: 12px; opacity: 0.85; display: flex; align-items: center; gap: 6px; }
#chatbot .chatbot-status .dot {
  width: 8px; height: 8px; border-radius: 50%; background: #4ade80;
  box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.6);
  animation: tesraPulse 1.6s infinite;
}
@keyframes tesraPulse {
  0% { box-shadow: 0 0 0 0 rgba(74,222,128,0.6); }
  70% { box-shadow: 0 0 0 6px rgba(74,222,128,0); }
  100% { box-shadow: 0 0 0 0 rgba(74,222,128,0); }
}
#chatbot .chatbot-close {
  background: transparent; border: none; color: #fff; font-size: 24px; cursor: pointer;
  width: 32px; height: 32px; border-radius: 50%; padding: 0;
  font-family: inherit;
}
#chatbot .chatbot-close:hover { background: rgba(255,255,255,0.1); }

#chatbot .chatbot-progress { height: 3px; background: #e3e7ee; }
#chatbot .chatbot-progress .bar {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, #e9c97c, #f3d990);
  transition: width .3s ease;
}
#chatbot .chatbot-remain {
  position: relative;
  background:
    linear-gradient(120deg,
      #fff3c2 0%,
      #ffe28a 30%,
      #ffd45a 50%,
      #ffe28a 70%,
      #fff3c2 100%);
  background-size: 200% 100%;
  color: #b04300;
  font-size: 16px;
  font-weight: 900;
  text-align: center;
  padding: 14px 16px;
  border-bottom: 3px solid #f0a830;
  letter-spacing: 0.04em;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  overflow: hidden;
  text-shadow: 0 1px 0 rgba(255,255,255,0.5);
  animation: tesraRemainShimmer 3s linear infinite;
}
#chatbot .chatbot-remain::before {
  content: '⏱';
  font-size: 20px;
  display: inline-block;
  animation: tesraRemainTick 1.4s ease-in-out infinite;
}
#chatbot .chatbot-remain .remain-num {
  display: inline-block;
  background: #d62828;
  color: #fff;
  border-radius: 8px;
  padding: 4px 12px;
  margin: 0 4px;
  font-size: 20px;
  font-weight: 900;
  min-width: 36px;
  box-shadow: 0 2px 0 rgba(0,0,0,0.2), 0 0 0 0 rgba(214, 40, 40, 0.6);
  animation: tesraRemainPulse 1.6s ease-in-out infinite;
  text-shadow: none;
  vertical-align: middle;
  line-height: 1.2;
}
#chatbot .chatbot-remain:empty { display: none; }

@keyframes tesraRemainShimmer {
  0%   { background-position: 0% 50%; }
  100% { background-position: 200% 50%; }
}
@keyframes tesraRemainTick {
  0%, 100% { transform: rotate(0deg); }
  25%      { transform: rotate(-12deg); }
  75%      { transform: rotate(12deg); }
}
@keyframes tesraRemainPulse {
  0%   { box-shadow: 0 2px 0 rgba(0,0,0,0.2), 0 0 0 0 rgba(214, 40, 40, 0.7); transform: scale(1); }
  50%  { box-shadow: 0 2px 0 rgba(0,0,0,0.2), 0 0 0 10px rgba(214, 40, 40, 0); transform: scale(1.08); }
  100% { box-shadow: 0 2px 0 rgba(0,0,0,0.2), 0 0 0 0 rgba(214, 40, 40, 0); transform: scale(1); }
}

@media (max-width: 480px) {
  #chatbot .chatbot-remain { font-size: 14px; padding: 12px 12px; }
  #chatbot .chatbot-remain .remain-num { font-size: 17px; padding: 3px 10px; min-width: 30px; }
  #chatbot .chatbot-remain::before { font-size: 17px; }
}

#chatbot .chatbot-body {
  flex: 1; overflow-y: auto;
  padding: 16px;
  background: #f8f9fc;
  display: flex; flex-direction: column; gap: 8px;
  scroll-behavior: smooth;
}

#chatbot .msg { display: flex; gap: 8px; max-width: 88%; align-items: flex-end; }
#chatbot .msg.bot { align-self: flex-start; }
#chatbot .msg.user { align-self: flex-end; flex-direction: row-reverse; }
#chatbot .msg-avatar {
  display: flex; flex-direction: column; align-items: center;
  flex-shrink: 0; width: 36px;
}
#chatbot .msg-avatar img {
  width: 36px; height: 36px; border-radius: 50%;
  object-fit: cover; border: 2px solid #fff;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
#chatbot .msg-avatar .name {
  font-size: 9px; color: #6b7280; margin-top: 2px;
  white-space: nowrap; line-height: 1;
}
#chatbot .msg-avatar.spacer img,
#chatbot .msg-avatar.spacer .name { visibility: hidden; }

#chatbot .bubble {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.6;
  word-break: break-word;
  white-space: pre-wrap;
}
#chatbot .msg.bot .bubble {
  background: #fff;
  color: #1a1f2c;
  border: 1px solid #e3e7ee;
  border-top-left-radius: 4px;
}
#chatbot .msg.user .bubble {
  background: #0c1b3a;
  color: #fff;
  border-top-right-radius: 4px;
}

#chatbot .bubble-typing { display: inline-flex; gap: 4px; padding: 4px 0; }
#chatbot .bubble-typing span {
  width: 6px; height: 6px; border-radius: 50%; background: #b0b6c2;
  animation: tesraBounce 1s infinite;
}
#chatbot .bubble-typing span:nth-child(2) { animation-delay: .15s }
#chatbot .bubble-typing span:nth-child(3) { animation-delay: .3s }
@keyframes tesraBounce {
  0%, 80%, 100% { transform: translateY(0); opacity: .5; }
  40% { transform: translateY(-4px); opacity: 1; }
}

#chatbot .chatbot-input {
  border-top: 1px solid #e3e7ee;
  background: #fff;
  padding: 12px;
  display: flex; flex-direction: column; gap: 8px;
}
#chatbot .field-meta {
  display: flex; align-items: center; gap: 8px;
  font-size: 11px;
  margin-bottom: -2px;
}
#chatbot .field-required {
  background: #d62828; color: #fff;
  font-weight: 700; padding: 2px 6px; border-radius: 4px;
  font-size: 10px;
}
#chatbot .field-optional {
  background: #6b7280; color: #fff;
  font-weight: 700; padding: 2px 6px; border-radius: 4px;
  font-size: 10px;
}
#chatbot .field-hint { color: #6b7280; }
#chatbot .field-error {
  color: #d62828; font-size: 12px; font-weight: 700;
  padding-top: 2px;
}
#chatbot .input-back {
  background: transparent; border: none;
  color: #6b7280; font-size: 12px; padding: 4px 8px;
  cursor: pointer; align-self: flex-start;
  text-decoration: underline;
}
#chatbot .input-back:hover { color: #0c1b3a; }
#chatbot .zip-preview {
  background: #e8f5e9; color: #1f5d2c;
  font-size: 12px; font-weight: 700;
  padding: 6px 10px; border-radius: 6px;
  border: 1px solid #4caf50;
}
#chatbot .zip-preview.error {
  background: #ffebee; color: #c62828; border-color: #ef5350;
}
#chatbot .chatbot-input .row { display: flex; gap: 8px; }
#chatbot .chatbot-input input[type=text],
#chatbot .chatbot-input input[type=email],
#chatbot .chatbot-input input[type=tel],
#chatbot .chatbot-input input[type=date],
#chatbot .chatbot-input textarea {
  flex: 1;
  padding: 12px 14px;
  border: 1px solid #e3e7ee;
  border-radius: 10px;
  font-size: 16px;
  outline: none;
  font-family: inherit;
  background: #fff;
  color: #1a1f2c;
}
#chatbot .chatbot-input input:focus,
#chatbot .chatbot-input textarea:focus { border-color: #0c1b3a; }
#chatbot .chatbot-input textarea { resize: vertical; min-height: 72px; }

#chatbot .send-btn {
  background: #0c1b3a;
  color: #fff;
  border: none;
  padding: 12px 20px;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 700;
  white-space: nowrap;
  font-family: inherit;
}
#chatbot .send-btn:hover { background: #16284a; }
#chatbot .send-btn:disabled { opacity: .5; cursor: not-allowed; }

#chatbot .skip-btn,
#chatbot .ghost-btn {
  background: transparent;
  color: #6b7280;
  border: 1px solid #e3e7ee;
  padding: 8px 14px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
}
#chatbot .skip-btn:hover,
#chatbot .ghost-btn:hover { background: #f1f3f7; }

#chatbot .chip-group { display: flex; flex-wrap: wrap; gap: 8px; }
#chatbot .chip {
  background: #fff;
  border: 1px solid #e3e7ee;
  padding: 10px 14px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 14px;
  transition: all .12s ease;
  font-family: inherit;
  color: #1a1f2c;
}
#chatbot .chip:hover { border-color: #0c1b3a; }
#chatbot .chip.selected {
  background: #0c1b3a; color: #fff; border-color: #0c1b3a;
}
#chatbot .chip-actions { display: flex; gap: 8px; margin-top: 4px; }

#chatbot .summary-card {
  background: #fff;
  border: 1px solid #e3e7ee;
  border-radius: 12px;
  padding: 12px 14px;
  margin: 8px 0;
}
#chatbot .summary-card dt { font-size: 12px; color: #6b7280; margin-top: 6px; }
#chatbot .summary-card dt:first-child { margin-top: 0; }
#chatbot .summary-card dd { margin: 0; font-size: 14px; }

/* ===== LP CTA bar (デフォルトはインライン表示) ===== */
.lp-cta {
  background: #0c1b3a;
  padding: 12px;
  display: flex;
  flex-direction: row;
  gap: 8px;
  margin: 0 auto;
  max-width: 980px;
  border-radius: 0;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", "Noto Sans JP", system-ui, sans-serif;
}
/* 親ブロック(ctwlpt-block-section)が wp:html ブロック周りに余白を作るのを打ち消す */
.lp-cta,
.wp-block-html .lp-cta {
  margin-top: 0 !important;
  margin-bottom: 0 !important;
}
.wp-block-html:has(> .lp-cta),
.lp-cta + p,
.lp-cta + br {
  margin: 0 !important;
}

/* 最下部の1つだけフローティング固定（JSで lp-cta--float クラス付与） */
.lp-cta.lp-cta--float {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 9000;
  margin: 0;
  max-width: none;
  border-radius: 0;
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  box-shadow: 0 -8px 24px rgba(0,0,0,0.4);
  border-top: 1px solid rgba(255,255,255,0.08);
  /* 初期は画面外に隠す - スクロール追跡で表示 */
  transform: translateY(110%);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.45s cubic-bezier(0.22, 0.61, 0.36, 1), opacity 0.35s ease;
}
.lp-cta.lp-cta--float.lp-cta--shown {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}
/* フローティング表示時に下端で隠れないようbodyに余白 */
body.tesra-cta-floating-active { padding-bottom: 96px; }
@media (max-width: 480px) {
  body.tesra-cta-floating-active { padding-bottom: 78px; }
}

.lp-cta .cta-btn {
  flex: 1 1 50%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  text-decoration: none;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  font-size: 14px;
  border: 1px solid rgba(0,0,0,0.2);
  box-shadow: 0 2px 6px rgba(0,0,0,0.25);
  transition: transform .12s ease, box-shadow .12s ease, filter .12s ease;
  min-width: 0;
}
.lp-cta .cta-btn:hover { transform: translateY(-1px); filter: brightness(1.05); }
.lp-cta .cta-btn:active { transform: translateY(1px); }

.lp-cta .cta-tel {
  background: linear-gradient(180deg, #fafbfd 0%, #dfe3ea 100%);
  color: #0c1b3a;
}
.lp-cta .cta-tel .cta-label { font-size: 10px; font-weight: 600; line-height: 1.2; }
.lp-cta .cta-tel .cta-num { font-size: 22px; font-weight: 800; letter-spacing: 0.02em; line-height: 1.1; color: #0c1b3a; }
.lp-cta .cta-tel .cta-note { font-size: 9px; color: #444; line-height: 1.3; }

.lp-cta .cta-form {
  background: linear-gradient(180deg, #d62828 0%, #8a1a1a 100%);
  color: #fff;
  position: relative;
  animation: tesraCtaPulse 2.4s infinite;
}
.lp-cta .cta-form .cta-title { font-size: 17px; font-weight: 800; line-height: 1.1; }
.lp-cta .cta-form .cta-note { font-size: 11px; color: #ffe7a3; line-height: 1.3; }
.lp-cta .cta-form .cta-arrow { font-size: 12px; color: #fff; flex-shrink: 0; padding-left: 4px; }

@keyframes tesraCtaPulse {
  0% { box-shadow: 0 2px 6px rgba(0,0,0,0.25), 0 0 0 0 rgba(214, 40, 40, 0.6); }
  70% { box-shadow: 0 2px 6px rgba(0,0,0,0.25), 0 0 0 12px rgba(214, 40, 40, 0); }
  100% { box-shadow: 0 2px 6px rgba(0,0,0,0.25), 0 0 0 0 rgba(214, 40, 40, 0); }
}

.lp-cta .cta-icon { display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.lp-cta .cta-icon svg { width: 26px; height: 26px; }
.lp-cta .cta-body { flex: 1; display: flex; flex-direction: column; align-items: center; text-align: center; min-width: 0; line-height: 1.3; }

@media (max-width: 480px) {
  .lp-cta { padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); gap: 6px; }
  .lp-cta .cta-btn { padding: 8px 10px; gap: 8px; border-radius: 10px; }
  .lp-cta .cta-icon svg { width: 20px; height: 20px; }
  .lp-cta .cta-tel .cta-label { font-size: 8px; }
  .lp-cta .cta-tel .cta-num { font-size: 16px; }
  .lp-cta .cta-tel .cta-note { font-size: 7px; }
  .lp-cta .cta-form .cta-title { font-size: 13px; }
  .lp-cta .cta-form .cta-note { font-size: 9px; }
  .lp-cta .cta-form .cta-arrow { font-size: 10px; }
}

.lp-footer { display: none; }
