/* =====================================================================
   選択式アセスメント 帳票レイアウト編集（assessments#sheet_edit）
   全社協『居宅サービス計画ガイドライン Ver.3』様式 6-①〜⑥ を
   A4縦（幅210mm基準）で再現し、選択式で直接編集する。
   care_plan_sheet_edit.css の視覚言語（編集欄=薄紫）を踏襲。
   ===================================================================== */

:root {
  --asx-purple: #7c3aed;
  --asx-edit-bg: rgba(124, 58, 237, 0.045);
  --asx-edit-bg-hover: rgba(124, 58, 237, 0.09);
  --asx-edit-outline: rgba(124, 58, 237, 0.4);
  --asx-ink: #1a1a1a;
  --asx-line: #333;
}

/* ---- 上部固定バー ---- */
.asx-topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.97);
  backdrop-filter: saturate(150%) blur(4px);
  border-bottom: 1px solid var(--gray-200);
  flex-wrap: wrap;
  margin: 0 0 14px;
}

.asx-topbar-title h1 { font-size: 18px; font-weight: 700; color: var(--navy); margin: 0; }
.asx-topbar-title p { font-size: 12.5px; color: var(--gray-500); margin: 2px 0 0; }
.asx-topbar-actions { display: flex; align-items: center; gap: 10px; margin-left: auto; flex-wrap: wrap; }

/* ---- 様式の充実度インジケータ ---- */
.asx-completeness { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.asx-completeness-label { font-size: 12px; font-weight: 600; color: var(--gray-600); }
.asx-completeness-pct { font-size: 13px; font-weight: 800; color: var(--navy); min-width: 38px; }
.asx-completeness-bar {
  display: inline-block; width: 160px; height: 6px; border-radius: 999px;
  background: var(--gray-200, #e5e7eb); overflow: hidden;
}
.asx-completeness-fill {
  display: block; height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, #C0A062, #D4B878);
  transition: width 0.3s ease;
}

/* ---- ボタン（care_plan_sheet_edit と同系） ---- */
.asx-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 18px; border-radius: 8px;
  font-size: 13.5px; font-weight: 600; cursor: pointer;
  text-decoration: none; border: 1.5px solid transparent;
  white-space: nowrap; transition: opacity 0.15s, background 0.15s, transform 0.1s;
  font-family: inherit;
}
.asx-btn-primary { background: var(--gold); color: #fff; border-color: var(--gold); box-shadow: 0 3px 10px rgba(192, 160, 98, 0.3); }
.asx-btn-primary:hover { opacity: 0.9; transform: translateY(-1px); }
.asx-btn-ghost { background: #fff; color: var(--gray-700); border-color: var(--gray-300); }
.asx-btn-ghost:hover { background: var(--gray-50); }
.asx-btn-ai { background: linear-gradient(135deg, #4f46e5, #7c3aed); color: #fff; border: none; box-shadow: 0 3px 10px rgba(124, 58, 237, 0.28); }
.asx-btn-ai:hover { opacity: 0.92; transform: translateY(-1px); }
.asx-btn-lg { padding: 14px 30px; font-size: 15.5px; font-weight: 800; border-radius: 12px; }

/* ---- 凡例 ---- */
.asx-legend {
  display: flex; align-items: center; gap: 18px;
  padding: 9px 16px; background: #f5f0ff; border: 1px solid #ddd6fe;
  border-radius: 8px; margin: 0 auto 16px; max-width: 820px; flex-wrap: wrap;
}
.asx-lg-title { font-size: 12.5px; font-weight: 700; color: var(--asx-purple); }
.asx-legend-item { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--gray-600); }
.asx-swatch { width: 18px; height: 14px; border-radius: 3px; border: 1px solid rgba(0,0,0,0.1); }
.asx-swatch.editable { background: var(--asx-edit-bg-hover); }

/* ---- 目次（ジャンプ） ---- */
.asx-toc {
  display: flex; gap: 8px; flex-wrap: wrap;
  max-width: 820px; margin: 0 auto 18px; padding: 0 6px;
}
.asx-toc a {
  font-size: 12px; padding: 6px 12px; border-radius: 999px;
  background: #fff; border: 1px solid var(--gray-300); color: var(--gray-700);
  text-decoration: none; transition: background 0.15s, border-color 0.15s;
}
.asx-toc a:hover { background: #f5f0ff; border-color: var(--asx-purple); color: var(--asx-purple); }

/* ---- A4縦シート ---- */
.asx-sheet {
  width: 210mm;
  max-width: 100%;
  margin: 0 auto 22px;
  background: #fff;
  padding: 8mm;
  box-sizing: border-box;
  font-family: 'Hiragino Mincho ProN', 'Hiragino Mincho Pro', 'Yu Mincho', 'YuMincho', 'MS Mincho', 'Noto Serif JP', serif;
  color: var(--asx-ink);
  font-size: 11.5px;
  line-height: 1.5;
}

/* グループ見出し（●6-① 等） */
.asx-group {
  scroll-margin-top: 70px;
  border: 1.5px solid var(--asx-line);
  margin-bottom: 16px;
  page-break-inside: auto;
}
.asx-group-head {
  background: #eef0f4;
  border-bottom: 1.5px solid var(--asx-line);
  font-weight: 700;
  font-size: 13.5px;
  padding: 7px 12px;
  color: #16233b;
  letter-spacing: 0.5px;
}

/* サブ見出し（体位変換・入浴 等） */
.asx-subhead {
  background: #f4f5f7;
  font-weight: 700;
  font-size: 11.5px;
  padding: 4px 10px;
  border-top: 1px solid #ccc;
  border-bottom: 1px solid #ccc;
  color: #333;
}

/* ---- 認定調査項目テーブル ---- */
.asx-survey { width: 100%; border-collapse: collapse; }
.asx-survey th, .asx-survey td { border: 1px solid #999; vertical-align: middle; padding: 3px 6px; }
.asx-survey thead th {
  background: #f0f0f0; font-size: 9.5px; font-weight: 700; text-align: center; line-height: 1.3;
  font-family: -apple-system, 'Hiragino Kaku Gothic ProN', sans-serif;
}
.asx-survey .asx-code { white-space: nowrap; font-weight: 700; font-size: 10.5px; width: 26mm; }
.asx-survey .asx-code .c { color: #7a6a3a; margin-right: 3px; }

/* 選択肢（数字+ラベルのラジオ・選択中は丸囲み） */
.asx-choices { display: flex; flex-wrap: wrap; gap: 4px 4px; }
.asx-choice {
  display: inline-flex; align-items: center; cursor: pointer;
  font-size: 10.5px; line-height: 1.25;
  border: 1px solid transparent; border-radius: 4px; padding: 1px 5px;
  transition: background 0.12s, border-color 0.12s;
  background: var(--asx-edit-bg);
}
.asx-choice:hover { background: var(--asx-edit-bg-hover); }
.asx-choice input { position: absolute; opacity: 0; width: 0; height: 0; }
.asx-choice .num {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 15px; height: 15px; margin-right: 4px;
  border: 1px solid #888; border-radius: 50%;
  font-size: 9.5px; font-weight: 700; color: #555;
  font-family: -apple-system, sans-serif;
}
.asx-choice .lbl { color: #333; }
/* 選択中 */
.asx-choice input:checked ~ .num { border-color: var(--asx-purple); background: var(--asx-purple); color: #fff; }
.asx-choice input:checked ~ .lbl { font-weight: 700; color: #1a1a1a; }
.asx-choice:has(input:checked) { background: rgba(124, 58, 237, 0.14); border-color: var(--asx-edit-outline); }
.asx-choice input:focus-visible ~ .num { outline: 2px solid var(--asx-edit-outline); outline-offset: 1px; }
/* 認定調査項目ラジオの選択解除ボタン（FB#7） */
.asx-choice-clear {
  border: 1px solid #ddd; background: #fff; color: #aaa; border-radius: 4px;
  font-size: 9.5px; line-height: 1.2; padding: 1px 6px; margin-left: 2px; cursor: pointer;
  transition: background .12s, color .12s, border-color .12s; white-space: nowrap;
}
.asx-choice-clear:hover { background: #fef2f2; color: #dc2626; border-color: #fecaca; }
@media print { .asx-choice-clear { display: none !important; } }

/* 援助セル（家族実施/サービス実施/希望/計画）のセレクト */
.asx-care-cols { width: 100%; border-collapse: collapse; }
.asx-care-cols th, .asx-care-cols td { border: 1px solid #999; padding: 3px 5px; vertical-align: middle; text-align: center; }
.asx-care-cols thead th { background: #f0f0f0; font-size: 9px; font-weight: 700; line-height: 1.25; font-family: -apple-system, 'Hiragino Kaku Gothic ProN', sans-serif; }
.asx-care-cols .asx-care-label { text-align: left; font-weight: 600; font-size: 11px; background: #fafafa; }
.asx-sel {
  border: 1px solid var(--gray-300); border-radius: 5px; padding: 3px 4px;
  font-size: 13px; background: var(--asx-edit-bg); color: #1a1a1a;
  font-family: -apple-system, sans-serif; min-width: 42px; text-align: center; cursor: pointer;
}
.asx-sel:hover { background: var(--asx-edit-bg-hover); }
.asx-sel:focus { outline: 2px solid var(--asx-edit-outline); outline-offset: -1px; border-color: var(--asx-purple); }
.asx-sel.filled { font-weight: 700; }

/* 特記 textarea（枠に溶け込む） */
.asx-note-cell { padding: 0; }
.asx-note-label {
  font-size: 9.5px; color: #8a8a8a; font-weight: 600; padding: 4px 8px 0;
  font-family: -apple-system, 'Hiragino Kaku Gothic ProN', sans-serif;
}
.asx-ta {
  width: 100%; border: none; background: var(--asx-edit-bg);
  font-family: 'Hiragino Mincho ProN', 'Yu Mincho', 'Noto Serif JP', serif;
  font-size: 11.5px; line-height: 1.6; color: var(--asx-ink);
  resize: none; outline: none; padding: 6px 8px; box-sizing: border-box; display: block; overflow: hidden; min-height: 2.6em;
}
.asx-ta:hover { background: var(--asx-edit-bg-hover); }
.asx-ta:focus { background: var(--asx-edit-bg-hover); }
.asx-ta::placeholder { color: #b9a9dd; }

/* extra ブロック（コミュニケーション・排泄用具・食事・医療） */
.asx-extra { padding: 8px 10px; border-top: 1px dashed #bbb; }
.asx-extra-title {
  font-size: 11px; font-weight: 700; color: #3a3a55; margin: 2px 0 8px;
  font-family: -apple-system, 'Hiragino Kaku Gothic ProN', sans-serif;
}
.asx-field-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 7px; }
.asx-field-label { font-size: 11px; font-weight: 600; min-width: 120px; }

/* インライン選択（ラジオ/チェックの横並び・小） */
.asx-inline { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.asx-pill {
  display: inline-flex; align-items: center; gap: 4px; cursor: pointer;
  font-size: 10.5px; padding: 2px 8px; border-radius: 999px;
  border: 1px solid #bbb; background: var(--asx-edit-bg); transition: background 0.12s, border-color 0.12s;
}
.asx-pill:hover { background: var(--asx-edit-bg-hover); }
.asx-pill input { position: absolute; opacity: 0; width: 0; height: 0; }
.asx-pill:has(input:checked) { background: rgba(124, 58, 237, 0.16); border-color: var(--asx-purple); font-weight: 700; color: #1a1a1a; }

.asx-inline-note {
  border: none; border-bottom: 1px solid #bbb; background: transparent;
  font-size: 11px; padding: 1px 4px; min-width: 120px; outline: none;
  font-family: 'Hiragino Mincho ProN', 'Yu Mincho', serif; color: var(--asx-ink);
}
.asx-inline-note:focus { border-bottom-color: var(--asx-purple); background: var(--asx-edit-bg); }

/* 現状/計画 2軸チェック表（医療処置・主食副食など） */
.asx-2axis { width: 100%; border-collapse: collapse; margin-top: 4px; }
.asx-2axis th, .asx-2axis td { border: 1px solid #999; padding: 3px 6px; font-size: 10.5px; }
.asx-2axis thead th { background: #f0f0f0; font-weight: 700; text-align: center; font-family: -apple-system, sans-serif; }
.asx-2axis .asx-2axis-label { text-align: left; }
.asx-2axis td.c { text-align: center; }
.asx-2axis input[type="checkbox"] { width: 15px; height: 15px; accent-color: var(--asx-purple); cursor: pointer; }

/* ページラベル */
.asx-page-label { text-align: right; font-size: 10px; color: #666; padding: 3px 8px; }

/* 下部アクション */
.asx-actions {
  display: flex; gap: 14px; align-items: center; justify-content: center;
  margin: 24px auto 40px; padding-top: 20px; flex-wrap: wrap; max-width: 820px;
}

/* AIまとめ カード（保存後） */
.asx-ai-card {
  max-width: 820px; margin: 0 auto 20px; padding: 16px 20px;
  border: 1px solid #ddd6fe; background: #f9f7ff; border-radius: 12px;
}
.asx-ai-card h3 { font-size: 14px; font-weight: 700; color: #4c1d95; margin: 0 0 6px; display: flex; align-items: center; gap: 6px; }
.asx-ai-card p { font-size: 12.5px; color: var(--gray-600); margin: 0 0 12px; line-height: 1.6; }

/* ===== 適切なケアマネジメント手法・疾患別ケアの選択（FB#2） ===== */
.asx-tekicare-body { padding: 10px 12px; }
.asx-tekicare-note { font-size: 11.5px; color: var(--gray-600); line-height: 1.6; margin: 0 0 10px; }
.asx-tekicare-hint { color: #b45309; }
.asx-tekicare-choices { gap: 8px 8px; }
/* 疾患別ケアの各選択肢はチェックボックス型（.num を持たないため専用に見た目を作る） */
.asx-tekicare-choices .asx-choice {
  font-size: 12.5px; padding: 6px 12px 6px 10px;
  border: 1px solid #d8d8e0; border-radius: 999px; background: #fff;
}
.asx-tekicare-choices .asx-choice .lbl { display: inline-flex; align-items: center; }
.asx-tekicare-choices .asx-choice .lbl::before {
  content: ""; display: inline-block; width: 15px; height: 15px; margin-right: 7px;
  border: 1.5px solid #9a9aa8; border-radius: 4px; background: #fff;
  transition: background 0.12s, border-color 0.12s;
}
.asx-tekicare-choices .asx-choice input:checked ~ .lbl::before {
  border-color: var(--asx-purple); background: var(--asx-purple);
  /* チェックマーク（白）を疑似的に描く */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='white' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 8l3.5 3.5L13 5'/%3E%3C/svg%3E");
  background-size: 13px 13px; background-position: center; background-repeat: no-repeat;
}
.asx-tekicare-choices .asx-choice:has(input:checked) {
  background: rgba(124, 58, 237, 0.10); border-color: var(--asx-edit-outline);
}
.asx-tekicare-choices .asx-choice input:focus-visible ~ .lbl::before {
  outline: 2px solid var(--asx-edit-outline); outline-offset: 1px;
}

/* レスポンシブ: 画面が210mmより狭ければ全幅 */
@media (max-width: 820px) {
  .asx-sheet { padding: 4mm; font-size: 11px; }
  .asx-survey .asx-code { width: auto; }
}
