/* AI Digital Employee チャット窓口
   テーマのCSSと混ざらないよう、すべて .ade の中だけに効かせる。
   画面の左下に置く(24ROADの企業ページは右下に追従ボタンがあるため)。 */

.ade {
  --ade-accent: #b3261e;
  --ade-accent-dark: #8e0200;
  --ade-text: #1f1f1f;
  --ade-muted: #5f6368;
  --ade-line: #dadce0;
  --ade-bg-soft: #f5f6f8;
  position: fixed;
  left: 20px;
  bottom: 20px;
  z-index: 9990;
  font-size: 15px;
  line-height: 1.7;
  color: var(--ade-text);
}

.ade *,
.ade *::before,
.ade *::after { box-sizing: border-box; }

.ade-launcher {
  display: block;
  margin: 0;
  padding: 14px 22px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(to right, var(--ade-accent-dark), var(--ade-accent));
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .25);
}

.ade-launcher:focus-visible,
.ade-close:focus-visible,
.ade-send:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 0;
  box-shadow: 0 0 0 5px #1a1a1a;
}

.ade.is-open .ade-launcher { display: none; }

.ade-panel {
  display: flex;
  flex-direction: column;
  width: 370px;
  max-width: calc(100vw - 40px);
  height: 560px;
  max-height: calc(100vh - 40px);
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .28);
  overflow: hidden;
}

.ade-panel[hidden] { display: none; }

.ade-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 12px 12px 16px;
  background: linear-gradient(to right, var(--ade-accent-dark), var(--ade-accent));
  color: #fff;
}

.ade .ade-title {
  margin: 0;
  padding: 0;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.4;
  color: #fff;
  border: 0;
  background: none;
  min-width: 0; /* 長い見出しはこちらで折り返す(閉じるボタンは折り返さない・0.2.4) */
}

.ade .ade-title::before,
.ade .ade-title::after { content: none; }

.ade-close {
  flex: 0 0 auto;
  white-space: nowrap;
  margin: 0;
  padding: 6px 12px;
  border: 1px solid rgba(255, 255, 255, .7);
  border-radius: 999px;
  background: transparent;
  color: #fff;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.ade .ade-notice {
  margin: 0;
  padding: 8px 16px;
  font-size: 12px;
  line-height: 1.6;
  color: var(--ade-muted);
  background: #fffbea;
  border-bottom: 1px solid var(--ade-line);
}

.ade .ade-log {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0;
  padding: 16px;
  list-style: none;
  overflow-y: auto;
  background: var(--ade-bg-soft);
}

.ade .ade-msg {
  max-width: 88%;
  margin: 0;
  padding: 10px 12px;
  border-radius: 12px;
  white-space: pre-wrap;
  word-break: break-word;
  list-style: none;
}

.ade .ade-msg::before { content: none; }

.ade-msg--user {
  align-self: flex-end;
  background: #2b2b2b;
  color: #fff;
  border-bottom-right-radius: 4px;
}

.ade-msg--assistant {
  align-self: flex-start;
  background: #fff;
  border: 1px solid var(--ade-line);
  border-bottom-left-radius: 4px;
}

.ade-msg--assistant a { color: var(--ade-accent); text-decoration: underline; word-break: break-all; }

.ade-msg--waiting { color: var(--ade-muted); }
.ade-msg--waiting::after {
  content: "…";
  animation: ade-blink 1s infinite;
}

@keyframes ade-blink { 50% { opacity: .2; } }

.ade-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.ade-form {
  margin: 0;
  padding: 10px 12px 12px;
  border-top: 1px solid var(--ade-line);
  background: #fff;
}

.ade-label {
  display: block;
  margin-bottom: 4px;
  font-size: 12px;
  color: var(--ade-muted);
}

.ade-input-row { display: flex; gap: 8px; align-items: flex-end; }

.ade .ade-input {
  flex: 1;
  min-width: 0;
  margin: 0;
  padding: 8px 10px;
  border: 1px solid #b8bcc2;
  border-radius: 8px;
  font: inherit;
  font-size: 16px; /* iPhoneで入力時に拡大されないよう16px */
  line-height: 1.5;
  resize: none;
  background: #fff;
  color: var(--ade-text);
}

.ade .ade-input:focus-visible {
  outline: 2px solid var(--ade-accent);
  outline-offset: 1px;
}

.ade-send {
  margin: 0;
  padding: 10px 16px;
  border: 0;
  border-radius: 8px;
  background: var(--ade-accent);
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.ade-send:disabled { opacity: .5; cursor: default; }

@media (max-width: 767px) {
  .ade { left: 12px; bottom: 12px; }
  /* 画面下に追従ボタンがあるページでは、その上に出す */
  body:has(.sticky-cta) .ade { bottom: 84px; }
  .ade-launcher { padding: 12px 18px; font-size: 14px; }
  .ade.is-open { left: 0; right: 0; bottom: 0; top: 0; }
  body:has(.sticky-cta) .ade.is-open { bottom: 0; }
  .ade-panel { width: 100%; max-width: none; height: 100%; max-height: none; border-radius: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .ade-msg--waiting::after { animation: none; }
}
