/* ============================================================
   自社LP チャットウィジェット スタイルシート
   既存 style.css のデザイントークン（:root の --color-* 等）をそのまま
   参照する。新規トークンは追加せず、既存LPのトーンに合わせる。
   モバイル幅（〜480px）でも崩れないよう、パネルの最大幅・高さを
   viewport基準で制御する。
   ============================================================ */

/* 視覚的には隠すがスクリーンリーダーには読ませるラベル用（既存style.cssに
   同等クラスが無いためここに追加。チャットウィジェット専用ではないが、
   使用箇所がこのウィジェットのみのため同居させる）。 */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.chat-widget {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 1000;
  font-family: var(--font-base);
}

.chat-widget-toggle {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: var(--color-blue);
  color: #ffffff;
  font-size: 24px;
  line-height: 56px;
  text-align: center;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(18, 33, 63, 0.28);
  transition: background 0.15s ease, transform 0.15s ease;
}

.chat-widget-toggle:hover {
  background: var(--color-blue-dark);
  transform: translateY(-2px);
}

.chat-widget-toggle:focus-visible {
  outline: 3px solid var(--color-accent);
  outline-offset: 2px;
}

.chat-widget-panel {
  position: fixed;
  right: 20px;
  bottom: 88px;
  width: 360px;
  max-width: calc(100vw - 32px);
  height: 480px;
  max-height: calc(100vh - 140px);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: 0 12px 32px rgba(18, 33, 63, 0.22);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-widget-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--color-navy);
  color: #ffffff;
}

.chat-widget-header h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
}

.chat-widget-close {
  background: none;
  border: none;
  color: #ffffff;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 6px;
}

.chat-widget-close:focus-visible {
  outline: 2px solid var(--color-accent);
}

.chat-widget-history {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
  background: var(--color-bg-soft);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chat-msg {
  max-width: 85%;
  padding: 8px 12px;
  border-radius: var(--radius);
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

.chat-msg--user {
  align-self: flex-end;
  background: var(--color-blue);
  color: #ffffff;
  border-bottom-right-radius: 4px;
}

.chat-msg--bot {
  align-self: flex-start;
  background: #ffffff;
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-bottom-left-radius: 4px;
}

.chat-widget-status {
  padding: 0 16px;
  font-size: 12px;
  color: var(--color-text-muted);
  min-height: 16px;
}

.chat-widget-form {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--color-border);
  background: var(--color-bg);
}

.chat-widget-input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 13px;
  font-family: var(--font-base);
  color: var(--color-text);
}

.chat-widget-input:focus-visible {
  outline: 2px solid var(--color-blue);
  outline-offset: 1px;
}

.chat-widget-send {
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius);
  background: var(--color-blue);
  color: #ffffff;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.chat-widget-send:hover {
  background: var(--color-blue-dark);
}

.chat-widget-send:disabled,
.chat-widget-input:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* モバイル幅: パネルを画面幅いっぱいに近づけ、トグルボタンと重ならないようにする */
@media (max-width: 480px) {
  .chat-widget {
    right: 12px;
    bottom: 12px;
  }

  .chat-widget-panel {
    right: 12px;
    bottom: 76px;
    width: calc(100vw - 24px);
    height: calc(100vh - 120px);
  }
}
