/* ═══════════════════════════════════════════════════════
   信用銀行 AI-RAG システム - スタイルシート
   ═══════════════════════════════════════════════════════ */

:root {
  --primary: #1a3c6e;
  --primary-light: #2558a8;
  --primary-dark: #112952;
  --accent: #c8a850;
  --accent-light: #e8c96a;
  --bg: #f4f6fa;
  --bg-card: #ffffff;
  --text: #1a2533;
  --text-muted: #6b7a8d;
  --border: #d8dfe8;
  --success: #2e7d32;
  --warning: #e65100;
  --error: #c62828;
  --radius: 10px;
  --shadow: 0 2px 12px rgba(26,60,110,0.10);
  --shadow-lg: 0 4px 24px rgba(26,60,110,0.16);
  --sidebar-w: 280px;
  --header-h: 64px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: "Hiragino Kaku Gothic ProN", "Meiryo", "Yu Gothic", sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ─── ヘッダー ─── */
.header {
  height: var(--header-h);
  background: var(--primary);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  flex-shrink: 0;
  z-index: 100;
}
.header-logo {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 2px;
  white-space: nowrap;
}
.header-title {
  font-size: 17px;
  font-weight: 700;
  color: #fff;
  flex: 1;
}
.header-badge {
  background: rgba(200,168,80,0.2);
  border: 1px solid var(--accent);
  color: var(--accent);
  font-size: 11px;
  padding: 2px 10px;
  border-radius: 20px;
  letter-spacing: 1px;
}
.header-nav a {
  color: rgba(255,255,255,0.8);
  text-decoration: none;
  font-size: 13px;
  padding: 6px 14px;
  border-radius: 6px;
  transition: all 0.2s;
}
.header-nav a:hover { background: rgba(255,255,255,0.12); color: #fff; }

/* ─── メインレイアウト ─── */
.main-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ─── サイドバー ─── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--primary-dark);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
}
.sidebar-section {
  padding: 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar-label {
  font-size: 10px;
  font-weight: 700;
  color: rgba(255,255,255,0.4);
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-bottom: 10px;
}
.sidebar-new-chat {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  background: var(--accent);
  color: var(--primary-dark);
  border: none;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}
.sidebar-new-chat:hover { background: var(--accent-light); }
.mode-list { display: flex; flex-direction: column; gap: 4px; }
.mode-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  background: transparent;
  border: none;
  border-radius: 8px;
  padding: 9px 12px;
  color: rgba(255,255,255,0.75);
  font-size: 13px;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s;
}
.mode-btn:hover { background: rgba(255,255,255,0.08); color: #fff; }
.mode-btn.active { background: rgba(200,168,80,0.18); color: var(--accent); }
.mode-icon { font-size: 16px; width: 22px; text-align: center; }
.history-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}
.history-list::-webkit-scrollbar { width: 4px; }
.history-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 2px; }
.history-item {
  padding: 8px 10px;
  border-radius: 6px;
  color: rgba(255,255,255,0.6);
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: all 0.15s;
}
.history-item:hover { background: rgba(255,255,255,0.07); color: rgba(255,255,255,0.9); }

/* ─── チャットエリア ─── */
.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px 40px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.chat-messages::-webkit-scrollbar { width: 6px; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ─── ウェルカム画面 ─── */
.welcome-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 32px;
  padding: 40px;
}
.welcome-logo {
  width: 72px;
  height: 72px;
  background: var(--primary);
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  box-shadow: var(--shadow-lg);
}
.welcome-title { font-size: 26px; font-weight: 700; color: var(--primary); text-align: center; }
.welcome-subtitle { font-size: 14px; color: var(--text-muted); text-align: center; max-width: 480px; line-height: 1.7; }
.quick-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  width: 100%;
  max-width: 640px;
}
.quick-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
}
.quick-card:hover {
  border-color: var(--primary-light);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}
.quick-card-icon { font-size: 22px; margin-bottom: 8px; }
.quick-card-title { font-size: 13px; font-weight: 700; color: var(--primary); margin-bottom: 4px; }
.quick-card-desc { font-size: 11px; color: var(--text-muted); line-height: 1.5; }

/* ─── メッセージ ─── */
.message { display: flex; gap: 14px; max-width: 900px; width: 100%; }
.message.user { align-self: flex-end; flex-direction: row-reverse; }
.message-avatar {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.message.user .message-avatar { background: var(--primary); }
.message.assistant .message-avatar { background: var(--accent); }
.message-content { flex: 1; min-width: 0; }
.message-bubble {
  padding: 14px 18px;
  border-radius: 12px;
  line-height: 1.7;
  font-size: 14px;
}
.message.user .message-bubble {
  background: var(--primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.message.assistant .message-bubble {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
  box-shadow: var(--shadow);
}
.message-mode-badge {
  display: inline-block;
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 20px;
  margin-bottom: 8px;
  font-weight: 700;
  letter-spacing: 0.5px;
}
.message-bubble p { margin-bottom: 10px; }
.message-bubble p:last-child { margin-bottom: 0; }
.message-bubble h1,.message-bubble h2,.message-bubble h3 {
  color: var(--primary); margin: 14px 0 8px; font-size: 15px;
}
.message-bubble ul,.message-bubble ol { padding-left: 20px; margin-bottom: 10px; }
.message-bubble li { margin-bottom: 4px; }
.message-bubble table {
  width: 100%; border-collapse: collapse; margin: 12px 0; font-size: 13px;
}
.message-bubble th { background: var(--primary); color: #fff; padding: 8px; }
.message-bubble td { padding: 7px 8px; border: 1px solid var(--border); }
.message-bubble tr:nth-child(even) td { background: #f8fafc; }
.message-bubble code {
  background: #f0f3f8; padding: 2px 6px; border-radius: 4px; font-size: 12px; font-family: monospace;
}
.message-bubble pre { background: #1a2533; color: #e2e8f0; padding: 14px; border-radius: 8px; overflow-x: auto; }
.message-bubble pre code { background: none; color: inherit; padding: 0; }

/* ─── ソース ─── */
.sources {
  margin-top: 12px;
  padding: 12px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 12px;
}
.sources-title { font-weight: 700; color: var(--text-muted); margin-bottom: 8px; }
.source-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 0;
  color: var(--text-muted);
}
.source-badge {
  background: var(--primary);
  color: #fff;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 4px;
}

/* ─── 入力エリア ─── */
.chat-input-area {
  padding: 16px 40px 20px;
  background: var(--bg);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.mode-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  font-size: 12px;
  color: var(--text-muted);
}
.mode-indicator-badge {
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
}
.input-box {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: 14px;
  padding: 10px 12px;
  transition: border-color 0.2s;
  box-shadow: var(--shadow);
}
.input-box:focus-within { border-color: var(--primary-light); }
.chat-input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 14px;
  font-family: inherit;
  resize: none;
  background: transparent;
  max-height: 140px;
  line-height: 1.6;
}
.send-btn {
  width: 40px;
  height: 40px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  transition: all 0.2s;
  flex-shrink: 0;
}
.send-btn:hover { background: var(--primary-light); }
.send-btn:disabled { background: var(--border); cursor: not-allowed; }
.input-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
  font-size: 11px;
  color: var(--text-muted);
}

/* ─── ローディング ─── */
.thinking-dots { display: flex; gap: 4px; align-items: center; padding: 4px 0; }
.thinking-dots span {
  width: 7px; height: 7px; background: var(--primary);
  border-radius: 50%; animation: bounce 1.2s infinite;
}
.thinking-dots span:nth-child(2) { animation-delay: 0.2s; }
.thinking-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes bounce {
  0%,60%,100% { transform: translateY(0); opacity: 0.6; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* ─── モードカラー ─── */
.mode-default { background: #1a3c6e22; color: #1a3c6e; }
.mode-summarize { background: #2e7d3222; color: #2e7d32; }
.mode-analyze { background: #6a1b9a22; color: #6a1b9a; }
.mode-predict { background: #e6510022; color: #e65100; }
.mode-plan { background: #0277bd22; color: #0277bd; }
.mode-legal { background: #c6282822; color: #c62828; }
.mode-fact { background: #37474f22; color: #37474f; }
.mode-compare { background: #00695c22; color: #00695c; }

/* ─── 管理画面共通 ─── */
.admin-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
}
.admin-sidebar {
  width: 220px;
  background: var(--primary-dark);
  padding: 20px 12px;
  flex-shrink: 0;
}
.admin-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 8px;
  color: rgba(255,255,255,0.75);
  font-size: 13px;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s;
  margin-bottom: 4px;
}
.admin-nav-item:hover { background: rgba(255,255,255,0.08); color: #fff; }
.admin-nav-item.active { background: rgba(200,168,80,0.18); color: var(--accent); }
.admin-main {
  flex: 1;
  overflow-y: auto;
  padding: 28px 32px;
}
.admin-section { display: none; }
.admin-section.active { display: block; }
.section-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--primary);
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ─── カード ─── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  text-align: center;
}
.stat-value { font-size: 36px; font-weight: 700; color: var(--primary); line-height: 1; }
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: 6px; }

/* ─── テーブル ─── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table th {
  background: var(--primary);
  color: #fff;
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
}
.data-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); }
.data-table tr:hover td { background: #f8fafc; }

/* ─── フォーム ─── */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}
.form-control:focus { border-color: var(--primary-light); }
select.form-control { cursor: pointer; }

/* ─── ボタン ─── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
  text-decoration: none;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-light); }
.btn-accent { background: var(--accent); color: var(--primary-dark); }
.btn-accent:hover { background: var(--accent-light); }
.btn-danger { background: var(--error); color: #fff; }
.btn-danger:hover { background: #b71c1c; }
.btn-ghost { background: transparent; border: 1.5px solid var(--border); color: var(--text); }
.btn-ghost:hover { background: var(--bg); }
.btn-sm { padding: 5px 12px; font-size: 12px; }

/* ─── ドラッグ&ドロップ ─── */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 40px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: #f8fafc;
}
.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--primary-light);
  background: rgba(37,88,168,0.04);
}
.drop-zone-icon { font-size: 40px; margin-bottom: 12px; }
.drop-zone-text { font-size: 15px; font-weight: 600; color: var(--primary); margin-bottom: 6px; }
.drop-zone-sub { font-size: 12px; color: var(--text-muted); }

/* ─── 通知 ─── */
.toast-container {
  position: fixed;
  top: 80px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  padding: 12px 18px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  animation: slideIn 0.3s ease;
  max-width: 340px;
}
.toast-success { background: var(--success); color: #fff; }
.toast-error { background: var(--error); color: #fff; }
.toast-info { background: var(--primary); color: #fff; }
@keyframes slideIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }

/* ─── バッジ ─── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
}
.badge-primary { background: rgba(26,60,110,0.12); color: var(--primary); }
.badge-success { background: rgba(46,125,50,0.12); color: var(--success); }
.badge-warning { background: rgba(230,81,0,0.12); color: var(--warning); }
.badge-danger { background: rgba(198,40,40,0.12); color: var(--error); }

/* ─── レスポンシブ ─── */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .chat-messages { padding: 16px; }
  .chat-input-area { padding: 12px 16px; }
  .quick-grid { grid-template-columns: 1fr; }
  .admin-sidebar { display: none; }
  .admin-main { padding: 16px; }
}

/* ─── アニメーション ─── */
.fade-in { animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ─── プログレスバー ─── */
.progress-bar {
  width: 100%; height: 6px; background: var(--border); border-radius: 3px; overflow: hidden;
}
.progress-fill {
  height: 100%; background: var(--primary); border-radius: 3px;
  transition: width 0.3s ease;
}

/* ─── スクロールバー全体 ─── */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #b0bac6; }
