/* ธีมเดียวกับ diageo.b2cgroups.com (app.css) */
:root {
  --navy: #15233a;
  --navy-2: #1c2f4d;
  --navy-soft: #243a5c;
  --gold: #c6a15b;
  --gold-2: #d4b36d;
  --gold-deep: #9a7a3a;
  --bg: #eef1f5;
  --card: #ffffff;
  --text: #141414;
  --muted: #6b7280;
  --line: #e5e9ef;
  --shadow: 0 10px 30px rgba(21, 35, 58, 0.08);
  --radius: 18px;
  --danger: #b42318;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body { min-height: 100%; }

body.apply-body {
  font-family: "IBM Plex Sans Thai", "Sarabun", sans-serif;
  min-height: 100vh;
  background:
    radial-gradient(800px 400px at 10% 0%, rgba(198, 161, 91, 0.18), transparent 50%),
    linear-gradient(180deg, #0f1b2e 0%, #15233a 45%, #1c2f4d 100%);
  color: #fff;
}

.apply-stage {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: 0 16px 32px;
  padding-top: max(20px, env(safe-area-inset-top));
  padding-bottom: max(32px, env(safe-area-inset-bottom));
}

.apply-brand {
  text-align: center;
  margin-bottom: 18px;
  position: relative;
}

.back-link {
  position: absolute;
  left: 0;
  top: 4px;
  color: var(--gold);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
}

.apply-logo {
  display: block;
  width: min(180px, 58vw);
  height: auto;
  background: #fff;
  border-radius: 16px;
  padding: 10px 14px;
  margin: 0 auto 14px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.28);
}

.apply-title {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 6px;
  letter-spacing: 0.01em;
}

.apply-sub {
  color: rgba(255, 255, 255, 0.68);
  font-size: 14px;
  line-height: 1.45;
  margin-bottom: 16px;
}

.apply-step {
  margin: 0 0 4px;
  color: var(--gold);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
}

.apply-position {
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  margin-bottom: 4px;
}

.apply-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}

.apply-screen { display: none; }
.apply-screen.active { display: block; }

.d-none { display: none !important; }

/* ── Step navigation ── */
.step-nav {
  display: flex;
  gap: 6px;
  margin: 14px 0 12px;
  flex-wrap: wrap;
  justify-content: center;
}

.step-item {
  flex: 1;
  min-width: 90px;
  text-align: center;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.45);
  padding: 8px 4px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  line-height: 1.3;
}

.step-item span {
  display: block;
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 2px;
}

.step-item.active {
  color: #fff;
  border-color: rgba(198, 161, 91, 0.55);
  background: rgba(198, 161, 91, 0.15);
}

.step-item.done {
  color: rgba(255, 255, 255, 0.75);
  border-color: rgba(110, 231, 183, 0.35);
}

/* ── Document viewer ── */
.doc-card-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}

.doc-card-desc {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 12px;
}

.pdf-viewer-wrap {
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: #f4f6f9;
  margin-bottom: 10px;
}

.pdf-frame {
  display: block;
  width: 100%;
  height: min(420px, 55vh);
  border: 0;
  background: #fff;
}

.pdf-embed {
  display: block;
  width: 100%;
  height: min(360px, 50vh);
  border: 0;
  background: #fff;
}

.pdf-mobile-hint {
  padding: 14px;
  margin-bottom: 12px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 12px;
  color: #1e3a5f;
  font-size: 14px;
  line-height: 1.45;
}

.pdf-mobile-hint p {
  margin-bottom: 10px;
}

.pdf-mobile-hint .apply-submit {
  margin-top: 0;
}

.doc-layout {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.doc-layout-viewer,
.doc-layout-actions {
  min-width: 0;
}

.action-stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pdf-open-link {
  display: block;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  color: #1d4ed8;
  margin-bottom: 14px;
  text-decoration: none;
}

.no-pdf-msg {
  padding: 24px 16px;
  background: #f7f9fc;
  border: 1px dashed var(--line);
  border-radius: 12px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 14px;
}

.confirm-check {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
  font-size: 14px;
  color: var(--text);
  margin: 12px 0 16px;
  padding: 14px;
  background: #f7f9fc;
  border: 1px solid var(--line);
  border-radius: 12px;
  cursor: pointer;
  line-height: 1.5;
  text-align: left;
}

.confirm-check input[type="checkbox"] {
  width: 20px !important;
  height: 20px !important;
  min-width: 20px !important;
  max-width: 20px !important;
  margin: 2px 0 0 !important;
  padding: 0 !important;
  flex-shrink: 0;
  accent-color: var(--gold);
  cursor: pointer;
}

.confirm-check span {
  flex: 1;
  min-width: 0;
  display: block;
}

.form-step-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--gold-deep);
  margin-bottom: 4px;
}

.form-grid-2 {
  display: grid;
  gap: 12px;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 999px;
  padding: 14px 22px;
  min-height: 48px;
  font-weight: 600;
  font-family: inherit;
  font-size: 15px;
  cursor: pointer;
  margin-top: 0;
  -webkit-tap-highlight-color: transparent;
}

.btn-outline:hover {
  border-color: var(--gold);
  color: var(--gold-deep);
}

/* การ์ดเอกสาร — ไม่ใช้ grid บีบ layout */
.apply-form.doc-card {
  display: block;
}

.doc-card > * + * {
  margin-top: 0;
}

.doc-card .doc-card-title,
.doc-card .doc-card-desc {
  margin-top: 0;
}

.doc-card .doc-card-desc {
  margin-top: 4px;
}

.doc-card .apply-submit,
.doc-card .btn-outline {
  width: 100%;
}
/* การ์ดฟอร์มสีขาว — เหมือน .login-form */
.apply-form {
  background: var(--card);
  color: var(--text);
  border-radius: var(--radius);
  padding: 20px;
  display: grid;
  gap: 12px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.18);
}

.apply-form .field {
  display: grid;
  gap: 6px;
}

.apply-form label:not(.confirm-check):not(.upload-zone) {
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
}

.apply-form input:not([type="checkbox"]):not([type="radio"]),
.apply-form textarea,
.apply-form select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 16px;
  font-family: inherit;
  background: #f7f9fc;
  color: var(--text);
}

.apply-form input:not([type="checkbox"]):not([type="radio"]):focus,
.apply-form textarea:focus,
.apply-form select:focus {
  outline: 2px solid rgba(198, 161, 91, 0.45);
  outline-offset: 1px;
  background: #fff;
}

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

.upload-zone {
  display: block;
  padding: 24px 16px;
  background: #f7f9fc;
  border: 2px dashed var(--line);
  border-radius: 12px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.upload-zone:hover,
.upload-zone.has-file {
  border-color: rgba(198, 161, 91, 0.55);
  background: #fdf8ef;
}

.upload-icon { font-size: 28px; margin-bottom: 6px; }
.upload-text { font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 2px; }
.upload-hint { font-size: 12px; color: var(--muted); }

.form-error {
  color: var(--danger);
  font-size: 14px;
  padding: 8px 10px;
  background: #fef2f2;
  border-radius: 8px;
}

.form-error.d-none { display: none; }

.btn-gold {
  background: linear-gradient(180deg, var(--gold-2), var(--gold));
  color: #1a1408;
  border: 0;
  border-radius: 999px;
  padding: 14px 22px;
  min-height: 48px;
  font-weight: 700;
  font-family: inherit;
  font-size: 16px;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.apply-submit {
  width: 100%;
  margin-top: 4px;
  text-align: center;
  text-decoration: none;
  display: block;
}

.btn-gold:hover { transform: translateY(-1px); }
.btn-gold:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

/* หน้าสำเร็จ */
.success-card {
  background: var(--card);
  color: var(--text);
  border-radius: var(--radius);
  padding: 28px 20px;
  text-align: center;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.18);
}

.success-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  background: #f0fdf4;
  color: #15803d;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 32px;
  font-weight: 700;
}

.success-title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 8px;
}

.success-desc {
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 16px;
}

.success-id {
  font-size: 13px;
  color: var(--muted);
  margin: 8px 0 20px;
}

@media (min-width: 768px) {
  .apply-stage {
    max-width: 720px;
    padding: 48px 24px 40px;
    padding-top: max(48px, env(safe-area-inset-top));
  }

  .apply-title { font-size: 28px; }

  .step-item {
    font-size: 12px;
    padding: 10px 8px;
  }

  .pdf-frame {
    height: min(560px, 70vh);
  }

  .pdf-embed {
    height: min(520px, 65vh);
  }

  .apply-form {
    padding: 24px;
  }

  /* ฟอร์ม 2 คอลัมน์บน PC */
  .form-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }

  .form-grid-2 .field-full {
    grid-column: 1 / -1;
  }
}

@media (min-width: 1024px) {
  .apply-stage {
    max-width: 960px;
  }

  /* ขั้นอ่านเอกสาร: PDF ซ้าย · ยืนยันขวา */
  .doc-layout {
    flex-direction: row;
    align-items: flex-start;
    gap: 24px;
  }

  .doc-layout-viewer {
    flex: 1.4;
  }

  .doc-layout-actions {
    flex: 1;
    position: sticky;
    top: 24px;
  }

  .pdf-frame {
    height: min(640px, 75vh);
  }

  .confirm-check {
    margin-top: 0;
  }
}

@media (max-width: 767px) {
  .back-link {
    position: static;
    display: inline-block;
    margin-bottom: 12px;
  }

  .apply-brand {
    text-align: left;
  }

  .apply-logo {
    margin: 0 0 14px;
  }

  .step-nav {
    gap: 4px;
  }

  .step-item {
    min-width: 0;
    font-size: 10px;
    padding: 8px 2px;
  }

  .step-item span {
    font-size: 13px;
  }

  .apply-position {
    font-size: 14px;
    word-break: break-word;
  }

  .doc-layout-actions {
    position: sticky;
    bottom: 0;
    z-index: 5;
    background: var(--card);
    margin: 0 -20px -20px;
    padding: 16px 20px max(16px, env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
    border-radius: 0 0 var(--radius) var(--radius);
    box-shadow: 0 -8px 24px rgba(21, 35, 58, 0.08);
  }

  .apply-form.doc-card {
    padding-bottom: 0;
    overflow: hidden;
  }
}

/* ═══════════════════════════════════════════
   Wizard multi-step (appended)
   ═══════════════════════════════════════════ */

.req {
  color: var(--danger);
  font-weight: 700;
}

.step-nav-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  margin: 14px 0 12px;
}

.step-pill {
  font-size: 11px;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 999px;
  color: rgba(255, 255, 255, 0.45);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  white-space: nowrap;
  line-height: 1.2;
}

.step-pill.active {
  color: #1a1408;
  background: linear-gradient(180deg, var(--gold-2), var(--gold));
  border-color: transparent;
}

.step-pill.done {
  color: rgba(255, 255, 255, 0.85);
  border-color: rgba(110, 231, 183, 0.4);
  background: rgba(110, 231, 183, 0.12);
}

.section-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--navy);
  margin: 8px 0 4px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.section-title:first-of-type {
  border-top: 0;
  padding-top: 0;
}

/* Agreement scroll box */
.agreement-box {
  max-height: min(320px, 45vh);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 14px 16px;
  background: #f7f9fc;
  border: 1px solid var(--line);
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.65;
  color: var(--text);
}

.agreement-box p {
  margin-bottom: 12px;
}

.agreement-heading {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 10px;
  color: var(--navy);
}

.agreement-end {
  font-weight: 600;
  color: var(--gold-deep);
  text-align: center;
  margin-bottom: 0 !important;
  padding: 8px 0 4px;
}

.agreement-hint {
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  margin: 4px 0 0;
}

.addr-same-check {
  margin-top: 4px;
}

/* Yes/No + radio chips */
.yn-grid {
  display: grid;
  gap: 10px;
  margin-bottom: 8px;
}

.yn-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px;
  background: #f7f9fc;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.yn-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.radio-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.radio-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.radio-chip:has(input:checked) {
  border-color: rgba(198, 161, 91, 0.65);
  background: #fdf8ef;
  color: var(--navy);
}

.radio-chip input {
  accent-color: var(--gold);
  width: 16px;
  height: 16px;
  margin: 0;
}

/* Criminal years */
.criminal-years {
  display: grid;
  gap: 10px;
}

.criminal-year-block {
  padding: 12px;
  background: #f7f9fc;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.criminal-year-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 8px;
}

/* Uploads grid */
.upload-grid {
  display: grid;
  gap: 12px;
}

@media (min-width: 768px) {
  .upload-grid {
    grid-template-columns: 1fr 1fr;
  }

  .yn-row {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }

  .yn-label {
    flex: 1;
    padding-right: 12px;
  }
}

/* Signature pad */
.sig-wrap {
  display: grid;
  gap: 10px;
  margin-bottom: 8px;
}

.sig-canvas {
  display: block;
  width: 100%;
  height: 220px;
  touch-action: none;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  cursor: crosshair;
}

.sig-actions {
  display: flex;
  gap: 8px;
}

.sig-actions .btn-outline,
.sig-actions .btn-gold {
  flex: 1;
  margin-top: 0;
  min-height: 44px;
  padding: 10px 16px;
  font-size: 14px;
}

.sig-status {
  font-size: 13px;
  color: var(--muted);
  text-align: center;
}

.sig-status.ok {
  color: #15803d;
  font-weight: 600;
}

@media (max-width: 767px) {
  .step-pill {
    font-size: 10px;
    padding: 5px 8px;
  }

  .agreement-box {
    max-height: min(280px, 40vh);
  }

  .radio-chip {
    font-size: 12px;
    padding: 7px 10px;
  }
}
