/*
 * 測定値の推移（Day9）・勤務開始／勤務終了・管理・接続できないとき の表示。
 *
 * グラフの色は検証済み（夕・朝・臨時の3色。明るい画面・暗い画面の両方で
 * 色覚の違いがあっても見分けられることを確認）。臨時の青緑は明るい画面で
 * コントラストが 3:1 を下回るため、凡例の文字と数値の一覧を必ず添えている。
 */

:root {
  --series-evening: #2a78d6;   /* 夕：青 */
  --series-morning: #eb6834;   /* 朝：橙 */
  --series-other: #1baf7a;     /* 臨時：青緑 */
  --chart-grid: #e6e8ec;
  --chart-axis: #565b66;
  --chart-cross: #9aa1ab;
}

@media (prefers-color-scheme: dark) {
  :root {
    --series-evening: #3987e5;
    --series-morning: #d95926;
    --series-other: #199e70;
    --chart-grid: #30353d;
    --chart-axis: #b3b9c4;
    --chart-cross: #6b7380;
  }
}

/* ---- 個人ページの切替（記録／測定の推移） -------------------------- */

.tabs {
  display: flex;
  gap: 0;
  padding: 0 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}

.tab {
  flex: 1 1 0;
  min-height: 46px;
  border: 0;
  border-bottom: 3px solid transparent;
  background: none;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}

.tab[aria-selected="true"] {
  border-bottom-color: var(--primary);
  color: var(--text);
}

/*
 * PC など広い画面では、切替も中央の内容（幅640px）にそろえる。
 * 【2026-09-12 訂正】以前は styles.css の同じ規則に .tabs を足していたが、
 * このファイルの方が後に読み込まれ「padding: 0 12px」で上書きされて効いていなかった。
 */
@media (min-width: 700px) {
  .tabs { padding-inline: max(12px, calc((100% - 640px) / 2)); }
}

/* ---- 期間の切替（グラフの上に1列） -------------------------------- */

.range-row {
  display: flex;
  gap: 6px;
  margin: 0 0 10px;
}

.range-btn {
  flex: 1 1 0;
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  cursor: pointer;
}

.range-btn[aria-pressed="true"] {
  border-color: var(--primary);
  background: var(--primary);
  color: var(--primary-text);
  font-weight: 700;
}

/* 読み込み中は前の表示を薄くして保つ（画面が跳ねないように） */
.trends-body.is-loading { opacity: .5; }

.trend-note, .trend-foot { margin: 0 0 10px; font-size: 13px; color: var(--text-muted); }

/* ---- グラフ1枚 ---------------------------------------------------- */

.trend-card {
  margin-bottom: 12px;
  padding: 12px 12px 8px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}

.trend-head { display: flex; align-items: baseline; justify-content: space-between; }
.trend-title { margin: 0; font-size: 16px; }
.trend-unit { font-size: 13px; font-weight: 400; color: var(--text-muted); }

.trend-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  margin: 6px 0 4px;
  padding: 0;
  list-style: none;
  font-size: 14px;
}

.trend-legend-item { display: inline-flex; align-items: center; gap: 6px; }
.trend-key { display: inline-block; width: 16px; height: 3px; border-radius: 2px; }
.trend-legend-label { color: var(--text-muted); }
.trend-legend-value { font-size: 16px; font-variant-numeric: tabular-nums; }
.trend-legend-when { font-size: 13px; color: var(--text-muted); }

.trend-empty { margin: 10px 0 6px; font-size: 14px; color: var(--text-muted); }

.trend-plot { position: relative; }

.trend-svg {
  display: block;
  width: 100%;
  height: auto;
  touch-action: pan-y;       /* 縦スクロールは妨げない */
  outline: none;
}
.trend-svg:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 6px; }

.trend-grid { stroke: var(--chart-grid); stroke-width: 1; }
.trend-baseline { stroke: var(--chart-grid); stroke-width: 1; }
.trend-axis { fill: var(--chart-axis); font-size: 12px; font-variant-numeric: tabular-nums; }
.trend-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.trend-dot { stroke: var(--surface); stroke-width: 2; }
.trend-cross { stroke: var(--chart-cross); stroke-width: 1; }

/* ---- 血圧（夕の血圧・朝の血圧。上＝実線・塗り／下＝点線・白抜き） -------- */

.trend-line-dashed { stroke-dasharray: 6 4; }
.trend-dot-hollow { fill: var(--surface); stroke-width: 2; }
/* 線の右端の「上」「下」。文字は線の色ではなく文字の色で書く */
.trend-direct { fill: var(--text); font-size: 13px; font-weight: 700; }

.trend-latest {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 8px;
  margin: 6px 0 2px;
}
.trend-latest-label { font-size: 14px; color: var(--text-muted); }
.trend-latest-value { font-size: 22px; font-variant-numeric: tabular-nums; }
.trend-latest-unit { font-size: 14px; color: var(--text-muted); }
.trend-latest-when { font-size: 13px; color: var(--text-muted); }

.trend-key-svg { flex: 0 0 auto; }
.trend-legend-name { color: var(--text); }

.trend-tip {
  position: absolute;
  top: -4px;
  transform: translate(-50%, -100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 2px 8px rgba(0, 0, 0, .12);
  pointer-events: none;
  white-space: nowrap;
  z-index: 2;
}
.trend-tip-value { font-size: 16px; }
.trend-tip-label { font-size: 13px; color: var(--text-muted); }

.trend-table { margin-top: 6px; }
.trend-table > summary {
  min-height: var(--tap-min);
  padding: 10px 0;
  color: var(--primary);
  font-size: 14px;
  cursor: pointer;
}
.trend-table table { width: 100%; border-collapse: collapse; font-size: 14px; }
.trend-table th, .trend-table td { padding: 6px 4px; border-top: 1px solid var(--border); text-align: left; }
.trend-table th { font-size: 13px; color: var(--text-muted); font-weight: 700; }
.trend-table td.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---- 勤務中／勤務外（閲覧のみ） ------------------------------------ */

/* 勤務開始／勤務終了のボタン（ボタンには「押すと何をするか」を書く） */
.mode-btn {
  flex: 0 0 auto;
  min-height: var(--tap-min);
  padding: 0 14px;
  border: 2px solid var(--primary);
  border-radius: 999px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
.mode-btn.is-start { background: var(--primary); color: var(--primary-text); }
.mode-btn.is-end { background: var(--surface); color: var(--primary); }

.viewing-banner {
  margin: 0 0 14px;
  padding: 12px;
  border: 2px dashed var(--pending);
  border-radius: 10px;
  color: var(--text);
}
.viewing-text { margin: 0 0 10px; font-size: 15px; }
.viewing-note { margin: 8px 0 0; font-size: 13px; color: var(--text-muted); }

/* 確認（勤務開始・勤務終了） */
.confirm-dialog {
  width: min(92vw, 380px);
  padding: 20px;
  border: 0;
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 8px 28px rgba(0, 0, 0, .25);
}
.confirm-dialog::backdrop { background: rgba(0, 0, 0, .45); }
.confirm-title { margin: 0 0 8px; font-size: 19px; font-weight: 700; }
.confirm-message { margin: 0 0 8px; font-size: 15px; }
.confirm-note { margin: 0 0 16px; font-size: 13px; color: var(--text-muted); }
.confirm-actions { display: flex; gap: 10px; }
.confirm-actions .btn { flex: 1 1 0; min-height: 52px; padding: 0 10px; }

.dev-note {
  margin: 0 0 14px;
  padding: 8px 12px;
  border-radius: 8px;
  background: repeating-linear-gradient(45deg, var(--surface-2), var(--surface-2) 8px, transparent 8px, transparent 16px);
  border: 1px solid var(--border);
  font-size: 13px;
}

/* ---- 管理（試用データの削除） --------------------------------------- */

.admin-batch {
  margin-bottom: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}
.admin-batch-id { font-size: 16px; font-weight: 700; word-break: break-all; }
.admin-breakdown { margin: 8px 0; padding: 0; list-style: none; font-size: 14px; }
.admin-breakdown li { display: flex; justify-content: space-between; padding: 3px 0; border-top: 1px dashed var(--border); }
.admin-keep { font-size: 13px; color: var(--text-muted); }
.btn-danger { min-height: 48px; background: var(--level-important); color: #ffffff; }

/* ---- 起動中・接続できないとき -------------------------------------- */

.boot-loading { margin: 0; padding: 40vh 24px 0; text-align: center; font-size: 16px; color: var(--text-muted); }

.offline-box { margin: auto; padding: 24px; max-width: 380px; text-align: center; }
.offline-title { font-size: 18px; margin: 0 0 8px; }
.offline-text { font-size: 15px; color: var(--text-muted); margin: 0 0 16px; }

/* ---- 日勤帯（日勤ホーム準備中） ------------------------------------ */

.day-list { margin: 0; padding: 0; list-style: none; }
.day-list li { margin-bottom: 8px; }

/* ---- ホーム画面から起動したとき（standalone） ----------------------- */

@media (display-mode: standalone) {
  /* iPhone の上端（時計・電池の表示）に試用バナーが隠れないように */
  .trial-banner { padding-top: calc(8px + env(safe-area-inset-top, 0px)); }
}
