/* Nobi Field Service — plain CSS (Tailwind Play CDN does NOT process @apply
   in external stylesheets; every component-level style must be written in
   plain rules. Colors mirror the tailwind.config block in index.html:
     night    #2e4447    morning  #37928b    day      #e0e5da
     sand     #faf6ee    muted    #58595b    mutedlt  #939597
     orange   #e86826
*/

* { -webkit-tap-highlight-color: transparent; }
html, body { overscroll-behavior-y: contain; }
body { font-family: 'Hanken Grotesk', system-ui, sans-serif; }

/* Touch targets */
button, .tap { min-height: 44px; }

/* ── Fields ──────────────────────────────────────────────────────── */
.field-input {
  width: 100%;
  padding: 0.75rem 1rem;
  background: #ffffff;
  border: 1px solid #e0e5da;
  border-radius: 0.625rem;
  color: #2e4447;
  font-size: 1rem;
  line-height: 1.4;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
  font-family: inherit;
  -webkit-appearance: none;
  appearance: none;
}
.field-input:focus {
  border-color: #37928b;
  box-shadow: 0 0 0 3px rgba(55, 146, 139, 0.25);
}
textarea.field-input { min-height: 96px; resize: vertical; }

/* Native <select> needs the chevron back after appearance:none */
select.field-input {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%2358595b'><path d='M5.23 7.21a.75.75 0 011.06.02L10 11.06l3.71-3.83a.75.75 0 111.08 1.04l-4.24 4.38a.75.75 0 01-1.08 0L5.21 8.27a.75.75 0 01.02-1.06z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 20px;
  padding-right: 40px;
}

.field-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: #58595b;
  margin-bottom: 0.375rem;
}
.field-required::after {
  content: " *";
  color: #e86826;
  font-weight: 700;
}

/* ── Card containers (steps on detail page) ─────────────────────── */
.card {
  background: #ffffff;
  border-radius: 0.875rem;
  box-shadow: 0 1px 2px rgba(46, 68, 71, 0.06), 0 1px 1px rgba(46, 68, 71, 0.04);
  border: 1px solid rgba(224, 229, 218, 0.6);
  overflow: hidden;
}
.card-header {
  background: #e0e5da;
  color: #2e4447;
  padding: 0.875rem 1rem;
  font-weight: 600;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
}
.card-body {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.card-body.dense { gap: 0.5rem; }

/* ── Step badge ─────────────────────────────────────────────────── */
.step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 9999px;
  background: #37928b;
  color: #ffffff;
  font-size: 0.75rem;
  font-weight: 700;
  margin-right: 0.5rem;
  flex-shrink: 0;
}

.invalid-dot {
  display: inline-block;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 9999px;
  background: #e86826;
  margin-left: 0.375rem;
}

/* ── Toggle switch ──────────────────────────────────────────────── */
.toggle {
  --w: 56px;
  --h: 32px;
  position: relative;
  display: inline-block;
  width: var(--w);
  height: var(--h);
  flex-shrink: 0;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: #cfd5cd;
  border-radius: 9999px;
  transition: background .15s ease;
}
.toggle-slider::before {
  content: "";
  position: absolute;
  height: calc(var(--h) - 6px);
  width: calc(var(--h) - 6px);
  left: 3px;
  top: 3px;
  background: #ffffff;
  border-radius: 50%;
  transition: transform .15s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}
.toggle input:checked + .toggle-slider { background: #37928b; }
.toggle input:checked + .toggle-slider::before {
  transform: translateX(calc(var(--w) - var(--h)));
}

/* ── Sticky bottom bar ──────────────────────────────────────────── */
.bottom-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #ffffff;
  border-top: 1px solid rgba(224, 229, 218, 0.8);
  padding: 0.75rem 1rem;
  padding-bottom: calc(0.75rem + env(safe-area-inset-bottom));
  z-index: 20;
}

/* ── Buttons ────────────────────────────────────────────────────── */
.btn-primary,
.btn-secondary,
.btn-night {
  display: block;
  width: 100%;
  padding: 1rem 1rem;
  border-radius: 0.75rem;
  font-weight: 600;
  font-size: 1rem;
  line-height: 1.25rem;
  text-align: center;
  transition: opacity 0.15s ease, background-color 0.15s ease;
  border: 0;
  cursor: pointer;
  min-height: 48px;
  font-family: inherit;
}
.btn-primary { background-color: #37928b; color: #ffffff; }
.btn-primary:active { opacity: 0.8; }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-secondary {
  background-color: #ffffff;
  border: 1px solid #e0e5da;
  color: #2e4447;
  padding: 0.75rem 1rem;
}
.btn-secondary:active { background-color: rgba(224, 229, 218, 0.5); }
.btn-night { background-color: #2e4447; color: #ffffff; }
.btn-night:active { opacity: 0.8; }

/* ── Signature pad ──────────────────────────────────────────────── */
.sig-pad {
  width: 100%;
  height: 220px;
  background: #ffffff;
  border: 2px dashed #cfd5cd;
  border-radius: 12px;
  touch-action: none;
  display: block;
}

/* ── Photo thumbnails ───────────────────────────────────────────── */
.photo-thumb {
  width: 80px;
  height: 80px;
  border-radius: 8px;
  background-size: cover;
  background-position: center;
  position: relative;
  border: 1px solid #e0e5da;
}
.photo-thumb button {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #e86826;
  color: #ffffff;
  font-size: 14px;
  line-height: 22px;
  text-align: center;
  border: 2px solid #ffffff;
  min-height: 0;
}

/* ── Task list (home screen) ────────────────────────────────────── */
.task-card {
  display: block;
  background: #ffffff;
  border-radius: 0.875rem;
  padding: 0.875rem 1rem;
  box-shadow: 0 1px 2px rgba(46, 68, 71, 0.06);
  border: 1px solid rgba(224, 229, 218, 0.7);
  cursor: pointer;
  transition: background-color 0.15s ease, transform 0.05s ease;
}
.task-card:active {
  background-color: rgba(224, 229, 218, 0.4);
  transform: scale(0.995);
}
.task-card-title {
  font-weight: 600;
  color: #2e4447;
  font-size: 1rem;
  line-height: 1.3;
  margin: 0 0 0.25rem 0;
  /* clamp to 2 lines so really long task names don't blow the card up */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.task-card-customer {
  font-size: 0.875rem;
  color: #58595b;
  line-height: 1.35;
  margin: 0 0 0.125rem 0;
}
.task-card-community {
  font-size: 0.8125rem;
  color: #939597;
  line-height: 1.35;
  margin: 0;
}
.task-card-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.375rem;
  margin-top: 0.625rem;
}

/* Chips */
.template-chip {
  display: inline-block;
  padding: 0.125rem 0.5rem;
  border-radius: 0.375rem;
  background: rgba(55, 146, 139, 0.15);
  color: #37928b;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.4;
}
.state-chip {
  display: inline-block;
  padding: 0.125rem 0.5rem;
  border-radius: 0.375rem;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.4;
}
.state-progress {
  background: rgba(232, 104, 38, 0.15);
  color: #e86826;
}
.state-pending {
  background: #e0e5da;
  color: #58595b;
}

/* Scan input — slight cue it's barcode-aware */
.scan-input {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2358595b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><rect x='3' y='5' width='2' height='14'/><rect x='7' y='5' width='1' height='14'/><rect x='10' y='5' width='3' height='14'/><rect x='15' y='5' width='1' height='14'/><rect x='18' y='5' width='3' height='14'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 22px;
  padding-right: 44px;
}

/* ── Login screen ───────────────────────────────────────────────── */
.login-card {
  background: #ffffff;
  border-radius: 1rem;
  padding: 1.5rem;
  box-shadow: 0 4px 12px rgba(46, 68, 71, 0.08);
  border: 1px solid rgba(224, 229, 218, 0.6);
  max-width: 24rem;
  margin: 3rem auto 0;
}

/* ── Page-level vertical rhythm ─────────────────────────────────── */
.page-section { padding: 1rem; display: flex; flex-direction: column; gap: 0.75rem; }
.page-section + .page-section { padding-top: 0; }

/* Stacked list — used by task list to avoid manual margins */
.stack > * + * { margin-top: 0.625rem; }

/* Slide animation between screens */
.view-enter { animation: fadeIn .15s ease-out; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}
