/* Craftline Built — Intake Form styles. Mobile-first. */

:root {
  --dark: #3d4f5f;
  --dark-2: #2f3d4a;
  --orange: #f97316;
  --orange-2: #ea6a0d;
  --light: #f6f7f9;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #d8dde3;
  --border-soft: #e6e9ee;
  --error: #c0392b;
  --success: #16a34a;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0,0,0,0.04), 0 4px 12px rgba(0,0,0,0.04);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--light);
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  padding-top: calc(env(safe-area-inset-top) + 64px);
  padding-bottom: env(safe-area-inset-bottom);
}

/* ---------- Top bar ---------- */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  background: var(--dark);
  color: #fff;
  padding: 10px 16px calc(10px + env(safe-area-inset-top)) 16px;
  padding-top: calc(10px + env(safe-area-inset-top));
  z-index: 10;
  box-shadow: 0 1px 0 rgba(0,0,0,0.08);
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 22px; height: 22px;
  border-radius: 6px;
  background: var(--orange);
  display: inline-block;
}
.brand-name { font-weight: 700; font-size: 15px; letter-spacing: 0.2px; }

.progress {
  height: 4px;
  background: rgba(255,255,255,0.15);
  border-radius: 2px;
  margin-top: 10px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  width: 0%;
  background: var(--orange);
  border-radius: 2px;
  transition: width 0.25s ease;
}
.step-label {
  font-size: 11px;
  opacity: 0.75;
  margin-top: 6px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

/* ---------- Layout ---------- */
main {
  max-width: 600px;
  margin: 0 auto;
  padding: 20px 18px 120px;
}

.screen { animation: fadeIn 0.2s ease; }
.hidden { display: none !important; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

h1 {
  font-size: 22px;
  margin: 4px 0 6px;
  color: var(--dark);
  letter-spacing: -0.3px;
}
.muted { color: var(--muted); margin: 0 0 18px; line-height: 1.45; }
.muted.small { font-size: 13px; }

/* ---------- Fields ---------- */
.field {
  display: block;
  margin-bottom: 16px;
}
.field > span,
.field-label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--dark);
  margin-bottom: 6px;
}
.field em {
  color: var(--orange);
  font-style: normal;
}
.optional {
  font-weight: 400;
  color: var(--muted);
  font-size: 12px;
}
.hint {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
  margin-bottom: 6px;
}

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="url"],
textarea {
  width: 100%;
  font: inherit;
  font-size: 16px; /* prevents iOS auto-zoom */
  color: var(--text);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  -webkit-appearance: none;
  appearance: none;
}
textarea {
  resize: vertical;
  min-height: 88px;
  line-height: 1.45;
}
input:focus, textarea:focus {
  border-color: var(--orange);
  box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.18);
}
input[readonly] {
  background: #eef0f3;
  color: var(--dark);
  font-weight: 600;
}
input.invalid, textarea.invalid {
  border-color: var(--error);
  box-shadow: 0 0 0 3px rgba(192, 57, 43, 0.12);
}

/* ---------- Services repeater ---------- */
.service-item {
  background: #fff;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 12px;
  position: relative;
}
.service-item .service-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.service-item .service-num {
  font-size: 13px;
  font-weight: 700;
  color: var(--dark);
}
.service-item .remove-service {
  background: none;
  border: 0;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  padding: 4px 6px;
}
.service-item .remove-service:hover { color: var(--error); }
.service-item input,
.service-item textarea {
  margin-bottom: 8px;
}
.service-item input:last-child,
.service-item textarea:last-child {
  margin-bottom: 0;
}

/* ---------- Uploads ---------- */
input[type="file"] {
  display: block;
  width: 100%;
  font-size: 14px;
  padding: 10px;
  background: #fff;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}
.upload-status {
  font-size: 13px;
  margin-top: 8px;
  min-height: 18px;
}
.upload-status .row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 0;
}
.upload-status .row .name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}
.upload-status .row .state { color: var(--muted); }
.upload-status .row .state.done { color: var(--success); }
.upload-status .row .state.err { color: var(--error); }

.photo-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 10px;
}
.photo-grid .thumb {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 8px;
  overflow: hidden;
  background: #e6e9ee;
}
.photo-grid .thumb img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.photo-grid .thumb .state {
  position: absolute;
  inset: auto 0 0 0;
  background: rgba(0,0,0,0.55);
  color: #fff;
  font-size: 10px;
  text-align: center;
  padding: 3px 4px;
  letter-spacing: 0.3px;
}
.photo-grid .thumb .state.done { background: rgba(22, 163, 74, 0.85); }
.photo-grid .thumb .state.err  { background: rgba(192, 57, 43, 0.85); }
.photo-grid .thumb .remove {
  position: absolute;
  top: 4px; right: 4px;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: rgba(0,0,0,0.6);
  color: #fff;
  border: 0;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}

/* ---------- Buttons ---------- */
.nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: #fff;
  border-top: 1px solid var(--border-soft);
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom)) 16px;
  display: flex;
  gap: 10px;
  max-width: 600px;
  margin: 0 auto;
  z-index: 9;
}
.nav button { flex: 1; }

.btn-primary, .btn-secondary {
  font: inherit;
  font-size: 16px;
  font-weight: 600;
  padding: 13px 18px;
  border-radius: var(--radius);
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.15s, border-color 0.15s, color 0.15s, opacity 0.15s;
}
.btn-primary {
  background: var(--orange);
  color: #fff;
}
.btn-primary:hover { background: var(--orange-2); }
.btn-primary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.btn-secondary {
  background: #fff;
  color: var(--dark);
  border-color: var(--border);
}
.btn-secondary:hover { background: #eef0f3; }
.btn-secondary:disabled { opacity: 0.5; cursor: not-allowed; }

/* full-width secondary buttons handled by .btn-secondary.full */

/* ---------- Loading / Done / Error ---------- */
.loading {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
}
.spinner {
  width: 38px; height: 38px;
  border: 3px solid var(--border);
  border-top-color: var(--orange);
  border-radius: 50%;
  margin: 0 auto 14px;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.done {
  text-align: center;
  padding: 60px 20px;
}
.done .check {
  width: 72px; height: 72px;
  background: var(--orange);
  color: #fff;
  border-radius: 50%;
  font-size: 36px;
  font-weight: 700;
  line-height: 72px;
  margin: 0 auto 22px;
}
.done h1 {
  font-size: 26px;
  margin-bottom: 10px;
}
.done p { font-size: 16px; color: var(--text); }
.done p.muted { color: var(--muted); margin-top: 30px; }

/* Hide nav on loading / done / error screens via JS-controlled class on body */
body.no-nav .nav { display: none; }

/* ---------- Service page checklist (step 3) ---------- */
.page-check-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
  background: #fff;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  margin-bottom: 8px;
  cursor: pointer;
  font-size: 15px;
  font-weight: 500;
  color: var(--dark);
  transition: border-color 0.15s, background 0.15s;
}
.page-check-item:has(input:checked) {
  border-color: var(--orange);
  background: #fff8f3;
}
.page-check-item.select-all {
  background: var(--dark);
  color: #fff;
  border-color: var(--dark);
  margin-bottom: 12px;
}
.page-check-item.select-all:has(input:checked) {
  background: var(--dark-2);
  border-color: var(--orange);
}
.page-check-item input[type="checkbox"] {
  width: 20px;
  height: 20px;
  min-width: 20px;
  accent-color: var(--orange);
  cursor: pointer;
  border-radius: 4px;
}

/* ---------- Service page detail cards ---------- */
.spc {
  background: #fff;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  margin-top: 12px;
  overflow: hidden;
}
.spc-header {
  background: var(--dark);
  color: #fff;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.spc-name {
  font-weight: 700;
  font-size: 14px;
}
.spc-badge {
  font-size: 11px;
  background: var(--orange);
  color: #fff;
  padding: 2px 8px;
  border-radius: 20px;
  white-space: nowrap;
}
.spc-body {
  padding: 14px;
}
.spc-body .field {
  margin-bottom: 14px;
}

/* ---------- Process steps & FAQ rows ---------- */
.step-row,
.faq-row {
  background: var(--light);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 8px;
}
.step-row-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.step-row-num {
  font-size: 12px;
  font-weight: 700;
  color: var(--dark);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.remove-row {
  background: none;
  border: 0;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
  padding: 2px 6px;
}
.remove-row:hover { color: var(--error); }
.step-row input,
.step-row textarea,
.faq-row input,
.faq-row textarea {
  margin-bottom: 6px;
  font-size: 15px;
}

/* Small secondary button variant */
.btn-secondary.small {
  font-size: 13px;
  padding: 8px 12px;
  width: auto;
  flex: none;
}

/* ---------- Divider ---------- */
.divider {
  height: 1px;
  background: var(--border-soft);
  margin: 20px 0;
}

/* ---------- Service photo grid inside cards ---------- */
.spc-photo-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-top: 8px;
}
.spc-photo-grid .thumb {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 6px;
  overflow: hidden;
  background: #e6e9ee;
}
.spc-photo-grid .thumb img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.spc-photo-grid .thumb .state {
  position: absolute;
  inset: auto 0 0 0;
  background: rgba(0,0,0,0.55);
  color: #fff;
  font-size: 10px;
  text-align: center;
  padding: 2px 4px;
}
.spc-photo-grid .thumb .state.done { background: rgba(22,163,74,0.85); }
.spc-photo-grid .thumb .state.err  { background: rgba(192,57,43,0.85); }

/* .full width button */
.btn-secondary.full { width: 100%; margin-top: 4px; }

/* Slight spacing tweak for desktop */
@media (min-width: 640px) {
  main { padding: 28px 24px 140px; }
  h1 { font-size: 26px; }
  .photo-grid { grid-template-columns: repeat(4, 1fr); }
}
