/* Self-hosted Noto Sans JP via @fontsource (ADR-0022 §5, #547) */
@import url('../vendor/fontsource/noto-sans-jp/400.css');
@import url('../vendor/fontsource/noto-sans-jp/500.css');
@import url('../vendor/fontsource/noto-sans-jp/700.css');

/* Design tokens (design-system.md §3) — SSOT: docs/specs/ui/design-system.md */
:root {
  --bs-body-font-family: 'Noto Sans JP', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --app-bg: #f4f5f7;
  --app-surface: #ffffff;
  --app-border: #e5e7eb;
  --app-ink: #1f2733;
  --app-muted: #6b7280;
  --app-primary: #3b5bdb;
  --app-primary-d: #2f49b0;
  --c-overdue: #e03131;
  --c-today: #e8830c;
  --c-soon: #1c7ed6;
  --c-done: #2f9e44;
  --ring: 0 0 0 3px rgba(59, 91, 219, 0.22);
  --shadow-sm: 0 1px 2px rgba(31, 39, 51, 0.06);
  --shadow-md: 0 6px 22px rgba(31, 39, 51, 0.09);
  --bs-body-bg: var(--app-bg);
  --bs-body-color: var(--app-ink);
  --bs-primary: var(--app-primary);
  --bs-primary-rgb: 59, 91, 219;
}

body {
  font-family: var(--bs-body-font-family);
}

*:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}

/* ---- App shell (design-system.md §6.7) ---- */
body {
  font-size: 14px;
}

.app-navbar {
  background: var(--app-surface);
  border-bottom: 1px solid var(--app-border);
  height: 56px;
}
.app-brand {
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--app-ink);
  text-decoration: none;
}
.app-brand .bi {
  color: var(--app-primary);
}

.app-layout {
  display: flex;
  min-height: calc(100vh - 56px);
}

.app-sidebar {
  width: 220px;
  flex: 0 0 220px;
  background: var(--app-surface);
  border-right: 1px solid var(--app-border);
  padding: 16px 12px;
}
.app-main {
  flex: 1 1 auto;
  min-width: 0;
  padding: 22px 26px 60px;
}

.nav-group-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #9aa1ad;
  text-transform: uppercase;
  padding: 0 12px;
  margin: 14px 0 6px;
}
.side-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  color: #3f4855;
  text-decoration: none;
  font-weight: 500;
  font-size: 13.5px;
  margin-bottom: 2px;
}
.side-link .bi {
  font-size: 16px;
  color: #7a828f;
}
.side-link:hover {
  background: #f2f4f7;
}
.side-link.active {
  background: #eef2ff;
  color: var(--app-primary);
}
.side-link.active .bi {
  color: var(--app-primary);
}

.admin-only {
  display: none;
}
body.role-admin .admin-only {
  display: block;
}

/* Adapt tenant-switcher to white navbar */
#tenant-switcher .btn-outline-light {
  color: var(--app-ink) !important;
  border-color: var(--app-border) !important;
}
#tenant-switcher .btn-outline-light:hover {
  background: #f2f4f7 !important;
  color: var(--app-ink) !important;
}
#tenant-switcher .badge {
  background-color: #eef2ff !important;
  color: #3b4cca !important;
  opacity: 1 !important;
}

/* ---- Page header ---- */
.page-title {
  font-weight: 700;
  font-size: 20px;
  margin: 0;
}

/* ---- Task table section (design-system.md §6.3) ---- */
.task-section {
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  border-radius: 12px;
  overflow: hidden;
}
.section-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 18px;
  border-bottom: 1px solid var(--app-border);
}
.section-head h2 {
  font-size: 15px;
  font-weight: 700;
  margin: 0;
}
.sec-count {
  font-size: 12px;
  color: var(--app-muted);
  font-weight: 500;
}

table.tasks {
  width: 100%;
  border-collapse: collapse;
}
table.tasks th {
  font-size: 11px;
  font-weight: 600;
  color: #9aa1ad;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 8px 14px;
  border-bottom: 1px solid var(--app-border);
  text-align: left;
  background: #fafbfc;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}
table.tasks th[data-nosort] {
  cursor: default;
}
table.tasks th .bi {
  font-size: 10px;
  opacity: 0.6;
}
table.tasks td {
  padding: 10px 14px;
  border-bottom: 1px solid #f1f2f4;
  vertical-align: middle;
}
table.tasks tr:last-child td {
  border-bottom: none;
}
table.tasks tbody tr {
  cursor: pointer;
}
table.tasks tbody tr:hover {
  background: #f8f9fb;
}
.task-title {
  font-weight: 500;
  color: var(--app-ink);
}
.task-desc {
  font-size: 11.5px;
  color: var(--app-muted);
  margin-top: 1px;
}
.due-overdue {
  color: var(--c-overdue);
  font-weight: 700;
}
.due-today {
  color: var(--c-today);
  font-weight: 700;
}
.owner-mini {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #eef2ff;
  color: #3b4cca;
  display: inline-grid;
  place-items: center;
  font-size: 10px;
  font-weight: 700;
  margin-right: 6px;
  flex-shrink: 0;
}
table.tasks .empty-row td {
  text-align: center;
  color: #9aa1ad;
  padding: 40px 14px;
  font-size: 13px;
}
table.tasks tr.group-head {
  cursor: default;
}
table.tasks tr.group-head:hover {
  background: transparent;
}
table.tasks tr.group-head td {
  background: #fafbfc;
  font-size: 12px;
  font-weight: 700;
  color: var(--app-ink);
  padding: 8px 14px;
}

/* ---- Badges (design-system.md §6.4) ---- */
.vis-badge {
  font-size: 11px;
  font-weight: 500;
  padding: 4px 8px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 1px solid transparent;
}
.vis-TENANT {
  background: #e7f5ec;
  color: #207a3a;
  border-color: #c3e6cf;
}
.vis-STAKEHOLDERS {
  background: #e7f0fb;
  color: #1f5fb0;
  border-color: #c2d8f2;
}
.vis-PRIVATE {
  background: #f3eef7;
  color: #7a4ba8;
  border-color: #e0d2ee;
}

.pri-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 6px;
}
.pri-HIGH {
  background: #fdeaea;
  color: #c92a2a;
}
.pri-MEDIUM {
  background: #fff3e2;
  color: #b8650b;
}
.pri-LOW {
  background: #eef1f6;
  color: #566173;
}

.st-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 9px;
  border-radius: 6px;
}
.st-NOT_STARTED {
  background: #eef1f6;
  color: #566173;
}
.st-IN_PROGRESS {
  background: #e7f0fb;
  color: #1f5fb0;
}
.st-DONE {
  background: #e7f5ec;
  color: #207a3a;
}
.st-ON_HOLD {
  background: #fff3e2;
  color: #b8650b;
}

/* ---- Pagination ---- */
.pager {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-top: 1px solid var(--app-border);
  font-size: 12px;
  color: var(--app-muted);
  background: #fafbfc;
}

/* ---- Loading skeleton (design-system.md §6.11) ---- */
.skel-row {
  height: 44px;
  border-bottom: 1px solid #f1f2f4;
  padding: 10px 14px;
}

/* ---- Drawer ---- */
.offcanvas-end {
  width: 440px;
}

/* ---- Inline editing (screen-flow.md §5.2) ---- */

/* Editable cell: subtle hover hint */
.edit-cell {
  cursor: pointer;
  border-radius: 4px;
  padding: 2px 4px;
  margin: -2px -4px;
  display: inline-block;
}
.edit-cell:hover {
  background: #eef2ff;
  outline: 1px solid #c5cff9;
}

/* Non-editable status/priority badge in readonly rows */
.readonly-cell {
  cursor: default;
}

/* Inline selects for status and priority */
.inline-sel {
  font-size: 12px;
  font-weight: 600;
  padding: 3px 24px 3px 8px;
  height: auto;
  border-radius: 6px;
  min-width: 76px;
  background-size: 12px;
}
/* Status select colors per value */
.st-sel-NOT_STARTED {
  background-color: #eef1f6;
  color: #566173;
  border-color: #c6cbd5;
}
.st-sel-IN_PROGRESS {
  background-color: #e7f0fb;
  color: #1f5fb0;
  border-color: #b4cff0;
}
.st-sel-DONE {
  background-color: #e7f5ec;
  color: #207a3a;
  border-color: #b2dfc0;
}
.st-sel-ON_HOLD {
  background-color: #fff3e2;
  color: #b8650b;
  border-color: #ffd6a0;
}
/* Priority select colors per value */
.pri-sel-HIGH {
  background-color: #fdeaea;
  color: #c92a2a;
  border-color: #f5c6cb;
}
.pri-sel-MEDIUM {
  background-color: #fff3e2;
  color: #b8650b;
  border-color: #ffd6a0;
}
.pri-sel-LOW {
  background-color: #eef1f6;
  color: #566173;
  border-color: #c6cbd5;
}

/* Inline text/date inputs that replace cell content */
td .inline-input {
  font-size: 13px;
  padding: 4px 8px;
  height: auto;
  width: 100%;
}

/* Description popover overlay */
.desc-overlay {
  position: fixed;
  z-index: 1055;
  background: #fff;
  border: 1px solid var(--app-border);
  border-radius: 10px;
  padding: 14px;
  width: 300px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.14);
}
.desc-overlay textarea {
  resize: vertical;
  min-height: 80px;
}

/* Disabled/saving state */
.inline-sel:disabled {
  opacity: 0.6;
  cursor: wait;
}

/* app-task-row is transparent to table layout (display:contents = no box generated) */
app-task-row {
  display: contents;
}

/* ---- Extracted inline styles (ADR-0022: no style= attributes) ---- */
.w-sort-sel {
  width: 172px;
}

.w-search {
  width: 240px;
}

#user-avatar {
  width: 30px;
  height: 30px;
  place-items: center;
  font-weight: 700;
  font-size: 12px;
  /* <button> 化(#814 プロフィールダイアログのトリガー)に伴うボタン既定装飾の打ち消し */
  padding: 0;
  line-height: 1;
  cursor: pointer;
}

.skel-placeholder {
  border-radius: 4px;
}

/* Task table column widths */
.col-status {
  width: 110px;
}
.col-owner {
  width: 104px;
}
.col-assignee {
  width: 116px;
}
#th-dueDate {
  width: 96px;
}
#th-priority {
  width: 80px;
}
.col-visibility {
  width: 112px;
}

/* Utility: whitespace and text sizes from rowHTML() */
.td-nowrap {
  white-space: nowrap;
}
.add-desc-hint {
  font-size: 11px;
}

/* ---- Drawer content (app-task-drawer) ---- */
.offcanvas-end {
  width: 460px;
}
.offcanvas-header {
  gap: 8px;
  flex-wrap: wrap;
}
.offcanvas-title {
  font-size: 15px;
}

.drawer-field-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--app-muted);
  text-transform: uppercase;
  margin-bottom: 5px;
}

.drawer-desc-text {
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--app-ink);
}

/* Meta key-value grid (2-column, label + value) */
.drawer-meta-grid {
  display: grid;
  grid-template-columns: 90px 1fr;
  row-gap: 8px;
  column-gap: 12px;
  align-items: baseline;
}
.drawer-meta-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--app-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.drawer-meta-value {
  font-size: 13px;
}

/* Stakeholder / selected-user chips */
.drawer-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 28px;
}
.drawer-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #eef2ff;
  color: #3b4cca;
  border: 1px solid #c5cff9;
  border-radius: 20px;
  padding: 3px 10px 3px 10px;
  font-size: 12px;
  font-weight: 500;
}
.drawer-chip-rm {
  background: none;
  border: none;
  padding: 0 0 0 4px;
  font-size: 14px;
  line-height: 1;
  color: #7a82c6;
  cursor: pointer;
}
.drawer-chip-rm:hover {
  color: #c92a2a;
}

/* ===== SaaS Admin ゲート (#812) =====
   認可確定(Auth.isAppAdmin)までシェルを隠し、非 APP_ADMIN への
   casual disclosure を防ぐ。admin.js 等が認可後に admin-gated を外す。
   非権限ユーザーはシェルを表示する前に dashboard.html へリダイレクトされる。 */
body.admin-gated .app-navbar,
body.admin-gated .app-layout {
  visibility: hidden;
}

/* ===== Dashboard / 個人ダッシュボード (S-03) ===== */
.dash-task-item:last-child {
  border-bottom: 0 !important;
}
/* flex 子要素での text-truncate を効かせるため min-width をリセットする */
.dash-task-title {
  min-width: 0;
}
