/* =========================================================
   แจ้งงานรวบสายไฟ — สไตล์ชีต
   ทิศทาง: เครื่องมือหน้างานริมถนน อ่านกลางแดดได้ ปุ่มใหญ่ กดด้วยนิ้วโป้ง
   ========================================================= */

:root {
  --paper:      #EEF1F4;
  --card:       #FFFFFF;
  --ink:        #16212B;
  --ink-soft:   #5C6C7A;
  --line:       #D3DBE2;
  --hi-vis:     #FFD400;   /* signature — เสื้อกั๊กสะท้อนแสง */
  --hi-vis-dk:  #E6BE00;
  --steel:      #2C3E4D;
  --danger:     #C62828;
  --danger-bg:  #FDECEC;
  --warn:       #B05A00;
  --warn-bg:    #FFF3E2;
  --ok:         #1F6B3D;
  --ok-bg:      #E8F5EC;

  --r:          10px;
  --shadow:     0 1px 2px rgba(22,33,43,.08), 0 6px 16px rgba(22,33,43,.05);
  --tap:        56px;      /* ความสูงขั้นต่ำของสิ่งที่กดได้ */
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  padding-bottom: 120px;
  background: var(--paper);
  color: var(--ink);
  font-family: "IBM Plex Sans Thai", system-ui, sans-serif;
  font-size: 18px;
  line-height: 1.65;
}

.wrap {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 0 16px;
}

/* ---------- หัวเว็บ ---------- */
.masthead {
  background: var(--steel);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 20;
}

.hazard-rail {
  height: 6px;
  background: repeating-linear-gradient(
    -45deg,
    var(--hi-vis) 0 14px,
    var(--steel) 14px 28px
  );
}

.masthead-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 12px;
  padding-bottom: 12px;
}

.eyebrow {
  display: block;
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--hi-vis);
}

.masthead h1 {
  margin: 2px 0 0;
  font-family: "IBM Plex Sans Thai Looped", "IBM Plex Sans Thai", sans-serif;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -.01em;
}

.link-quiet {
  color: #C9D4DD;
  font-size: 15px;
  text-decoration: none;
  border-bottom: 1px solid rgba(201,212,221,.4);
  padding-bottom: 1px;
  white-space: nowrap;
}
.link-quiet:hover { color: #fff; border-color: #fff; }

/* ---------- แจ้งเตือน ---------- */
.notice {
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: var(--r);
  border-left: 5px solid;
  font-size: 17px;
}
.notice-ok  { background: var(--ok-bg);     border-color: var(--ok);     color: var(--ok); }
.notice-bad { background: var(--danger-bg); border-color: var(--danger); color: var(--danger); }

/* ---------- บล็อกคำถาม ---------- */
.block {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  margin-top: 16px;
  overflow: hidden;
}

.block-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: #FAFBFC;
}

.step {
  flex: none;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--steel);
  color: var(--hi-vis);
  font-family: "IBM Plex Mono", monospace;
  font-size: 14px;
  font-weight: 600;
}

.block-head h2 {
  margin: 0;
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -.01em;
}

.req { color: var(--danger); margin-left: 3px; }

.optional {
  margin-left: auto;
  font-size: 13px;
  color: var(--ink-soft);
  border: 1px solid var(--line);
  border-radius: 99px;
  padding: 2px 10px;
}

.block-body { padding: 18px; }

/* บล็อกพิกัด — จุดเด่นของหน้านี้ */
.block-signature { border-top: 4px solid var(--hi-vis); }

/* ---------- ช่องกรอก ---------- */
input[type="text"],
input[type="tel"],
input[type="password"],
select {
  width: 100%;
  min-height: var(--tap);
  padding: 12px 14px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-family: inherit;
  font-size: 18px;
}

input:focus-visible,
select:focus-visible,
button:focus-visible,
.choice input:focus-visible + .choice-box,
.chip input:focus-visible + span {
  outline: 3px solid var(--hi-vis-dk);
  outline-offset: 2px;
}

input::placeholder { color: #9AA8B4; }

select {
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%232C3E4D' stroke-width='2.5'><path d='M6 9l6 6 6-6'/></svg>");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 20px;
  padding-right: 44px;
}

.field { display: block; margin-top: 14px; }
.field:first-of-type { margin-top: 0; }

.field-key {
  display: block;
  margin-bottom: 6px;
  font-size: 15px;
  font-weight: 600;
  color: var(--ink-soft);
}

/* ---------- พิกัด ---------- */
.coord-grid {
  display: grid;
  gap: 14px;
  margin: 16px 0;
}
@media (min-width: 560px) {
  .coord-grid { grid-template-columns: 1fr 1fr; }
}

.coord { display: block; }

.coord-key {
  display: block;
  margin-bottom: 6px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.coord input {
  font-family: "IBM Plex Mono", monospace;
  font-size: 21px;
  font-weight: 500;
  letter-spacing: .01em;
}

.coord-hint {
  display: block;
  margin-top: 5px;
  font-size: 14px;
  color: var(--ink-soft);
}

.gps-status {
  margin: 10px 0 0;
  font-size: 15px;
  color: var(--ink-soft);
  min-height: 1.6em;
}
.gps-status.is-ok  { color: var(--ok); }
.gps-status.is-bad { color: var(--danger); }

/* ---------- ปุ่ม ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: var(--tap);
  padding: 0 22px;
  border: 2px solid transparent;
  border-radius: 8px;
  font-family: inherit;
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  transition: transform .06s ease, background .15s ease;
}
.btn:active { transform: translateY(1px); }

.btn-hivis {
  background: var(--hi-vis);
  color: var(--ink);
  border-color: var(--hi-vis-dk);
}
.btn-hivis:hover { background: var(--hi-vis-dk); }

.btn-line {
  background: #fff;
  color: var(--steel);
  border-color: var(--line);
}
.btn-line:hover { border-color: var(--steel); }

.btn-wide { width: 100%; }
.btn-lg   { min-height: 62px; font-size: 20px; width: 100%; }

.btn-text {
  background: none;
  border: 0;
  padding: 6px 2px;
  color: var(--danger);
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
}

.ico    { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ico-lg { width: 30px; height: 30px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- ตัวเลือกแบบการ์ด ---------- */
.choices { display: grid; gap: 10px; }

.choice { display: block; cursor: pointer; }
.choice input { position: absolute; opacity: 0; width: 0; height: 0; }

.choice-box {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: var(--tap);
  justify-content: center;
  padding: 12px 16px 12px 48px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: #fff;
  position: relative;
}

.choice-box::before {
  content: "";
  position: absolute;
  left: 15px;
  top: 50%;
  transform: translateY(-50%);
  width: 22px;
  height: 22px;
  border: 2px solid #A9B6C1;
  border-radius: 50%;
  background: #fff;
}

.choice input:checked + .choice-box::before {
  border-width: 7px;
  border-color: currentColor;
}

.choice-label { font-size: 17px; font-weight: 500; color: var(--ink); line-height: 1.4; }
.choice-note  { font-size: 14px; color: var(--ink-soft); }

.tone-danger .choice-box { color: var(--danger); }
.tone-warn   .choice-box { color: var(--warn); }
.tone-ok     .choice-box { color: var(--ok); }

.choice input:checked + .choice-box { border-color: currentColor; }
.tone-danger input:checked + .choice-box { background: var(--danger-bg); }
.tone-warn   input:checked + .choice-box { background: var(--warn-bg); }
.tone-ok     input:checked + .choice-box { background: var(--ok-bg); }

.footnote {
  margin: 14px 0 0;
  padding: 12px 14px;
  background: #F5F7F9;
  border-radius: 8px;
  font-size: 15px;
  color: var(--ink-soft);
}

/* ---------- ชิป (Ticket) ---------- */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.chip { cursor: pointer; }
.chip input { position: absolute; opacity: 0; width: 0; height: 0; }

.chip span {
  display: inline-flex;
  align-items: center;
  min-height: 46px;
  padding: 0 18px;
  border: 2px solid var(--line);
  border-radius: 99px;
  background: #fff;
  font-size: 16px;
  font-weight: 500;
}

.chip input:checked + span {
  background: var(--steel);
  border-color: var(--steel);
  color: #fff;
}

/* ---------- แนบไฟล์ ---------- */
.capture-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.capture {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 104px;
  padding: 14px 6px;
  border: 2px dashed var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--steel);
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
}
.capture:hover { border-color: var(--steel); border-style: solid; }
.capture.is-active {
  border-style: solid;
  border-color: var(--hi-vis-dk);
  background: #FFFBE6;
}

.preview { margin-top: 16px; }

.preview img {
  width: 100%;
  max-height: 320px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
  display: block;
}

.preview-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
  font-size: 15px;
  color: var(--ink-soft);
  word-break: break-all;
}

.file-empty {
  margin: 14px 0 0;
  font-size: 15px;
  color: var(--ink-soft);
}

/* ---------- ผู้บันทึก ---------- */
.who {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-bottom: 16px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.who-avatar {
  flex: none;
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--steel);
  color: var(--hi-vis);
  font-size: 20px;
  font-weight: 700;
}

.who strong { display: block; font-size: 17px; font-weight: 600; }

.who-id {
  font-family: "IBM Plex Mono", monospace;
  font-size: 13px;
  color: var(--ink-soft);
}

/* ---------- ปุ่มส่ง ---------- */
.submit-desktop { margin-top: 22px; }

.actionbar {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  align-items: center;
  gap: 12px;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  background: rgba(255,255,255,.96);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--line);
  box-shadow: 0 -4px 20px rgba(22,33,43,.1);
}

.actionbar .btn { flex: none; padding: 0 26px; }

.actionbar-count {
  flex: 1;
  font-size: 14px;
  line-height: 1.35;
  color: var(--ink-soft);
}
.actionbar-count.is-ready { color: var(--ok); font-weight: 600; }

@media (max-width: 719px) {
  body { font-size: 17px; }
  .actionbar      { display: flex; }
  .submit-desktop { display: none; }
  .masthead h1    { font-size: 19px; }
  .capture-row    { grid-template-columns: 1fr; }
  .capture        { flex-direction: row; min-height: var(--tap); gap: 12px; justify-content: flex-start; padding-left: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ---------- แถบผู้ใช้บนหัวเว็บ ---------- */
.masthead-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.masthead-actions .link-quiet { white-space: nowrap; }

/* ---------- ปุ่มดูรหัสผ่านในหน้าล็อกอิน ---------- */
.pw-wrap {
  position: relative;
  display: block;
}

/* เว้นที่ด้านขวาของช่องไว้ให้ปุ่ม ไม่ให้ตัวอักษรลอดไปใต้ปุ่ม */
.pw-wrap input { padding-right: 60px; }

.pw-toggle {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 46px;               /* สี่เหลี่ยมจัตุรัส กดด้วยนิ้วโป้งได้ */
  height: 44px;
  padding: 0;
  border: 2px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--steel);
  cursor: pointer;
}
.pw-toggle:hover { border-color: var(--steel); }

/* <svg> ไม่ได้ถูกซ่อนด้วย attribute hidden เองเหมือน element ของ HTML ต้องสั่งเอง */
.pw-toggle svg[hidden] { display: none; }
.pw-toggle[aria-pressed="true"] {
  background: var(--steel);
  border-color: var(--steel);
  color: #fff;
}
