@import url('https://fonts.googleapis.com/css2?family=Inter:opsz@14..32&display=swap');

:root {
  --bs-font-sans-serif: 'Inter', system-ui, -apple-system, sans-serif;
  --bs-body-font-size: 0.9375rem;
  --bs-body-line-height: 1.6;

  --bs-primary: #4F46E5;
  --bs-primary-rgb: 79, 70, 229;
  --bs-primary-bg-subtle: #EEF2FF;
  --bs-primary-text-emphasis: #3730A3;

  --bs-secondary: #475569;
  --bs-secondary-rgb: 71, 85, 105;
  --bs-secondary-bg-subtle: #F1F5F9;
  --bs-secondary-text-emphasis: #334155;

  --bs-success: #10B981;
  --bs-success-rgb: 16, 185, 129;
  --bs-success-bg-subtle: #ECFDF5;
  --bs-success-text-emphasis: #047857;

  --bs-danger: #E11D48;
  --bs-danger-rgb: 225, 29, 72;
  --bs-danger-bg-subtle: #FFF1F2;
  --bs-danger-text-emphasis: #BE123C;

  --bs-warning: #F59E0B;
  --bs-warning-rgb: 245, 158, 11;
  --bs-warning-bg-subtle: #FFFBEB;
  --bs-warning-text-emphasis: #B45309;

  --bs-info: #06B6D4;
  --bs-info-rgb: 6, 182, 212;
  --bs-info-bg-subtle: #ECFEFF;
  --bs-info-text-emphasis: #0891B2;

  --bs-body-bg: #F8FAFC;
  --bs-body-color: #1E293B;
  --bs-body-color-rgb: 30, 41, 59;
  --bs-emphasis-color: #0F172A;
  --bs-emphasis-color-rgb: 15, 23, 42;
  --bs-secondary-color: #475569;
  --bs-tertiary-color: #94A3B8;

  --bs-border-color: #E2E8F0;
  --bs-border-width: 1px;
  --bs-border-radius: 0.5rem;
  --bs-border-radius-lg: 0.75rem;
  --bs-border-radius-sm: 0.375rem;

  --bs-card-bg: #FFFFFF;
  --bs-card-cap-bg: #FFFFFF;
  --bs-card-border-color: #E2E8F0;
  --bs-card-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);

  --bs-btn-font-weight: 500;
  --bs-btn-padding-y: 0.5rem;
  --bs-btn-padding-x: 1rem;
  --bs-btn-border-radius: 0.5rem;

  --bs-input-bg: #FFFFFF;
  --bs-input-border-color: #CBD5E1;
  --bs-input-focus-border-color: #4F46E5;
  --bs-input-focus-box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);

  --bs-navbar-bg: #FFFFFF;
  --bs-navbar-border-bottom: 1px solid #E2E8F0;
  --bs-dropdown-bg: #FFFFFF;
  --bs-dropdown-border-color: #E2E8F0;
  --bs-dropdown-box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.navbar {
  border-bottom: var(--bs-navbar-border-bottom);
  box-shadow: none;
}

.card {
  box-shadow: var(--bs-card-box-shadow);
  border: var(--bs-border-width) solid var(--bs-card-border-color);
}

.card-header {
  border-bottom: var(--bs-border-width) solid var(--bs-border-color);
  background: var(--bs-card-cap-bg);
}

.btn {
  letter-spacing: 0.01em;
}

.btn-primary {
  --bs-btn-bg: var(--bs-primary);
  --bs-btn-border-color: var(--bs-primary);
  --bs-btn-hover-bg: #4338CA;
  --bs-btn-hover-border-color: #4338CA;
  --bs-btn-active-bg: #3730A3;
  --bs-btn-active-border-color: #3730A3;
}

.form-control, .form-select {
  border-color: var(--bs-input-border-color);
  background-color: var(--bs-input-bg);
  box-shadow: none;
}

.form-control:focus, .form-select:focus {
  border-color: var(--bs-input-focus-border-color);
  box-shadow: var(--bs-input-focus-box-shadow);
}

.table {
  --bs-table-hover-bg: #F1F5F9;
}

.dropdown-menu {
  border-color: var(--bs-dropdown-border-color);
  box-shadow: var(--bs-dropdown-box-shadow);
}

.badge {
  font-weight: 500;
  letter-spacing: 0.02em;
}

a {
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.list-group {
  /* Bootstrap sets --bs-list-group-active-bg locally on .list-group itself
     (not via :root), so it must be overridden here to pick up the brand
     primary instead of Bootstrap's stock blue */
  --bs-list-group-active-bg: var(--bs-primary);
  --bs-list-group-active-border-color: var(--bs-primary);
}

.list-group-item {
  border-color: var(--bs-border-color);
}

.nav-tabs .nav-link.active {
  font-weight: 500;
  border-bottom-color: var(--bs-primary);
}

.progress {
  background-color: #E2E8F0;
  border-radius: 999px;
}

.modal-content {
  border: none;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
}

.pagination {
  --bs-pagination-active-bg: var(--bs-primary);
  --bs-pagination-active-border-color: var(--bs-primary);
}

.accordion-button:not(.collapsed) {
  background-color: var(--bs-primary-bg-subtle);
  color: var(--bs-primary-text-emphasis);
  box-shadow: none;
}

.accordion-item {
  border-color: var(--bs-border-color);
}

.tooltip-inner {
  font-size: 0.8125rem;
}

.toast {
  border: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.offcanvas {
  border: none;
}

/* Utility: subtle top border for section headers */
.section-divider {
  border-top: 2px solid var(--bs-border-color);
}

/* Touch target: primary CTA min height (uiux-rules §touch targets = 48px) */
.btn-cta { min-height: 48px; }
/* Touch target: secondary/modal action min height = 44px */
.btn-touch { min-height: 44px; }

/* Constrain content width on the template manager page */
.page-narrow { max-width: 960px; }

/* Empty-state icon size */
.empty-state-icon { font-size: 2.5rem; }

/* Search icon inset for field-type picker */
.ft-search-icon { left: 12px; }

/* Field-type icon in template item list */
.ft-icon {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--bs-border-radius-sm);
  font-size: 0.875rem;
  flex-shrink: 0;
}

/* Template card in list view */
.tpl-card {
  cursor: pointer;
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}
.tpl-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  transform: translateY(-1px);
}

/* Field-type picker container */
#ftPickerContainer {
  max-height: 260px;
  overflow-y: auto;
  border: 1px solid var(--bs-border-color);
  border-radius: var(--bs-border-radius);
  padding: 0.5rem;
}

/* Field-type picker grid */
.ft-picker-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}
@media (max-width: 575.98px) {
  .ft-picker-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
.ft-picker-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--bs-border-color);
  border-radius: var(--bs-border-radius);
  background: var(--bs-card-bg);
  color: var(--bs-body-color);
  font-size: 0.8125rem;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  text-align: left;
  min-height: 44px;
}
.ft-picker-btn:hover {
  border-color: var(--bs-primary);
  background: var(--bs-primary-bg-subtle);
}
.ft-picker-btn.active {
  border-color: var(--bs-primary);
  background: var(--bs-primary-bg-subtle);
  color: var(--bs-primary-text-emphasis);
  font-weight: 500;
}
.ft-picker-btn i {
  font-size: 1rem;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

/* ── Template builder ───────────────────────────────────────── */

:root {
  /* Vertical offset for builder sticky elements: sticky header height + gap */
  --builder-sticky-top: 72px;
  /* Toast region clearance above the sticky bottom action bar */
  --toast-clearance: 84px;
}

/* Wide layout for the 3-pane builder (nav / canvas / palette) */
.page-wide { max-width: 1400px; }

/* Flex-child truncation helper: Bootstrap 5 has no min-width utility, but
   text-truncate only works inside flex rows when the child may shrink */
.min-w-0 { min-width: 0; }

/* Side panels (section nav + field palette) stick below the header */
.builder-side {
  position: sticky;
  top: var(--builder-sticky-top);
  max-height: calc(100vh - var(--builder-sticky-top) - 1rem);
  display: flex;
  flex-direction: column;
}
.section-nav,
.field-palette {
  overflow-y: auto;
  min-height: 0;
}

/* Section nav entries (desktop sidebar) */
.section-nav-item {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.375rem 0.5rem;
  border-radius: var(--bs-border-radius);
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--bs-body-color);
  min-height: 44px; /* uiux-rules: tappable elements ≥ 44px */
}
.section-nav-item:hover {
  background: var(--bs-secondary-bg-subtle);
}
.section-nav-item.active {
  background: var(--bs-primary-bg-subtle);
  color: var(--bs-primary-text-emphasis);
  font-weight: 500;
}

/* Mobile section chips: horizontally scrollable, sticky under the header */
.section-chips {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  position: sticky;
  top: var(--builder-sticky-top);
  z-index: 1;
  padding: 0.25rem 0;
}
.section-chips:empty { display: none; }
.section-chip {
  flex-shrink: 0;
  border: 1px solid var(--bs-border-color);
  border-radius: 999px;
  background: var(--bs-card-bg);
  color: var(--bs-body-color);
  font-size: 0.8125rem;
  padding: 0.375rem 0.875rem;
  min-height: 44px; /* uiux-rules: tappable elements ≥ 44px */
  white-space: nowrap;
}
.section-chip.active {
  border-color: var(--bs-primary);
  background: var(--bs-primary-bg-subtle);
  color: var(--bs-primary-text-emphasis);
  font-weight: 500;
}

/* Drag handles */
.drag-handle {
  cursor: grab;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  min-height: 44px; /* uiux-rules: tappable elements ≥ 44px */
  touch-action: none;
  flex-shrink: 0;
}
.drag-handle:active { cursor: grabbing; }
.no-drag .drag-handle { display: none; }

/* Section cards land just below the sticky header when jumped to from the nav */
.builder-section { scroll-margin-top: var(--builder-sticky-top); }

/* Item lists are drop targets; keep a visible zone when empty */
.item-list:empty {
  min-height: 56px;
  border: 1px dashed var(--bs-border-color);
  border-radius: var(--bs-border-radius);
  display: flex;
  align-items: center;
  justify-content: center;
}
.item-list:empty::after {
  content: "Drop a field here, or use Add item";
  color: var(--bs-tertiary-color);
  font-size: 0.8125rem;
}

/* SortableJS state classes */
.sortable-ghost {
  opacity: 0.4;
  background: var(--bs-primary-bg-subtle);
  border-radius: var(--bs-border-radius);
}
.sortable-chosen { background: var(--bs-secondary-bg-subtle); }
.sortable-drag { opacity: 0.9; }

/* Palette fields fill the sidebar width, one per row */
.palette-group {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.375rem;
  margin-bottom: 0.5rem;
}
.palette-field { cursor: grab; }

/* Autocomplete preview list inside the item modal */
.ac-preview-list {
  max-height: 200px;
  overflow-y: auto;
}

/* Utility: soft card hover */
.card-hover:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  transition: box-shadow 0.15s ease;
}

/* Extended spacing utilities (Bootstrap stops at 5) */
.py-6 { padding-top: 4rem !important; padding-bottom: 4rem !important; }
.py-lg-7 { padding-top: 5rem !important; padding-bottom: 5rem !important; }
@media (min-width: 992px) {
  .py-lg-7 { padding-top: 5rem !important; padding-bottom: 5rem !important; }
}
.p-6 { padding: 4rem !important; }
.p-lg-6 { padding: 4rem !important; }
@media (min-width: 992px) {
  .p-lg-6 { padding: 4.5rem !important; }
}

/* ── Landing Page ───────────────────────────────────────────── */

/* Navbar */
#mainNav {
  transition: background .2s, box-shadow .2s;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  background: transparent;
}
#mainNav.scrolled {
  background: rgba(255,255,255,.92);
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.nav-pill {
  border-radius: 999px;
  padding: .375rem 1rem !important;
  font-size: .875rem;
  color: var(--bs-body-color) !important;
}
.nav-pill:hover {
  background: var(--bs-primary-bg-subtle);
  color: var(--bs-primary) !important;
}
.btn-pill { border-radius: 999px; }
.rs-1 { letter-spacing: .01em; }

/* Hero */
.hero {
  background: linear-gradient(135deg, #F8FAFC 0%, #EEF2FF 50%, #E0E7FF 100%);
  min-height: 100vh;
  display: flex;
  align-items: center;
}
.hero-bg-shapes {
  position: absolute; inset: 0; overflow: hidden; pointer-events: none;
}
.shape {
  position: absolute; border-radius: 50%;
}
.shape-1 {
  width: 400px; height: 400px; background: radial-gradient(circle, rgba(79,70,229,.08) 0%, transparent 70%);
  top: -100px; right: -80px;
}
.shape-2 {
  width: 300px; height: 300px; background: radial-gradient(circle, rgba(79,70,229,.06) 0%, transparent 70%);
  bottom: -60px; left: -60px;
}
.shape-3 {
  width: 200px; height: 200px; background: radial-gradient(circle, rgba(79,70,229,.05) 0%, transparent 70%);
  top: 40%; left: 50%;
}
.grid-overlay {
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(79,70,229,.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(79,70,229,.03) 1px, transparent 1px);
  background-size: 60px 60px;
}
.hero-badge {
  font-size: .8125rem;
}
.status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--bs-success); display: inline-block;
  animation: pulse-dot 2s infinite;
}
@keyframes pulse-dot {
  0%,100% { opacity: 1; }
  50% { opacity: .4; }
}
.hero-title { letter-spacing: -.03em; }
.text-gradient {
  background: linear-gradient(135deg, var(--bs-primary) 0%, #818CF8 50%, #6366F1 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.max-w-lg { max-width: 540px; }
.hero-stats .display-6 { color: var(--bs-primary); }

/* Hero visual */
.visual-container {
  position: relative; width: 100%; padding-bottom: 100%;
}
.visual-ring {
  position: absolute; inset: 0; border-radius: 50%;
  border: 1px solid var(--bs-border-color);
}
.ring-1 { top: 5%; left: 5%; right: 5%; bottom: 5%; }
.ring-2 { top: 15%; left: 15%; right: 15%; bottom: 15%; }
.ring-3 { top: 25%; left: 25%; right: 25%; bottom: 25%; }
.visual-card {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%);
  background: var(--bs-card-bg); border-radius: var(--bs-border-radius-lg);
  padding: 1.25rem; width: 220px;
  box-shadow: 0 8px 24px rgba(0,0,0,.08);
  border: 1px solid var(--bs-border-color);
}
.avatar {
  width: 40px; height: 40px; font-size: .8125rem; flex-shrink: 0;
}
.tiny { font-size: .6875rem; }
.visual-float {
  position: absolute;
}
.vf-1 { top: 18%; right: -10px; }
.vf-2 { bottom: 18%; left: -10px; }

/* Counters */
.counter { font-variant-numeric: tabular-nums; }

/* Reveal animation */
.reveal {
  opacity: 0; transform: translateY(24px);
  transition: opacity .6s ease, transform .6s ease;
}
.revealed {
  opacity: 1; transform: translateY(0);
}

/* Features section */
.features-section {
  background: var(--bs-body-bg);
}
.ls-lg { letter-spacing: .08em; }
.feature-tile {
  background: var(--bs-card-bg);
  border: 1px solid var(--bs-border-color);
  transition: box-shadow .2s, transform .2s;
}
.feature-tile:hover {
  box-shadow: 0 8px 24px rgba(0,0,0,.06);
  transform: translateY(-2px);
}
.feature-icon-lg {
  width: 56px; height: 56px; display: flex;
  align-items: center; justify-content: center;
}

/* Workflow section */
.workflow-section {
  background: var(--bs-card-bg);
  border-top: 1px solid var(--bs-border-color);
  border-bottom: 1px solid var(--bs-border-color);
}
.workflow-track {
  display: flex; justify-content: space-between;
  position: relative; padding: 2rem 0;
}
.workflow-track::before {
  content: ''; position: absolute; top: 2rem; left: 0; right: 0;
  height: 2px; background: var(--bs-border-color); z-index: 0;
}
.workflow-step {
  display: flex; flex-direction: column; align-items: center;
  position: relative; z-index: 1; flex: 1; text-align: center;
}
.step-dot {
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--bs-border-color); border: 3px solid var(--bs-card-bg);
  margin-bottom: .5rem; transition: background .3s;
}
.workflow-step.active .step-dot,
.workflow-step:hover .step-dot {
  background: var(--bs-primary);
}
.step-label {
  font-weight: 600; font-size: .875rem; margin-bottom: .25rem;
}
.step-desc {
  font-size: .75rem; color: var(--bs-secondary-color); max-width: 120px;
}

/* Analytics section */
.analytics-section {
  background: linear-gradient(180deg, var(--bs-body-bg) 0%, #EEF2FF 100%);
}
.icon-box {
  width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.analytics-card-inner {
  animation: float-y 6s ease-in-out infinite;
}
@keyframes float-y {
  0%,100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

/* Field types section */
.types-section {
  background: var(--bs-body-bg);
}
.field-types-grid {
  display: flex; flex-wrap: wrap; gap: .75rem;
  justify-content: center; max-width: 780px; margin: 0 auto;
}
.field-type-chip {
  padding: .5rem 1.25rem; border-radius: 999px;
  border: 1px solid var(--bs-border-color);
  background: var(--bs-card-bg);
  font-size: .875rem; transition: border-color .2s, box-shadow .2s;
}
.field-type-chip:hover {
  border-color: var(--bs-primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,.1);
}
.badge-soft {
  background: var(--bs-primary-bg-subtle);
  color: var(--bs-primary-text-emphasis);
  font-weight: 500; margin-left: .25rem;
}

/* CTA section */
.cta-section {
  background: var(--bs-body-bg);
}
.cta-card {
  background: linear-gradient(135deg, var(--bs-primary) 0%, #6366F1 100%);
  color: #fff;
}
.cta-shape {
  position: absolute; border-radius: 50%; pointer-events: none;
}
.cta-shape-1 {
  width: 300px; height: 300px; background: rgba(255,255,255,.06);
  top: -100px; right: -60px;
}
.cta-shape-2 {
  width: 200px; height: 200px; background: rgba(255,255,255,.04);
  bottom: -80px; left: -40px;
}

/* Footer */
.footer a:hover { color: var(--bs-primary) !important; }

/* Responsive */
@media (max-width: 991.98px) {
  .hero-title { font-size: calc(2.5rem + 1.5vw); }
  .visual-container { padding-bottom: 60%; margin-top: 2rem; }
  .visual-card { width: 180px; }
  .workflow-track { flex-direction: column; gap: 1.5rem; align-items: flex-start; }
  .workflow-track::before { display: none; }
  .workflow-step { flex-direction: row; gap: 1rem; text-align: left; }
  .step-dot { margin-bottom: 0; flex-shrink: 0; }
  .step-desc { max-width: none; }
  .field-types-grid { gap: .5rem; }
  .field-type-chip { font-size: .8125rem; padding: .375rem 1rem; }
}

@media (max-width: 575.98px) {
  .hero-title { font-size: 2rem; }
  .hero-stats .display-6 { font-size: 1.75rem; }
  .feature-tile { padding: 1.5rem !important; }
  .cta-card { padding: 2rem 1.5rem !important; }
}

/* ── Proof photos (attach to any question) ──────────────── */
.audit-photo-thumb-wrap {
  width: 4.5rem;
  height: 4.5rem;
  margin-top: 0.75rem; /* clearance for the overhanging remove button below */
}
.audit-photo-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.audit-photo-remove {
  position: absolute;
  top: -0.75rem;
  right: -0.75rem;
  width: 44px; /* uiux-rules: tappable elements >= 44px, even over a small thumb */
  height: 44px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

/* ── Audit wizard (one question at a time) ─────────────────── */
:root {
  /* Thin top progress bar height for the audit wizard */
  --wizard-progress-height: 6px;
}

.wizard-progress {
  height: var(--wizard-progress-height);
  background-color: var(--bs-border-color);
}
.wizard-progress .progress-bar {
  background-color: var(--bs-primary);
}

/* Focus-mode back button: circular, matches the 44px touch-target rules */
.wizard-back-btn {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

/* Desktop question list (sidebar) rows: compact version of the
   offcanvas jump-drawer rows, sized to fit the .builder-side rail */
#jumpSidebarList .list-group-item {
  padding: 0.5rem;
  border-radius: var(--bs-border-radius);
  font-size: 0.8125rem;
}
#jumpSidebarList .list-group-item + .list-group-item {
  margin-top: 0.125rem;
}

/* Cap the single-question card's reading width once the sidebar frees up
   the rest of the row - a lone label + input shouldn't stretch edge to
   edge on wide screens, unlike the review list, which reads fine full-width */
#wizardContainer .card {
  max-width: 42rem;
}

/* ── Scanner ─────────────────────────────────────────────── */
.scanner-viewport {
  max-width: 480px;
  aspect-ratio: 4 / 3;
}

.scanner-video {
  object-fit: cover;
}

.scanner-reticle {
  width: 60%;
  height: 50%;
  pointer-events: none;
  opacity: 0.7;
}
