/* Attendant app — mobile-first, designed for 360–414px phone screens */

/* Screen system */
.screen { display: none; min-height: 100dvh; }
.screen.active { display: flex; flex-direction: column; }

/* ── START SCREEN ────────────────────────────────────────── */
#screen-start {
  background: var(--color-bg);
  padding-bottom: env(safe-area-inset-bottom, 16px);
}
.start-hero {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  padding: 48px 24px 36px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: #fff;
}
.start-hero-icon {
  width: 64px;
  height: 64px;
  background: rgba(255,255,255,0.2);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
}
.start-hero h1 {
  font-size: 22px;
  font-weight: 700;
  text-align: center;
  line-height: 1.3;
}
.start-hero p {
  font-size: 14px;
  opacity: 0.85;
  text-align: center;
}
.start-body {
  flex: 1;
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.start-body .card { padding: 20px; }
.start-body .card h2 {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 16px;
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.start-actions { display: flex; flex-direction: column; gap: 10px; padding: 0 16px 16px; }
.btn-start { min-height: 52px; font-size: 16px; border-radius: var(--radius-md); }
.draft-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--color-surface);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
}
.draft-row-info { flex: 1; min-width: 0; }
.draft-row-title { font-size: 14px; font-weight: 600; }
.draft-row-meta { font-size: 12px; color: var(--color-text-secondary); }
.draft-row .btn-sm { white-space: nowrap; }
.no-drafts { text-align: center; color: var(--color-text-muted); font-size: 13px; padding: 8px; }

/* ── CHECKLIST SCREEN ─────────────────────────────────────── */
#screen-checklist {
  background: var(--color-bg);
  padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px));
}
.checklist-topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: 0 16px;
}
.checklist-topbar-row1 {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 0 8px;
}
.btn-back-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--color-primary);
  font-size: 15px;
  font-weight: 600;
  min-height: 36px;
  padding: 4px 0;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.topbar-meta { flex: 1; text-align: right; }
.topbar-meta-villa { font-size: 14px; font-weight: 600; }
.topbar-meta-date { font-size: 12px; color: var(--color-text-secondary); }
.progress-wrap {
  padding: 6px 0 10px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.progress-track {
  flex: 1;
  height: 6px;
  background: var(--color-border);
  border-radius: var(--radius-pill);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #3b82f6, #10b981);
  border-radius: var(--radius-pill);
  transition: width 300ms ease;
  width: 0%;
}
.progress-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-secondary);
  white-space: nowrap;
  min-width: 50px;
  text-align: right;
}
.checklist-body { padding: 12px 0 8px; }

/* Category */
.category-section { margin-bottom: 4px; }
.category-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
}
.category-header:active { background: #f9fafb; }
.category-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--color-primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}
.category-title-wrap { flex: 1; min-width: 0; }
.category-name { font-size: 15px; font-weight: 600; }
.category-stats { font-size: 12px; color: var(--color-text-secondary); margin-top: 1px; }
.category-chevron {
  font-size: 18px;
  color: var(--color-text-muted);
  transition: transform var(--transition);
  flex-shrink: 0;
}
.category-section.expanded .category-chevron { transform: rotate(180deg); }
.category-done-badge {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--color-good);
  color: #fff;
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.category-items { display: none; }
.category-section.expanded .category-items { display: block; }

/* Checklist items */
.checklist-item {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: 14px 16px;
  transition: background var(--transition);
}
.checklist-item.rated-good { border-left: 3px solid var(--color-good); }
.checklist-item.rated-not-good { border-left: 3px solid var(--color-not-good); }
.item-number {
  font-size: 11px;
  font-weight: 700;
  color: var(--color-text-muted);
  margin-bottom: 4px;
  letter-spacing: 0.03em;
}
.item-text {
  font-size: 14px;
  line-height: 1.5;
  color: var(--color-text);
  margin-bottom: 10px;
}
.item-toggles {
  display: flex;
  gap: 8px;
}
.toggle-btn {
  flex: 1;
  min-height: 40px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  border: 1.5px solid var(--color-border);
  background: var(--color-bg);
  color: var(--color-text-secondary);
  transition: all var(--transition);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}
.toggle-btn:active { transform: scale(0.97); }
.toggle-btn.active-good {
  background: var(--color-good);
  border-color: var(--color-good);
  color: #fff;
}
.toggle-btn.active-not-good {
  background: var(--color-not-good);
  border-color: var(--color-not-good);
  color: #fff;
}
.toggle-btn-na { flex: 0 0 auto; min-width: 52px; font-size: 13px; }
.toggle-btn.active-na {
  background: #6b7280;
  border-color: #6b7280;
  color: #fff;
}
@keyframes incompleteFlash {
  0%, 100% { background: var(--color-surface); }
  40% { background: #fef3c7; border-left-color: #f59e0b; }
}
.checklist-item.incomplete-flash { animation: incompleteFlash 1.2s ease; }
.item-remarks {
  width: 100%;
  margin-top: 10px;
  padding: 10px 12px;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  line-height: 1.5;
  resize: none;
  min-height: 70px;
  background: #fafafa;
  color: var(--color-text);
  transition: border-color var(--transition);
}
.item-remarks:focus {
  outline: none;
  border-color: var(--color-primary);
  background: var(--color-surface);
}
.item-remarks::placeholder { color: var(--color-text-muted); }

/* Photo capture */
.item-photo-section { margin-top: 10px; }
.photo-add-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border: 1.5px dashed var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-secondary);
  cursor: pointer;
  background: var(--color-bg);
  transition: border-color var(--transition), color var(--transition);
  touch-action: manipulation;
}
.photo-add-btn:hover { border-color: var(--color-primary); color: var(--color-primary); }
.photo-add-btn input { display: none; }
.photo-preview-wrap {
  position: relative;
  display: inline-block;
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.photo-preview-img {
  display: block;
  max-width: 100%;
  max-height: 220px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--color-border);
  object-fit: cover;
}
.photo-remove-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(0,0,0,0.55);
  color: #fff;
  border: none;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
}

/* Fixed bottom action bar */
.checklist-action-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  padding: 12px 16px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  display: flex;
  gap: 10px;
  box-shadow: 0 -4px 12px rgba(0,0,0,0.06);
}
.checklist-action-bar .btn { flex: 1; }
.btn-review { min-height: 48px; font-size: 16px; border-radius: var(--radius-md); }

/* ── REVIEW SCREEN ────────────────────────────────────────── */
#screen-review {
  background: var(--color-bg);
  padding-bottom: calc(80px + env(safe-area-inset-bottom, 0px));
}
.review-topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.review-topbar h2 { font-size: 17px; font-weight: 700; flex: 1; }
.review-body { padding: 16px; display: flex; flex-direction: column; gap: 16px; }

/* Summary stats */
.summary-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.stat-card {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  padding: 14px 12px;
  text-align: center;
  box-shadow: var(--shadow-sm);
}
.stat-card .stat-number { font-size: 26px; font-weight: 700; line-height: 1; }
.stat-card .stat-label { font-size: 11px; font-weight: 600; color: var(--color-text-secondary); text-transform: uppercase; letter-spacing: 0.04em; margin-top: 4px; }
.stat-card.good .stat-number { color: var(--color-good); }
.stat-card.not-good .stat-number { color: var(--color-not-good); }
.stat-card.na .stat-number { color: #6b7280; }
.stat-card.unmarked .stat-number { color: var(--color-text-muted); }

/* Not-good items list in review */
.not-good-list { display: flex; flex-direction: column; gap: 8px; }
.not-good-item {
  background: var(--color-not-good-light);
  border: 1px solid #fecaca;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 13px;
}
.not-good-item .ngi-category { font-size: 11px; font-weight: 700; color: var(--color-not-good); text-transform: uppercase; letter-spacing: 0.03em; margin-bottom: 2px; }
.not-good-item .ngi-text { color: var(--color-text); line-height: 1.4; }
.not-good-item .ngi-remarks { font-size: 12px; color: var(--color-text-secondary); margin-top: 4px; font-style: italic; }

/* Signature area */
.signature-container {
  position: relative;
  background: #fafafa;
  border: 1.5px dashed var(--color-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
#signature-canvas {
  display: block;
  width: 100%;
  height: 120px;
  touch-action: none;
}
.signature-placeholder {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 13px;
  color: var(--color-text-muted);
  pointer-events: none;
  display: flex;
  align-items: center;
  gap: 6px;
}
.btn-clear-sig {
  font-size: 12px;
  color: var(--color-text-secondary);
  text-decoration: underline;
  padding: 4px 0;
  margin-top: 6px;
  touch-action: manipulation;
}

/* Review action bar */
.review-action-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  padding: 12px 16px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 -4px 12px rgba(0,0,0,0.06);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.review-action-row { display: flex; gap: 8px; }
.review-action-row .btn { flex: 1; }
.btn-pdf { background: #f3f4f6; color: var(--color-text); border: 1.5px solid var(--color-border); }
.btn-pdf:active { background: var(--color-border); }
.btn-whatsapp { background: #25d366; color: #fff; }
.btn-whatsapp:active { background: #1ebe5d; }
.btn-submit-main { min-height: 52px; font-size: 16px; border-radius: var(--radius-md); }

/* Submit success screen overlay */
.success-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,0.97);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  text-align: center;
  gap: 16px;
}
.success-icon {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--color-good-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  animation: pop 400ms cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes pop {
  from { transform: scale(0.5); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
.success-overlay h2 { font-size: 22px; font-weight: 700; }
.success-overlay p { font-size: 15px; color: var(--color-text-secondary); line-height: 1.5; }
.success-actions { display: flex; flex-direction: column; gap: 10px; width: 100%; max-width: 320px; margin-top: 8px; }

/* Pending badge on submit button */
.pending-badge-wrap { position: relative; display: inline-flex; }
.pending-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  background: var(--color-warning);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}
