/* =====================================================
   清掃管理アプリ - スタイル
   ===================================================== */

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #dbeafe;
  --success: #16a34a;
  --success-light: #dcfce7;
  --warning: #d97706;
  --warning-light: #fef3c7;
  --danger: #dc2626;
  --danger-light: #fee2e2;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  --white: #ffffff;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.1), 0 2px 4px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
}

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

html, body {
  font-family: 'Noto Sans JP', sans-serif;
  background: var(--gray-50);
  color: var(--gray-800);
  font-size: 14px;
  min-height: 100vh;
}

/* =====================================================
   ヘッダー・ナビ
   ===================================================== */
#header-bar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--primary);
  color: var(--white);
  display: none;
  flex-direction: column;
  box-shadow: var(--shadow-md);
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
}

.header-logo {
  font-size: 16px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-logo i { font-size: 20px; }

.header-user {
  font-size: 12px;
  opacity: 0.9;
  flex: 1;
  text-align: center;
}

.header-logout {
  background: rgba(255,255,255,0.2);
  border: none;
  color: white;
  padding: 6px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.header-logout:hover { background: rgba(255,255,255,0.3); }

#main-nav {
  display: flex;
  overflow-x: auto;
  padding: 0 8px 8px;
  gap: 4px;
  scrollbar-width: none;
}
#main-nav::-webkit-scrollbar { display: none; }

.nav-btn {
  background: rgba(255,255,255,0.15);
  border: none;
  color: white;
  padding: 8px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 12px;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: background 0.2s;
}
.nav-btn:hover, .nav-btn.active { background: rgba(255,255,255,0.3); }

/* =====================================================
   ページ管理
   ===================================================== */
.page { display: none; padding: 16px; max-width: 900px; margin: 0 auto; }
.page.active { display: block; }

/* =====================================================
   ログインページ
   ===================================================== */
#page-login {
  display: none;
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1e40af 0%, #3b82f6 50%, #60a5fa 100%);
}
#page-login.active {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 40px 20px 40px;
  overflow-y: auto;
  min-height: 100vh;
}

.login-card {
  background: white;
  border-radius: var(--radius-lg);
  padding: 24px 24px 28px;
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 380px;
}

.login-logo {
  text-align: center;
  margin-bottom: 20px;
}
.login-logo i {
  font-size: 40px;
  color: var(--primary);
  display: block;
  margin-bottom: 8px;
}
.login-logo h1 {
  font-size: 20px;
  font-weight: 700;
  color: var(--gray-800);
}
.login-logo p {
  font-size: 12px;
  color: var(--gray-500);
  margin-top: 2px;
}

.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 6px;
}
.form-control {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius);
  font-size: 15px;
  font-family: inherit;
  background: var(--white);
  transition: border-color 0.2s;
  outline: none;
}
.form-control:focus { border-color: var(--primary); }

.login-error {
  color: var(--danger);
  font-size: 13px;
  text-align: center;
  margin-bottom: 12px;
  min-height: 18px;
}

/* =====================================================
   ボタン
   ===================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #15803d; }
.btn-secondary { background: var(--gray-100); color: var(--gray-700); border: 1px solid var(--gray-200); }
.btn-secondary:hover { background: var(--gray-200); }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #b91c1c; }
.btn-outline { background: transparent; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-outline:hover { background: var(--primary-light); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-full { width: 100%; justify-content: center; }
.btn-lg { padding: 14px 24px; font-size: 16px; }
.btn-icon { padding: 8px; width: 36px; height: 36px; justify-content: center; }

/* =====================================================
   カード・セクション
   ===================================================== */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 8px;
}
.section-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--gray-800);
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-title i { color: var(--primary); }

.card {
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 16px;
}

/* =====================================================
   テーブル
   ===================================================== */
.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
th {
  background: var(--gray-50);
  color: var(--gray-600);
  font-weight: 600;
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--gray-200);
  white-space: nowrap;
}
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--gray-100);
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--gray-50); }

/* =====================================================
   バッジ
   ===================================================== */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
}
.badge-scheduled { background: var(--primary-light); color: var(--primary); }
.badge-inprogress { background: var(--warning-light); color: var(--warning); }
.badge-completed { background: var(--success-light); color: var(--success); }
.badge-cancelled { background: var(--gray-100); color: var(--gray-500); }
.badge-role-master { background: #fce7f3; color: #be185d; }
.badge-role-admin { background: #ede9fe; color: #7c3aed; }
.badge-role-staff { background: var(--primary-light); color: var(--primary); }

/* =====================================================
   カレンダー
   ===================================================== */
.cal-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.cal-nav-title {
  font-size: 18px;
  font-weight: 700;
}
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  background: var(--gray-200);
  border-radius: var(--radius);
  overflow: hidden;
}
.cal-header-cell {
  background: var(--gray-700);
  color: white;
  text-align: center;
  padding: 8px 2px;
  font-size: 12px;
  font-weight: 600;
}
.cal-header-cell:first-child { color: #fca5a5; }
.cal-header-cell:last-child { color: #93c5fd; }

.cal-cell {
  background: white;
  min-height: 80px;
  padding: 4px;
  position: relative;
  cursor: default;
}
.cal-cell.cal-blank { background: var(--gray-50); }
.cal-cell.cal-today { background: #eff6ff; }
.cal-cell.cal-sun .cal-date { color: var(--danger); }
.cal-cell.cal-sat .cal-date { color: var(--primary); }

.cal-date {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 2px;
  text-align: right;
  padding-right: 2px;
}
.cal-today .cal-date {
  background: var(--primary);
  color: white;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: auto;
  font-size: 11px;
}

.cal-events { display: flex; flex-direction: column; gap: 2px; }
.cal-event {
  font-size: 10px;
  padding: 2px 4px;
  border-radius: 3px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 500;
}
.cal-event.scheduled { background: var(--primary-light); color: var(--primary); }
.cal-event.in_progress { background: var(--warning-light); color: var(--warning); }
.cal-event.completed { background: var(--success-light); color: var(--success); }
.cal-event-more { font-size: 10px; color: var(--gray-500); cursor: pointer; padding: 1px 4px; }

.cal-add-btn {
  position: absolute;
  bottom: 3px;
  right: 3px;
  background: var(--primary);
  color: white;
  border: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  font-size: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s;
}
.cal-cell:hover .cal-add-btn { opacity: 1; }

/* =====================================================
   作業カード（スタッフ）
   ===================================================== */
.work-card {
  background: white;
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 12px;
  border-left: 4px solid var(--gray-200);
}
.work-card:has(.badge-scheduled) { border-left-color: var(--primary); }
.work-card:has(.badge-inprogress) { border-left-color: var(--warning); }
.work-card:has(.badge-completed) { border-left-color: var(--success); }

.work-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.work-card-location {
  font-size: 16px;
  font-weight: 700;
  color: var(--gray-800);
}
.work-card-info {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  color: var(--gray-600);
  font-size: 13px;
  margin-bottom: 8px;
}
.work-card-info i { color: var(--primary); }
.work-stamp {
  background: var(--gray-50);
  border-radius: var(--radius);
  padding: 6px 10px;
  font-size: 13px;
  margin-bottom: 6px;
  color: var(--gray-700);
}
.work-note {
  font-size: 12px;
  color: var(--gray-600);
  background: #fffbeb;
  padding: 6px 10px;
  border-radius: var(--radius);
  margin-bottom: 8px;
}
.work-card-actions { margin-top: 10px; }
.work-completed-msg {
  text-align: center;
  color: var(--success);
  font-weight: 600;
  padding: 10px;
  background: var(--success-light);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

/* =====================================================
   集計ページ
   ===================================================== */
.report-filter {
  background: white;
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
}
.report-filter .form-group { margin: 0; flex: 1; min-width: 140px; }

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}
.summary-card {
  background: white;
  border-radius: var(--radius-lg);
  padding: 14px 10px;
  text-align: center;
  box-shadow: var(--shadow);
  border-top: 3px solid var(--gray-200);
}
.summary-card.completed { border-top-color: var(--success); }
.summary-card.inprogress { border-top-color: var(--warning); }
.summary-card.scheduled { border-top-color: var(--primary); }
.summary-num {
  font-size: 24px;
  font-weight: 800;
  color: var(--gray-800);
}
.summary-label {
  font-size: 11px;
  color: var(--gray-500);
  margin-top: 2px;
}

/* =====================================================
   モーダル
   ===================================================== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  align-items: flex-end;
  justify-content: center;
}
.modal-overlay.active {
  display: flex;
  animation: fadeIn 0.2s ease;
}

.modal-sheet {
  background: white;
  border-radius: 16px 16px 0 0;
  padding: 24px 20px 32px;
  width: 100%;
  max-width: 600px;
  max-height: 92vh;
  overflow-y: auto;
  animation: slideUp 0.25s ease;
}
.modal-handle {
  width: 36px;
  height: 4px;
  background: var(--gray-300);
  border-radius: 2px;
  margin: -12px auto 20px;
}
.modal-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 20px;
  color: var(--gray-800);
  display: flex;
  align-items: center;
  gap: 8px;
}
.modal-title i { color: var(--primary); }

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}
.modal-actions .btn { flex: 1; justify-content: center; }

/* =====================================================
   日付別詳細
   ===================================================== */
.day-detail-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid var(--gray-100);
}
.day-detail-item:last-child { border-bottom: none; }
.day-detail-info { flex: 1; }
.day-detail-location { font-size: 15px; font-weight: 700; margin-bottom: 4px; }
.day-detail-staff { font-size: 13px; color: var(--gray-600); margin-bottom: 2px; }
.day-detail-time { font-size: 12px; color: var(--gray-500); margin-bottom: 4px; }
.day-detail-actions { display: flex; gap: 6px; }

/* =====================================================
   トースト
   ===================================================== */
.toast {
  position: fixed;
  bottom: -80px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--gray-800);
  color: white;
  padding: 12px 24px;
  border-radius: 99px;
  font-size: 14px;
  font-weight: 500;
  z-index: 999;
  transition: bottom 0.3s ease;
  white-space: nowrap;
  box-shadow: var(--shadow-lg);
}
.toast.show { bottom: 32px; }
.toast.toast-error { background: var(--danger); }
.toast.toast-success { background: var(--success); }

/* =====================================================
   空の状態
   ===================================================== */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--gray-400);
}
.empty-state i { font-size: 48px; margin-bottom: 12px; display: block; }
.empty-state p { font-size: 15px; }

/* =====================================================
   アニメーション
   ===================================================== */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes slideUp {
  from { transform: translateY(60px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* =====================================================
   ユーティリティ
   ===================================================== */
.text-muted { color: var(--gray-500); }
.text-center { text-align: center; }
.text-sm { font-size: 12px; color: var(--gray-500); margin-top: 2px; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mb-2 { margin-bottom: 8px; }
.gap-2 { gap: 8px; }
.d-flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }

.select-control {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: inherit;
  background: white;
  outline: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}
.select-control:focus { border-color: var(--primary); }

textarea.form-control { resize: vertical; min-height: 80px; }

.std-minutes-hint {
  font-size: 12px;
  color: var(--primary);
  margin-top: 4px;
  font-weight: 600;
}

/* =====================================================
   レスポンシブ
   ===================================================== */
@media (min-width: 600px) {
  .cal-cell { min-height: 100px; }
  .cal-event { font-size: 11px; }
  .summary-grid { grid-template-columns: repeat(6, 1fr); }
}

@media (max-width: 480px) {
  .cal-grid { gap: 1px; }
  .cal-cell { min-height: 64px; padding: 2px; }
  .cal-header-cell { padding: 6px 1px; font-size: 11px; }
  .table-wrap { font-size: 12px; }
  th, td { padding: 8px 8px; }
}

/* =====================================================
   スクロールバー
   ===================================================== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--gray-100); }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 3px; }

/* =====================================================
   日付表示
   ===================================================== */
.today-date-label {
  font-size: 15px;
  font-weight: 700;
  color: var(--gray-700);
  margin-bottom: 16px;
  padding: 10px 14px;
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 8px;
}
.today-date-label i { color: var(--primary); }
