/* ============================================================
   ฟอร์มขอราคา: ปุ่มเลือกวันที่/เวลา + หน้าต่างแผนที่
   ============================================================ */

/* ---------- ช่องกรอก + ปุ่มแผนที่ ---------- */
.input-map { display: flex; gap: 8px; }
.input-map input { flex: 1; min-width: 0; }
.map-btn {
  flex: none; display: inline-flex; align-items: center; gap: 5px;
  font: inherit; font-size: 14px; font-weight: 600; color: var(--p7);
  padding: 0 12px; border: 1.5px solid var(--p2); border-radius: 10px; background: #fff; cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.map-btn .icon { width: 18px; height: 18px; }
.map-btn:hover { border-color: var(--p6); background: var(--p1); }
.map-btn.is-set { background: var(--p7); border-color: var(--p7); color: #fff; }

.route-preview {
  display: inline-flex; align-items: center; gap: 6px; margin: -2px 0 12px;
  font-size: 13.5px; font-weight: 600; color: var(--p7); text-decoration: underline; text-underline-offset: 3px;
}
.route-preview[hidden] { display: none; }
.route-preview .icon { width: 16px; height: 16px; }

.picker-btn {
  width: 100%; display: flex; align-items: center; gap: 8px; text-align: left;
  font: inherit; font-size: 15px; color: var(--muted);
  padding: 10px 12px; border: 1.5px solid var(--border); border-radius: 10px; background: var(--p1); cursor: pointer;
  transition: border-color .15s, background .15s;
}
.picker-btn:hover { border-color: var(--p4); }
.picker-btn .icon { flex: none; width: 18px; height: 18px; color: var(--p6); }
.picker-btn span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.picker-btn.has-value { color: var(--ink); font-weight: 500; background: #fff; border-color: var(--p4); }

.btn-primary { background: var(--p7); color: #fff; }
.btn-text { font: inherit; font-size: 14.5px; font-weight: 600; color: var(--muted); background: none; border: 0; padding: 8px 4px; cursor: pointer; }
.btn-text:hover { color: var(--p7); }

/* ---------- หน้าต่าง (dialog) ---------- */
html:has(dialog[open]) { overflow: hidden; }
.sheet {
  width: min(400px, calc(100vw - 32px)); max-height: calc(100dvh - 32px);
  padding: 0; border: 0; border-radius: 20px; color: var(--ink); background: #fff;
  box-shadow: 0 40px 80px -20px rgba(46, 16, 101, .55); overflow: hidden;
}
.sheet[open] { display: flex; flex-direction: column; animation: sheet-in .2s ease-out; }
.sheet::backdrop { background: rgba(31, 18, 53, .55); backdrop-filter: blur(2px); }
@keyframes sheet-in { from { opacity: 0; transform: translateY(14px); } }

.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 14px 10px 20px; }
.sheet-head h3 { font-family: var(--head); font-size: 19px; font-weight: 600; color: var(--p7); margin: 0; }
.sheet-close { display: grid; place-items: center; width: 40px; height: 40px; border: 0; border-radius: 50%; background: var(--p1); color: var(--p7); cursor: pointer; }
.sheet-close .icon { width: 20px; height: 20px; }
.sheet-body { padding: 4px 20px 8px; overflow-y: auto; }
.sheet-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 20px 16px; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  font: inherit; font-size: 14px; font-weight: 500; color: var(--p7); white-space: nowrap;
  padding: 7px 14px; border: 1.5px solid var(--p2); border-radius: 999px; background: #fff; cursor: pointer;
}
.chip:hover { background: var(--p1); border-color: var(--p4); }

/* ---------- ปฏิทิน ---------- */
.cal-nav { display: flex; align-items: center; justify-content: space-between; margin: 14px 0 8px; }
.cal-nav b { font-family: var(--head); font-size: 17px; font-weight: 600; }
.cal-nav button { width: 40px; height: 40px; border: 0; border-radius: 50%; background: var(--p1); color: var(--p7); font-size: 22px; line-height: 1; cursor: pointer; }
.cal-nav button:disabled { opacity: .35; cursor: default; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-dow span { text-align: center; font-size: 12.5px; font-weight: 600; color: var(--muted); padding: 4px 0; }
.cal-grid button {
  aspect-ratio: 1; min-height: 40px; border: 0; border-radius: 50%; background: none;
  font: inherit; font-size: 15px; color: var(--ink); cursor: pointer;
}
.cal-grid button:hover:not(:disabled) { background: var(--p1); }
.cal-grid button:disabled { color: #c9bfdc; cursor: default; }
.cal-grid button.is-today { box-shadow: inset 0 0 0 1.5px var(--gold); font-weight: 600; }
.cal-grid button.is-selected { background: var(--p7); color: #fff; font-weight: 600; box-shadow: none; }

/* ---------- เวลา ---------- */
.time-preview { font-family: var(--head); font-size: 34px; font-weight: 600; color: var(--p7); text-align: center; letter-spacing: 1px; padding: 2px 0 6px; }
.pick-label { font-size: 13px; font-weight: 600; color: var(--muted); margin: 10px 0 6px; }
.pick-grid { display: grid; gap: 6px; }
.pick-grid.hours, .pick-grid.mins { grid-template-columns: repeat(6, 1fr); }
.pick-grid button {
  min-height: 42px; border: 1.5px solid var(--border); border-radius: 10px; background: #fff;
  font: inherit; font-size: 15px; font-variant-numeric: tabular-nums; color: var(--ink); cursor: pointer;
}
.pick-grid button:hover { background: var(--p1); border-color: var(--p4); }
.pick-grid button.is-selected { background: var(--p7); border-color: var(--p7); color: #fff; font-weight: 600; }

/* ---------- แผนที่ ---------- */
.sheet-map { width: min(760px, calc(100vw - 32px)); height: min(720px, calc(100dvh - 32px)); }
.map-search { display: flex; gap: 8px; padding: 0 16px 10px; }
.map-search input {
  flex: 1; min-width: 0; font: inherit; font-size: 16px; color: var(--ink);
  padding: 10px 14px; border: 1.5px solid var(--border); border-radius: 12px; background: var(--p1);
}
.map-search input:focus { border-color: var(--p6); background: #fff; outline: none; }
.map-search .btn { padding: 0 16px; border-radius: 12px; }
.map-search .btn .icon { width: 20px; height: 20px; }
.map-chips { flex-wrap: nowrap; overflow-x: auto; padding: 0 16px 10px; scrollbar-width: none; }
.map-chips::-webkit-scrollbar { display: none; }

.map-wrap { position: relative; flex: 1; min-height: 220px; background: var(--p1); }
#map { position: absolute; inset: 0; z-index: 0; font-family: var(--body); }
.map-pin {
  position: absolute; left: 50%; top: 50%; z-index: 2; width: 44px; height: 55px;
  transform: translate(-50%, -95%); pointer-events: none;
  filter: drop-shadow(0 6px 6px rgba(46, 16, 101, .4)); transition: transform .15s;
}
.map-wrap.is-moving .map-pin { transform: translate(-50%, -115%); }
.map-wrap::after { /* เงาจุดปักหมุด */
  content: ''; position: absolute; left: 50%; top: 50%; z-index: 1; width: 10px; height: 5px; border-radius: 50%;
  background: rgba(31, 18, 53, .45); transform: translate(-50%, -50%); pointer-events: none;
}
.map-locate {
  position: absolute; right: 12px; bottom: 30px; z-index: 3; display: inline-flex; align-items: center; gap: 6px;
  font: inherit; font-size: 14px; font-weight: 600; color: var(--p7);
  padding: 9px 14px; border: 0; border-radius: 999px; background: #fff; cursor: pointer;
  box-shadow: 0 6px 16px -4px rgba(46, 16, 101, .45);
}
.map-locate .icon { width: 18px; height: 18px; }
.map-hint {
  position: absolute; left: 50%; top: 10px; z-index: 3; transform: translateX(-50%); margin: 0; max-width: calc(100% - 24px);
  font-size: 12.5px; color: #fff; text-align: center; padding: 5px 12px; border-radius: 999px; background: rgba(46, 16, 101, .82);
  pointer-events: none; transition: opacity .3s;
}
.map-wrap.is-touched .map-hint { opacity: 0; }
.map-results {
  position: absolute; left: 12px; right: 12px; top: 8px; z-index: 4; margin: 0; padding: 6px; list-style: none;
  max-height: 60%; overflow-y: auto; border-radius: 14px; background: #fff; box-shadow: 0 16px 36px -10px rgba(46, 16, 101, .5);
}
.map-results[hidden] { display: none; }
.map-results button { width: 100%; text-align: left; font: inherit; font-size: 14.5px; color: var(--ink); padding: 10px 12px; border: 0; border-radius: 10px; background: none; cursor: pointer; }
.map-results button:hover, .map-results button:focus-visible { background: var(--p1); }
.map-results button small { display: block; font-size: 12.5px; color: var(--muted); }
.map-results li.empty { padding: 10px 12px; font-size: 14.5px; color: var(--muted); }

.map-foot { padding-top: 12px; border-top: 1px solid var(--border); }
.map-addr { display: flex; align-items: flex-start; gap: 8px; flex: 1; min-width: 0; font-size: 14.5px; line-height: 1.45; }
.map-addr .icon { flex: none; width: 20px; height: 20px; margin-top: 1px; color: var(--p6); }
.map-addr span { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.map-foot .btn { flex: none; }

/* ---------- มือถือ: หน้าต่างเลื่อนขึ้นจากด้านล่าง ---------- */
@media (max-width: 640px) {
  .sheet { width: 100%; max-width: 100%; margin: auto 0 0; border-radius: 22px 22px 0 0; max-height: 92dvh; }
  .sheet[open] { animation-name: sheet-up; }
  .sheet-map { height: 100dvh; max-height: 100dvh; border-radius: 0; }
  .sheet-foot { padding-bottom: max(16px, env(safe-area-inset-bottom)); }
  .map-foot { flex-direction: column; align-items: stretch; }
  .map-foot .btn { width: 100%; }
  .map-btn span { display: none; }
  .map-btn { padding: 0 13px; }
}
@keyframes sheet-up { from { transform: translateY(100%); } }
@media (prefers-reduced-motion: reduce) { .sheet[open] { animation: none; } .map-pin { transition: none; } }

/* ---------- ปุ่ม "ตอนนี้" ---------- */
.now-btn {
  display: inline-flex; align-items: center; gap: 6px; margin: -2px 0 12px;
  font: inherit; font-size: 13.5px; font-weight: 600; color: var(--p7);
  padding: 6px 14px; border: 1.5px solid var(--p2); border-radius: 999px; background: #fff; cursor: pointer;
}
.now-btn:hover { background: var(--p1); border-color: var(--p4); }
.now-btn .icon { width: 16px; height: 16px; }
.time-quick { justify-content: center; margin-bottom: 4px; }

/* ---------- ข้อความเตือนในฟอร์ม ---------- */
.field-error { margin: 5px 0 0; font-size: 13px; font-weight: 500; color: #c81e1e; }
.field-error[hidden] { display: none; }
.field input.is-invalid { border-color: #c81e1e; background: #fff5f5; }
