/* ─── Reset & Variables ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --navy:       #1a3f57;
  --navy-dark:  #112b3c;
  --teal:       #127cbf;
  --teal-light: #1a90d9;
  --green:      #79a127;
  --green-dark: #628020;
  --blue-light: #47acec;
  --pale-blue:  #e1f5ff;
  --pale-blue2: #c8eafb;
  --white:      #ffffff;
  --gray-50:    #f8fafc;
  --gray-100:   #f0f4f8;
  --gray-200:   #e2eaf2;
  --gray-400:   #94a3b8;
  --gray-600:   #64748b;
  --gray-800:   #334155;
  --danger:     #e53e3e;
  --warning:    #f59e0b;
  --success:    #38a169;

  --radius-sm:  8px;
  --radius:     14px;
  --radius-lg:  20px;
  --shadow-sm:  0 1px 3px rgba(0,0,0,.12), 0 1px 2px rgba(0,0,0,.08);
  --shadow:     0 4px 16px rgba(26,63,87,.15);
  --shadow-lg:  0 8px 32px rgba(26,63,87,.22);
  --transition: 0.22s ease;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--navy);
  color: var(--gray-800);
  min-height: 100dvh;
  overflow-x: hidden;
}

/* ─── App Shell ─────────────────────────────────────────────────── */
#app {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  max-width: 520px;
  margin: 0 auto;
  background: var(--gray-50);
}

/* ─── Header ────────────────────────────────────────────────────── */
.app-header {
  background: var(--navy);
  padding: 12px 20px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 12px rgba(0,0,0,.3);
}

.header-logo {
  width: 44px;
  height: 44px;
  object-fit: contain;
  filter: brightness(1.1);
}

.header-text h1 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--white);
  line-height: 1.2;
}

.header-text p {
  font-size: 0.72rem;
  color: var(--blue-light);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 500;
}

/* ─── Progress Bar ──────────────────────────────────────────────── */
.progress-container {
  background: var(--navy-dark);
  padding: 10px 20px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.progress-steps {
  display: flex;
  gap: 6px;
  flex: 1;
}

.progress-step {
  flex: 1;
  height: 4px;
  border-radius: 2px;
  background: rgba(255,255,255,.2);
  transition: background var(--transition);
  position: relative;
  overflow: hidden;
}

.progress-step.done {
  background: var(--green);
}

.progress-step.active {
  background: rgba(255,255,255,.2);
}

.progress-step.active::after {
  content: '';
  position: absolute;
  left: 0; top: 0;
  height: 100%;
  width: 60%;
  background: var(--teal);
  border-radius: 2px;
  animation: progress-pulse 1.4s ease-in-out infinite;
}

@keyframes progress-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.progress-label {
  font-size: 0.7rem;
  color: rgba(255,255,255,.6);
  white-space: nowrap;
  font-weight: 500;
}

/* ─── Screens ───────────────────────────────────────────────────── */
.screen {
  display: none;
  flex-direction: column;
  flex: 1;
  animation: slideIn var(--transition) ease;
}

.screen.active {
  display: flex;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(24px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes slideInBack {
  from { opacity: 0; transform: translateX(-24px); }
  to   { opacity: 1; transform: translateX(0); }
}

.screen.back-anim { animation: slideInBack var(--transition) ease; }

/* ─── Welcome Screen ────────────────────────────────────────────── */
.welcome-hero {
  background: linear-gradient(160deg, var(--navy) 0%, var(--teal) 100%);
  padding: 36px 24px 40px;
  text-align: center;
  color: var(--white);
  position: relative;
  overflow: hidden;
}

.welcome-hero::before {
  content: '';
  position: absolute;
  bottom: -1px; left: 0; right: 0;
  height: 40px;
  background: var(--gray-50);
  clip-path: ellipse(55% 100% at 50% 100%);
}

.welcome-logo {
  width: 100px;
  height: 100px;
  margin: 0 auto 16px;
  display: block;
  filter: drop-shadow(0 4px 12px rgba(0,0,0,.3));
}

.welcome-hero h2 {
  font-size: 1.7rem;
  font-weight: 800;
  margin-bottom: 8px;
  text-shadow: 0 2px 8px rgba(0,0,0,.2);
}

.welcome-hero p {
  font-size: 0.95rem;
  opacity: 0.88;
  max-width: 320px;
  margin: 0 auto;
  line-height: 1.5;
}

.welcome-body {
  padding: 28px 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.info-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
  border-left: 4px solid var(--teal);
}

.info-card.warning { border-left-color: var(--warning); }
.info-card.danger  { border-left-color: var(--danger); }
.info-card.success { border-left-color: var(--success); }

.info-card h3 {
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--teal);
  margin-bottom: 6px;
}

.info-card.warning h3 { color: var(--warning); }
.info-card.danger  h3 { color: var(--danger); }
.info-card.success h3 { color: var(--success); }

.info-card p, .info-card ul {
  font-size: 0.88rem;
  color: var(--gray-600);
  line-height: 1.55;
}

.info-card ul { padding-left: 16px; }
.info-card li { margin-bottom: 3px; }

.emergency-call-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: var(--danger);
  color: var(--white);
  border: none;
  border-radius: var(--radius);
  padding: 16px 20px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  box-shadow: 0 4px 14px rgba(229,62,62,.4);
  transition: all var(--transition);
  -webkit-tap-highlight-color: transparent;
}

.emergency-call-btn:active {
  transform: scale(0.97);
  box-shadow: 0 2px 8px rgba(229,62,62,.3);
}

.emergency-call-btn svg { flex-shrink: 0; }

/* ─── Form Sections ─────────────────────────────────────────────── */
.screen-body {
  padding: 20px 20px 100px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.section-header {
  text-align: center;
  padding: 24px 20px 4px;
}

.section-icon {
  font-size: 2.4rem;
  line-height: 1;
  margin-bottom: 8px;
}

.section-header h2 {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--navy);
  margin-bottom: 4px;
}

.section-header p {
  font-size: 0.85rem;
  color: var(--gray-600);
  line-height: 1.45;
}

/* ─── Form Controls ─────────────────────────────────────────────── */
.form-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-sm);
}

.form-card h3 {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--teal);
  margin-bottom: 14px;
}

.field-group { display: flex; flex-direction: column; gap: 12px; }

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.field label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--gray-800);
}

.field label .req { color: var(--danger); }

.field input,
.field select,
.field textarea {
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  font-size: 0.95rem;
  color: var(--gray-800);
  background: var(--white);
  transition: border-color var(--transition), box-shadow var(--transition);
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  font-family: inherit;
}

.field select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 36px;
}

.field textarea {
  min-height: 90px;
  resize: vertical;
  line-height: 1.5;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(18,124,191,.12);
}

.field input.error,
.field select.error { border-color: var(--danger); }

.field-hint {
  font-size: 0.76rem;
  color: var(--gray-400);
  line-height: 1.4;
}

.field-error {
  font-size: 0.76rem;
  color: var(--danger);
  display: none;
}

.field-error.show { display: block; }

/* ─── Radio / Checkbox Groups ───────────────────────────────────── */
.radio-group, .check-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.radio-group.horizontal {
  flex-direction: row;
  flex-wrap: wrap;
  gap: 8px;
}

.radio-option, .check-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.radio-group.horizontal .radio-option {
  flex: 1;
  min-width: 80px;
  justify-content: center;
}

.radio-option input, .check-option input {
  width: 18px; height: 18px;
  accent-color: var(--teal);
  flex-shrink: 0;
  cursor: pointer;
}

.radio-option:has(input:checked),
.check-option:has(input:checked) {
  border-color: var(--teal);
  background: rgba(18,124,191,.06);
}

.radio-option span, .check-option span {
  font-size: 0.88rem;
  color: var(--gray-800);
  font-weight: 500;
}

/* ─── Toggle / Conditional Fields ──────────────────────────────── */
.conditional-field {
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.3s ease, opacity 0.2s ease;
  opacity: 0;
}

.conditional-field.open {
  max-height: 400px;
  opacity: 1;
}

/* ─── GPS Location ──────────────────────────────────────────────── */
.gps-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 14px 20px;
  border: 2px dashed var(--teal);
  border-radius: var(--radius);
  background: rgba(18,124,191,.04);
  color: var(--teal);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  -webkit-tap-highlight-color: transparent;
}

.gps-btn:active { transform: scale(0.98); }

.gps-btn.loading {
  border-style: solid;
  background: rgba(18,124,191,.08);
  pointer-events: none;
}

.gps-btn.success {
  border-style: solid;
  border-color: var(--success);
  background: rgba(56,161,105,.08);
  color: var(--success);
}

.gps-btn.error-state {
  border-color: var(--danger);
  background: rgba(229,62,62,.06);
  color: var(--danger);
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.spin { animation: spin 1s linear infinite; display: inline-block; }

.gps-result {
  background: var(--pale-blue);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-top: 10px;
  display: none;
}

.gps-result.show { display: block; }

.gps-result p {
  font-size: 0.82rem;
  color: var(--navy);
  font-weight: 600;
  margin-bottom: 2px;
}

.gps-result small {
  font-size: 0.74rem;
  color: var(--gray-600);
}

.gps-map-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.76rem;
  color: var(--teal);
  text-decoration: none;
  font-weight: 600;
  margin-top: 6px;
}

/* ─── Photo Upload ──────────────────────────────────────────────── */
.photo-upload-area {
  border: 2px dashed var(--gray-200);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}

.photo-upload-area:hover, .photo-upload-area:focus-within {
  border-color: var(--teal);
  background: rgba(18,124,191,.03);
}

.photo-upload-area input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

.photo-upload-icon { font-size: 2rem; margin-bottom: 8px; }

.photo-upload-area p {
  font-size: 0.85rem;
  color: var(--gray-600);
  margin-bottom: 4px;
  font-weight: 500;
}

.photo-upload-area small {
  font-size: 0.75rem;
  color: var(--gray-400);
}

.photo-preview-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 12px;
}

.photo-thumb {
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  position: relative;
  background: var(--gray-100);
}

.photo-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-thumb .remove-photo {
  position: absolute;
  top: 4px; right: 4px;
  width: 22px; height: 22px;
  background: rgba(0,0,0,.6);
  color: white;
  border: none;
  border-radius: 50%;
  font-size: 0.75rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

/* ─── Review Screen ─────────────────────────────────────────────── */
.review-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-sm);
}

.review-card h3 {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--teal);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--gray-100);
}

.review-row {
  display: flex;
  gap: 8px;
  padding: 5px 0;
  border-bottom: 1px solid var(--gray-100);
  align-items: flex-start;
}

.review-row:last-child { border-bottom: none; }

.review-label {
  font-size: 0.8rem;
  color: var(--gray-600);
  flex: 0 0 120px;
  padding-top: 1px;
}

.review-value {
  font-size: 0.85rem;
  color: var(--gray-800);
  font-weight: 500;
  flex: 1;
  word-break: break-word;
}

.review-value.missing {
  color: var(--gray-400);
  font-style: italic;
  font-weight: 400;
}

.ref-badge {
  background: var(--pale-blue);
  border: 1px solid var(--pale-blue2);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  text-align: center;
}

.ref-badge p {
  font-size: 0.76rem;
  color: var(--gray-600);
  margin-bottom: 2px;
}

.ref-badge strong {
  font-size: 1rem;
  color: var(--navy);
  letter-spacing: 0.05em;
}

.gdpr-check {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px;
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1.5px solid var(--gray-200);
  cursor: pointer;
  transition: border-color var(--transition);
  -webkit-tap-highlight-color: transparent;
}

.gdpr-check:has(input:checked) { border-color: var(--teal); }

.gdpr-check input {
  width: 20px; height: 20px;
  flex-shrink: 0;
  margin-top: 1px;
  accent-color: var(--teal);
  cursor: pointer;
}

.gdpr-check p {
  font-size: 0.82rem;
  color: var(--gray-600);
  line-height: 1.5;
}

.gdpr-check a { color: var(--teal); }

/* ─── WhatsApp Button ───────────────────────────────────────────── */
.whatsapp-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  padding: 17px 20px;
  background: #25D366;
  color: var(--white);
  border: none;
  border-radius: var(--radius);
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  box-shadow: 0 4px 16px rgba(37,211,102,.4);
  transition: all var(--transition);
  -webkit-tap-highlight-color: transparent;
}

.whatsapp-btn:active {
  transform: scale(0.97);
  box-shadow: 0 2px 8px rgba(37,211,102,.3);
}

.whatsapp-btn svg { flex-shrink: 0; }

.whatsapp-note {
  font-size: 0.78rem;
  color: var(--gray-600);
  text-align: center;
  padding: 0 8px;
  line-height: 1.5;
}

/* ─── Navigation Buttons ────────────────────────────────────────── */
.nav-bar {
  position: fixed;
  bottom: 0; left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 520px;
  background: var(--white);
  border-top: 1px solid var(--gray-200);
  padding: 12px 20px;
  display: flex;
  gap: 10px;
  z-index: 200;
  box-shadow: 0 -4px 20px rgba(0,0,0,.08);
}

.btn {
  flex: 1;
  padding: 13px 16px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition);
  -webkit-tap-highlight-color: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--green);
  color: var(--white);
  box-shadow: 0 2px 10px rgba(121,161,39,.35);
}

.btn-primary:active { background: var(--green-dark); }

.btn-secondary {
  background: var(--gray-100);
  color: var(--gray-800);
  flex: 0 0 auto;
  padding: 13px 18px;
}

.btn-secondary:active { background: var(--gray-200); }

.btn-teal {
  background: var(--teal);
  color: var(--white);
  box-shadow: 0 2px 10px rgba(18,124,191,.35);
}

.btn:disabled {
  opacity: 0.45;
  pointer-events: none;
}

/* ─── Utility ───────────────────────────────────────────────────── */
.hidden { display: none !important; }
.text-center { text-align: center; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.divider { height: 1px; background: var(--gray-200); margin: 4px 0; }

/* Seal separator wave */
.wave-divider {
  width: 100%;
  height: 20px;
  background: linear-gradient(90deg, var(--teal) 0%, var(--blue-light) 50%, var(--teal) 100%);
  clip-path: polygon(0 50%, 5% 0, 10% 50%, 15% 100%, 20% 50%, 25% 0, 30% 50%, 35% 100%, 40% 50%, 45% 0, 50% 50%, 55% 100%, 60% 50%, 65% 0, 70% 50%, 75% 100%, 80% 50%, 85% 0, 90% 50%, 95% 100%, 100% 50%, 100% 100%, 0 100%);
  opacity: 0.25;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 90px; left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--navy);
  color: var(--white);
  padding: 10px 20px;
  border-radius: 100px;
  font-size: 0.85rem;
  font-weight: 500;
  opacity: 0;
  transition: all 0.3s ease;
  z-index: 300;
  white-space: nowrap;
  box-shadow: var(--shadow-lg);
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ─── Animations ────────────────────────────────────────────────── */
@keyframes bounce-in {
  0%   { transform: scale(0.8); opacity: 0; }
  60%  { transform: scale(1.06); opacity: 1; }
  100% { transform: scale(1); }
}

.bounce-in { animation: bounce-in 0.4s ease forwards; }

/* ─── Responsive tweaks for very small screens ──────────────────── */
@media (max-width: 360px) {
  .section-header h2 { font-size: 1.15rem; }
  .btn { font-size: 0.88rem; padding: 12px 12px; }
}

/* ─── iOS safe area support ─────────────────────────────────────── */
@supports (padding: max(0px)) {
  .nav-bar { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
}
