/* ============================================================
   チームチャット スタイルシート
   ============================================================ */

:root {
  --bg:        #f4f6fa;
  --surface:   #ffffff;
  --border:    #dfe4ec;
  --text:      #1f2937;
  --muted:     #6b7280;
  --primary:   #2563eb;
  --primary-d: #1d4ed8;
  --danger:    #dc2626;
  --accent:    #f59e0b;
  --radius:    10px;
  --shadow:    0 1px 3px rgba(17, 24, 39, .08), 0 1px 2px rgba(17, 24, 39, .04);
  --topbar-h:  56px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.6;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 20px; margin: 0; }
h2 { font-size: 16px; margin: 0 0 12px; }
code { background: #eef1f6; padding: 1px 5px; border-radius: 4px; font-size: 12px; }
.muted { color: var(--muted); font-size: 12px; }
.hidden { display: none !important; }

/* ---------- ヘッダー ---------- */
.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 24px;
  padding: 0 20px;
  position: sticky; top: 0; z-index: 50;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 700; }
.brand:hover { text-decoration: none; }
.brand-mark {
  display: inline-grid; place-items: center;
  width: 30px; height: 30px; border-radius: 8px;
  background: var(--primary); color: #fff; font-size: 13px; font-weight: 700;
}
.brand-mark.large { width: 48px; height: 48px; font-size: 18px; border-radius: 12px; }
.topnav { display: flex; gap: 16px; }
.topnav a { color: var(--muted); font-weight: 600; }
.topnav a:hover { color: var(--primary); text-decoration: none; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 16px; }
.me { font-weight: 600; }
.logout { color: var(--muted); font-size: 13px; }

/* ---------- 通知ベル ---------- */
.bell-wrap { position: relative; }
.bell {
  background: none; border: none; cursor: pointer;
  font-size: 18px; line-height: 1; padding: 6px; border-radius: 8px; position: relative;
}
.bell:hover { background: #eef1f6; }
.badge {
  position: absolute; top: -1px; right: -3px;
  min-width: 17px; height: 17px; padding: 0 4px;
  background: var(--danger); color: #fff;
  border-radius: 9px; font-size: 11px; font-weight: 700;
  display: grid; place-items: center;
}
.badge-inline {
  position: static; background: var(--accent); color: #fff;
  border-radius: 9px; padding: 0 7px; font-size: 11px; font-weight: 700;
}

/* 自分がメンションされた件数（タスク名称の横） */
.mention-count {
  display: inline-flex; align-items: center; gap: 5px;
  background: #dbeafe; color: #1e40af;
  border-radius: 9px; padding: 1px 8px;
  font-size: 11px; font-weight: 700; white-space: nowrap;
}
.mention-count.has-unread { background: var(--accent); color: #fff; }
.mention-count em {
  font-style: normal; font-size: 10px; font-weight: 700;
  background: rgba(255, 255, 255, .3); border-radius: 7px; padding: 0 5px;
}
.bell-panel {
  position: absolute; right: 0; top: 40px; width: 360px; max-height: 460px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  display: flex; flex-direction: column; overflow: hidden; z-index: 60;
}
.bell-panel-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 14px; border-bottom: 1px solid var(--border); font-weight: 600;
}
.bell-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
.bell-list li { border-bottom: 1px solid #f0f2f6; }
.bell-list a { display: block; padding: 10px 14px; color: var(--text); }
.bell-list a:hover { background: #f7f9fc; text-decoration: none; }
.bell-item-task { font-size: 12px; color: var(--primary); font-weight: 600; }
.bell-item-body { font-size: 13px; color: var(--muted); }
.bell-empty { padding: 20px 14px; text-align: center; color: var(--muted); font-size: 13px; }
.bell-hint {
  padding: 8px 14px; font-size: 11px; line-height: 1.5;
  background: #fffbeb; color: #92400e; border-bottom: 1px solid #fde68a;
}
.bell-panel-foot {
  padding: 9px; text-align: center; border-top: 1px solid var(--border);
  font-size: 13px; background: #fafbfd;
}
.link-btn {
  background: none; border: none; color: var(--primary);
  cursor: pointer; font-size: 12px; padding: 0;
}
.link-btn.danger { color: var(--danger); }

.bell-tools { display: flex; align-items: center; gap: 12px; }
.icon-btn {
  background: none; border: none; cursor: pointer;
  font-size: 14px; line-height: 1; padding: 2px 4px; border-radius: 6px;
}
.icon-btn:hover { background: #eef1f6; }
.icon-btn.off { opacity: .45; }

/* ---------- レイアウト ---------- */
.container { max-width: 1020px; margin: 0 auto; padding: 24px 20px 48px; }
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }

.flashes { margin-bottom: 16px; display: grid; gap: 8px; }
.flash { padding: 10px 14px; border-radius: 8px; font-size: 13px; border: 1px solid; }
.flash-success { background: #ecfdf5; border-color: #a7f3d0; color: #065f46; }
.flash-error   { background: #fef2f2; border-color: #fecaca; color: #991b1b; }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px; margin-bottom: 16px;
}
.card-title { font-size: 14px; font-weight: 700; }

.empty {
  background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius);
  padding: 48px 20px; text-align: center; color: var(--muted);
}
.empty .btn { margin-top: 12px; }

/* ---------- ボタン・フォーム ---------- */
.btn {
  display: inline-block; padding: 8px 16px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font-size: 13px; font-weight: 600; cursor: pointer; font-family: inherit;
}
.btn:hover { background: #f3f5f9; text-decoration: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-d); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-ghost { background: transparent; }
.btn-small { padding: 5px 11px; font-size: 12px; }
.btn-block { width: 100%; margin-top: 8px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

input[type="text"], input[type="password"], input[type="search"], input[type="date"],
select, textarea {
  width: 100%; padding: 8px 10px;
  border: 1px solid var(--border); border-radius: 8px;
  font-family: inherit; font-size: 14px; background: #fff; color: var(--text);
}
textarea { resize: vertical; line-height: 1.6; }
input:focus, select:focus, textarea:focus {
  outline: 2px solid rgba(37, 99, 235, .35); outline-offset: 0; border-color: var(--primary);
}

.form .field { display: block; margin-bottom: 18px; }
.field-label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 13px; }
.req { color: var(--danger); font-size: 11px; font-style: normal; margin-left: 4px; }
.field-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
fieldset.field { border: none; padding: 0; margin: 0 0 18px; }
.checkbox-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 6px;
  border: 1px solid var(--border); border-radius: 8px; padding: 12px; background: #fafbfd;
}
.checkbox { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.checkbox input { width: auto; }
.hint { margin: 6px 0 0; }
.form-actions { display: flex; gap: 10px; padding-top: 4px; }
.narrow-form { max-width: 520px; }
.form-lead { margin: 0 0 20px; font-size: 13px; }
.form-note {
  margin: 20px 0 0; padding-top: 14px; border-top: 1px solid var(--border);
  font-size: 11px; line-height: 1.7;
}
.show-password { margin-bottom: 18px; }
.inline-form { display: inline-flex; gap: 6px; align-items: center; }
.inline-form select { width: auto; min-width: 120px; }
.danger-zone {
  display: flex; align-items: center; gap: 12px;
  padding: 16px; border: 1px solid #fecaca; border-radius: var(--radius); background: #fff7f7;
}

/* ---------- ログイン ---------- */
.login-main { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card {
  width: 100%; max-width: 380px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); padding: 32px;
}
.login-head { text-align: center; margin-bottom: 24px; }
.login-head h1 { margin: 12px 0 4px; }
.login-card label { display: block; margin-bottom: 14px; font-weight: 600; font-size: 13px; }
.login-card label input { margin-top: 6px; font-weight: 400; }
.login-note { margin: 18px 0 0; text-align: center; }

/* ---------- タスク一覧 ---------- */
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.filters select, .filters input { width: auto; min-width: 160px; }
.filters input[type="search"] { min-width: 240px; flex: 1; }

.task-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.task-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
}
.task-card:hover { border-color: #c7d2fe; }
.task-card-main { display: block; padding: 14px 18px; color: var(--text); }
.task-card-main:hover { text-decoration: none; }
.task-card-top { display: flex; align-items: center; gap: 10px; }
.task-name { font-weight: 700; font-size: 15px; }
.task-excerpt {
  margin: 6px 0 0; color: var(--muted); font-size: 13px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.task-meta {
  margin-top: 10px; display: flex; flex-wrap: wrap; gap: 16px;
  font-size: 12px; color: var(--muted);
}

.status {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 700; white-space: nowrap;
  background: #e5e7eb; color: #374151;
}
.status[data-status="未着手"]   { background: #e5e7eb; color: #374151; }
.status[data-status="対応中"]   { background: #dbeafe; color: #1e40af; }
.status[data-status="レビュー中"] { background: #fef3c7; color: #92400e; }
.status[data-status="完了"]     { background: #d1fae5; color: #065f46; }
.status[data-status="保留"]     { background: #fee2e2; color: #991b1b; }

/* ---------- チャット画面 ---------- */
.chat-main { padding: 0; }
.chat-wrap {
  max-width: 1020px; margin: 0 auto; padding: 16px 20px 20px;
  height: calc(100vh - var(--topbar-h)); display: flex; flex-direction: column; gap: 12px;
}

.task-panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); flex: none;
}
.task-toggle {
  width: 100%; display: flex; align-items: center; gap: 10px;
  padding: 13px 18px; background: none; border: none; cursor: pointer;
  font-family: inherit; font-size: 15px; text-align: left; color: var(--text);
}
.task-toggle:hover { background: #f7f9fc; border-radius: var(--radius); }
.chevron { color: var(--muted); font-size: 11px; transition: transform .15s ease; }
.task-toggle[aria-expanded="true"] .chevron { transform: rotate(90deg); }
.task-title { font-weight: 700; }
.toggle-hint { margin-left: auto; }

.task-detail { padding: 4px 18px 18px; border-top: 1px solid var(--border); }
.task-detail-grid {
  display: grid; grid-template-columns: 90px 1fr; gap: 8px 16px; margin: 14px 0 0;
}
.task-detail-grid dt { font-weight: 600; font-size: 12px; color: var(--muted); padding-top: 2px; }
.task-detail-grid dd { margin: 0; font-size: 13px; }
.task-content { white-space: pre-wrap; }
.task-detail-actions { display: flex; gap: 8px; margin-top: 16px; }
.chip {
  display: inline-block; background: #eef2ff; color: #3730a3;
  border-radius: 999px; padding: 2px 10px; font-size: 12px; margin: 0 4px 4px 0;
}
.chip small { opacity: .7; }

.messages {
  flex: 1; overflow-y: auto; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px 18px; display: flex; flex-direction: column; gap: 4px;
}
.messages-loading, .messages-empty { text-align: center; margin: auto; }

.day-sep { text-align: center; margin: 14px 0 8px; }
.day-sep span {
  background: #eef1f6; color: var(--muted);
  border-radius: 999px; padding: 2px 12px; font-size: 11px; font-weight: 600;
}

.msg { display: flex; gap: 10px; padding: 4px 0; align-items: flex-start; }
.msg-avatar {
  flex: none; width: 32px; height: 32px; border-radius: 50%;
  background: #c7d2fe; color: #312e81; display: grid; place-items: center;
  font-size: 12px; font-weight: 700;
}
.msg-main { min-width: 0; flex: 1; display: flex; flex-direction: column; align-items: flex-start; }
.msg-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 2px; }
.msg-name { font-weight: 700; font-size: 13px; }
.msg-time { font-size: 11px; color: var(--muted); }
.msg-body {
  display: inline-block; max-width: min(78%, 620px);
  padding: 7px 12px; border-radius: 4px 12px 12px 12px;
  background: #f1f3f7; border: 1px solid #e4e8f0;
  white-space: pre-wrap; word-break: break-word; font-size: 14px; text-align: left;
}

/* 自分が発信したメッセージは右側に表示する */
.msg-mine { flex-direction: row-reverse; }
.msg-mine .msg-avatar { background: var(--primary); color: #fff; }
.msg-mine .msg-main { align-items: flex-end; }
.msg-mine .msg-head { flex-direction: row-reverse; }
.msg-mine .msg-body {
  background: #dbeafe; border-color: #bfdbfe; border-radius: 12px 4px 12px 12px;
}

.msg-continued .msg-avatar { visibility: hidden; }
.msg-continued .msg-head { display: none; }
.msg-continued .msg-body { border-radius: 12px; }

/* 自分がメンションされたメッセージは吹き出しを強調する */
.msg-mention-me .msg-body {
  background: #fffbeb; border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent) inset;
}
.msg-highlight .msg-body { animation: flash-bg 2.4s ease-out; }
@keyframes flash-bg {
  from { background: #fde68a; }
  to   { background: transparent; }
}

.mention {
  background: #dbeafe; color: #1e40af; border-radius: 4px;
  padding: 0 4px; font-weight: 600;
}
.mention-self { background: var(--accent); color: #fff; }
/* 自分の吹き出しは青系のため、メンションの色を一段濃くして埋もれないようにする */
.msg-mine .msg-body .mention { background: #b9d4fd; color: #1e3a8a; }
.msg-mine .msg-body .mention-self { background: var(--accent); color: #fff; }

.composer {
  position: relative; flex: none; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 12px 14px;
}
.composer textarea { border: none; padding: 0; font-size: 14px; min-height: 44px; }
.composer textarea:focus { outline: none; }
.composer-actions {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-top: 8px; padding-top: 8px; border-top: 1px solid #f0f2f6;
}
.composer-hint { font-size: 11px; }
.composer-error {
  background: #fef2f2; color: #991b1b; border: 1px solid #fecaca;
  border-radius: 6px; padding: 6px 10px; font-size: 12px; margin-bottom: 8px;
}
.mention-box {
  position: absolute; bottom: calc(100% + 6px); left: 14px; width: 300px; max-height: 220px;
  overflow-y: auto; background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; box-shadow: 0 6px 18px rgba(17, 24, 39, .14); z-index: 40;
}
.mention-item {
  padding: 8px 12px; cursor: pointer; font-size: 13px;
  display: flex; align-items: center; gap: 8px;
}
.mention-item:hover, .mention-item.active { background: #eef2ff; }
.mention-item .mid { color: var(--muted); font-size: 12px; }

/* ---------- 添付・通知一覧 ---------- */
.attach-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.attach-list li { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 13px; }
.attach-list.compact li { gap: 8px; }
.attach-list form { margin: 0; }

.notif-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.notif {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
}
.notif a { display: block; padding: 12px 16px; color: var(--text); }
.notif a:hover { background: #f7f9fc; text-decoration: none; }
.notif-unread { border-left: 3px solid var(--accent); }
.notif-head { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.notif-time { margin-left: auto; }
.notif-task { font-size: 12px; color: var(--primary); font-weight: 600; margin-top: 4px; }
.notif-body { font-size: 13px; color: var(--muted); margin-top: 2px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: none; }

@media (max-width: 720px) {
  .field-row { grid-template-columns: 1fr; }
  .topnav { display: none; }
  .bell-panel { width: min(340px, calc(100vw - 32px)); }
}
