/* ==========================================================================
   介護シフト自動作成 — 共通スタイル
   ========================================================================== */

:root {
  --c-early: #fff7ed;   /* 早番 */
  --c-day: #eff6ff;     /* 日勤 */
  --c-late: #f5f3ff;    /* 遅番 */
  --c-night: #1e293b;   /* 夜勤 */
  --c-after: #cbd5e1;   /* 明け */
  --c-holiday: #f1f5f9; /* 公休 */
  --c-paid: #ecfdf5;    /* 有給 */
  --c-train: #fefce8;   /* 研修 */
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Kaku Gothic ProN",
    "Noto Sans JP", "Yu Gothic", Meiryo, sans-serif;
}

/* ---------------- ナビゲーション ---------------- */

.nav-btn {
  padding: 0.35rem 0.7rem;
  border-radius: 0.375rem;
  color: #475569;
  white-space: nowrap;
  transition: background-color 0.12s, color 0.12s;
}
.nav-btn:hover { background: #f1f5f9; color: #0f172a; }
.nav-btn.active { background: #4f46e5; color: #fff; font-weight: 600; }

/* ---------------- 汎用パーツ ---------------- */

.card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 0.5rem;
  padding: 1rem;
}
.card-title {
  font-weight: 700;
  font-size: 0.95rem;
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.btn {
  padding: 0.4rem 0.85rem;
  border-radius: 0.375rem;
  font-size: 0.875rem;
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
  white-space: nowrap;
  transition: filter 0.12s;
}
.btn:hover:not(:disabled) { filter: brightness(0.94); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: #4f46e5; color: #fff; }
.btn-secondary { background: #fff; color: #334155; border-color: #cbd5e1; }
.btn-danger { background: #dc2626; color: #fff; }
.btn-success { background: #059669; color: #fff; }
.btn-sm { padding: 0.2rem 0.55rem; font-size: 0.78rem; }

.input, .select {
  border: 1px solid #cbd5e1;
  border-radius: 0.375rem;
  padding: 0.35rem 0.55rem;
  font-size: 0.875rem;
  background: #fff;
}
.input:focus, .select:focus {
  outline: 2px solid #a5b4fc;
  outline-offset: -1px;
  border-color: #6366f1;
}

.badge {
  display: inline-block;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.5;
}
.badge-ok { background: #d1fae5; color: #065f46; }
.badge-warn { background: #fef3c7; color: #92400e; }
.badge-err { background: #fee2e2; color: #991b1b; }
.badge-info { background: #e0e7ff; color: #3730a3; }

/* ---------------- テーブル（マスタ系） ---------------- */

.tbl { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.tbl th {
  background: #f8fafc;
  border-bottom: 2px solid #e2e8f0;
  padding: 0.5rem 0.6rem;
  text-align: left;
  font-weight: 600;
  color: #475569;
  white-space: nowrap;
}
.tbl td { border-bottom: 1px solid #f1f5f9; padding: 0.45rem 0.6rem; }
.tbl tbody tr:hover { background: #fafbfc; }

/* ==========================================================================
   シフトグリッド
   ========================================================================== */

.grid-wrap {
  overflow: auto;
  border: 1px solid #cbd5e1;
  border-radius: 0.5rem;
  background: #fff;
  max-height: calc(100vh - 260px);
}

table.shift-grid {
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.75rem;
  table-layout: fixed;
}

table.shift-grid th, table.shift-grid td {
  border-right: 1px solid #e2e8f0;
  border-bottom: 1px solid #e2e8f0;
  padding: 0;
  text-align: center;
  height: 26px;
}

/* 職員名列（横スクロール時に固定） */
.sg-name {
  position: sticky;
  left: 0;
  z-index: 2;
  background: #f8fafc;
  min-width: 92px;
  width: 92px;
  max-width: 92px;
  text-align: left !important;
  padding: 0 0.4rem !important;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-right: 2px solid #cbd5e1 !important;
}

/* ヘッダ行（縦スクロール時に固定） */
.sg-head th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: #f8fafc;
  font-weight: 600;
  color: #475569;
}
.sg-head th.sg-name { z-index: 4; }
.sg-head2 th {
  position: sticky;
  top: 26px;
  z-index: 3;
  background: #f8fafc;
  font-size: 0.68rem;
  color: #64748b;
}
.sg-head2 th.sg-name { z-index: 4; }

/* 日付セル幅 */
.sg-day { width: 30px; min-width: 30px; max-width: 30px; }

/* 土日祝 */
.sg-sat { background: #eff6ff !important; color: #1d4ed8; }
.sg-sun { background: #fef2f2 !important; color: #b91c1c; }

/* 集計列 */
.sg-sum {
  width: 40px; min-width: 40px;
  background: #f8fafc;
  font-size: 0.7rem;
  color: #475569;
}

/* セル本体 */
.sg-cell {
  cursor: pointer;
  user-select: none;
  position: relative;
  font-weight: 600;
  transition: box-shadow 0.08s;
}
.sg-cell:hover { box-shadow: inset 0 0 0 2px #6366f1; }
.sg-cell.selected { box-shadow: inset 0 0 0 2px #4f46e5; background-image: linear-gradient(rgba(79,70,229,0.12), rgba(79,70,229,0.12)); }

/* 勤務区分カラー（category ベース） */
.cat-work-1 { background: var(--c-early); }
.cat-work-2 { background: var(--c-day); }
.cat-work-3 { background: var(--c-late); }
.cat-night { background: var(--c-night); color: #fff; }
.cat-after_night { background: var(--c-after); }
.cat-holiday { background: var(--c-holiday); color: #94a3b8; }
.cat-paid_leave { background: var(--c-paid); color: #047857; }
.cat-other { background: var(--c-train); color: #a16207; }
.cat-empty { background: #fff; color: #cbd5e1; }

/* ロック（手動確定）マーク */
.sg-cell.locked::after {
  content: '';
  position: absolute;
  top: 1px; right: 1px;
  width: 0; height: 0;
  border-top: 5px solid #4f46e5;
  border-left: 5px solid transparent;
}

/* 希望休マーク */
.sg-cell.req-preferred { outline: 1px dashed #f59e0b; outline-offset: -2px; }
.sg-cell.req-required { outline: 2px solid #f59e0b; outline-offset: -2px; }

/* 違反マーク */
.sg-cell.violation { box-shadow: inset 0 0 0 2px #dc2626; }

/* 日別人数フッタ */
.sg-foot td, .sg-foot th {
  position: sticky;
  bottom: 0;
  background: #f8fafc;
  font-size: 0.68rem;
  z-index: 2;
}
.sg-foot th.sg-name { z-index: 3; }
.sg-short { background: #fee2e2 !important; color: #991b1b; font-weight: 700; }
.sg-under { background: #fef3c7 !important; color: #92400e; }

/* ---------------- 凡例 ---------------- */

.legend { display: flex; flex-wrap: wrap; gap: 0.4rem; font-size: 0.72rem; }
.legend-item {
  display: inline-flex; align-items: center; gap: 0.25rem;
  border: 1px solid #e2e8f0; border-radius: 0.25rem;
  padding: 0.1rem 0.4rem; background: #fff;
}
.legend-chip {
  width: 15px; height: 15px; border-radius: 2px;
  border: 1px solid #cbd5e1;
  display: inline-block;
  text-align: center; line-height: 15px; font-size: 0.6rem; font-weight: 700;
}

/* ---------------- トースト ---------------- */

.toast {
  padding: 0.6rem 0.9rem;
  border-radius: 0.375rem;
  color: #fff;
  font-size: 0.85rem;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.18);
  max-width: 380px;
  animation: toast-in 0.18s ease-out;
}
.toast-success { background: #059669; }
.toast-error { background: #dc2626; }
.toast-info { background: #334155; }
.toast-warn { background: #d97706; }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------------- 希望休入力グリッド ---------------- */

.leave-cell { cursor: pointer; user-select: none; }
.leave-none { background: #fff; }
.leave-preferred { background: #fef3c7; color: #92400e; font-weight: 700; }
.leave-required { background: #fca5a5; color: #7f1d1d; font-weight: 700; }
.leave-over { outline: 2px solid #dc2626; outline-offset: -2px; }

/* ---------------- 進捗バー ---------------- */

.progress-track { height: 8px; background: #e2e8f0; border-radius: 999px; overflow: hidden; }
.progress-bar { height: 100%; background: #4f46e5; transition: width 0.2s; }

/* ==========================================================================
   印刷（A3 横）
   ========================================================================== */

@media print {
  @page { size: A3 landscape; margin: 8mm; }

  .no-print, #app-header, #toast-area, #modal-root, footer { display: none !important; }

  body { background: #fff !important; font-size: 8pt; }
  #app-main { padding: 0 !important; }

  .card { border: none; padding: 0; }
  .grid-wrap {
    overflow: visible !important;
    max-height: none !important;
    border: none;
  }
  table.shift-grid { font-size: 7pt; width: 100%; }
  table.shift-grid th, table.shift-grid td {
    height: auto;
    padding: 1px 0;
    border-right: 0.4pt solid #999;
    border-bottom: 0.4pt solid #999;
  }
  .sg-name { position: static !important; min-width: 60px; width: 60px; }
  .sg-head th, .sg-head2 th, .sg-foot td, .sg-foot th { position: static !important; }
  .cat-night { background: #333 !important; color: #fff !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .sg-cell, .sg-sat, .sg-sun, .sg-short, .sg-under,
  .cat-work-1, .cat-work-2, .cat-work-3, .cat-after_night,
  .cat-holiday, .cat-paid_leave, .cat-other {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  .print-only { display: block !important; }
}

.print-only { display: none; }

/* マニュアルダウンロードリンク（ナビ内） */
#manual-link {
  text-decoration: none;
  background: #0f4c81;
  color: #fff !important;
  border-color: #0f4c81;
}
#manual-link:hover { background: #1a6fa8; border-color: #1a6fa8; }
