/* ============================================================
   style.css - 勤務表作成システム スタイル
   ============================================================ */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Helvetica Neue', 'Hiragino Sans', 'Hiragino Kaku Gothic ProN',
    'Meiryo', sans-serif;
  background: #f5f7fa;
  color: #333;
  font-size: 14px;
  line-height: 1.5;
}

#app {
  max-width: 1400px;
  margin: 0 auto;
  padding: 10px 20px;
}

/* ---- ヘッダー ---- */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 2px solid #2563eb;
  margin-bottom: 12px;
}

header h1 {
  font-size: 20px;
  color: #1e40af;
}

.month-selector {
  display: flex;
  gap: 12px;
  align-items: center;
}

.month-selector label {
  font-weight: bold;
}

.month-selector input {
  width: 80px;
  padding: 4px 8px;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  font-size: 14px;
}

/* ---- タブ ---- */
.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.tab-btn {
  padding: 8px 20px;
  border: 1px solid #cbd5e1;
  border-bottom: none;
  background: #e2e8f0;
  cursor: pointer;
  border-radius: 6px 6px 0 0;
  font-size: 14px;
  font-weight: bold;
  color: #64748b;
  transition: all 0.15s;
}

.tab-btn.active {
  background: #fff;
  color: #1e40af;
  border-color: #2563eb;
  border-bottom: 2px solid #fff;
  margin-bottom: -1px;
}

.tab-btn:hover:not(.active) {
  background: #f1f5f9;
}

.tab-content {
  display: none;
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 0 6px 6px 6px;
  padding: 16px;
}

.tab-content.active {
  display: block;
}

/* ---- セクション ---- */
.section {
  margin-bottom: 20px;
}

.section h2 {
  font-size: 16px;
  color: #1e40af;
  margin-bottom: 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid #e2e8f0;
}

.hint {
  color: #64748b;
  font-size: 12px;
  margin-bottom: 10px;
}

/* ---- ボタン ---- */
.btn {
  padding: 6px 16px;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.15s;
}

.btn:hover {
  background: #f1f5f9;
}

.btn-primary {
  background: #2563eb;
  color: #fff;
  border-color: #2563eb;
}

.btn-primary:hover {
  background: #1d4ed8;
}

.btn-danger {
  color: #dc2626;
  border-color: #fca5a5;
}

.btn-danger:hover {
  background: #fef2f2;
}

.btn-small {
  padding: 4px 10px;
  font-size: 12px;
}

.btn-small.active {
  background: #2563eb;
  color: #fff;
  border-color: #2563eb;
}

.btn-large {
  padding: 10px 32px;
  font-size: 16px;
  font-weight: bold;
}

/* ---- スタッフテーブル ---- */
#staff-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 12px;
}

#staff-table th,
#staff-table td {
  padding: 6px 10px;
  border: 1px solid #e2e8f0;
  text-align: left;
}

#staff-table th {
  background: #f1f5f9;
  font-size: 13px;
  color: #475569;
}

#staff-table input[type='text'] {
  width: 100%;
  padding: 4px 6px;
  border: 1px solid #cbd5e1;
  border-radius: 3px;
  font-size: 13px;
}

#staff-table .dow-checks {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

#staff-table .dow-checks label {
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 2px;
}

.night-target-input {
  width: 56px;
  font-size: 13px;
  padding: 4px 6px;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  text-align: center;
}

/* ---- 委員会セル（スタッフ表） ---- */
.committee-cell {
  min-width: 150px;
}

.committee-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 4px;
}

.committee-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: #fef9c3;
  border: 1px solid #fde68a;
  border-radius: 10px;
  padding: 1px 7px;
  font-size: 11px;
  color: #92400e;
  white-space: nowrap;
}

.committee-chip button {
  border: none;
  background: none;
  color: #b45309;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}

.committee-add {
  display: flex;
  gap: 3px;
  align-items: center;
}

.committee-add select {
  font-size: 11px;
  padding: 2px;
  border: 1px solid #cbd5e1;
  border-radius: 3px;
}

.committee-add button {
  font-size: 13px;
  padding: 1px 8px;
  border: 1px solid #cbd5e1;
  border-radius: 3px;
  background: #fff;
  cursor: pointer;
}

/* ---- ペア禁止設定 ---- */
.ban-pair-form {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.ban-pair-form select {
  padding: 4px 8px;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  font-size: 13px;
  min-width: 120px;
}

.ban-x {
  font-weight: bold;
  font-size: 16px;
  color: #dc2626;
}

.ban-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.ban-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: #fef2f2;
  border: 1px solid #fca5a5;
  border-radius: 16px;
  font-size: 13px;
  color: #991b1b;
}

.ban-item button {
  background: none;
  border: none;
  color: #dc2626;
  font-size: 16px;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
}

/* ---- 条件入力 ---- */
.prev-night-inputs {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}

.prev-night-inputs label {
  font-weight: bold;
}

.prev-night-inputs select {
  padding: 4px 8px;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  font-size: 13px;
  min-width: 140px;
}

.input-controls {
  display: flex;
  gap: 16px;
  align-items: center;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.input-controls select {
  padding: 4px 8px;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  font-size: 13px;
  min-width: 140px;
}

.input-mode-btns {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

/* ---- 固定日勤設定 ---- */
.fixed-day-form {
  margin-bottom: 12px;
  padding: 10px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
}

.fd-row {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.fd-row label {
  font-size: 13px;
  font-weight: bold;
}

.fd-row select,
.fd-row input {
  padding: 4px 8px;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  font-size: 13px;
}

.fd-list-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.fd-list-table th,
.fd-list-table td {
  padding: 4px 8px;
  border: 1px solid #e2e8f0;
  text-align: left;
}

.fd-list-table th {
  background: #f1f5f9;
  color: #475569;
  font-size: 12px;
}

/* ---- ミニカレンダー ---- */
.mini-calendar {
  margin-bottom: 12px;
}

.mini-calendar table {
  border-collapse: collapse;
}

.mini-calendar th,
.mini-calendar td {
  width: 42px;
  height: 36px;
  text-align: center;
  border: 1px solid #e2e8f0;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.1s;
}

.mini-calendar th {
  background: #f1f5f9;
  color: #475569;
  font-size: 12px;
  cursor: default;
}

.mini-calendar td:hover {
  background: #e0e7ff;
}

.mini-calendar td.empty {
  background: #fafafa;
  cursor: default;
}

.mini-calendar td.cal-reqOff {
  background: #e2e8f0;
  color: #334155;
  font-weight: bold;
}

.mini-calendar td.cal-reqPaid {
  background: #bbf7d0;
  color: #166534;
  font-weight: bold;
}

.mini-calendar td.cal-reqDay {
  background: #fef3c7;
  color: #92400e;
  font-weight: bold;
}

.mini-calendar td.cal-reqNight {
  background: #c4b5fd;
  color: #4c1d95;
  font-weight: bold;
}

.mini-calendar td.cal-reqAke {
  background: #ddd6fe;
  color: #5b21b6;
  font-weight: bold;
}

.mini-calendar td.cal-unavailable {
  background: #fecaca;
  color: #991b1b;
  font-weight: bold;
}

.mini-calendar td.cal-sunday {
  color: #dc2626;
}

.mini-calendar td.cal-saturday {
  color: #2563eb;
}

.schedule-table thead th.is-holiday {
  color: #dc2626;
}

.input-summary {
  font-size: 13px;
  color: #475569;
  padding: 8px;
  background: #f8fafc;
  border-radius: 4px;
  border: 1px solid #e2e8f0;
}

.input-summary strong {
  color: #1e40af;
}

/* ---- 勤務表 ---- */
.schedule-actions {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
}

.status-msg {
  font-size: 13px;
  color: #16a34a;
  font-weight: bold;
}

.legend {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
  font-size: 12px;
}

.legend-item {
  padding: 2px 8px;
  border-radius: 3px;
  border: 1px solid #e2e8f0;
}

.schedule-table-wrapper {
  overflow-x: auto;
  margin-bottom: 16px;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
}

.schedule-table {
  border-collapse: collapse;
  white-space: nowrap;
  font-size: 13px;
}

.schedule-table th,
.schedule-table td {
  padding: 4px 2px;
  border: 1px solid #d1d5db;
  text-align: center;
  min-width: 36px;
}

.schedule-table thead th {
  background: #f1f5f9;
  position: sticky;
  top: 0;
  z-index: 2;
  font-size: 11px;
  color: #475569;
}

.schedule-table thead th.day-header {
  padding: 2px 1px;
  line-height: 1.3;
}

.schedule-table .staff-name-cell {
  position: sticky;
  left: 0;
  background: #f8fafc;
  z-index: 1;
  font-weight: bold;
  min-width: 80px;
  text-align: left;
  padding-left: 6px;
}

.schedule-table thead th:first-child {
  position: sticky;
  left: 0;
  z-index: 3;
  background: #e2e8f0;
}

.schedule-table .summary-cell {
  background: #f8fafc;
  font-weight: bold;
  font-size: 12px;
  min-width: 50px;
}

/* シフト種別の色 */
.shift-day {
  background: #fff;
  color: #333;
}

.shift-night {
  background: #7c3aed;
  color: #fff;
  font-weight: bold;
}

.shift-ake {
  background: #c4b5fd;
  color: #4c1d95;
}

.shift-off {
  background: #e2e8f0;
  color: #64748b;
}

.shift-paid {
  background: #bbf7d0;
  color: #166534;
  font-weight: bold;
}

.shift-am {
  background: #fed7aa;
  color: #9a3412;
}

.shift-committee {
  background: #fde68a;
  color: #92400e;
  font-weight: bold;
}

/* 警告色（日付ヘッダー） */
.day-warning-yellow {
  background: #fef08a !important;
  color: #92400e !important;
}

.day-warning-red {
  background: #fca5a5 !important;
  color: #991b1b !important;
}

/* ---- シフト編集モーダル ---- */
.shift-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.shift-modal-overlay[hidden] {
  display: none;
}

.shift-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  opacity: 0;
  transition: opacity 0.25s ease;
}

.shift-modal-overlay.open .shift-modal-backdrop {
  opacity: 1;
}

.shift-modal-sheet {
  position: relative;
  width: 100%;
  max-width: 480px;
  background: #fff;
  border-radius: 16px 16px 0 0;
  padding: 16px 16px 24px;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
}

.shift-modal-overlay.open .shift-modal-sheet {
  transform: translateY(0);
}

.shift-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid #e2e8f0;
}

.shift-modal-header span {
  font-size: 16px;
  font-weight: bold;
  color: #1e40af;
}

.shift-modal-close-btn {
  width: 36px;
  height: 36px;
  border: none;
  background: #f1f5f9;
  border-radius: 50%;
  font-size: 20px;
  color: #64748b;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.shift-modal-buttons {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.shift-modal-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 64px;
  border: 2px solid #cbd5e1;
  border-radius: 12px;
  background: #fff;
  cursor: pointer;
  font-size: 20px;
  font-weight: bold;
  color: #334155;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.shift-modal-btn .btn-label {
  font-size: 11px;
  font-weight: normal;
  color: #64748b;
  margin-top: 2px;
}

.shift-modal-btn:active {
  transform: scale(0.95);
}

/* 現在のシフト */
.shift-modal-btn.is-current {
  border-color: #2563eb;
  background: #eff6ff;
  box-shadow: 0 0 0 2px #2563eb;
}

/* 推奨 */
.shift-modal-btn.is-recommended {
  border-color: #16a34a;
  background: #f0fdf4;
}
.shift-modal-btn.is-recommended::after {
  content: '推奨';
  font-size: 9px;
  color: #16a34a;
  font-weight: bold;
  margin-top: 2px;
}

/* 警告 */
.shift-modal-btn.is-warn {
  border-color: #f59e0b;
  background: #fffbeb;
}

/* 無効 */
.shift-modal-btn.is-disabled {
  border-color: #e2e8f0;
  background: #f8fafc;
  color: #cbd5e1;
  cursor: not-allowed;
  opacity: 0.5;
}

/* シフト種別ごとの色 */
.shift-modal-btn[data-shift="日"] { color: #334155; }
.shift-modal-btn[data-shift="夜"] { color: #7c3aed; }
.shift-modal-btn[data-shift="明"] { color: #6d28d9; }
.shift-modal-btn[data-shift="休"] { color: #64748b; }
.shift-modal-btn[data-shift="有"] { color: #16a34a; }
.shift-modal-btn[data-shift="午前"] { color: #ea580c; }

/* 変更セルのハイライト */
.cell-changed {
  animation: cell-flash 2s ease-out;
}
@keyframes cell-flash {
  0% { box-shadow: inset 0 0 0 3px #2563eb; }
  100% { box-shadow: none; }
}

/* 手動変更済みマーカー */
.cell-modified::after {
  content: '';
  position: absolute;
  top: 1px;
  right: 1px;
  width: 5px;
  height: 5px;
  background: #2563eb;
  border-radius: 50%;
}

.schedule-table td.editable {
  cursor: pointer;
  position: relative;
}

.schedule-table td.editable:hover {
  outline: 2px solid #2563eb;
  outline-offset: -2px;
}

/* 勤務表フッター（集計行） */
.schedule-table tfoot td {
  background: #f1f5f9;
  font-weight: bold;
  font-size: 11px;
}

/* ---- 条件違反 ---- */
.violations-panel {
  border: 1px solid #fca5a5;
  border-radius: 6px;
  padding: 12px;
  background: #fef2f2;
}

.violations-panel h3 {
  color: #dc2626;
  font-size: 15px;
  margin-bottom: 8px;
}

.violations-panel ul {
  list-style: none;
  padding: 0;
}

.violations-panel li {
  padding: 4px 8px;
  margin-bottom: 4px;
  font-size: 13px;
  border-left: 3px solid #dc2626;
  background: #fff;
  border-radius: 0 3px 3px 0;
}

.violations-panel li.warn {
  border-left-color: #f59e0b;
}

/* ---- 役割色 ---- */
.role-leader { background: #fef3c7; color: #92400e; font-weight: bold; }
.role-team-a { background: #dbeafe; color: #1e40af; font-weight: bold; }
.role-team-b { background: #d1fae5; color: #065f46; font-weight: bold; }
.role-shochi { background: #fee2e2; color: #991b1b; font-weight: bold; }
.role-night-team { background: #7c3aed; color: #fff; font-weight: bold; }
.role-night-sub { background: #c4b5fd; color: #4c1d95; }
.role-none { background: #f1f5f9; color: #94a3b8; }

/* ---- 印刷用ヘッダー（画面では非表示）---- */
.print-header {
  display: none;
}

.print-legend {
  display: none;
}

/* ---- 設定タブ ---- */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 10px 20px;
  margin-bottom: 12px;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  font-size: 13px;
  font-weight: bold;
  color: #334155;
}

.setting-row input[type='number'] {
  width: 72px;
  padding: 6px 8px;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  font-size: 14px;
  text-align: center;
}

.setting-row.setting-check {
  justify-content: flex-start;
  font-weight: normal;
}

.setting-row.setting-check input {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.settings-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.data-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.prev-night-count-list {
  margin-top: 4px;
}

.prev-night-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.prev-night-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 10px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  font-size: 13px;
}

.prev-night-row input {
  width: 56px;
  padding: 4px 6px;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  font-size: 13px;
  text-align: center;
}

/* ---- レスポンシブ ---- */
@media (max-width: 768px) {
  #app {
    padding: 8px;
  }

  header h1 {
    font-size: 16px;
  }

  .tab-btn {
    padding: 6px 12px;
    font-size: 12px;
  }

  .schedule-table th,
  .schedule-table td {
    min-width: 30px;
    font-size: 11px;
    padding: 2px 1px;
  }
}

/* ============================================================
   印刷用スタイル (@media print)
   ============================================================ */
@media print {
  /* 不要なUI要素を非表示 */
  header,
  .tabs,
  .schedule-actions,
  .legend,
  .violations-panel,
  .shift-modal-overlay,
  #role-modal-overlay,
  #tab-staff,
  #tab-input,
  #tab-roles,
  #tab-settings {
    display: none !important;
  }

  body {
    background: #fff;
    font-size: 10px;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  #app {
    max-width: none;
    padding: 0;
    margin: 0;
  }

  /* 勤務表タブを強制表示 */
  #tab-schedule {
    display: block !important;
    border: none;
    padding: 0;
  }

  .tab-content {
    border: none;
    padding: 0;
  }

  /* 印刷ヘッダー表示 */
  .print-header {
    display: block !important;
    text-align: center;
    margin-bottom: 8px;
  }

  .print-header h2 {
    font-size: 16px;
    color: #000;
    border: none;
  }

  /* 印刷用凡例 */
  .print-legend {
    display: flex !important;
    gap: 12px;
    font-size: 9px;
    margin-top: 6px;
    justify-content: center;
  }

  /* テーブルラッパー */
  .schedule-table-wrapper {
    overflow: visible;
    border: none;
  }

  .schedule-table {
    width: 100%;
    font-size: 9px;
  }

  .schedule-table th,
  .schedule-table td {
    min-width: auto;
    padding: 2px 1px;
    border: 1px solid #999;
  }

  .schedule-table thead th {
    position: static;
    background: #e8e8e8 !important;
    font-size: 8px;
  }

  .schedule-table .staff-name-cell {
    position: static;
    min-width: auto;
    font-size: 9px;
    padding-left: 3px;
  }

  .schedule-table thead th:first-child {
    position: static;
  }

  .schedule-table tfoot td {
    font-size: 8px;
  }

  /* シフト色を印刷でも出す */
  .shift-night { background: #7c3aed !important; color: #fff !important; }
  .shift-ake { background: #c4b5fd !important; }
  .shift-off { background: #e2e8f0 !important; }
  .shift-paid { background: #bbf7d0 !important; }
  .shift-am { background: #fed7aa !important; }
  .shift-committee { background: #fde68a !important; color: #92400e !important; }

  /* A4横向き */
  @page {
    size: A4 landscape;
    margin: 10mm;
  }

  /* ページ改ページ防止 */
  .schedule-table {
    page-break-inside: avoid;
  }

  /* editable カーソルやホバーを消す */
  .schedule-table td.editable {
    cursor: default;
  }
  .schedule-table td.editable:hover {
    outline: none;
  }
  .cell-modified::after {
    display: none;
  }
}
