/* ===================================================
   AO AI大学 質問窓口 — メインスタイルシート
   カラーパレット:
     Primary (Navy)  : #1E2A3A
     Secondary (Steel Blue) : #4A6080
     Accent (Gold)   : #C9A84C
     Light BG        : #F5F7FA
     White           : #FFFFFF
     Text Main       : #1A1A2E
     Text Sub        : #5A6478
   =================================================== */

/* ---------- リセット・ベース ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: 'Noto Sans JP', 'Inter', sans-serif;
  background: #F0F3F8;
  color: #1A1A2E;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.6;
}

/* ---------- ヘッダー ---------- */
.header {
  background: linear-gradient(135deg, #1E2A3A 0%, #2C3E55 60%, #3D5268 100%);
  box-shadow: 0 2px 16px rgba(0,0,0,0.25);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  max-width: 860px;
  margin: 0 auto;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo-img {
  height: 38px;
  width: auto;
  filter: brightness(0) invert(1);
  object-fit: contain;
}

.header-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: rgba(255,255,255,0.85);
  background: rgba(255,255,255,0.1);
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid rgba(255,255,255,0.2);
}

.badge-dot {
  width: 7px;
  height: 7px;
  background: #4AE54A;
  border-radius: 50%;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(1.3); }
}

/* ---------- メイン ---------- */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px 16px 16px;
  gap: 12px;
}

/* ---------- チャットコンテナ ---------- */
.chat-container {
  width: 100%;
  max-width: 780px;
  background: #FFFFFF;
  border-radius: 18px;
  box-shadow: 0 4px 32px rgba(30, 42, 58, 0.12);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 540px;
  max-height: calc(100vh - 180px);
}

/* チャットヘッダー */
.chat-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 24px;
  background: linear-gradient(135deg, #1E2A3A 0%, #2C4A6E 100%);
  border-bottom: 2px solid #C9A84C;
}

.chat-header-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255,255,255,0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 2px solid rgba(201, 168, 76, 0.5);
  flex-shrink: 0;
}

.chat-header-icon img {
  width: 32px;
  height: 32px;
  object-fit: contain;
  filter: brightness(0) invert(1);
}

.chat-title {
  font-size: 1rem;
  font-weight: 700;
  color: #FFFFFF;
  letter-spacing: 0.02em;
}

.chat-subtitle {
  font-size: 0.72rem;
  color: rgba(255,255,255,0.7);
  margin-top: 2px;
}

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

.chat-messages::-webkit-scrollbar { width: 5px; }
.chat-messages::-webkit-scrollbar-track { background: #f0f3f8; }
.chat-messages::-webkit-scrollbar-thumb { background: #b0bcc8; border-radius: 10px; }

/* バブル共通 */
.message { display: flex; gap: 10px; align-items: flex-start; animation: fadeInUp 0.3s ease; }

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Botメッセージ */
.message.bot { flex-direction: row; }

.message-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1E2A3A, #4A6080);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 2px solid #C9A84C;
  overflow: hidden;
}

.message-avatar img {
  width: 22px;
  height: 22px;
  object-fit: contain;
  filter: brightness(0) invert(1);
}

.message-avatar.user-avatar {
  background: linear-gradient(135deg, #4A6080, #6080A0);
  border-color: #8090A8;
}

.message-avatar.user-avatar i { color: #fff; font-size: 0.9rem; }

.bubble {
  max-width: 78%;
  padding: 12px 16px;
  border-radius: 14px;
  font-size: 0.875rem;
  line-height: 1.7;
  word-break: break-word;
}

.bot .bubble {
  background: #F0F4F8;
  color: #1A1A2E;
  border-radius: 4px 14px 14px 14px;
  border-left: 3px solid #4A6080;
}

/* Userメッセージ */
.message.user { flex-direction: row-reverse; }

.user .bubble {
  background: linear-gradient(135deg, #1E2A3A 0%, #2C4A6E 100%);
  color: #FFFFFF;
  border-radius: 14px 4px 14px 14px;
}

/* ウェルカムバブル */
.bubble.welcome {
  border-left: 3px solid #C9A84C;
  background: linear-gradient(135deg, #FDF8EE 0%, #F5F7FA 100%);
}

.welcome-title {
  font-weight: 700;
  font-size: 0.95rem;
  color: #1E2A3A;
  margin-bottom: 6px;
}

.welcome-desc {
  font-size: 0.82rem;
  color: #5A6478;
  margin-bottom: 8px;
}

/* 回答フォーマット */
.answer-block { margin-top: 4px; }
.answer-section { margin-bottom: 10px; }

.answer-section-title {
  font-weight: 700;
  font-size: 0.82rem;
  color: #1E2A3A;
  display: flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 4px;
}

.answer-section-body {
  font-size: 0.85rem;
  color: #3A4A5A;
  padding-left: 4px;
}

.answer-section-body ul { padding-left: 16px; }
.answer-section-body li { margin-bottom: 3px; }

/* タイムスタンプ */
.message-time {
  font-size: 0.68rem;
  color: #9AA0AA;
  margin-top: 4px;
  padding: 0 4px;
}

.bot .message-time { text-align: left; }
.user .message-time { text-align: right; }

/* タイピングインジケーター */
.typing-indicator {
  display: flex;
  gap: 5px;
  padding: 10px 14px;
  background: #F0F4F8;
  border-radius: 4px 14px 14px 14px;
  border-left: 3px solid #4A6080;
  align-items: center;
  width: fit-content;
}

.typing-dot {
  width: 7px;
  height: 7px;
  background: #4A6080;
  border-radius: 50%;
  animation: typing 1.2s infinite;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
  0%, 80%, 100% { transform: scale(1); opacity: 0.4; }
  40% { transform: scale(1.2); opacity: 1; }
}

/* フィードバックボタン */
.feedback-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid #E8ECF0;
}

.feedback-label { font-size: 0.72rem; color: #8090A0; }

.feedback-btn {
  background: none;
  border: 1px solid #C8D0DA;
  border-radius: 20px;
  padding: 3px 10px;
  font-size: 0.72rem;
  cursor: pointer;
  transition: all 0.2s;
  color: #6A7A8A;
}

.feedback-btn:hover { background: #F0F4F8; border-color: #4A6080; color: #1E2A3A; }
.feedback-btn.active-good { background: #E8F4E8; border-color: #4CAF50; color: #2E7D32; }
.feedback-btn.active-bad { background: #FDE8E8; border-color: #EF5350; color: #C62828; }

/* ---------- サジェストボタン ---------- */
.suggested-questions {
  padding: 8px 20px 12px;
  border-top: 1px solid #EDF0F5;
}

.suggest-label {
  font-size: 0.72rem;
  color: #8090A0;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.suggest-label i { color: #C9A84C; }

.suggest-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.suggest-btn {
  background: #F0F4F8;
  border: 1px solid #D8E0EA;
  border-radius: 20px;
  padding: 5px 13px;
  font-size: 0.78rem;
  color: #1E2A3A;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
  white-space: nowrap;
}

.suggest-btn:hover {
  background: #1E2A3A;
  color: #FFFFFF;
  border-color: #1E2A3A;
  transform: translateY(-1px);
}

/* ---------- 入力エリア ---------- */
.chat-input-area {
  padding: 12px 20px 14px;
  border-top: 1px solid #EDF0F5;
  background: #FAFBFD;
}

.input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: #FFFFFF;
  border: 1.5px solid #C8D4E0;
  border-radius: 14px;
  padding: 8px 8px 8px 14px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.input-wrapper:focus-within {
  border-color: #4A6080;
  box-shadow: 0 0 0 3px rgba(74, 96, 128, 0.12);
}

.chat-input {
  flex: 1;
  border: none;
  outline: none;
  resize: none;
  font-family: inherit;
  font-size: 0.9rem;
  color: #1A1A2E;
  background: transparent;
  max-height: 120px;
  overflow-y: auto;
  line-height: 1.5;
}

.chat-input::placeholder { color: #A0AABB; }

.send-btn {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, #1E2A3A 0%, #2C4A6E 100%);
  color: #FFFFFF;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  transition: all 0.2s;
  flex-shrink: 0;
}

.send-btn:hover:not(:disabled) {
  background: linear-gradient(135deg, #2C4A6E 0%, #3D6090 100%);
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(30, 42, 58, 0.35);
}

.send-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.input-hint {
  font-size: 0.68rem;
  color: #A0AABB;
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.input-hint i { color: #C9A84C; }

/* ---------- フェーズバナー（ユーザー非表示・運営内部情報のみ） ---------- */
.phase-banner {
  display: none; /* ユーザーには非表示。運営用メモはHTMLコメントとして保持 */
}

.phase-banner i { color: #4A6080; }
.phase-banner strong { color: #1E2A3A; }

.phase-note {
  color: #8090A8;
  margin-left: auto;
  font-size: 0.7rem;
}

/* ---------- フッター ---------- */
.footer {
  background: #1E2A3A;
  color: rgba(255,255,255,0.6);
  padding: 18px 20px;
  text-align: center;
}

.footer-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.footer-logo {
  height: 28px;
  width: auto;
  filter: brightness(0) invert(1);
  opacity: 0.5;
}

.footer p { font-size: 0.75rem; }
.footer-sub { font-size: 0.68rem; font-style: italic; color: rgba(255,255,255,0.35); }

/* ---------- マークダウン風レンダリング ---------- */
.bubble strong { font-weight: 700; color: #1E2A3A; }
.bubble em { font-style: italic; }

.bubble .md-bold { font-weight: 700; }

/* ---------- レスポンシブ ---------- */
@media (max-width: 600px) {
  .header-inner { padding: 8px 14px; }
  .logo-img { height: 30px; }
  .chat-container { max-height: calc(100vh - 160px); min-height: 480px; }
  .chat-header { padding: 12px 16px; gap: 10px; }
  .chat-messages { padding: 14px 14px 10px; gap: 12px; }
  .bubble { max-width: 88%; font-size: 0.84rem; }
  .suggested-questions { padding: 8px 14px 10px; }
  .chat-input-area { padding: 10px 14px 12px; }
  .phase-banner { font-size: 0.7rem; }
  .phase-note { display: none; }
}

@media (max-width: 400px) {
  .logo-img { height: 26px; }
  .header-badge span:not(.badge-dot) { display: none; }
}
