/* ReceiptSubmitter — app.css
   Mobile-first, no framework, no build step.
   Tested on iOS Safari and Android Chrome.
   ─────────────────────────────────────────── */

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

:root {
  --blue:        #1a7a6e;
  --blue-dark:   #135f55;
  --blue-light:  #e0f2ef;
  --green:       #1e8e3e;
  --green-light: #e6f4ea;
  --red:         #d93025;
  --red-light:   #fce8e6;
  --gray-50:     #f8f9fa;
  --gray-100:    #f1f3f4;
  --gray-200:    #e8eaed;
  --gray-400:    #9aa0a6;
  --gray-700:    #5f6368;
  --gray-900:    #202124;
  --radius:      12px;
  --radius-sm:   8px;
  --shadow:      0 1px 3px rgba(0,0,0,.12), 0 1px 2px rgba(0,0,0,.08);
  --shadow-md:   0 4px 12px rgba(0,0,0,.15);
  --font:        -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

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

body {
  font-family: var(--font);
  color: var(--gray-900);
  background: var(--gray-100);
  min-height: 100dvh;
  line-height: 1.5;
}

/* ── Layout ───────────────────────────────────────────────────────────── */
.container {
  max-width: 540px;
  margin: 0 auto;
  padding: 0 0 40px;
}

/* ── Header ───────────────────────────────────────────────────────────── */
.app-header {
  background: var(--blue);
  color: #fff;
  padding: 24px 20px 20px;
  text-align: center;
}

.app-header h1 {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -.01em;
}

.subtitle {
  font-size: .875rem;
  opacity: .85;
  margin-top: 4px;
}

/* ── Form sections ────────────────────────────────────────────────────── */
.form-section {
  background: #fff;
  margin: 16px 12px 0;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

.section-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--gray-200);
}

/* ── Photo area ───────────────────────────────────────────────────────── */
.photo-area {
  position: relative;
}

/* Two-button row: camera + file picker */
.photo-buttons {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  gap: 10px;
  width: 100%;
}

.photo-btn {
  -webkit-box-flex: 1;
      -ms-flex: 1 1 0%;
          flex: 1 1 0%;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-orient: vertical;
  -webkit-box-direction: normal;
      -ms-flex-direction: column;
          flex-direction: column;
  -webkit-box-align: center;
      -ms-flex-align: center;
          align-items: center;
  -webkit-box-pack: center;
      -ms-flex-pack: center;
          justify-content: center;
  gap: 6px;
  min-height: 100px;
  padding: 16px 8px;
  border: 2px solid var(--gray-400);
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: center;
  background: var(--gray-50);
  -webkit-transition: border-color .2s, background .2s;
          transition: border-color .2s, background .2s;
  -webkit-user-select: none;
     -moz-user-select: none;
      -ms-user-select: none;
          user-select: none;
  box-sizing: border-box;
}

.photo-btn:hover,
.photo-btn:active {
  border-color: var(--blue);
  background: var(--blue-light);
}

.photo-btn-icon {
  font-size: 2rem;
  line-height: 1;
  display: block;
}

.photo-btn-label {
  font-size: .875rem;
  font-weight: 500;
  color: var(--blue);
  display: block;
}

.photo-hint-global {
  display: block;
  text-align: center;
  font-size: .75rem;
  color: var(--gray-400);
  margin-top: 8px;
}

/* ── Mode toggle ──────────────────────────────────────────────────────────── */
.mode-toggle {
  display: flex;
  gap: 10px;
}

.mode-option {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 10px;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: center;
  transition: border-color .2s, background .2s;
  background: var(--gray-50);
  user-select: none;
}

.mode-option input[type="radio"] {
  /* Visually hidden — label acts as the control */
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.mode-option:hover {
  border-color: var(--blue);
  background: var(--blue-light);
}

.mode-option--active {
  border-color: var(--blue);
  background: var(--blue-light);
}

.mode-icon {
  font-size: 1.75rem;
  line-height: 1;
}

.mode-label {
  font-size: .875rem;
  font-weight: 500;
  color: var(--gray-700);
}

.mode-option--active .mode-label {
  color: var(--blue-dark);
  font-weight: 600;
}

/* ── Checkbox label (international plate) ─────────────────────────────────── */
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  font-size: .875rem;
  color: var(--gray-700);
  cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--blue);
  cursor: pointer;
  flex-shrink: 0;
}

/* ── File input ───────────────────────────────────────────────────────────── */
.file-input {
  /* Visually hidden but accessible */
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
}

.photo-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 140px;
  border: 2px dashed var(--gray-400);
  border-radius: var(--radius-sm);
  cursor: pointer;
  padding: 24px 16px;
  text-align: center;
  transition: border-color .2s, background .2s;
  background: var(--gray-50);
}

.photo-label:hover,
.photo-label:focus-within {
  border-color: var(--blue);
  background: var(--blue-light);
}

.photo-icon {
  font-size: 2.5rem;
  line-height: 1;
}

.photo-text {
  font-size: 1rem;
  font-weight: 500;
  color: var(--blue);
}

.photo-hint {
  font-size: .75rem;
  color: var(--gray-400);
}

/* Image preview */
.image-preview {
  width: 100%;
  max-height: 300px;
  object-fit: contain;
  border-radius: var(--radius-sm);
  border: 1px solid var(--gray-200);
  margin-top: 12px;
  background: var(--gray-50);
}

.btn-remove {
  display: block;
  width: 100%;
  margin-top: 10px;
  padding: 8px;
  background: none;
  border: 1px solid var(--red);
  color: var(--red);
  border-radius: var(--radius-sm);
  font-size: .875rem;
  cursor: pointer;
  transition: background .15s;
}

.btn-remove:hover {
  background: var(--red-light);
}

/* ── Form fields ──────────────────────────────────────────────────────── */
.field {
  margin-bottom: 18px;
}

.field:last-child {
  margin-bottom: 0;
}

.field label {
  display: block;
  font-size: .875rem;
  font-weight: 500;
  color: var(--gray-700);
  margin-bottom: 6px;
}

.optional {
  font-weight: 400;
  color: var(--gray-400);
  font-size: .8rem;
}

.required-marker {
  font-weight: 600;
  color: var(--red);
  font-size: .9rem;
}

.field input,
.field textarea {
  width: 100%;
  padding: 12px 14px;
  font-size: 1rem;
  font-family: var(--font);
  color: var(--gray-900);
  background: #fff;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color .2s, box-shadow .2s;
  -webkit-appearance: none;
  appearance: none;
}

.field input:focus,
.field textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(26,115,232,.15);
}

.field input.invalid,
.field textarea.invalid {
  border-color: var(--red);
}

.field textarea {
  resize: vertical;
  min-height: 80px;
}

/* ── Field errors ─────────────────────────────────────────────────────── */
.field-error {
  display: block;
  font-size: .8rem;
  color: var(--red);
  margin-top: 4px;
  min-height: 1.2em;
}

/* ── Turnstile widget ─────────────────────────────────────────────────── */
.cf-turnstile {
  margin: 16px 12px 0;
  display: flex;
  justify-content: center;
}

/* ── Submit button ────────────────────────────────────────────────────── */
.submit-area {
  margin: 16px 12px 0;
}

.btn-submit {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 16px;
  font-size: 1.0625rem;
  font-weight: 600;
  font-family: var(--font);
  color: #fff;
  background: var(--blue);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: background .2s, box-shadow .2s;
  -webkit-appearance: none;
  appearance: none;
}

.btn-submit:hover {
  background: var(--blue-dark);
  box-shadow: var(--shadow-md);
}

.btn-submit:active {
  transform: scale(.98);
}

.btn-submit:disabled {
  background: var(--gray-400);
  cursor: not-allowed;
  box-shadow: none;
}

/* ── Spinner ──────────────────────────────────────────────────────────── */
.spinner {
  width: 20px;
  height: 20px;
  border: 2.5px solid rgba(255,255,255,.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  flex-shrink: 0;
}

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

/* ── Form message (success / error banner) ────────────────────────────── */
.form-message {
  margin: 16px 12px 0;
  padding: 16px 18px;
  border-radius: var(--radius);
  font-size: .9375rem;
  line-height: 1.5;
}

.form-message.success {
  background: var(--green-light);
  color: var(--green);
  border: 1px solid #a8d5b5;
}

.form-message.error {
  background: var(--red-light);
  color: var(--red);
  border: 1px solid #f5c6c3;
}

/* ── Footer ───────────────────────────────────────────────────────────── */
.app-footer {
  text-align: center;
  padding: 24px 20px 8px;
  font-size: .75rem;
  color: var(--gray-400);
}

/* ── Utility ──────────────────────────────────────────────────────────── */
.hidden {
  display: none !important;
}

/* ── Responsive: larger screens ───────────────────────────────────────── */
@media (min-width: 600px) {
  .container {
    padding-top: 24px;
    padding-bottom: 60px;
  }

  .app-header {
    border-radius: var(--radius) var(--radius) 0 0;
  }
}
