/* =========================================================
   社内ナレッジチャット 共通スタイル
   参考ポータルのトーン: 白カード・角丸・淡いアクセント・
   システムフォント・余白広め・薄いグレー背景
   ========================================================= */

:root {
  --bg: #f4f5f7;
  --card-bg: #ffffff;
  --text: #1f2933;
  --text-sub: #6b7280;
  --border: #e5e7eb;
  --accent: #4f7cff;
  --accent-soft: #eaf0ff;
  --accent-2: #00b894;
  --available: #22c55e;
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.06), 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-hover: 0 8px 24px rgba(16, 24, 40, 0.10);
  --radius: 16px;
  --radius-sm: 10px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Kaku Gothic ProN",
    "Hiragino Sans", Meiryo, sans-serif;
  -webkit-font-smoothing: antialiased;
  line-height: 1.6;
}

a { color: inherit; text-decoration: none; }

.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 40px 24px 64px;
}

/* ---------- ヘッダー ---------- */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 32px;
}
.app-header .title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.01em;
}
.app-header .subtitle {
  color: var(--text-sub);
  font-size: 13px;
  margin-top: 2px;
}
.nav {
  display: flex;
  gap: 8px;
}
.nav a {
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 14px;
  color: var(--text-sub);
  background: transparent;
  border: 1px solid transparent;
  transition: all 0.15s ease;
}
.nav a:hover { background: #fff; box-shadow: var(--shadow); color: var(--text); }
.nav a.active { background: var(--accent); color: #fff; }

/* ---------- アプリ内タブ ---------- */
.tabs {
  display: inline-flex;
  gap: 4px;
  background: #fff;
  padding: 5px;
  border-radius: 999px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}
.tab {
  border: none;
  background: transparent;
  color: var(--text-sub);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 9px 20px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.tab:hover { color: var(--text); }
.tab.active { background: var(--accent); color: #fff; }
.tab-panel[hidden] { display: none; }

/* ---------- カードグリッド（ポータル風） ---------- */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.portal-card {
  position: relative;
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 220px;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.portal-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-hover); }

/* 上端の色アクセントバー */
.portal-card .accent-bar {
  height: 5px;
  width: 100%;
  background: linear-gradient(90deg, var(--accent), #7aa0ff);
}
.portal-card.alt .accent-bar { background: linear-gradient(90deg, var(--accent-2), #4fd6b3); }

.portal-card .card-body {
  padding: 22px 22px 56px;
  flex: 1;
}

/* 淡い色のアイコンタイル（角丸四角） */
.icon-tile {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  margin-bottom: 16px;
}
.portal-card.alt .icon-tile { background: #e3f8f1; color: var(--accent-2); }

.card-eyebrow {
  font-size: 11px;
  letter-spacing: 0.12em;
  font-weight: 600;
  color: var(--text-sub);
  text-transform: uppercase;
  margin-bottom: 6px;
}
.card-title {
  font-size: 18px;
  font-weight: 700;
  margin: 0 0 8px;
}
.card-desc {
  font-size: 13.5px;
  color: var(--text-sub);
  margin: 0;
}

/* ステータスピル */
.status-pill {
  position: absolute;
  left: 22px;
  bottom: 18px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: #15803d;
  background: #ecfdf3;
  padding: 4px 10px;
  border-radius: 999px;
}
.status-pill .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--available);
}

/* 右下の矢印 */
.card-arrow {
  position: absolute;
  right: 18px;
  bottom: 16px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: background 0.15s ease, transform 0.15s ease;
}
.portal-card:hover .card-arrow { background: var(--accent); color: #fff; transform: translateX(2px); }
.portal-card.alt .card-arrow { background: #e3f8f1; color: var(--accent-2); }
.portal-card.alt:hover .card-arrow { background: var(--accent-2); color: #fff; }

/* ---------- 汎用パネル ---------- */
.panel {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}
.panel + .panel { margin-top: 20px; }
.panel h2 { font-size: 16px; margin: 0 0 16px; }

/* ---------- フォーム ---------- */
.form-row { margin-bottom: 16px; }
.form-row label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}
.form-row .hint { font-weight: 400; color: var(--text-sub); font-size: 12px; }
input[type="text"],
input[type="date"],
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea { resize: vertical; min-height: 90px; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s ease, opacity 0.15s ease;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #3f6cf0; }
.btn-ghost { background: transparent; color: var(--text-sub); border: 1px solid var(--border); }
.btn-ghost:hover { background: #f9fafb; color: var(--text); }
.btn-danger { background: #fff; color: #dc2626; border: 1px solid #fee2e2; }
.btn-danger:hover { background: #fef2f2; }
.btn-sm { padding: 6px 12px; font-size: 13px; }

.form-actions { display: flex; gap: 10px; align-items: center; }
.form-msg { font-size: 13px; }
.form-msg.ok { color: #15803d; }
.form-msg.err { color: #dc2626; }

/* ---------- メモ一覧 ---------- */
.memo-list { display: flex; flex-direction: column; gap: 12px; }
.memo-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  background: #fff;
}
.memo-item .memo-content { white-space: pre-wrap; margin-bottom: 8px; }
.memo-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  align-items: center;
  font-size: 12.5px;
  color: var(--text-sub);
}
.tag {
  display: inline-block;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 12px;
}
.memo-actions { display: flex; gap: 8px; margin-top: 10px; }
.empty { color: var(--text-sub); font-size: 14px; padding: 12px 0; }

/* ---------- チャット ---------- */
.chat-wrap {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  height: calc(100vh - 200px);
  min-height: 460px;
  overflow: hidden;
}
.chat-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.chat-head .icon-tile { margin: 0; width: 38px; height: 38px; font-size: 18px; }
.chat-head .h-title { font-weight: 700; font-size: 15px; }
.chat-head .h-sub { font-size: 12px; color: var(--text-sub); }

.chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: #fbfbfc;
}
.bubble-row { display: flex; }
.bubble-row.user { justify-content: flex-end; }
.bubble-row.bot { justify-content: flex-start; }
.bubble {
  max-width: 78%;
  padding: 11px 15px;
  border-radius: 16px;
  font-size: 14px;
  white-space: pre-wrap;
  word-break: break-word;
  box-shadow: var(--shadow);
}
.bubble-row.user .bubble {
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 5px;
}
.bubble-row.bot .bubble {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--border);
  border-bottom-left-radius: 5px;
}
.bubble.nohit { color: var(--text-sub); }
.bubble .src { display: block; margin-top: 4px; font-size: 12px; color: var(--text-sub); }
.bubble-row.user .bubble .src { color: rgba(255,255,255,0.85); }

.matched-tags { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 6px; }
.matched-tags .mtag {
  font-size: 11px; background: var(--accent-soft); color: var(--accent);
  border-radius: 999px; padding: 1px 8px;
}

.chat-input {
  display: flex;
  gap: 10px;
  padding: 14px 16px;
  border-top: 1px solid var(--border);
  background: #fff;
}
.chat-input input {
  flex: 1;
  border-radius: 999px;
  padding: 11px 16px;
}
.chat-input .btn { border-radius: 999px; }

.typing { font-size: 13px; color: var(--text-sub); font-style: italic; }

.footer-note {
  text-align: center;
  color: var(--text-sub);
  font-size: 12px;
  margin-top: 28px;
}

/* ---------- セグメント（ナレッジ/ToDo 切替） ---------- */
.seg {
  display: inline-flex;
  gap: 4px;
  background: #f3f4f6;
  padding: 4px;
  border-radius: 10px;
  margin-bottom: 18px;
}
.seg-btn {
  border: none;
  background: transparent;
  color: var(--text-sub);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.seg-btn.active { background: #fff; color: var(--text); box-shadow: var(--shadow); }

/* ---------- フィルタチップ ---------- */
.filter-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.chip {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text-sub);
  font-family: inherit;
  font-size: 13px;
  padding: 6px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.chip:hover { color: var(--text); }
.chip.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ---------- バッジ（種別） ---------- */
.memo-top { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.badge {
  display: inline-block;
  font-size: 11.5px;
  font-weight: 700;
  padding: 2px 10px;
  border-radius: 999px;
}
.badge-knowledge { background: var(--accent-soft); color: var(--accent); }
.badge-todo { background: #e3f8f1; color: var(--accent-2); }

/* 完了した ToDo */
.memo-item.done .memo-content { text-decoration: line-through; color: var(--text-sub); }

/* ToDo 完了チェック（一覧内・インライン） */
.todo-check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; font-size: 13px; color: var(--text-sub); }
.todo-check input { width: 16px; height: 16px; accent-color: var(--accent-2); cursor: pointer; }
.todo-check.inline { margin-left: auto; }

/* ---------- チャット内 ToDo リスト ---------- */
.todo-bubble { max-width: 90%; }
.todo-head { font-weight: 700; margin-bottom: 8px; }
.todo-list-chat { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.todo-line { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; }
.todo-line .todo-check { color: var(--text); font-size: 14px; align-items: flex-start; }
.todo-line.done .todo-text { text-decoration: line-through; color: var(--text-sub); }
.todo-meta { font-size: 12px; color: var(--text-sub); }

/* ---------- クイック追加 FAB ---------- */
.fab {
  position: fixed;
  right: 28px;
  bottom: 28px;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 30px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(79, 124, 255, 0.45);
  z-index: 900;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.fab:hover { transform: translateY(-2px) scale(1.04); box-shadow: 0 10px 26px rgba(79, 124, 255, 0.55); }
.fab:active { transform: scale(0.97); }

.qa-overlay {
  position: fixed;
  inset: 0;
  background: rgba(16, 24, 40, 0.35);
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  padding: 24px 28px 100px;
  z-index: 1000;
}
.qa-overlay[hidden] { display: none; }
.qa-popup {
  width: 360px;
  max-width: calc(100vw - 48px);
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-hover);
  padding: 18px;
  animation: qa-pop 0.15s ease;
}
@keyframes qa-pop { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.qa-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.qa-title { font-weight: 700; font-size: 15px; }
.qa-close { border: none; background: transparent; font-size: 16px; color: var(--text-sub); cursor: pointer; }
.qa-content { width: 100%; margin-bottom: 10px; }
.qa-row { display: flex; gap: 8px; margin-bottom: 12px; }
.qa-row input { flex: 1; min-width: 0; }
.qa-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.qa-msg { font-size: 12.5px; }
.qa-msg.ok { color: #15803d; }
.qa-msg.err { color: #dc2626; }

@media (max-width: 640px) {
  .container { padding: 24px 16px 48px; }
  .app-header { flex-direction: column; align-items: flex-start; }
  .fab { right: 18px; bottom: 18px; }
  .qa-overlay { padding: 16px; align-items: center; justify-content: center; }
}
