/* AI Chat Widget — 右下浮動ボタン + チャット窓
 * 既存サイトのダーク系デザインに合わせる
 */

#aichat-fab {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #2563eb;
  color: white;
  border: none;
  cursor: pointer;
  font-size: 24px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  z-index: 9998;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s, background 0.15s;
}
#aichat-fab:hover { background: #1d4ed8; transform: scale(1.05); }
#aichat-fab[data-open="true"] { background: #475569; }

#aichat-panel {
  position: fixed;
  right: 24px;
  bottom: 96px;
  width: 420px;
  max-width: calc(100vw - 32px);
  height: 600px;
  max-height: calc(100vh - 120px);
  background: #0f172a;
  color: #e2e8f0;
  border: 1px solid #334155;
  border-radius: 12px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.6);
  z-index: 9999;
  display: none;
  flex-direction: column;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.6;
}
#aichat-panel[data-open="true"] { display: flex; }

#aichat-header {
  padding: 12px 16px;
  border-bottom: 1px solid #334155;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
#aichat-header h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: #f1f5f9;
}
#aichat-header .meta {
  font-size: 11px;
  color: #94a3b8;
  margin-top: 2px;
}
#aichat-close {
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 20px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}
#aichat-close:hover { color: #e2e8f0; }

#aichat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
  scroll-behavior: smooth;
}

.aichat-msg {
  margin-bottom: 16px;
  word-wrap: break-word;
}
.aichat-msg-user {
  background: #1e293b;
  border-left: 3px solid #2563eb;
  padding: 8px 12px;
  border-radius: 4px;
  color: #cbd5e1;
}
.aichat-msg-status {
  font-size: 12px;
  color: #94a3b8;
  font-style: italic;
}
.aichat-msg-error {
  background: #450a0a;
  color: #fca5a5;
  border-left: 3px solid #dc2626;
  padding: 8px 12px;
  border-radius: 4px;
}
.aichat-msg-answer {
  color: #e2e8f0;
  white-space: pre-wrap;
}
.aichat-msg-answer h2 {
  font-size: 13px;
  font-weight: 700;
  color: #94a3b8;
  margin: 12px 0 6px;
  border-bottom: 1px solid #334155;
  padding-bottom: 4px;
}
.aichat-msg-answer strong { color: #f1f5f9; }
.aichat-msg-answer a {
  color: #60a5fa;
  text-decoration: none;
}
.aichat-msg-answer a:hover { text-decoration: underline; }

.aichat-citations {
  margin-top: 12px;
  padding-top: 8px;
  border-top: 1px dashed #334155;
}
.aichat-citations-title {
  font-size: 11px;
  color: #64748b;
  margin-bottom: 4px;
}
.aichat-citation-link {
  display: block;
  font-size: 12px;
  color: #93c5fd;
  text-decoration: none;
  padding: 2px 0;
}
.aichat-citation-link:hover { color: #60a5fa; text-decoration: underline; }

#aichat-input-wrap {
  padding: 12px 16px;
  border-top: 1px solid #334155;
  flex-shrink: 0;
  display: flex;
  gap: 8px;
}
#aichat-input {
  flex: 1;
  background: #1e293b;
  color: #e2e8f0;
  border: 1px solid #334155;
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 14px;
  font-family: inherit;
  resize: none;
  min-height: 40px;
  max-height: 120px;
  line-height: 1.4;
}
#aichat-input:focus {
  outline: none;
  border-color: #2563eb;
}
#aichat-send {
  background: #2563eb;
  color: white;
  border: none;
  border-radius: 6px;
  padding: 0 14px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  flex-shrink: 0;
}
#aichat-send:hover { background: #1d4ed8; }
#aichat-send:disabled {
  background: #475569;
  cursor: not-allowed;
}

#aichat-suggest {
  padding: 0 16px 12px;
  flex-shrink: 0;
}
.aichat-suggest-title {
  font-size: 11px;
  color: #64748b;
  margin-bottom: 6px;
}
.aichat-suggest-chip {
  display: inline-block;
  background: #1e293b;
  border: 1px solid #334155;
  color: #cbd5e1;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 12px;
  margin: 2px 4px 2px 0;
  cursor: pointer;
}
.aichat-suggest-chip:hover {
  background: #334155;
  border-color: #475569;
}

@media (max-width: 600px) {
  #aichat-panel {
    right: 8px;
    bottom: 80px;
    width: calc(100vw - 16px);
    height: calc(100vh - 100px);
  }
  #aichat-fab { right: 16px; bottom: 16px; }
}
