/* ========================================
   モーダル共通スタイル
   legacyのモーダルデザインを再現
   ======================================== */

/* モーダルオーバーレイ */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.modal-overlay.active {
  display: flex;
}

/* モーダルコンテンツ */
.modal-content {
  background: white;
  border-radius: 12px;
  padding: 32px;
  width: 640px;
  max-width: 90vw;
  position: relative;
  max-height: 90vh;
  overflow-y: auto;
}

/* モーダルヘッダー */
.modal-header-title {
  font-size: 20px;
  font-weight: 700;
  color: #333;
  margin-bottom: 24px;
  text-align: center;
}

/* 閉じるボタン */
.modal-close-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  background: rgba(0, 0, 0, 0.05);
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 9999px;
  padding: 0 12px;
  height: 30px;
  font-size: 14px;
  color: #888;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}

.modal-close-btn:hover {
  color: #333;
  background: rgba(0, 0, 0, 0.1);
}

/* フォームグループ */
.settings-group {
  margin-bottom: 24px;
}

.settings-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 500;
  color: #333;
}

.settings-group input,
.settings-group select,
.settings-group textarea {
  width: 100%;
  padding: 12px;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  font-size: 16px;
  font-family: inherit;
}

.settings-group input:focus,
.settings-group select:focus,
.settings-group textarea:focus {
  outline: none;
  border-color: #1976D2;
  box-shadow: 0 0 0 3px rgba(25, 118, 210, 0.1);
}

/* モーダルアクション */
.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}

/* モーダルボタン */
.btn-modal {
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.btn-modal:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.btn-modal-save {
  background: linear-gradient(to right, #2E7D32 0%, #4CAF50 50%, #66BB6A 100%);
  color: white;
}

.btn-modal-cancel {
  background: linear-gradient(to right, rgba(255, 255, 255, 0.6), rgba(255, 255, 255, 0.2));
  border: 1px solid rgba(0, 0, 0, 0.15);
  color: #333;
}

.btn-modal-primary {
  background: #1976D2;
  color: white;
}

.btn-modal-danger {
  background: linear-gradient(to right, #C62828 0%, #f44336 50%, #FF5252 100%);
  color: white;
}

/* ============================================
   エラー報告モーダル
   ============================================ */
#error-report-modal .modal-content {
  max-width: 560px;
}

/* ============================================
   ユニット設定モーダル
   ============================================ */
#unit-settings-modal .modal-content {
  max-width: 640px;
}

/* ============================================
   歯科衛生士管理モーダル
   ============================================ */
#staff-management-modal .modal-content {
  width: 800px;
}

#staff-management-modal .staff-mgmt-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 16px;
}

#staff-management-modal .staff-mgmt-table th,
#staff-management-modal .staff-mgmt-table td {
  padding: 8px;
  border-bottom: 1px solid #e0e0e0;
  text-align: left;
}

#staff-management-modal .staff-mgmt-table th {
  background: #f5f5f5;
  font-weight: 600;
  color: #333;
}

.btn-delete-staff {
  padding: 4px 12px;
  border: none;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  background: #ffebee;
  color: #c62828;
  transition: all 0.2s;
}

.btn-delete-staff:hover {
  background: #ef9a9a;
  color: white;
}

.btn-edit-furigana {
  padding: 4px 12px;
  border: none;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  background: #e3f2fd;
  color: #1976d2;
  transition: all 0.2s;
  margin-right: 4px;
}

.btn-edit-furigana:hover {
  background: #90caf9;
  color: white;
}

/* ============================================
   スタッフ選択モーダル（Ver2.0 50音順）
   ============================================ */

/* トリガーボタン（メイン画面） */
.staff-select-trigger {
  width: 100%;
  min-height: 56px;
  padding: 16px 20px;
  border: 2px solid #e0e0e0;
  background: white;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 16px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 12px;
}

.staff-select-trigger:hover {
  border-color: #2196f3;
}

.staff-select-trigger.selected {
  border-color: #2196f3;
  background: #e3f2fd;
  color: #1976d2;
}

.staff-select-trigger-icon {
  font-size: 20px;
  color: #666;
}

.staff-select-trigger.selected .staff-select-trigger-icon {
  color: #1976d2;
}

.staff-select-trigger-text {
  flex: 1;
  text-align: left;
}

.staff-select-trigger-arrow {
  color: #999;
  font-size: 14px;
}

/* モーダルコンテンツ */
.staff-select-modal-content {
  width: 780px;
  max-height: 80vh;
  overflow-y: auto;
}

/* 職種タブ */
.staff-role-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 16px;
  border-bottom: 2px solid #e0e0e0;
}

.staff-role-tab {
  flex: 1;
  padding: 10px 0;
  border: none;
  background: transparent;
  font-size: 15px;
  font-weight: 600;
  color: #999;
  cursor: pointer;
  transition: all 0.15s;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
}

.staff-role-tab:hover {
  color: #333;
  background: #f5f5f5;
}

.staff-role-tab.active {
  color: #1976d2;
  border-bottom-color: #1976d2;
}

.staff-tab-content {
  padding: 4px 0;
  height: 50vh;
  overflow-y: auto;
}

/* 院長バッジ */
.staff-owner-badge {
  display: inline-block;
  font-size: 10px;
  background: #ef6c00;
  color: white;
  border-radius: 4px;
  padding: 1px 5px;
  margin-right: 4px;
  vertical-align: middle;
  font-weight: 700;
}

.staff-gojuon-btn.staff-owner {
  border-color: #ef6c00;
  background: #fff8e1;
}

.staff-gojuon-items {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

/* スタッフボタン（モーダル内共通） */
.staff-gojuon-btn {
  padding: 12px 8px;
  border: 1px solid #e0e0e0;
  background: white;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
  font-size: 14px;
  font-weight: 500;
  text-align: center;
  min-height: 44px;
}

.staff-gojuon-btn:hover {
  border-color: #2196f3;
  background: #e3f2fd;
}

.staff-gojuon-btn:active {
  transform: scale(0.97);
  background: #bbdefb;
}

/* ============================================
   準備中オーバーレイ
   ============================================ */
.preparation-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(224, 208, 110, 0.3);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 999;
}

.preparation-overlay.active {
  display: flex;
}

.preparation-card {
  background: white;
  border-radius: 12px;
  padding: 40px;
  text-align: center;
  box-shadow: 0 16px 64px rgba(0, 0, 0, 0.2);
  position: relative;
  min-width: 400px;
}

.preparation-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: rgba(0, 0, 0, 0.05);
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 9999px;
  padding: 0 16px;
  height: 30px;
  font-size: 14px;
  font-weight: bold;
  color: #999;
  cursor: pointer;
  transition: all 0.2s;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.preparation-close:hover {
  color: #333;
  transform: scale(1.1);
}

.preparation-title {
  font-size: 24px;
  font-weight: 700;
  color: #f57c00;
  margin-bottom: 16px;
}

.preparation-timer {
  font-family: 'Courier New', monospace;
  font-size: 48px;
  font-weight: 700;
  color: #333;
  margin: 20px 0;
}

.preparation-info {
  color: #666;
  font-size: 14px;
  line-height: 1.5;
}

/* ============================================
   回数一覧ポップアップ
   ============================================ */
#chart-popup-modal {
  backdrop-filter: blur(8px);
  background: rgba(0, 0, 0, 0.4);
}

#chart-popup-modal .modal-content {
  width: 900px;
  max-width: 95vw;
  max-height: 90vh;
  overflow-y: auto;
  border-radius: 20px;
  border: none;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  padding: 0;
}

.chart-popup-header {
  padding: 20px 32px;
  background: #fff;
  border-bottom: 1px solid #f0f0f0;
  border-radius: 20px 20px 0 0;
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 12px;
}

.chart-popup-header-accent {
  width: 4px;
  height: 24px;
  background: #1976D2;
  border-radius: 2px;
}

.chart-popup-title {
  font-size: 20px;
  font-weight: 800;
  color: #1e293b;
  flex: 1;
}

.chart-popup-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
  gap: 24px;
  padding: 32px;
  background: #f8fafc;
}

.chart-popup-card {
  border: none;
  border-radius: 16px;
  padding: 24px;
  background: #fff;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  transition: transform 0.2s;
}

.chart-popup-card-title {
  margin-bottom: 20px;
  font-size: 15px;
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.chart-popup-container {
  position: relative;
  height: 220px;
  width: 100%;
}

.chart-popup-footer {
  padding: 16px;
  text-align: center;
  color: #94a3b8;
  font-size: 13px;
  background: #fff;
  border-top: 1px solid #f0f0f0;
  border-radius: 0 0 20px 20px;
}

/* ============================================
   1日の締めモーダル
   ============================================ */
#end-of-day-modal .modal-content {
  background: transparent;
  padding: 0;
  border: none;
  box-shadow: none;
  width: auto;
  max-width: none;
}

.eod-container {
  width: 750px;
  max-width: 95vw;
  border-radius: 16px;
  border: 1px solid #e5e7eb;
  background: #fff;
  box-shadow: 0 14px 40px rgba(2, 6, 23, 0.18);
  overflow: hidden;
}

.eod-header {
  padding: 10px 14px;
  background: linear-gradient(90deg, #fff, #eef2ff);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.eod-title {
  font-size: 18px;
  font-weight: 900;
}

.eod-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* 疲労度パネル */
.eod-pane {
  border-radius: 14px;
  padding: 0 12px 12px 12px;
  box-shadow: 0 14px 40px rgba(2, 6, 23, 0.18);
  background: #fff;
  position: relative;
}

.eod-pane-band {
  position: absolute;
  inset: 0 0 auto 0;
  height: 38px;
  border-radius: 14px 14px 0 0;
  opacity: 0.30;
}

.eod-pane-band.fatigue {
  background: linear-gradient(90deg, #ea580c, #fed7aa);
}

.eod-pane-band.delay {
  background: linear-gradient(90deg, #2563eb, #bfdbfe);
}

.eod-pane-title {
  margin: 0 0 10px;
  text-align: center;
  font-size: 16px;
  position: relative;
  z-index: 1;
  height: 38px;
  line-height: 38px;
  font-weight: 700;
}

.eod-pane-title.fatigue {
  color: #9a3412;
}

.eod-pane-title.delay {
  color: #1e40af;
}

/* 1-10 選択ボタングリッド */
.eod-choices {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 6px;
  position: relative;
  z-index: 1;
}

.eod-choice-btn {
  border: 1px solid rgba(0, 0, 0, 0.08);
  background: #fff;
  border-radius: 8px;
  padding: 8px 0;
  font-size: 17px;
  font-weight: 900;
  cursor: pointer;
  transition: 0.15s;
  text-align: center;
}

.eod-choice-btn:hover {
  background: #f3f4f6;
}

.eod-choice-btn.selected-fatigue {
  background: #ea580c;
  color: #fff;
  border-color: #ea580c;
}

.eod-choice-btn.selected-delay {
  background: #2563eb;
  color: #fff;
  border-color: #2563eb;
}

.eod-arrow-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 15px;
  color: #374151;
  margin-top: 6px;
  position: relative;
  z-index: 1;
}

.eod-arrow-row span {
  font-weight: 700;
}

.eod-arrow-line {
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, #9ca3af, #d1d5db);
  position: relative;
  margin: 0 8px;
}

/* ============================================
   チェアくんフィードバックモーダル
   ============================================ */
#chair-feedback-modal .modal-content {
  width: 800px;
  height: auto;
  max-width: 90vw;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 14px 40px rgba(2, 6, 23, 0.18);
  padding: 12px;
}

.chair-feedback-pane {
  position: relative;
  border-radius: 12px;
  padding: 12px 12px 10px;
  box-shadow: 0 8px 24px rgba(2, 6, 23, 0.12);
  background: #fff;
  border: 1px solid #e5e7eb;
}

.chair-feedback-band {
  position: absolute;
  inset: 0 0 auto 0;
  height: 36px;
  border-radius: 12px 12px 0 0;
  opacity: 0.30;
  background: linear-gradient(90deg, #2563eb, #bfdbfe);
}

.chair-feedback-title {
  margin: 0 0 8px;
  text-align: center;
  font-size: 18px;
  font-weight: 900;
  position: relative;
  z-index: 1;
  color: #1e40af;
  height: 36px;
  line-height: 36px;
}

.chair-feedback-message {
  margin-bottom: 12px;
  padding: 12px;
  background: #f8fafc;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
}

.chair-feedback-message-label {
  font-size: 17px;
  font-weight: 700;
  color: #1f2937;
  margin-bottom: 4px;
}

.chair-feedback-message-text {
  font-weight: 600;
  font-size: 16px;
  color: #374151;
  line-height: 1.5;
}

.chair-feedback-buttons {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 6px;
  position: relative;
  z-index: 1;
}

.chair-feedback-btn {
  border: 1px solid rgba(0, 0, 0, 0.08);
  background: #fff;
  border-radius: 8px;
  padding: 8px 0;
  font-size: 17px;
  font-weight: 900;
  cursor: pointer;
  transition: 0.15s;
  text-align: center;
}

.chair-feedback-btn:hover {
  background: #f3f4f6;
}

.chair-feedback-btn.selected {
  background: #2563eb;
  color: #fff;
  border-color: #2563eb;
}

/* ============================================
   チャート職種タブ
   ============================================ */
.chart-role-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
}

.chart-role-tab {
  padding: 4px 12px;
  border: 1px solid #e0e0e0;
  background: #fff;
  border-radius: 16px;
  font-size: 12px;
  font-weight: 600;
  color: #666;
  cursor: pointer;
  transition: all 0.15s;
}

.chart-role-tab:hover {
  border-color: #90caf9;
  color: #1976d2;
}

.chart-role-tab.active {
  background: #1976d2;
  border-color: #1976d2;
  color: #fff;
}

/* レスポンシブ */
@media (max-width: 768px) {
  .modal-content {
    padding: 20px;
    margin: 16px;
  }

  .eod-container {
    width: auto;
  }

  .eod-choices {
    grid-template-columns: repeat(5, 1fr);
  }

  .chart-popup-grid {
    grid-template-columns: 1fr;
    padding: 16px;
  }

  .preparation-card {
    min-width: auto;
    margin: 16px;
  }

  .staff-select-modal-content {
    margin: 8px;
    max-height: 85vh;
  }

  .staff-gojuon-items {
    grid-template-columns: repeat(3, 1fr);
  }

  .staff-role-tab {
    font-size: 13px;
    padding: 8px 0;
  }
}
