/* Decision Works AI チャットウィジェット */
:root {
  --cw-blue: #005baa;
  --cw-blue-dark: #004488;
  --cw-blue-light: #e6f0fa;
  --cw-text: #1e293b;
  --cw-text-light: #64748b;
  --cw-border: #e2e8f0;
}

#dw-chat-bubble {
  position: fixed; bottom: 28px; right: 28px;
  width: 60px; height: 60px; border-radius: 50%;
  background: var(--cw-blue); color: #fff; border: none; cursor: pointer;
  box-shadow: 0 4px 24px rgba(0,91,170,.18);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999; transition: transform .2s, background .2s;
}
#dw-chat-bubble:hover { background: var(--cw-blue-dark); transform: scale(1.08); }
#dw-chat-bubble svg { width: 28px; height: 28px; fill: #fff; }
#dw-chat-bubble .cw-badge {
  position: absolute; top: 2px; right: 2px; width: 14px; height: 14px;
  background: #f59e0b; border-radius: 50%; border: 2px solid #fff; display: none;
}
#dw-chat-bubble.cw-notif .cw-badge { display: block; }

#dw-chat-window {
  position: fixed; bottom: 100px; right: 28px;
  width: 360px; height: 520px;
  background: #fff; border-radius: 16px;
  box-shadow: 0 4px 24px rgba(0,91,170,.18);
  display: flex; flex-direction: column;
  z-index: 9998; overflow: hidden;
  transition: opacity .25s, transform .25s; transform-origin: bottom right;
}
#dw-chat-window.cw-hidden { opacity: 0; pointer-events: none; transform: scale(.9) translateY(10px); }
#dw-chat-window.cw-visible { opacity: 1; pointer-events: auto; transform: scale(1) translateY(0); }

/* ヘッダー */
.cw-header {
  background: var(--cw-blue); color: #fff;
  padding: 14px 16px; display: flex; align-items: center; gap: 10px; flex-shrink: 0;
}
.cw-header-icon {
  width: 36px; height: 36px; background: rgba(255,255,255,.2);
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
}
.cw-header-icon svg { width: 20px; height: 20px; fill: #fff; }
.cw-header-text { flex: 1; }
.cw-header-title { font-size: 14px; font-weight: 700; margin: 0; }
.cw-header-sub { font-size: 11px; opacity: .8; margin: 2px 0 0; }
.cw-close {
  background: none; border: none; color: rgba(255,255,255,.8);
  cursor: pointer; padding: 4px; border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
}
.cw-close:hover { color: #fff; }
.cw-close svg { width: 18px; height: 18px; stroke: currentColor; fill: none; }

/* メッセージ */
.cw-messages {
  flex: 1; overflow-y: auto; padding: 16px;
  display: flex; flex-direction: column; gap: 12px; scroll-behavior: smooth;
}
.cw-messages::-webkit-scrollbar { width: 4px; }
.cw-messages::-webkit-scrollbar-thumb { background: var(--cw-border); border-radius: 2px; }

.cw-msg { display: flex; gap: 8px; animation: cw-in .2s ease; }
@keyframes cw-in { from { opacity: 0; transform: translateY(6px); } }

.cw-msg-ai { align-items: flex-start; }
.cw-msg-ai .cw-avatar {
  width: 30px; height: 30px; background: var(--cw-blue); border-radius: 50%;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.cw-msg-ai .cw-avatar svg { width: 16px; height: 16px; fill: #fff; }
.cw-msg-ai .cw-bubble {
  background: var(--cw-blue-light); color: var(--cw-text);
  border-radius: 4px 14px 14px 14px; padding: 10px 12px;
  font-size: 13.5px; line-height: 1.6; max-width: calc(100% - 42px); word-break: break-word;
}

.cw-msg-user { flex-direction: row-reverse; }
.cw-msg-user .cw-bubble {
  background: var(--cw-blue); color: #fff;
  border-radius: 14px 4px 14px 14px; padding: 10px 12px;
  font-size: 13.5px; line-height: 1.6; max-width: 80%; word-break: break-word;
}

/* タイピング */
.cw-typing { display: flex; align-items: flex-start; gap: 8px; }
.cw-typing .cw-avatar { width: 30px; height: 30px; background: var(--cw-blue); border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.cw-typing .cw-avatar svg { width: 16px; height: 16px; fill: #fff; }
.cw-dots { background: var(--cw-blue-light); border-radius: 4px 14px 14px 14px; padding: 12px 14px; display: flex; gap: 4px; }
.cw-dots span { width: 6px; height: 6px; background: var(--cw-blue); border-radius: 50%; animation: cw-bounce 1.2s infinite ease-in-out; }
.cw-dots span:nth-child(2) { animation-delay: .2s; }
.cw-dots span:nth-child(3) { animation-delay: .4s; }
@keyframes cw-bounce { 0%,60%,100% { transform: translateY(0); opacity: .4; } 30% { transform: translateY(-4px); opacity: 1; } }

/* 入力 */
.cw-form {
  padding: 12px 14px; border-top: 1px solid var(--cw-border);
  display: flex; gap: 8px; align-items: flex-end; flex-shrink: 0;
}
.cw-input {
  flex: 1; resize: none; border: 1.5px solid var(--cw-border);
  border-radius: 8px; padding: 9px 12px; font-size: 16px; font-family: inherit;
  line-height: 1.5; color: var(--cw-text); outline: none; max-height: 100px;
}
.cw-input:focus { border-color: var(--cw-blue); }
.cw-input::placeholder { color: var(--cw-text-light); }
.cw-send {
  width: 38px; height: 38px; border-radius: 8px;
  background: var(--cw-blue); color: #fff; border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  transition: background .15s;
}
.cw-send:hover:not(:disabled) { background: var(--cw-blue-dark); }
.cw-send:disabled { background: var(--cw-border); cursor: not-allowed; }
.cw-send svg { width: 18px; height: 18px; fill: #fff; }

/* フッター */
.cw-footer {
  padding: 6px 14px 8px; text-align: center; font-size: 10px;
  color: var(--cw-text-light); border-top: 1px solid var(--cw-border);
}
.cw-footer a { color: var(--cw-blue); text-decoration: none; }

/* モバイル */
@media (max-width: 768px) {
  #dw-chat-bubble { bottom: 24px; right: 16px; width: 50px; height: 50px; }
  #dw-chat-bubble svg { width: 24px; height: 24px; }
  #dw-chat-window { bottom: 0; right: 0; left: 0; top: 0; width: 100%; height: 100%; border-radius: 0; }
}
