/* ===== Reset & Base ===== */
* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  overflow-x: hidden;
  width: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Microsoft JhengHei', 'Segoe UI', sans-serif;
  background: #f5f5f7;
  color: #1d1d1f;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ===== Header ===== */
header {
  background: rgba(255, 245, 248, 0.85);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  position: sticky;
  top: 0;
  z-index: 100;
  padding: 0 20px;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  max-width: 1200px;
  margin: 0 auto;
}

header h1 {
  font-size: 24px;
  color: #e8456a;
  letter-spacing: 0.5px;
  font-weight: 700;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 1;
  min-width: 0;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.points-badge {
  background: linear-gradient(135deg, #fff0f3, #ffe4ea);
  color: #d63a5e;
  padding: 6px 18px;
  border-radius: 20px;
  font-size: 16px;
  font-weight: 700;
  position: relative;
}

.points-float {
  position: absolute;
  left: 50%;
  top: 0;
  transform: translateX(-50%);
  font-size: 24px;
  font-weight: 800;
  pointer-events: none;
  animation: points-fly 1.2s ease-out forwards;
  white-space: nowrap;
}

.points-float.positive { color: #e8456a; }
.points-float.negative { color: #e8456a; }

@keyframes points-fly {
  0% { opacity: 1; top: 0; }
  70% { opacity: 1; }
  100% { opacity: 0; top: -50px; }
}

.header-btn {
  background: rgba(0, 0, 0, 0.04);
  color: #86868b;
  border: none;
  padding: 8px 18px;
  border-radius: 20px;
  font-size: 16px;
  cursor: pointer;
  font-family: inherit;
  font-weight: 500;
  transition: all 0.2s;
}

.header-btn:hover {
  background: rgba(0, 0, 0, 0.08);
  color: #1d1d1f;
}

.header-btn.active {
  background: #e8456a;
  color: #fff;
}

/* ===== Status Bar ===== */
.status-bar {
  background: transparent;
  padding: 22px 20px;
  text-align: center;
}

@media (min-width: 768px) {
  .status-bar {
    max-width: 1200px;
    margin: 0 auto;
  }
}

.status-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  min-height: 100%;
}

.status-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.verify-btn {
  background: rgba(232, 69, 106, 0.08);
  color: #e8456a;
  border: 1px solid rgba(232, 69, 106, 0.2);
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s;
  white-space: nowrap;
  flex-shrink: 0;
}

.verify-btn:hover {
  background: rgba(232, 69, 106, 0.15);
  border-color: #e8456a;
}

.verify-modal-content {
  text-align: center;
}

.verify-modal-content h2 {
  margin-bottom: 8px;
}

.verify-location {
  font-size: 18px;
  font-weight: 700;
  color: #e8456a;
  margin-bottom: 24px;
}

.verify-actions {
  display: flex;
  gap: 12px;
}

.verify-action-btn {
  flex: 1;
  padding: 16px;
  border: none;
  border-radius: 12px;
  font-size: 20px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s;
}

.verify-yes {
  background: #e8456a;
  color: #fff;
}

.verify-yes:hover {
  background: #d63a5e;
  box-shadow: 0 2px 8px rgba(232, 69, 106, 0.3);
}

.verify-no {
  background: #f5f5f7;
  color: #6e6e73;
}

.verify-no:hover {
  background: #eeeef0;
}

.status-icon { display: none; }

#statusText {
  font-size: 22px;
  font-weight: 700;
  color: #1d1d1f;
  letter-spacing: -0.3px;
}

.status-meta {
  font-size: 13px;
  color: #86868b;
  margin-top: 2px;
}

.status-stale {
  color: #ff9500 !important;
}

/* ===== Main Layout ===== */
#mainContent {
  display: flex;
  flex-direction: column;
}

.main-left {
  flex: 1;
  min-width: 0;
}

.main-right {
  display: none;
}

@media (min-width: 768px) {
  #mainContent {
    flex-direction: row;
    justify-content: center;
    align-items: stretch;
    max-width: 1200px;
    margin: 0 auto;
    gap: 16px;
    padding: 0 20px;
  }
  .main-left {
    flex: 1;
    min-width: 0;
  }
  .main-right {
    display: flex;
    flex: 1;
    min-width: 0;
    padding: 16px 0;
  }
  .building-3d-container {
    width: 100%;
    flex: 1;
    min-height: 450px;
    border-radius: 12px;
    overflow: hidden;
    background: #d4e8f5;
    border: 2px solid rgba(232, 69, 106, 0.25);
  }
  .building-3d-container canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
  }
}

/* ===== Floor Map ===== */
.floor-map-container {
  padding: 16px 20px;
}

.floor-map {
  display: flex;
  flex-direction: column;
  gap: 5px;
  max-width: 600px;
  margin: 0 auto;
}

.floor-row {
  display: flex;
  align-items: center;
  gap: 5px;
}

.floor-label {
  width: 44px;
  text-align: right;
  font-size: 15px;
  font-weight: 700;
  color: #6e6e73;
  padding-right: 8px;
  flex-shrink: 0;
  white-space: nowrap;
}

.floor-divider {
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  margin: 5px 0;
}

.floor-cells {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
  flex: 1;
}

.cell {
  height: 48px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 2px solid transparent;
  position: relative;
  overflow: hidden;
}

.cell.active {
  background: #fff;
  color: #3a3a3c;
  border-color: rgba(0, 0, 0, 0.1);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

@media (hover: hover) {
  .cell.active:hover {
    background: #fff;
    border-color: #e8456a;
    color: #1d1d1f;
    transform: scale(1.04);
    box-shadow: 0 2px 8px rgba(232, 69, 106, 0.15);
  }
}

.cell.disabled {
  background: #eeeef0;
  color: #c7c7cc;
  cursor: default;
}

.cell.my-office {
  border-color: rgba(232, 69, 106, 0.3);
}

.cell.boss-here {
  background: linear-gradient(135deg, #fce4ec, #f8d0da);
  color: #c62851;
  border-color: #e8456a;
  animation: pulse 2.5s ease-in-out infinite;
  box-shadow: 0 2px 8px rgba(232, 69, 106, 0.15);
}

@media (hover: hover) {
  .cell.boss-here:hover {
    background: linear-gradient(135deg, #f8d0da, #f0b8c6);
    border-color: #d63a5e;
    color: #a31d42;
    transform: scale(1.04);
    box-shadow: 0 3px 12px rgba(232, 69, 106, 0.3);
  }
}

.cell.boss-here::after {
  content: '\1F464';
  font-size: 12px;
  margin-left: 2px;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 2px 8px rgba(232, 69, 106, 0.1); }
  50% { box-shadow: 0 2px 14px rgba(232, 69, 106, 0.25); }
}

/* 點擊波紋動畫 */
.cell.ripple::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(232, 69, 106, 0.15);
  border-radius: 10px;
  animation: ripple-fade 0.6s ease-out forwards;
}

@keyframes ripple-fade {
  from { opacity: 1; transform: scale(0.85); }
  to { opacity: 0; transform: scale(1.15); }
}

/* ===== Special Buttons ===== */
.special-buttons {
  display: none;
}

/* ===== Timeline (now inside modal) ===== */

.timeline-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.timeline-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 12px;
  background: #fff;
  font-size: 13px;
  transition: all 0.2s;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

@media (hover: hover) {
  .timeline-item:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transform: translateY(-1px);
  }
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.timeline-info {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.timeline-location {
  color: #e8456a;
  font-weight: 600;
}

.timeline-time {
  color: #aeaeb2;
  font-size: 12px;
}

.timeline-confirms {
  margin-left: auto;
  color: #34c759;
  font-size: 12px;
  flex-shrink: 0;
  font-weight: 500;
}

.timeline-denials {
  color: #ff3b30;
  font-size: 12px;
  flex-shrink: 0;
  font-weight: 500;
}

/* ===== Toast (覆蓋 header) ===== */
.toast {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  font-weight: 700;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
}

.toast.show {
  animation: toast-fade 10s ease forwards;
}

.toast.success {
  background: #34c759;
  color: #fff;
}

.toast.error {
  background: #ff3b30;
  color: #fff;
}

.toast.info {
  background: #007aff;
  color: #fff;
}

@keyframes toast-fade {
  0%, 80% { opacity: 1; }
  100% { opacity: 0; }
}

/* ===== Modal ===== */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-content {
  background: #fff;
  border-radius: 16px;
  padding: 28px;
  width: 100%;
  max-width: 420px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.12);
  border: none;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.modal-header h2 {
  font-size: 18px;
  color: #1d1d1f;
  font-weight: 700;
}

.modal-close {
  background: rgba(0, 0, 0, 0.04);
  border: none;
  color: #86868b;
  font-size: 18px;
  cursor: pointer;
  padding: 4px 10px;
  border-radius: 50%;
  transition: background 0.2s;
}

.modal-close:hover {
  background: rgba(0, 0, 0, 0.08);
  color: #1d1d1f;
}

.modal-content h2 {
  font-size: 18px;
  color: #1d1d1f;
  margin-bottom: 20px;
  font-weight: 700;
}

/* ===== Forms ===== */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 13px;
  color: #86868b;
  margin-bottom: 6px;
  font-weight: 500;
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  background: #f5f5f7;
  color: #1d1d1f;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: all 0.2s;
}

.form-group input:focus,
.form-group select:focus {
  border-color: #e8456a;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(232, 69, 106, 0.1);
}

.btn-primary {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 10px;
  background: #e8456a;
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s;
  margin-top: 8px;
}

.btn-primary:hover {
  background: #d63a5e;
  box-shadow: 0 2px 8px rgba(232, 69, 106, 0.3);
}
.btn-primary:disabled { background: #d1d1d6; color: #fff; cursor: not-allowed; box-shadow: none; }

/* ===== Leaderboard ===== */
.leaderboard-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.lb-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: #f5f5f7;
  border-radius: 10px;
}

.lb-rank {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.04);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: #86868b;
}

.lb-rank.gold { background: #fff3cd; color: #c79100; }
.lb-rank.silver { background: #e8e8ed; color: #6e6e73; }
.lb-rank.bronze { background: #ffe8d6; color: #c75b00; }

.lb-name { flex: 1; font-weight: 600; }
.lb-count { color: #e8456a; font-size: 13px; font-weight: 500; }
.lb-points { color: #d63a5e; font-size: 13px; min-width: 60px; text-align: right; font-weight: 600; }

/* ===== Points History ===== */
.points-display {
  font-size: 24px;
  font-weight: 700;
  color: #e8456a;
}

.point-history {
  max-height: 200px;
  overflow-y: auto;
  margin-top: 12px;
}

.ph-item {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.04);
  font-size: 12px;
}

.ph-reason { color: #86868b; }
.ph-amount.positive { color: #34c759; }
.ph-amount.negative { color: #ff3b30; }
.ph-time { color: #aeaeb2; }

/* ===== 3D Container (base, mobile hidden via .main-right display:none) ===== */

/* ===== Responsive ===== */
@media (max-width: 480px) {
  header { padding: 10px 12px; }
  header h1 { font-size: 15px; white-space: nowrap; }
  .header-btn { padding: 4px 10px; font-size: 11px; }
  .points-badge { font-size: 11px; padding: 3px 10px; }

  .floor-map-container { padding: 6px 8px; }
  .floor-map { gap: 3px; }
  .floor-row { gap: 3px; }
  .floor-label { width: 36px; font-size: 12px; padding-right: 4px; }
  .floor-cells { gap: 3px; }
  .cell { height: 36px; font-size: 13px; }

  .floor-divider { margin: 2px 0; }

  .status-bar { padding: 12px; text-align: left; }
  .status-row { justify-content: space-between; }
  .status-content { align-items: flex-start; }
  #statusText { font-size: 16px; }
  .status-meta { font-size: 11px; }

  .modal-content { padding: 20px; margin: 0 10px; }
}

/* ===== Empty state ===== */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: #aeaeb2;
}

.empty-state .icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.empty-state p {
  font-size: 14px;
  line-height: 1.6;
}
