/* 共通UIキットのスタイル。theme.css の :root トークンを使用。theme.css の後に読込。 */

/* ---- データテーブル ツールバー ---- */
.dt-toolbar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-bottom: 10px;
}
.dt-search { position: relative; flex: 1 1 220px; min-width: 160px; }
.dt-search-ic { position: absolute; left: 9px; top: 50%; transform: translateY(-50%); opacity: .5; font-size: 13px; pointer-events: none; }
.dt-search .input { width: 100%; padding-left: 30px; }
.dt-filter { min-width: 120px; }
.dt-extra { display: flex; gap: 8px; align-items: center; }
.dt-clear { white-space: nowrap; }
.dt-count { margin-left: auto; color: var(--muted, #5b6573); font-size: 12px; white-space: nowrap; }

.table-wrap { overflow: auto; border: 1px solid var(--line, #d3d9e2); border-radius: var(--radius, 10px); background: var(--surface, #fff); }
.table-wrap .table { margin: 0; }
.table th.is-sortable { cursor: pointer; user-select: none; white-space: nowrap; }
.table th.is-sortable:hover { background: #e9eef5; }
.ta-right { text-align: right; }
.ta-center { text-align: center; }
.table tr.is-clickable { cursor: pointer; }
.table tr.is-clickable:hover td { background: #eef4fb; }
.dt-empty { text-align: center; color: var(--muted, #5b6573); padding: 28px 12px; }

/* ---- チップ / ステータスラベル ---- */
.chip { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 999px;
  background: #eef1f5; color: var(--muted, #5b6573); border: 1px solid var(--line, #d3d9e2); }
.chip-brand { background: #e8eef6; color: var(--brand, #1f3a5f); border-color: #c9d8ea; }
.chip-ok { background: #e3f3ea; color: var(--ok, #1e7d46); border-color: #bfe3cd; }
.chip-warn { background: #fdeede; color: var(--warn, #b15c00); border-color: #f3d4ab; }
.chip-danger { background: #fae3e1; color: var(--danger, #c2261b); border-color: #f0c2bd; }
.status-label { font-size: 12px; color: var(--text, #1f2937); vertical-align: middle; }

/* ---- レイヤー: モーダル / ドロワー ---- */
body.ui-locked { overflow: hidden; }
#ui-layer-host { position: fixed; inset: 0; z-index: 1000; pointer-events: none; }
.ui-overlay { position: fixed; inset: 0; pointer-events: auto; display: flex; }
.ui-scrim { position: absolute; inset: 0; background: rgba(17, 26, 42, .46); }
.ui-overlay-modal { align-items: center; justify-content: center; padding: 24px; }
.ui-overlay-drawer { justify-content: flex-end; }

.ui-modal, .ui-drawer {
  position: relative; background: var(--surface, #fff); border-radius: var(--radius, 10px);
  box-shadow: 0 18px 50px rgba(0,0,0,.3); display: flex; flex-direction: column;
  max-height: calc(100vh - 48px); animation: ui-pop .14s ease-out;
}
.ui-modal { width: min(720px, 100%); }
.ui-modal.lg { width: min(960px, 100%); }
.ui-modal.sm { width: min(480px, 100%); }
.ui-drawer { width: min(560px, 100%); height: 100vh; max-height: 100vh; border-radius: 0; }
.ui-drawer.left { animation: ui-slide-l .16s ease-out; }
.ui-drawer { animation: ui-slide-r .16s ease-out; }
@keyframes ui-pop { from { transform: translateY(8px) scale(.98); opacity: 0; } }
@keyframes ui-slide-r { from { transform: translateX(40px); opacity: .4; } }
@keyframes ui-slide-l { from { transform: translateX(-40px); opacity: .4; } }

.ui-panel-head { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line, #d3d9e2); }
.ui-panel-title { font-weight: 700; font-size: 16px; color: var(--text, #1f2937); flex: 1; }
.ui-panel-sub { padding: 8px 18px 0; color: var(--muted, #5b6573); font-size: 13px; }
.ui-panel-body { padding: 16px 18px; overflow: auto; }
.ui-panel-foot { padding: 12px 18px; border-top: 1px solid var(--line, #d3d9e2); display: flex; gap: 8px; justify-content: flex-end; }
.ui-x { background: transparent; border: 0; font-size: 22px; line-height: 1; color: var(--muted, #5b6573); cursor: pointer; padding: 2px 6px; border-radius: 6px; }
.ui-x:hover { background: #eef1f5; color: var(--text, #1f2937); }

/* ---- カレンダー ---- */
.cal { border: 1px solid var(--line, #d3d9e2); border-radius: var(--radius, 10px); overflow: hidden; background: var(--surface, #fff); }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); }
.cal-head .cal-h { text-align: center; font-size: 12px; font-weight: 700; color: var(--muted, #5b6573); padding: 8px 0; background: #f3f6fa; border-bottom: 1px solid var(--line, #d3d9e2); }
.cal-cell { min-height: 76px; border-right: 1px solid var(--line, #eef1f5); border-bottom: 1px solid var(--line, #eef1f5); padding: 6px; position: relative; }
.cal-cell.is-clickable { cursor: pointer; }
.cal-cell.is-clickable:hover { background: #eef4fb; }
.cal-empty { background: #fafbfc; }
.cal-d { font-size: 12px; font-weight: 700; color: var(--text, #1f2937); }
.cal-cell.is-today { outline: 2px solid var(--brand, #1f3a5f); outline-offset: -2px; }
.cal-cell.heat-ok { background: #e7f4ec; }
.cal-cell.heat-warn { background: #fdf0e0; }
.cal-cell.heat-danger { background: #fae4e2; }
.cal-rate { font-size: 11px; color: var(--muted, #5b6573); margin-top: 2px; }

/* ---- 汎用ミニ表示（ドリルダウン内） ---- */
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; font-size: 13px; }
.kv dt { color: var(--muted, #5b6573); }
.kv dd { margin: 0; color: var(--text, #1f2937); }
.mini-list { display: flex; flex-direction: column; gap: 6px; }
.mini-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--line, #d3d9e2); border-radius: 8px; background: #fff; }
.mini-row.is-clickable { cursor: pointer; } .mini-row.is-clickable:hover { background: #eef4fb; }
.mini-grow { flex: 1; min-width: 0; }
.unit { font-size: 12px; font-weight: 600; color: var(--muted, #5b6573); margin-left: 2px; }
.section-label { font-size: 12px; font-weight: 700; color: var(--muted, #5b6573); margin: 14px 0 6px; text-transform: none; }

@media (max-width: 640px) {
  .dt-count { margin-left: 0; order: 5; flex-basis: 100%; }
  .ui-overlay-modal { padding: 0; align-items: stretch; }
  .ui-modal { width: 100%; max-height: 100vh; border-radius: 0; }
  .cal-cell { min-height: 56px; }
}

/* ---- ローディング（処理中スピナー） ---- */
.ui-overlay-loading { align-items: center; justify-content: center; pointer-events: auto; }
.ui-overlay-loading .ui-scrim { background: rgba(17,26,42,.32); }
.ui-loader { position: relative; background: rgba(255,255,255,.97); border-radius: 16px;
  padding: 26px 34px; display: flex; flex-direction: column; align-items: center; gap: 14px;
  box-shadow: 0 16px 48px rgba(0,0,0,.28); animation: ui-pop .22s cubic-bezier(.32,.72,0,1); }
.ui-spinner { width: 40px; height: 40px; border-radius: 50%;
  border: 3px solid rgba(31,58,95,.16); border-top-color: var(--brand, #1f3a5f);
  animation: ui-spin .7s linear infinite; }
.ui-loader-text { font-size: 14px; font-weight: 700; color: var(--text, #1f2937); }
.ui-loader-sub { font-size: 12px; color: var(--muted, #5b6573); margin-top: -6px; text-align: center; max-width: 240px; }
@keyframes ui-spin { to { transform: rotate(360deg); } }

/* ---- モーダル/ドロワーを macOS 風の滑らかさに（イージング上書き） ---- */
.ui-modal { animation: ui-pop .24s cubic-bezier(.32,.72,0,1); }
.ui-drawer { animation: ui-slide-r .26s cubic-bezier(.32,.72,0,1); }
.ui-drawer.left { animation: ui-slide-l .26s cubic-bezier(.32,.72,0,1); }
.ui-scrim { animation: ui-fade .2s ease-out; }
@keyframes ui-fade { from { opacity: 0; } }

/* ---- アクセシビリティ: モーションを抑える設定を尊重（スピナーだけ残す） ---- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
  .ui-spinner { animation: ui-spin .8s linear infinite !important; }
}

/* ---- トースト（成功通知・Undo） ---- */
#ui-toast-host { position: fixed; top: 14px; left: 0; right: 0; z-index: 1200; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.ui-toast { pointer-events: auto; display: flex; align-items: center; gap: 12px; background: #1f2937; color: #fff; border-radius: 10px; padding: 11px 16px; font-size: 14px; box-shadow: 0 8px 28px rgba(0,0,0,.3); max-width: calc(100% - 32px); animation: ui-toast-in .22s cubic-bezier(.32,.72,0,1); }
.ui-toast.is-danger { background: #7a1f17; } .ui-toast.is-ok { background: #155e35; }
.ui-toast.leaving { opacity: 0; transform: translateY(-8px); transition: opacity .18s, transform .18s; }
.ui-toast-act { background: transparent; border: 1px solid rgba(255,255,255,.45); color: #fff; border-radius: 8px; padding: 6px 12px; font-size: 13px; font-weight: 700; cursor: pointer; min-height: 36px; white-space: nowrap; }
.ui-toast-act:hover { background: rgba(255,255,255,.14); }
@keyframes ui-toast-in { from { opacity: 0; transform: translateY(-12px); } }

/* ---- タップ標的（共通: 閉じる・小ボタン） ---- */
.ui-x { min-width: 44px; min-height: 44px; display: grid; place-items: center; }
.btn.sm { min-height: 40px; }
/* 色付き背景に乗るテキストのコントラスト補正（対背景4.5:1以上へ） */
.chip-warn { color: #8a4700; } .chip-danger { color: #9e1c14; } .chip-ok { color: #155e35; }
