/* モエル塾 Q&Aチャットウィジェット */
:root {
  --qabot-primary: #1a3a5c;
  --qabot-primary-dark: #132d47;
  --qabot-primary-light: #2a5580;
  --qabot-accent: #c9a227;
  --qabot-bg: #ffffff;
  --qabot-text: #333333;
  --qabot-muted: #666666;
  --qabot-border: #dde4ea;
  --qabot-user-bg: #1a3a5c;
  --qabot-user-text: #ffffff;
  --qabot-bot-bg: #f0f4f8;
  --qabot-bot-text: #333333;
  --qabot-shadow: 0 8px 32px rgba(26, 58, 92, 0.18);
  --qabot-radius: 12px;
  --qabot-z: 99999;
}

#qabot-root {
  font-family: "Hiragino Kaku Gothic ProN", "Hiragino Sans", Meiryo, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

#qabot-root *,
#qabot-root *::before,
#qabot-root *::after {
  box-sizing: border-box;
}

/* フローティングボタン */
.qabot-fab {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: 56px;
  height: 56px;
  border: none;
  border-radius: 50%;
  background: var(--qabot-primary);
  color: #fff;
  font-size: 24px;
  cursor: pointer;
  box-shadow: var(--qabot-shadow);
  z-index: var(--qabot-z);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, background 0.2s ease;
}

.qabot-fab:hover {
  background: var(--qabot-primary-light);
  transform: scale(1.05);
}

.qabot-fab.is-open {
  background: var(--qabot-primary-dark);
}

/* チャットウィンドウ */
.qabot-window {
  position: fixed;
  right: 20px;
  bottom: 88px;
  width: 340px;
  height: 480px;
  background: var(--qabot-bg);
  border-radius: var(--qabot-radius);
  box-shadow: var(--qabot-shadow);
  z-index: var(--qabot-z);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(16px) scale(0.96);
  transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s;
}

.qabot-window.is-open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* ヘッダー */
.qabot-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: var(--qabot-primary);
  color: #fff;
  flex-shrink: 0;
}

.qabot-header-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.3);
  flex-shrink: 0;
}

.qabot-header-avatar--placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--qabot-primary-light);
  font-size: 18px;
}

.qabot-header-info {
  flex: 1;
  min-width: 0;
}

.qabot-header-title {
  font-size: 14px;
  font-weight: 700;
  margin: 0;
  line-height: 1.3;
}

.qabot-header-sub {
  font-size: 11px;
  opacity: 0.85;
  margin: 2px 0 0;
}

.qabot-close {
  background: none;
  border: none;
  color: #fff;
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
  opacity: 0.8;
  flex-shrink: 0;
}

.qabot-close:hover {
  opacity: 1;
}

/* メッセージエリア */
.qabot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

.qabot-messages::-webkit-scrollbar {
  width: 4px;
}

.qabot-messages::-webkit-scrollbar-thumb {
  background: var(--qabot-border);
  border-radius: 2px;
}

.qabot-message {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 16px;
  word-break: break-word;
}

.qabot-message--bot {
  align-self: flex-start;
  background: var(--qabot-bot-bg);
  color: var(--qabot-bot-text);
  border-bottom-left-radius: 4px;
}

.qabot-message--user {
  align-self: flex-end;
  background: var(--qabot-user-bg);
  color: var(--qabot-user-text);
  border-bottom-right-radius: 4px;
}

.qabot-message a {
  color: var(--qabot-accent);
  text-decoration: underline;
  word-break: break-all;
}

.qabot-message--user a {
  color: #ffe082;
}

/* タイピングインジケーター */
.qabot-typing {
  align-self: flex-start;
  display: flex;
  gap: 4px;
  padding: 12px 16px;
  background: var(--qabot-bot-bg);
  border-radius: 16px;
  border-bottom-left-radius: 4px;
}

.qabot-typing span {
  width: 7px;
  height: 7px;
  background: var(--qabot-muted);
  border-radius: 50%;
  animation: qabot-bounce 1.2s infinite ease-in-out;
}

.qabot-typing span:nth-child(2) {
  animation-delay: 0.2s;
}

.qabot-typing span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes qabot-bounce {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.4;
  }
  30% {
    transform: translateY(-6px);
    opacity: 1;
  }
}

/* 入力エリア */
.qabot-input-area {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--qabot-border);
  flex-shrink: 0;
  background: var(--qabot-bg);
}

.qabot-input {
  flex: 1;
  border: 1px solid var(--qabot-border);
  border-radius: 20px;
  padding: 10px 16px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  resize: none;
  max-height: 80px;
  line-height: 1.4;
  transition: border-color 0.2s;
}

.qabot-input:focus {
  border-color: var(--qabot-primary-light);
}

.qabot-send {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: var(--qabot-primary);
  color: #fff;
  cursor: pointer;
  font-size: 16px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.qabot-send:hover:not(:disabled) {
  background: var(--qabot-primary-light);
}

.qabot-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* モバイル：フルスクリーンシート */
@media (max-width: 480px) {
  .qabot-window {
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    border-radius: 0;
    transform: translateY(100%);
  }

  .qabot-window.is-open {
    transform: translateY(0);
  }

  .qabot-fab {
    right: 16px;
    bottom: 16px;
  }

  .qabot-fab.is-open {
    display: none;
  }
}
