/* public/progress-mobile.css
 * 進度總覽 mobile-first 建築立面設計的樣式
 * 所有 class 都用 .mp- 前綴避免跟 style.css 衝突（.btn / .chip / .modal 等）
 * 顏色變數跟 style.css 共用（透過 :root 繼承）
 */

.mp-root {
  /* local overrides */
  --c-bldg-a: #3b82f6;
  --c-bldg-b: #a855f7;

  /* CSS variables used by .mp-* selectors.
   * 命名跟 style.css 不同（--bg-card vs --bg-2），所以在這裡重新定義避免破壞其他 tab。
   * 對應 style.css 同色系：--bg-2 / --surface-2 / --surface-3 / --text / --text-muted / --text-subtle / --success / --warning / --danger */
  --bg-card:   #141414;  /* card bg (與 page bg --bg #0D0D0D 區隔) */
  --bg-card-2: #1A1A1A;  /* hover / 較淺的 card */
  --bg-card-3: #272727;  /* active pressed state */
  --fg:        #FFFFFF;  /* 主要文字 */
  --fg-mute:   #B3B3B3;  /* 次要文字 */
  --fg-dim:    #6B6B6B;  /* 提示 / label */
  --c-done:    #1EFE9D;  /* 已完成 = 綠 */
  --c-mid:     #ECD60E;  /* 進行中 = 黃 */
  --c-todo:    #F0989E;  /* 未開始 = 紅 */
  --c-none:    #6B6B6B;  /* 無施作 = 中性灰 */
}

/* === Filter labels === */
.mp-filters-label {
  font-size: 11px;
  color: var(--fg-dim);
  margin: 8px 0 4px;
  font-weight: 500;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.mp-filters {
  display: flex;
  flex-wrap: wrap;       /* 工項要在手機全部顯示，不要水平捲動藏起來 */
  gap: 6px;
  margin-bottom: 10px;
}

.mp-chip {
  flex: 0 0 auto;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--fg-mute);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  min-height: 36px;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.mp-chip:active { transform: scale(0.96); }
.mp-chip.active { background: var(--fg); color: var(--bg); border-color: var(--fg); }

/* === Work-type summary card === */
#mp-wt-summary {
  background: var(--bg-card);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 14px;
  border: 1px solid var(--border);
}
.mp-summary-title {
  font-size: 12px;
  color: var(--fg-mute);
  margin-bottom: 8px;
  font-weight: 500;
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.mp-summary-title strong { color: var(--fg); font-size: 14px; font-weight: 600; }
.mp-summary-pct {
  margin-left: auto;
  font-size: 18px;
  font-weight: 700;
  color: var(--c-done);
  font-variant-numeric: tabular-nums;
}
.mp-summary-bar {
  display: flex;
  height: 10px;
  border-radius: 5px;
  overflow: hidden;
  background: var(--bg-card-2);
  margin-bottom: 10px;
}
.mp-seg { height: 100%; transition: flex-grow 0.3s ease; }
.mp-seg.done { background: var(--c-done); }
.mp-seg.mid { background: var(--c-mid); }
.mp-seg.todo { background: var(--c-todo); }
.mp-seg.none { background: var(--c-none); }
.mp-seg.partial { background: linear-gradient(135deg, var(--c-done) 50%, var(--c-todo) 50%); }
.mp-summary-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  font-size: 12px;
}
.mp-stat { display: flex; align-items: center; gap: 5px; }
.mp-stat-dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; }
.mp-stat-label { color: var(--fg-mute); }
.mp-stat-value { color: var(--fg); font-weight: 600; font-variant-numeric: tabular-nums; }

/* === Legend === */
.mp-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-card);
  border-radius: 6px;
  margin-bottom: 14px;
  font-size: 12px;
  color: var(--fg-mute);
}
.mp-legend-item { display: flex; align-items: center; gap: 6px; }
.mp-legend-swatch {
  width: 14px; height: 14px; border-radius: 3px;
  border: 1px solid var(--border);
}

/* === Building facade === */
.mp-building {
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--bg-card);
  padding: 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.mp-unit-header {
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 8px;
  padding: 0 0 8px;
  position: sticky;
  top: 0;
  background: var(--bg-card);
  z-index: 10;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}
.mp-unit-header-letters {
  display: grid;
  grid-template-columns: repeat(13, 1fr);
  gap: 3px;
}
.mp-unit-letter {
  height: 24px;
  min-height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  border-radius: 4px;
  border: 1.5px solid transparent;
  font-variant-numeric: tabular-nums;
}
.mp-unit-letter.building-a { background: rgba(59, 130, 246, 0.22); color: #93c5fd; border-color: rgba(59, 130, 246, 0.4); }
.mp-unit-letter.building-b { background: rgba(168, 85, 247, 0.22); color: #d8b4fe; border-color: rgba(168, 85, 247, 0.4); }

/* === Floor rows === */
.mp-floor {
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 8px;
  align-items: stretch;
  padding: 4px 0;
  border-bottom: 1px solid var(--border);
}
.mp-floor:last-of-type { border-bottom: 0; }

.mp-floor-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--fg-mute);
  text-align: center;
  font-variant-numeric: tabular-nums;
  padding: 4px 2px;
  background: var(--bg-card-2);
  border-radius: 4px;
  min-height: 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1.15;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s ease;
  user-select: none;
}
.mp-floor-label:active { background: var(--bg-card-3); }
.mp-floor-label.roof { color: var(--accent); }
.mp-floor-label::after {
  content: '✎';
  font-size: 9px;
  color: var(--fg-dim);
  margin-top: 1px;
}

.mp-floor-windows {
  display: grid;
  grid-template-columns: repeat(13, 1fr);
  gap: 3px;
}

.mp-win {
  height: 24px;
  min-height: 24px;
  border-radius: 4px;
  border: 1.5px solid transparent;
  cursor: pointer;
  transition: transform 0.1s ease;
  -webkit-tap-highlight-color: transparent;
}
.mp-win:active { transform: scale(0.92); }
.mp-win.todo { background: var(--c-todo); }
.mp-win.mid { background: var(--c-mid); }
.mp-win.done { background: var(--c-done); }
.mp-win.none { background: var(--c-none); border-color: var(--border); }
.mp-win.partial { background: linear-gradient(135deg, var(--c-done) 50%, var(--c-todo) 50%); }

.mp-floor-summary {
  font-size: 9px;
  color: var(--fg-dim);
  margin-top: 1px;
  font-variant-numeric: tabular-nums;
}

/* === Modal === */
.mp-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(2px);
  z-index: 100;
  display: none;
  align-items: flex-end;
  justify-content: center;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  animation: mpFadeIn 0.18s ease;
}
.mp-modal-backdrop.open { display: flex; }
@keyframes mpFadeIn { from { opacity: 0; } to { opacity: 1; } }

.mp-modal {
  background: var(--bg);
  border-top-left-radius: 16px;
  border-top-right-radius: 16px;
  width: 100%;
  max-width: 480px;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-bottom: 0;
  overflow: hidden;
  animation: mpSlideUp 0.22s ease;
}
@keyframes mpSlideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }

.mp-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}
.mp-modal-title { font-size: 16px; font-weight: 600; letter-spacing: 0.3px; }
.mp-modal-title small { color: var(--fg-mute); font-weight: 500; font-size: 12px; margin-left: 6px; }
.mp-modal-close {
  background: transparent;
  border: 0;
  color: var(--fg-mute);
  font-size: 22px;
  line-height: 1;
  padding: 4px 8px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.mp-modal-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 12px 16px;
  -webkit-overflow-scrolling: touch;
}

.mp-modal-foot {
  flex: 0 0 auto;
  display: flex;
  gap: 8px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  background: var(--bg);
}
.mp-modal-foot .mp-btn { flex: 1; }

/* === Buttons === */
.mp-btn {
  padding: 12px 18px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--fg);
  cursor: pointer;
  transition: all 0.15s ease;
  min-height: 44px;
  -webkit-tap-highlight-color: transparent;
}
.mp-btn:active { transform: scale(0.98); }
.mp-btn.primary { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.mp-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.mp-btn:disabled:active { transform: none; }

/* === Pending indicator === */
.mp-pending-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: 8px;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(234, 179, 8, 0.15);
  color: var(--c-mid);
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.mp-pending-badge::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--c-mid);
  animation: mpPulse 1.5s ease-in-out infinite;
}
@keyframes mpPulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }
.mp-pending-badge.zero { background: rgba(107, 114, 128, 0.15); color: var(--fg-dim); }
.mp-pending-badge.zero::before { background: var(--fg-dim); animation: none; }

/* === Unit edit form === */
.mp-edit-row {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 10px;
}
.mp-edit-row-name {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 10px;
  color: var(--fg);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.mp-edit-row-name small { color: var(--fg-dim); font-size: 11px; font-weight: 500; }
.mp-edit-row-controls {
  display: grid;
  grid-template-columns: 1fr 90px;
  gap: 10px;
  align-items: center;
}
.mp-status-select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 6px;
  background: var(--bg-card-2);
  border: 1px solid var(--border);
  color: var(--fg);
  font-size: 14px;
  font-family: inherit;
  appearance: none;
  cursor: pointer;
}
.mp-progress-input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 6px;
  background: var(--bg-card-2);
  border: 1px solid var(--border);
  color: var(--fg);
  font-size: 14px;
  font-family: inherit;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* === Floor bulk edit === */
.mp-floor-bulk-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.mp-bulk-btn {
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--fg-mute);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.mp-bulk-btn:active { transform: scale(0.97); }
.mp-bulk-btn.done { color: var(--c-done); border-color: rgba(22, 163, 74, 0.4); }
.mp-bulk-btn.todo { color: var(--c-todo); border-color: rgba(107, 114, 128, 0.4); }
.mp-bulk-btn.reset { color: #fca5a5; border-color: rgba(239, 68, 68, 0.3); }

.mp-floor-edit-list { display: flex; flex-direction: column; gap: 6px; }
.mp-floor-edit-unit {
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 10px;
  align-items: center;
  padding: 8px 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
}
.mp-floor-edit-unit-name {
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.mp-floor-edit-pills { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 4px; }
.mp-pill {
  padding: 8px 4px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  border: 1.5px solid transparent;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  transition: all 0.12s ease;
  line-height: 1.1;
}
.mp-pill:active { transform: scale(0.94); }
.mp-pill.done { background: rgba(22, 163, 74, 0.18); color: var(--c-done); border-color: rgba(22, 163, 74, 0.5); }
.mp-pill.mid { background: rgba(234, 179, 8, 0.18); color: var(--c-mid); border-color: rgba(234, 179, 8, 0.5); }
.mp-pill.todo { background: rgba(107, 114, 128, 0.18); color: var(--c-todo); border-color: rgba(107, 114, 128, 0.4); }
.mp-pill.none { background: rgba(245, 245, 245, 0.06); color: var(--fg-mute); border-color: var(--border); }
.mp-pill-name {
  display: block;
  font-size: 9px;
  color: var(--fg-dim);
  margin-bottom: 2px;
  font-weight: 500;
}

/* === State === */
.mp-state { text-align: center; padding: 60px 20px; color: var(--fg-mute); font-size: 14px; }
.mp-state.error { color: #ef4444; }

/* === Footer === */
.mp-footer {
  margin-top: 18px;
  text-align: center;
  font-size: 11px;
  color: var(--fg-dim);
  font-family: ui-monospace, monospace;
  line-height: 1.6;
}
