@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+JP:wght@400;500;700&display=swap');

:root {
  --bg: #f5f5f5;
  --surface: #ffffff;
  --text: #1a1a1a;
  --text-secondary: #666666;
  --border: #e0e0e0;
  --primary: #2563eb;
  --primary-light: #dbeafe;
  --success: #16a34a;
  --success-light: #dcfce7;
  --warning: #d97706;
  --warning-light: #fef3c7;
  --danger: #dc2626;
  --danger-light: #fee2e2;
  --info: #0891b2;
  --info-light: #cffafe;
  --before-checkout: #9ca3af;
  --before-checkout-bg: #f3f4f6;
  --uncleaned: #ef4444;
  --uncleaned-bg: #fef2f2;
  --cleaning: #f59e0b;
  --cleaning-bg: #fffbeb;
  --cleaned: #22c55e;
  --cleaned-bg: #f0fdf4;
  --reclean: #8b5cf6;
  --reclean-bg: #f5f3ff;
  --shadow: 0 1px 3px rgba(0,0,0,0.1);
  --shadow-lg: 0 4px 12px rgba(0,0,0,0.1);
  --radius: 12px;
  --radius-sm: 8px;
}

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

body {
  font-family: 'Noto Sans JP', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
}

.app-header {
  background: var(--primary);
  color: #fff;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

.app-header h1 {
  font-size: 16px;
  font-weight: 700;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 24px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  touch-action: manipulation;
}
.btn:active { transform: scale(0.97); }

.btn-primary { background: var(--primary); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 2px solid var(--primary);
}
.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  padding: 8px 12px;
}
.btn-lg {
  padding: 20px 32px;
  font-size: 22px;
  font-weight: 700;
  border-radius: var(--radius);
  width: 100%;
  min-height: 72px;
}
.btn-sm { padding: 8px 16px; font-size: 14px; }

/* 右下に固定表示の「担当者変更」が最後の行に重なるので、その分の余白を確保する */
.container { max-width: 800px; margin: 0 auto; padding: 16px 16px 76px; }
.container-wide { max-width: 1200px; margin: 0 auto; padding: 16px; }

/* Room Cards */
.room-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
@media (min-width: 600px) {
  .room-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 900px) {
  .room-grid { grid-template-columns: repeat(5, 1fr); }
}

.room-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  text-align: center;
  cursor: pointer;
  transition: box-shadow 0.15s, transform 0.1s;
  border-left: 5px solid transparent;
  position: relative;
}
.room-card:active { transform: scale(0.97); }
.room-card.disabled { opacity: 0.5; cursor: default; pointer-events: none; }
/* 退室待ち: 押せるが「今の作業対象ではない」ことが分かる程度に控えめにする */
.room-card.awaiting { opacity: 0.8; }
.room-card.awaiting::after {
  content: 'タップで退室';
  display: block;
  margin-top: 6px;
  font-size: 11px;
  color: var(--text-secondary);
}

.room-card[data-status="before_checkout"] { border-left-color: var(--before-checkout); background: var(--before-checkout-bg); }
.room-card[data-status="uncleaned"] { border-left-color: var(--uncleaned); background: var(--uncleaned-bg); }
.room-card[data-status="cleaning"] { border-left-color: var(--cleaning); background: var(--cleaning-bg); }
.room-card[data-status="cleaned"] { border-left-color: var(--cleaned); background: var(--cleaned-bg); }
.room-card[data-status="reclean"] { border-left-color: var(--reclean); background: var(--reclean-bg); }

.room-number {
  font-size: 32px;
  font-weight: 700;
  line-height: 1.2;
}
.room-status {
  font-size: 14px;
  font-weight: 500;
  margin-top: 4px;
}
.room-meta {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
}
.room-priority {
  position: absolute;
  top: 8px;
  right: 8px;
  font-size: 11px;
  background: var(--warning);
  color: #fff;
  padding: 2px 6px;
  border-radius: 4px;
}

/* Cleaner Selection */
.cleaner-select {
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: center;
  justify-content: center;
  min-height: 60dvh;
  padding: 32px 16px;
}
.cleaner-select h2 {
  font-size: 24px;
  font-weight: 700;
  text-align: center;
}
.cleaner-buttons {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
  max-width: 400px;
}
.cleaner-btn {
  padding: 32px;
  font-size: 28px;
  font-weight: 700;
  border-radius: var(--radius);
  min-height: 100px;
}

/* Cleaning In-Progress */
.cleaning-active {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 70dvh;
  padding: 32px 16px;
  text-align: center;
}
.cleaning-active .room-label {
  font-size: 20px;
  color: var(--text-secondary);
}
.cleaning-active .room-big {
  font-size: 64px;
  font-weight: 700;
}
.cleaning-active .timer {
  font-size: 48px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--warning);
  margin: 24px 0;
}
.cleaning-active .finish-btn {
  margin-top: 24px;
}

/* Confirmation Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 16px;
}
.modal {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 32px 24px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
  text-align: center;
}
.modal h3 {
  font-size: 24px;
  margin-bottom: 8px;
}
.modal p {
  color: var(--text-secondary);
  margin-bottom: 24px;
}
.modal-actions {
  display: flex;
  gap: 12px;
}
.modal-actions .btn { flex: 1; }

/* Status Badge */
.status-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
}
.status-badge.before_checkout { background: var(--before-checkout-bg); color: var(--before-checkout); border: 1px solid var(--before-checkout); }
.status-badge.uncleaned { background: var(--uncleaned-bg); color: var(--uncleaned); border: 1px solid var(--uncleaned); }
.status-badge.cleaning { background: var(--cleaning-bg); color: var(--cleaning); border: 1px solid var(--cleaning); }
.status-badge.cleaned { background: var(--cleaned-bg); color: var(--cleaned); border: 1px solid var(--cleaned); }
.status-badge.reclean { background: var(--reclean-bg); color: var(--reclean); border: 1px solid var(--reclean); }

/* Admin Dashboard */
.stat-cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}
@media (min-width: 768px) {
  .stat-cards { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 1024px) {
  .stat-cards { grid-template-columns: repeat(4, 1fr); }
}

.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}
.stat-card .label {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}
.stat-card .value {
  font-size: 28px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.stat-card .unit {
  font-size: 14px;
  color: var(--text-secondary);
}
.stat-card.highlight {
  border: 2px solid var(--primary);
}
.stat-card.savings {
  background: var(--success-light);
  border: 1px solid var(--success);
}
.stat-card.savings .value { color: var(--success); }

/* Section */
.section {
  margin-bottom: 24px;
}
.section-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--border);
}

/* Tables */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
th, td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  white-space: nowrap;
}
th {
  background: var(--bg);
  font-weight: 500;
  color: var(--text-secondary);
  font-size: 12px;
}

/* Issue Report Form */
.issue-form {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.form-group {
  margin-bottom: 16px;
}
.form-group label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 6px;
}
.form-group select,
.form-group input,
.form-group textarea {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 16px;
}
.form-group textarea { resize: vertical; min-height: 80px; }

/* Tabs */
.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.tab {
  padding: 8px 16px;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}
.tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* Anomaly */
.anomaly-card {
  background: var(--warning-light);
  border: 1px solid var(--warning);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-bottom: 8px;
  font-size: 13px;
}
.anomaly-card .anomaly-label {
  font-weight: 700;
  color: var(--warning);
  margin-bottom: 4px;
}

/* Period Selector */
.period-selector {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
}
.period-btn {
  padding: 6px 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 20px;
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
}
.period-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* Admin Nav */
.admin-nav {
  display: flex;
  gap: 4px;
  padding: 8px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.admin-nav a {
  padding: 8px 14px;
  text-decoration: none;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  white-space: nowrap;
}
.admin-nav a.active {
  background: var(--primary-light);
  color: var(--primary);
}

/* Login */
.login-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 16px;
}
.login-box {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 40px 32px;
  width: 100%;
  max-width: 400px;
}
.login-box h2 {
  text-align: center;
  margin-bottom: 24px;
}
.login-box .form-group { margin-bottom: 20px; }
.login-error {
  color: var(--danger);
  font-size: 14px;
  text-align: center;
  margin-bottom: 12px;
  min-height: 20px;
}

/* Change cleaner btn */
.change-cleaner {
  position: fixed;
  bottom: 16px;
  right: 16px;
  z-index: 50;
  /* 画面に浮いているので、下の部屋カードに文字が重なって読めなくならないよう
     背景と影を持たせて「浮いているボタン」だと分かる形にする */
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: var(--shadow-lg);
}

/* Toast */
.toast {
  position: fixed;
  top: 60px;
  left: 50%;
  transform: translateX(-50%);
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  color: #fff;
  font-weight: 500;
  z-index: 300;
  animation: toast-in 0.3s ease;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
@keyframes toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(-10px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* Two-person checkbox */
.two-person-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  font-size: 15px;
}
.two-person-toggle input[type="checkbox"] {
  width: 20px;
  height: 20px;
}

/* Hide on print etc */
@media print { .app-header, .change-cleaner { display: none; } }

/* Loading spinner */
.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 20px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }


/* ── 体験ツアー ───────────────────────────────── */
.tour-start {
  position: fixed;
  bottom: 16px;
  left: 16px;
  z-index: 50;
  padding: 8px 14px;
  font-size: 14px;
  font-family: inherit;
  color: var(--primary);
  background: var(--surface);
  border: 1px solid var(--primary);
  border-radius: 999px;
  box-shadow: var(--shadow-lg);
  cursor: pointer;
}
/* ツアー中は開始ボタンを隠す(終了は上部バーから) */
body.tour-on .tour-start { display: none; }

.tour-bar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 200;
  background: var(--primary);
  color: #fff;
  box-shadow: var(--shadow-lg);
}
.tour-bar-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  max-width: 800px;
  margin: 0 auto;
}
.tour-badge {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(255,255,255,0.22);
}
.tour-text { flex: 1; min-width: 0; }
.tour-title { font-size: 13px; font-weight: 700; }
.tour-desc { font-size: 13px; line-height: 1.5; opacity: 0.95; }
.tour-desc strong { text-decoration: underline; }
.tour-close {
  flex-shrink: 0;
  font-family: inherit;
  font-size: 13px;
  color: #fff;
  background: rgba(255,255,255,0.18);
  border: 1px solid rgba(255,255,255,0.5);
  border-radius: 999px;
  padding: 6px 12px;
  cursor: pointer;
}
/* 案内バーの高さは文言の長さで変わるので、実測値(--tour-bar-h)で押し下げる。
   ヘッダーは position:sticky なので、margin ではなく top をずらす必要がある。 */
body.tour-on { padding-top: var(--tour-bar-h, 74px); }
body.tour-on .app-header { top: var(--tour-bar-h, 74px); }
/* トーストも案内バーの下に出す(既定の top:60px だとバーに重なる) */
body.tour-on .toast { top: calc(var(--tour-bar-h, 74px) + 60px); }
