/* =========================================================
   T-SYSTEMS AI Chat Widget
   ========================================================= */

.tsys-chat { position: fixed; z-index: 9999; bottom: 0; right: 0; pointer-events: none; }
.tsys-chat * { box-sizing: border-box; }
/* FABは常時クリック可能（is-open時のみ非表示＆非クリックに切替）。
   パネルは閉じてる時 pointer-events:none、開いた時 auto。これにより
   閉じパネルの中の要素が FAB のクリックを吸収する事故を防ぐ */
.tsys-chat__fab { pointer-events: auto; }

/* ----- Floating Action Button ----- */
.tsys-chat__fab {
  position: fixed; bottom: 24px; right: 24px;
  display: flex; align-items: center; gap: 8px;
  padding: 14px 22px; border-radius: 999px; border: none;
  background: linear-gradient(120deg, #38bdf8, #818cf8);
  color: #05121f; font-weight: 700; font-size: 14px;
  font-family: "Noto Sans JP", system-ui, sans-serif;
  cursor: pointer;
  box-shadow: 0 10px 30px -10px rgba(56,189,248,.7), 0 4px 10px rgba(0,0,0,.3);
  transition: transform .3s cubic-bezier(.22,.61,.36,1), box-shadow .3s;
}
.tsys-chat__fab:hover {
  transform: translateY(-3px);
  box-shadow: 0 16px 40px -10px rgba(56,189,248,.8), 0 8px 16px rgba(0,0,0,.4);
}
.tsys-chat__fab svg { stroke: #05121f; }
.tsys-chat__fab-text { white-space: nowrap; }
.tsys-chat.is-open .tsys-chat__fab { transform: translateY(80px); opacity: 0; pointer-events: none; }

/* ----- Panel ----- */
.tsys-chat__panel {
  position: fixed; bottom: 24px; right: 24px;
  width: 380px; max-width: calc(100vw - 32px);
  height: 620px; max-height: calc(100vh - 48px);
  background: #0d1322;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 18px;
  display: flex; flex-direction: column;
  overflow: hidden;
  box-shadow: 0 30px 60px -20px rgba(0,0,0,.8), 0 10px 30px rgba(0,0,0,.5);
  color: #e7ecf5;
  font-family: "Noto Sans JP", system-ui, sans-serif;
  transform: translateY(20px) scale(.96); opacity: 0; pointer-events: none;
  transition: transform .35s cubic-bezier(.22,.61,.36,1), opacity .25s;
}
.tsys-chat.is-open .tsys-chat__panel {
  transform: none; opacity: 1; pointer-events: auto;
}

/* Header */
.tsys-chat__head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  background: rgba(255,255,255,.02);
  flex-shrink: 0;
}
.tsys-chat__head-id { display: flex; align-items: center; gap: 12px; }
.tsys-chat__avatar {
  width: 36px; height: 36px; border-radius: 10px;
  display: grid; place-items: center;
  background: linear-gradient(120deg, #38bdf8, #818cf8);
  color: #05121f; font-weight: 800; font-size: 16px;
}
.tsys-chat__head-id > div { line-height: 1.3; }
.tsys-chat__head strong { display: block; font-size: 14px; color: #e7ecf5; font-weight: 700; }
.tsys-chat__head small { display: block; font-size: 11px; color: #93a0b8; }
.tsys-chat__close {
  background: transparent; border: none; color: #93a0b8;
  cursor: pointer; padding: 6px; border-radius: 8px;
  display: grid; place-items: center;
  transition: background .2s, color .2s;
}
.tsys-chat__close:hover { background: rgba(255,255,255,.06); color: #e7ecf5; }

/* Body / messages */
.tsys-chat__body {
  flex: 1; overflow-y: auto; padding: 18px 16px;
  display: flex; flex-direction: column; gap: 10px;
  scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.15) transparent;
}
.tsys-chat__body::-webkit-scrollbar { width: 6px; }
.tsys-chat__body::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 3px; }

.tsys-chat__msg { display: flex; animation: tsysFadeIn .25s ease; }
.tsys-chat__msg--user { justify-content: flex-end; }
.tsys-chat__msg--bot { justify-content: flex-start; }
@keyframes tsysFadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.tsys-chat__bubble {
  max-width: 85%; padding: 10px 14px; border-radius: 14px;
  font-size: 13.5px; line-height: 1.65; word-wrap: break-word; word-break: break-word;
}
.tsys-chat__msg--user .tsys-chat__bubble {
  background: linear-gradient(120deg, #38bdf8, #818cf8); color: #05121f;
  border-bottom-right-radius: 4px;
}
.tsys-chat__msg--bot .tsys-chat__bubble {
  background: rgba(255,255,255,.05); color: #e7ecf5;
  border: 1px solid rgba(255,255,255,.06);
  border-bottom-left-radius: 4px;
}
.tsys-chat__bubble a { color: #38bdf8; text-decoration: underline; }
.tsys-chat__bubble strong { font-weight: 700; color: #fff; }

/* Typing dots */
.tsys-chat__dots { display: inline-flex; gap: 4px; align-items: center; height: 1.65em; }
.tsys-chat__dots span {
  width: 7px; height: 7px; border-radius: 50%; background: #93a0b8;
  animation: tsysDot 1.2s ease-in-out infinite;
}
.tsys-chat__dots span:nth-child(2) { animation-delay: .2s; }
.tsys-chat__dots span:nth-child(3) { animation-delay: .4s; }
@keyframes tsysDot {
  0%, 80%, 100% { transform: scale(.5); opacity: .35; }
  40% { transform: scale(1); opacity: 1; }
}

/* Action chips */
.tsys-chat__actions {
  padding: 8px 14px; display: flex; gap: 8px; flex-wrap: wrap;
  border-top: 1px solid rgba(255,255,255,.05);
  flex-shrink: 0;
}
.tsys-chat__chip {
  font-size: 12px; padding: 6px 12px; border-radius: 999px;
  background: rgba(56,189,248,.12); color: #38bdf8;
  border: 1px solid rgba(56,189,248,.3);
  cursor: pointer; transition: background .2s, color .2s, border-color .2s;
  font-family: inherit;
}
.tsys-chat__chip:hover { background: rgba(56,189,248,.2); }
.tsys-chat__chip--ghost {
  background: transparent; color: #93a0b8; border-color: rgba(255,255,255,.1);
}
.tsys-chat__chip--ghost:hover { color: #e7ecf5; border-color: rgba(255,255,255,.25); }

/* Form */
.tsys-chat__form {
  display: flex; gap: 8px; padding: 10px 14px;
  border-top: 1px solid rgba(255,255,255,.08);
  background: rgba(255,255,255,.02);
  align-items: flex-end;
  flex-shrink: 0;
}
.tsys-chat__form textarea {
  flex: 1; resize: none;
  border: 1px solid rgba(255,255,255,.1);
  background: #0a0e1a; color: #e7ecf5;
  border-radius: 10px; padding: 9px 12px; font-size: 14px;
  font-family: inherit; line-height: 1.5;
  max-height: 120px; min-height: 38px; outline: none;
  transition: border-color .2s;
}
.tsys-chat__form textarea:focus { border-color: #38bdf8; }
.tsys-chat__form textarea::placeholder { color: #6b7894; }
.tsys-chat__send {
  width: 40px; height: 40px; border-radius: 10px; border: none;
  background: linear-gradient(120deg, #38bdf8, #818cf8); color: #05121f;
  cursor: pointer; display: grid; place-items: center;
  transition: transform .2s, opacity .2s; flex-shrink: 0;
}
.tsys-chat__send:hover { transform: scale(1.05); }
.tsys-chat__send:disabled { opacity: .5; cursor: wait; transform: none; }

/* Note */
.tsys-chat__note {
  font-size: 10.5px; color: #6b7894; text-align: center;
  padding: 6px 14px 10px; margin: 0;
  flex-shrink: 0;
}

/* Mobile fullscreen */
@media (max-width: 600px) {
  .tsys-chat__fab { bottom: 16px; right: 16px; padding: 12px 18px; }
  .tsys-chat__fab-text { display: none; }
  .tsys-chat__panel {
    width: 100vw; height: 100svh; max-width: 100vw; max-height: 100svh;
    bottom: 0; right: 0; border-radius: 0; border: none;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .tsys-chat__panel, .tsys-chat__fab { transition: opacity .15s !important; }
  .tsys-chat__dots span { animation: none !important; }
  .tsys-chat__msg { animation: none !important; }
}
