@import url('./tokens.css');

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: -webkit-fill-available;
  display: flex;
  flex-direction: column;
  padding-bottom: 72px; /* bottom nav clearance */
  user-select: none;
}

/* Header Top Bar */
.field-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow-sm);
}

.field-brand {
  display: flex;
  align-items: center;
  gap: 8px;
}

.field-title {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.field-role-chip {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background: var(--badge-vacant-bg);
  color: var(--badge-vacant-fg);
  font-weight: 600;
  text-transform: uppercase;
}

/* Offline Sync Status Banner */
.sync-banner {
  background: #fef3c7;
  color: #92400e;
  padding: 8px 16px;
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #fde68a;
}
.sync-banner.online {
  background: var(--badge-occupied-bg);
  color: var(--badge-occupied-fg);
  border-bottom-color: #bbf7d0;
}

/* Main Container */
.field-content {
  flex: 1;
  padding: 16px;
  max-width: 600px;
  width: 100%;
  margin: 0 auto;
}

.tab-pane {
  display: none;
}
.tab-pane.active {
  display: block;
}

/* Filters & Search */
.field-search-bar {
  margin-bottom: 14px;
  display: flex;
  gap: 8px;
}

.field-input {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--input-bg);
  color: var(--text);
  font-size: 15px;
}
.field-input:focus {
  outline: none;
  border-color: var(--primary);
}

/* Turn Board Cards */
.site-turn-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.card-top-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.site-badge-num {
  font-size: 18px;
  font-weight: 700;
  color: var(--primary);
}

.status-badge {
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  text-transform: capitalize;
}
.status-badge.dirty { background: var(--badge-dirty-bg); color: var(--badge-dirty-fg); }
.status-badge.clean { background: var(--badge-clean-bg); color: var(--badge-clean-fg); }
.status-badge.inspected { background: var(--badge-inspected-bg); color: var(--badge-inspected-fg); }
.status-badge.ready { background: var(--badge-ready-bg); color: var(--badge-ready-fg); }
.status-badge.occupied { background: var(--badge-occupied-bg); color: var(--badge-occupied-fg); }
.status-badge.vacant { background: var(--badge-vacant-bg); color: var(--badge-vacant-fg); }

.card-meta-row {
  font-size: 13px;
  color: var(--muted);
}

/* Big 1-Tap Action Buttons */
.turn-action-btn {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.1s ease, opacity 0.15s ease;
}
.turn-action-btn:active {
  transform: scale(0.98);
}
.turn-action-btn.btn-clean { background: #2563eb; color: #ffffff; }
.turn-action-btn.btn-inspect { background: #d97706; color: #ffffff; }
.turn-action-btn.btn-ready { background: #16a34a; color: #ffffff; }
.turn-action-btn.btn-reopen { background: var(--code-bg); color: var(--text); border: 1px solid var(--border); }

/* Work Order Items */
.wo-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
}
.wo-card.urgent { border-left: 4px solid var(--red); }
.wo-card.normal { border-left: 4px solid var(--primary); }
.wo-card.low { border-left: 4px solid var(--muted); }

.wo-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 6px;
}
.wo-title {
  font-size: 16px;
  font-weight: 600;
}
.wo-desc {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 10px;
}
.wo-meta {
  font-size: 12px;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Floating Action Button (FAB) */
.field-fab {
  position: fixed;
  bottom: 84px;
  right: 20px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--primary);
  color: #ffffff;
  border: none;
  font-size: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-lg);
  cursor: pointer;
  z-index: 30;
}

/* Bottom Navigation Bar */
.field-bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 64px;
  background: var(--card-bg);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 50;
  box-shadow: 0 -2px 8px rgba(0,0,0,0.05);
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  padding: 6px 0;
}
.nav-item.active {
  color: var(--primary);
  font-weight: 700;
}
.nav-item .nav-icon {
  font-size: 20px;
}

/* Modals & Dialogs */
.field-modal {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.field-modal.active {
  opacity: 1;
  pointer-events: auto;
}
.field-modal-sheet {
  background: var(--card-bg);
  border-radius: 18px 18px 0 0;
  width: 100%;
  max-width: 600px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 20px;
  box-shadow: var(--shadow-lg);
  transform: translateY(100%);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
.field-modal.active .field-modal-sheet {
  transform: translateY(0);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.modal-close-btn {
  background: var(--code-bg);
  border: none;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  font-size: 16px;
  cursor: pointer;
  color: var(--muted);
}

/* ---------- PWA Install Card & Banner ---------- */
.pwa-install-card {
  position: fixed;
  bottom: 74px;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 24px);
  max-width: 440px;
  background: var(--card-bg, #ffffff);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 12px;
  box-shadow: 0 10px 25px -5px rgba(0,0,0,0.18);
  padding: 12px 14px;
  z-index: 9999;
  animation: pwaSlideUp 0.3s ease-out;
}
@keyframes pwaSlideUp {
  from { transform: translate(-50%, 30px); opacity: 0; }
  to { transform: translate(-50%, 0); opacity: 1; }
}
.pwa-card-content {
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
}
.pwa-card-icon {
  font-size: 26px;
  flex-shrink: 0;
}
.pwa-card-text {
  flex: 1;
  min-width: 0;
}
.pwa-card-text strong {
  display: block;
  font-size: 13.5px;
  color: var(--text, #0f172a);
  line-height: 1.2;
}
.pwa-card-text p {
  font-size: 12px;
  color: var(--muted, #64748b);
  margin: 3px 0 0;
  line-height: 1.3;
}
.pwa-ios-instructions {
  margin-top: 5px;
  font-size: 11.5px;
  background: var(--code-bg, #f1f5f9);
  padding: 4px 8px;
  border-radius: 6px;
  color: var(--text, #334155);
}
.pwa-install-btn {
  flex-shrink: 0;
  padding: 6px 14px;
  font-size: 12.5px;
  background: var(--primary, #1b4332);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
}
.pwa-close-btn {
  background: none;
  border: none;
  font-size: 18px;
  color: var(--muted, #94a3b8);
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}
.pwa-close-btn:hover {
  color: var(--text, #0f172a);
}
