/* =========================================
   Burst AI Chat CTA - フロント用スタイル
   - すべてのクラスを baicc- でプレフィックスし、テーマ側CSSと衝突しないようにしています
   - z-index は WPテーマや他プラグインに負けないように高めに設定
========================================= */

:root {
  --baicc-brand: #1e6fd6;
  --baicc-brand-dark: #155aac;
  --baicc-brand-light: #e8f1fc;
  --baicc-text: #1f2937;
  --baicc-text-sub: #6b7280;
  --baicc-bg: #f5f8fc;
  --baicc-white: #ffffff;
  --baicc-border: #e5e7eb;
  --baicc-line: #06c755;
  --baicc-shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.18);
}

/* ---------- 共通 ---------- */
#baicc-toggle,
#baicc-panel,
#baicc-panel * {
  box-sizing: border-box;
  font-family: "Noto Sans JP", "Hiragino Sans", "Yu Gothic", "Meiryo", system-ui, -apple-system, sans-serif;
}

.baicc-visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* ---------- フローティング開閉ボタン ---------- */
.baicc-toggle {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 99998;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 12px 18px 12px 14px;
  background: var(--baicc-brand);
  color: var(--baicc-white);
  border: none;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.2;
  cursor: pointer;
  box-shadow: var(--baicc-shadow-lg);
  transition: background .2s ease, transform .1s ease;
  -webkit-appearance: none;
  appearance: none;
}
.baicc-toggle:hover { background: var(--baicc-brand-dark); }
.baicc-toggle:active { transform: translateY(1px); }
.baicc-toggle__icon {
  width: 28px; height: 28px;
  display: grid; place-items: center;
  background: rgba(255,255,255,0.2);
  border-radius: 50%;
  font-size: 16px;
}

/* ---------- チャットパネル ---------- */
.baicc-panel {
  position: fixed;
  right: 20px;
  bottom: 88px;
  z-index: 99999;
  width: min(380px, calc(100vw - 24px));
  height: min(580px, calc(100vh - 120px));
  background: var(--baicc-white);
  color: var(--baicc-text);
  border-radius: 18px;
  box-shadow: var(--baicc-shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(20px) scale(0.98);
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
  font-size: 14px;
  line-height: 1.65;
}
.baicc-panel.is-open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.baicc-panel__header {
  background: var(--baicc-brand);
  color: var(--baicc-white);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.baicc-panel__title { display: flex; align-items: center; gap: 12px; }
.baicc-panel__badge {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  display: grid; place-items: center;
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.5px;
}
.baicc-panel__name { margin: 0; font-weight: 700; font-size: 15px; }
.baicc-panel__status {
  margin: 2px 0 0;
  font-size: 12px;
  opacity: 0.9;
  display: flex; align-items: center; gap: 6px;
}
.baicc-panel__status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #4ade80;
  box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.7);
  animation: baicc-pulse 1.8s infinite;
}
@keyframes baicc-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.7); }
  70%  { box-shadow: 0 0 0 8px rgba(74, 222, 128, 0); }
  100% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0); }
}
.baicc-panel__close {
  width: 32px; height: 32px;
  border: none;
  background: rgba(255,255,255,0.15);
  color: var(--baicc-white);
  font-size: 20px;
  border-radius: 50%;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}
.baicc-panel__close:hover { background: rgba(255,255,255,0.28); }

/* ---------- メッセージ ---------- */
.baicc-panel__messages {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 16px;
  background: var(--baicc-bg);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.baicc-msg {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
  animation: baicc-msgIn .18s ease;
}
@keyframes baicc-msgIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.baicc-msg--ai {
  align-self: flex-start;
  background: var(--baicc-white);
  color: var(--baicc-text);
  border: 1px solid var(--baicc-border);
  border-top-left-radius: 4px;
}
.baicc-msg--user {
  align-self: flex-end;
  background: var(--baicc-brand);
  color: var(--baicc-white);
  border-top-right-radius: 4px;
}
.baicc-msg--system {
  align-self: center;
  background: transparent;
  color: var(--baicc-text-sub);
  font-size: 12px;
  padding: 4px 8px;
}

/* サマリーカード */
.baicc-summary {
  align-self: flex-start;
  width: 100%;
  background: var(--baicc-white);
  border: 1px solid var(--baicc-border);
  border-radius: 14px;
  padding: 14px;
  font-size: 13px;
  color: var(--baicc-text);
}
.baicc-summary__title {
  font-weight: 700;
  margin: 0 0 8px;
  color: var(--baicc-brand-dark);
  font-size: 13px;
}
.baicc-summary__list { list-style: none; padding: 0; margin: 0 0 10px; }
.baicc-summary__list li {
  display: flex;
  gap: 8px;
  padding: 4px 0;
  border-bottom: 1px dashed var(--baicc-border);
}
.baicc-summary__list li:last-child { border-bottom: none; }
.baicc-summary__list dt {
  min-width: 70px;
  color: var(--baicc-text-sub);
}
.baicc-summary__cta {
  display: flex; flex-direction: column; gap: 8px;
  margin-top: 10px;
}
.baicc-summary__cta a {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
  padding: 11px 12px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 14px;
  text-decoration: none;
  transition: background .15s ease, transform .1s ease, box-shadow .15s ease;
}
.baicc-summary__cta a:active { transform: translateY(1px); }

/* LINE：1番目／最も目立たせる */
.baicc-summary__cta a.is-line {
  background: var(--baicc-line);
  color: var(--baicc-white);
  padding: 13px 12px;
  font-size: 15px;
  box-shadow: 0 4px 12px rgba(6, 199, 85, 0.28);
}
.baicc-summary__cta a.is-line:hover { background: #05ad4a; }
.baicc-summary__cta a.is-line .baicc-cta-icon {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 20px;
  border-radius: 6px;
  background: var(--baicc-white);
  color: var(--baicc-line);
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.5px;
}
/* お問い合わせフォーム：2番目 */
.baicc-summary__cta a.is-primary {
  background: var(--baicc-brand); color: var(--baicc-white);
}
.baicc-summary__cta a.is-primary:hover { background: var(--baicc-brand-dark); }
/* 電話：3番目 */
.baicc-summary__cta a.is-ghost {
  background: var(--baicc-white); color: var(--baicc-brand);
  border: 1px solid var(--baicc-brand);
}
.baicc-summary__cta a.is-ghost:hover { background: var(--baicc-brand-light); }

/* タイピングインジケータ */
.baicc-typing { display: inline-flex; gap: 4px; align-items: center; }
.baicc-typing span {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--baicc-text-sub);
  animation: baicc-typing 1.2s infinite;
}
.baicc-typing span:nth-child(2) { animation-delay: .15s; }
.baicc-typing span:nth-child(3) { animation-delay: .30s; }
@keyframes baicc-typing {
  0%, 60%, 100% { transform: translateY(0); opacity: .3; }
  30%           { transform: translateY(-3px); opacity: 1; }
}

/* ---------- クイック返信 ---------- */
.baicc-panel__quick {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 12px 0;
  background: var(--baicc-white);
  border-top: 1px solid var(--baicc-border);
}
.baicc-panel__quick:empty { display: none; }
.baicc-quick-btn {
  border: 1px solid var(--baicc-brand);
  background: var(--baicc-white);
  color: var(--baicc-brand);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s ease;
}
.baicc-quick-btn:hover { background: var(--baicc-brand-light); }

/* ---------- 入力 ---------- */
.baicc-panel__form {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  background: var(--baicc-white);
  border-top: 1px solid var(--baicc-border);
  margin: 0;
}
.baicc-panel__input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--baicc-border);
  border-radius: 999px;
  font-size: 14px;
  outline: none;
  color: var(--baicc-text);
  background: var(--baicc-white);
  transition: border-color .15s ease, box-shadow .15s ease;
  -webkit-appearance: none;
  appearance: none;
}
.baicc-panel__input:focus {
  border-color: var(--baicc-brand);
  box-shadow: 0 0 0 3px rgba(30, 111, 214, 0.15);
}
.baicc-panel__send {
  border: none;
  background: var(--baicc-brand);
  color: var(--baicc-white);
  padding: 0 18px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  line-height: 1.2;
  -webkit-appearance: none;
  appearance: none;
}
.baicc-panel__send:hover { background: var(--baicc-brand-dark); }
.baicc-panel__send:disabled { background: #9ab4d8; cursor: not-allowed; }

/* ---------- 常時表示の下部CTA ---------- */
.baicc-panel__footer {
  padding: 8px 12px 12px;
  background: var(--baicc-white);
  text-align: center;
  font-size: 12px;
  color: var(--baicc-text-sub);
}
.baicc-panel__footer-link {
  color: var(--baicc-brand);
  font-weight: 700;
  text-decoration: none;
}
.baicc-panel__footer-link:hover { text-decoration: underline; }
.baicc-panel__footer-link.is-line-text { color: var(--baicc-line); }
.baicc-panel__footer-sep { margin: 0 6px; color: var(--baicc-border); }

/* ---------- スマホ最適化 ---------- */
@media (max-width: 480px) {
  .baicc-toggle__label { display: none; }
  .baicc-toggle {
    padding: 14px;
    right: 14px;
    bottom: 14px;
  }
  /* チャットを開いている間は丸ボタンを非表示にして重なりを防ぐ */
  body.baicc-open .baicc-toggle { display: none; }

  .baicc-panel {
    right: 12px;
    left: 12px;
    top: 64px;
    bottom: 12px;
    width: auto;
    height: auto;
    max-height: none;
    border-radius: 16px;
  }
  @supports (height: 100dvh) {
    .baicc-panel {
      top: auto;
      bottom: 12px;
      height: calc(100dvh - 76px);
      max-height: calc(100dvh - 76px);
    }
  }

  .baicc-panel__messages {
    padding: 14px;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }

  .baicc-msg { font-size: 15px; }

  .baicc-summary { padding: 14px 12px; }
  .baicc-summary__cta { gap: 10px; }
  .baicc-summary__cta a {
    min-height: 52px;
    padding: 14px 14px;
    font-size: 15.5px;
    border-radius: 12px;
  }
  .baicc-summary__cta a.is-line {
    min-height: 56px;
    padding: 16px 14px;
    font-size: 16px;
  }

  .baicc-panel__form {
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
    gap: 8px;
  }
  .baicc-panel__input {
    min-height: 48px;
    padding: 12px 16px;
    font-size: 16px;
    border-radius: 999px;
  }
  .baicc-panel__send {
    min-height: 48px;
    min-width: 64px;
    padding: 0 18px;
    font-size: 15px;
  }

  .baicc-panel__footer {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px 12px calc(12px + env(safe-area-inset-bottom, 0px));
  }
  .baicc-panel__footer-sep { display: none; }
  .baicc-panel__footer-link {
    display: block;
    text-align: center;
    min-height: 48px;
    line-height: 1.3;
    padding: 13px 12px;
    font-size: 15px;
    border-radius: 10px;
    border: 1px solid var(--baicc-brand);
    color: var(--baicc-brand);
    background: var(--baicc-white);
  }
  .baicc-panel__footer-link:hover { text-decoration: none; }
  .baicc-panel__footer-link.is-line-text {
    color: var(--baicc-white);
    background: var(--baicc-line);
    border-color: var(--baicc-line);
    box-shadow: 0 3px 10px rgba(6, 199, 85, 0.25);
  }

  .baicc-quick-btn {
    padding: 8px 14px;
    font-size: 13.5px;
  }
}
