/* Thành phần dùng chung: ghim bản đồ Leaflet, thẻ điểm lấy/giao (.pt-card), khung dịch vụ thêm (.opt-panel).
   Chỉ dùng biến màu trong base.css. */

/* =================================================================
   Bản đồ
   ================================================================= */
.leaflet-container { font-family: var(--font); background: #e8ecef; }
.leaflet-control-attribution { font-size: 10px; background: rgba(255, 255, 255, .75) !important; }
/* Ghi nguồn gọn: thu thành nút ⓘ tròn nhỏ, bấm để mở lại */
.leaflet-control-attribution.gn-attr { border-radius: 10px; margin: 0 6px 6px 0 !important; padding: 1px 8px; cursor: pointer; color: var(--text-2); }
.leaflet-control-attribution.gn-attr a { color: var(--text-2); }
.leaflet-control-attribution.gn-attr.collapsed { width: 20px; height: 20px; padding: 0; border-radius: 50%; overflow: hidden;
  font-size: 0; position: relative; background: rgba(255, 255, 255, .85) !important; box-shadow: var(--shadow-sm); }
.leaflet-control-attribution.gn-attr.collapsed::after { content: "i"; position: absolute; inset: 0; display: flex; align-items: center;
  justify-content: center; font: italic 700 11px/1 Georgia, serif; color: var(--text-2); }
.leaflet-bar { border: 0 !important; box-shadow: var(--shadow) !important; border-radius: 10px !important; overflow: hidden; }
.leaflet-bar a { width: 34px !important; height: 34px !important; line-height: 34px !important; color: var(--text) !important;
                 border-bottom-color: var(--line) !important; font-size: 18px !important; }
.leaflet-bar a:hover { background: var(--surface-2) !important; }
.leaflet-div-icon.gn-pin-wrap, .gn-pin-wrap { background: transparent; border: 0; }

/* Ghim dạng giọt: hình vuông bo 3 góc xoay -45°, mũi nhọn chạm toạ độ; bóng elip dưới chân. */
.gn-pin { position: relative; width: 32px; height: 44px; }
.gn-pin-drop { position: absolute; left: 3px; top: 1px; width: 26px; height: 26px; border-radius: 50% 50% 50% 0;
               transform: rotate(-45deg); transform-origin: center; background: var(--pin-b); border: 2px solid #fff;
               box-shadow: 0 3px 8px rgba(16, 24, 40, .35); display: flex; align-items: center; justify-content: center;
               transition: transform .15s ease; }
.gn-pin-a .gn-pin-drop { background: var(--pin-a); }
.gn-pin-text { transform: rotate(45deg); color: #fff; font: 700 13px/1 var(--font); letter-spacing: -.02em; }
.gn-pin.long .gn-pin-text { font-size: 11px; }
.gn-pin-shadow { position: absolute; left: 50%; bottom: 0; width: 14px; height: 5px; margin-left: -7px; border-radius: 50%;
                 background: rgba(16, 24, 40, .3); filter: blur(1px); }
.leaflet-marker-draggable .gn-pin-drop { cursor: grab; }
.leaflet-drag-target .gn-pin-drop, .leaflet-dragging .leaflet-marker-draggable .gn-pin-drop { transform: rotate(-45deg) translate(2px, -2px) scale(1.08); }

/* Nhãn quãng đường trên tuyến: viên thuốc trắng chữ xanh */
.leaflet-tooltip.gn-route-tag { background: #fff; color: var(--map-route); border: 1.5px solid var(--map-route); border-radius: 999px;
  padding: 3px 10px; font: 700 12px/1.3 var(--font); white-space: nowrap; box-shadow: 0 2px 6px rgba(16, 24, 40, .2); }
.leaflet-tooltip.gn-route-tag::before { display: none; }

/* Cảnh báo ghim ngoài vùng phục vụ: dải trên đầu bản đồ */
.gn-area-warn { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); z-index: 800; max-width: calc(100% - 24px);
  background: var(--warn-50); color: var(--warn); border: 1px solid var(--warn-100); border-radius: 10px; padding: 7px 12px;
  font: 600 12.5px/1.4 var(--font); box-shadow: var(--shadow); pointer-events: none; text-align: center; }

/* Nhãn chủ quyền Hoàng Sa, Trường Sa */
.leaflet-div-icon.gn-sea-label, .gn-sea-label { background: transparent; border: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center; pointer-events: none; color: #1d3a8a;
  text-shadow: 0 0 3px #fff, 0 0 3px #fff, 0 0 3px #fff; }
.gn-sea-label b { font: italic 700 12.5px/1.2 var(--font); }
.gn-sea-label span { font: italic 500 11px/1.2 var(--font); }

/* Quán trên bản đồ: chấm đỏ, popup có nút lấy hàng */
.leaflet-div-icon.gn-shop-wrap, .gn-shop-wrap { background: transparent; border: 0; }
.gn-shop { width: 26px; height: 26px; border-radius: 50%; background: var(--pin-b); color: #fff; border: 2px solid #fff;
  box-shadow: 0 2px 6px rgba(16, 24, 40, .3); display: flex; align-items: center; justify-content: center; cursor: pointer; }
.gn-shop-pop { display: flex; flex-direction: column; gap: 4px; font-family: var(--font); }
.gn-shop-pop b { font-size: 14px; color: var(--text); }
.gn-shop-kind { align-self: flex-start; font-size: 11px; font-weight: 600; color: var(--pin-b); background: #fdebee; border-radius: 6px; padding: 1px 6px; }
.gn-shop-addr { font-size: 12px; color: var(--text-2); line-height: 1.4; margin-bottom: 4px; }

/* Tài xế: chấm tròn có vòng toả */
.gn-driver { position: relative; width: 40px; height: 40px; }
.gn-driver-dot { position: absolute; inset: 4px; border-radius: 50%; background: var(--info); color: #fff; border: 3px solid #fff;
                 box-shadow: 0 3px 10px rgba(16, 24, 40, .35); display: flex; align-items: center; justify-content: center; }
.gn-driver-pulse { position: absolute; inset: 0; border-radius: 50%; background: var(--info); opacity: .25;
                   animation: gn-pulse 1.8s ease-out infinite; }
@keyframes gn-pulse { from { transform: scale(.6); opacity: .45; } to { transform: scale(1.6); opacity: 0; } }

/* =================================================================
   Thẻ điểm lấy / giao
   ================================================================= */
.pt-card { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
           padding: 12px 14px 8px; box-shadow: var(--shadow-sm); transition: border-color .15s, box-shadow .15s; }
.pt-card:hover { border-color: var(--line-2); }
.pt-card.active { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-50), var(--shadow-sm); }
.pt-card.sug-open { z-index: 30; }

.pt-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; min-height: 28px; }
.pt-pin { position: relative; width: 24px; height: 24px; border-radius: 50%; flex: none; margin-bottom: 3px;
          display: inline-flex; align-items: center; justify-content: center; color: #fff; background: var(--pin-b);
          font-size: 11.5px; font-weight: 700; line-height: 1; box-shadow: 0 1px 3px rgba(16, 24, 40, .25); }
.pt-pin::after { content: ""; position: absolute; left: 50%; bottom: -4px; margin-left: -4px; border: 4px solid transparent;
                 border-bottom: 0; border-top: 5px solid var(--pin-b); }
.pt-pin.a { background: var(--pin-a); }
.pt-pin.a::after { border-top-color: var(--pin-a); }
.pt-pin.long { font-size: 10px; }
.pt-title { font-size: 13px; font-weight: 600; color: var(--text-2); flex: 1; min-width: 0; }
.pt-remove { width: 28px; height: 28px; margin: -2px -6px -2px 0; color: var(--muted); }
.pt-remove:hover { color: var(--danger); background: var(--danger-50); }
.pt-remove:disabled { opacity: .35; cursor: not-allowed; background: transparent; color: var(--muted); }

/* Ô địa chỉ nổi bật + danh sách gợi ý */
.pt-addr { position: relative; margin-bottom: 8px; }
.pt-addr input { height: 44px; padding: 0 40px 0 38px; font-size: 15px; font-weight: 600; border-color: var(--line);
                 background: var(--surface-2); text-overflow: ellipsis; }
.pt-addr input::placeholder { font-weight: 500; color: var(--muted); }
.pt-addr input:focus { background: var(--surface); }
.pt-addr-ic { position: absolute; left: 12px; top: 14px; color: var(--pin-b); pointer-events: none; display: flex; }
.pt-card[data-point="pickup"] .pt-addr-ic { color: var(--pin-a); }
.pt-sug-btn { position: absolute; right: 4px; top: 6px; width: 32px; height: 32px; border: 0; border-radius: 6px; background: transparent;
              color: var(--muted); cursor: pointer; display: flex; align-items: center; justify-content: center; }
.pt-sug-btn:hover { background: var(--grey-50); color: var(--text); }
.pt-sug-btn:disabled { display: none; }
.sug-open .pt-sug-btn svg { transform: rotate(180deg); }

.pt-sug { position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 1200; background: var(--surface);
          border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow-lg); max-height: 300px; overflow-y: auto;
          padding: 6px; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.pt-sug.up { top: auto; bottom: calc(100% + 6px); }
.pt-sug-head { font-size: 11px; font-weight: 600; color: var(--muted); padding: 4px 10px 6px; }
.pt-sug-head.miss { font-size: 12px; font-weight: 500; color: var(--text-2); background: var(--warn-50); border-radius: 6px;
                    padding: 8px 10px; margin: 0 0 4px; line-height: 1.4; }
.pt-sug-item { display: flex; align-items: flex-start; gap: 10px; padding: 9px 10px; border-radius: 8px; cursor: pointer;
               user-select: none; -webkit-user-select: none; }
.pt-sug-item.hi, .pt-sug-item:hover { background: var(--brand-50); }
.pt-sug-ic { width: 28px; height: 28px; border-radius: 50%; background: var(--grey-50); color: var(--text-2); flex: none;
             display: flex; align-items: center; justify-content: center; }
.pt-sug-item.hi .pt-sug-ic { background: var(--surface); color: var(--brand); }
.pt-sug-txt { min-width: 0; display: flex; flex-direction: column; }
.pt-sug-txt b { font-size: 14px; font-weight: 600; color: var(--text); }
.pt-sug-txt small { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Địa chỉ bị khoá (popup sửa đơn khi bên giao không cho đổi) */
/* Địa chỉ nhận diện từ vị trí ghim / đang tìm theo chữ */
.pt-geo { margin: -2px 0 8px; padding: 8px 10px; border-radius: var(--radius-sm); background: var(--brand-50);
          font-size: 12.5px; line-height: 1.45; color: var(--text-2); display: flex; flex-direction: column; gap: 6px; }
.pt-geo b { color: var(--text); font-weight: 600; }
.pt-geo.wait { background: var(--grey-50); flex-direction: row; align-items: center; gap: 8px; color: var(--muted); }
.pt-geo.miss { background: var(--warn-50); color: var(--warn); }
.pt-geo-msg { overflow-wrap: anywhere; }
.pt-geo-act { display: flex; }
.pt-geo-use { border: 0; border-radius: 6px; padding: 5px 10px; background: var(--brand); color: #fff; font: inherit;
              font-size: 12.5px; font-weight: 600; cursor: pointer; }
.pt-geo-use:hover { background: var(--brand-600); }
.pt-geo-alt { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.pt-geo-alt > span { color: var(--muted); }
.pt-geo-chip { max-width: 100%; border: 1px solid var(--brand-100); border-radius: 999px; padding: 3px 10px; background: var(--surface);
               color: var(--text); font: inherit; font-size: 12px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pt-geo-chip:hover { border-color: var(--brand); color: var(--brand-600); }
.pt-geo-use:focus-visible, .pt-geo-chip:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.pt-sug-wait { display: flex; align-items: center; gap: 8px; }
.pt-geo .spin, .pt-sug-wait .spin { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--line-2);
                                     border-top-color: var(--brand); animation: pt-spin .8s linear infinite; flex: none; }
@keyframes pt-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .pt-geo .spin, .pt-sug-wait .spin { animation: none; } }

.pt-card.addr-locked .pt-addr input { background-color: var(--grey-50); color: var(--text-2); }
.pt-cod input:disabled ~ .pt-unit, .opt-money input:disabled + span { display: none; }
.pt-card.addr-locked .pt-addr-ic { color: var(--muted); }
.pt-card.addr-locked .pt-coord-edit { display: none; }
.pt-card.addr-locked .pt-coord > summary { cursor: default; }
.pt-card.addr-locked .pt-addr input, .pt-card.addr-locked .pt-coord input { cursor: not-allowed; }
.pt-in input:disabled { color: var(--text-2); }

/* Hàng ô nhỏ có biểu tượng: tên + SĐT, COD + ghi chú */
.pt-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 8px; }
.pt-row.one { grid-template-columns: 1fr; }
.pt-row:has(.pt-cod) { grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); }
.pt-in { position: relative; display: block; margin: 0; min-width: 0; }
.pt-in input { height: 36px; padding: 0 10px 0 32px; font-size: 13.5px; }
.pt-in-ic { position: absolute; left: 10px; top: 10px; color: var(--muted); pointer-events: none; display: flex; }
.pt-in input:focus ~ .pt-in-ic, .pt-in:focus-within .pt-in-ic { color: var(--brand); }
.pt-cod input { padding-right: 24px; font-variant-numeric: tabular-nums; }
.pt-unit { position: absolute; right: 10px; top: 9px; font-size: 13px; color: var(--muted); pointer-events: none; }
.pt-cod input:placeholder-shown ~ .pt-unit { display: none; }
.pt-in input[type=number] { -moz-appearance: textfield; appearance: textfield; }
.pt-in input[type=number]::-webkit-inner-spin-button, .pt-in input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

/* Toạ độ thu gọn */
.pt-coord { margin: 0 -2px; font-size: 12px; color: var(--muted); }
.pt-coord > summary { list-style: none; display: inline-flex; align-items: center; gap: 6px; cursor: pointer; padding: 2px 4px;
                      border-radius: 6px; font-variant-numeric: tabular-nums; user-select: none; }
.pt-coord > summary::-webkit-details-marker { display: none; }
.pt-coord > summary:hover { color: var(--text-2); background: var(--grey-50); }
.pt-coord-ic { display: flex; }
.pt-coord-edit { color: var(--brand); font-weight: 600; margin-left: 2px; }
.pt-coord[open] .pt-coord-edit { display: none; }
.pt-coord-body { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 6px 2px 4px; }
.pt-coord-body label { display: block; margin: 0; }
.pt-coord-body span { display: block; font-size: 11px; margin-bottom: 3px; color: var(--muted); }
.pt-coord-body input { height: 32px; font: 12.5px var(--mono); padding: 0 8px; }

@media (max-width: 520px) {
  .pt-card { padding: 12px 12px 8px; }
  .pt-row:has(.pt-cod) { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .pt-in input { padding-left: 30px; }
  .pt-addr input { font-size: 16px; }   /* iOS không tự phóng to khi focus */
  .pt-in input, .pt-coord-body input { font-size: 16px; }
}
@media (max-width: 359px) {
  .pt-row, .pt-row:has(.pt-cod) { grid-template-columns: 1fr; }
}

/* =================================================================
   Dịch vụ thêm
   ================================================================= */
.opt-panel { display: flex; flex-direction: column; gap: 16px; }
.opt-sec-title { font-size: 12px; font-weight: 600; color: var(--text-2); margin: 0 0 8px; }
.opt-sup { display: inline-flex; align-items: center; height: 18px; padding: 0 6px; border-radius: 4px; font-size: 10.5px;
           font-weight: 600; background: var(--aha-50); color: var(--aha); white-space: nowrap; vertical-align: middle; }
.opt-sup.none { background: var(--grey-50); color: var(--muted); }

/* Gói của từng đơn vị */
.opt-svc { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.opt-svc-item { display: block; margin: 0; min-width: 0; }
.opt-svc-head { display: flex; align-items: center; margin-bottom: 6px; font-size: 13px; }
.opt-svc-head .prov-logo { width: 20px; height: 20px; font-size: 10px; }
.opt-svc-item select { height: 38px; font-size: 13.5px; text-overflow: ellipsis; }
.opt-svc-item.warn select { border-color: var(--warn-100); }

/* Ô chọn dạng thẻ */
.opt-tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 8px; }
/* Thanh toán phí giao: 3 lựa chọn dạng thẻ, chọn một */
.opt-pay { display: grid; grid-template-columns: 1fr; gap: 8px; }
.opt-pay .opt-tile { align-items: center; }
.opt-check.opt-radio { border-radius: 50%; top: 50%; margin-top: -9px; }
.opt-check.opt-radio::after { left: 4px; top: 4px; width: 7px; height: 7px; border: 0; border-radius: 50%; background: #fff; transform: none; }
.opt-tile, .opt-ins-head { position: relative; display: flex; align-items: flex-start; gap: 10px; margin: 0; cursor: pointer;
                            user-select: none; -webkit-user-select: none; }
.opt-tile { padding: 10px 34px 10px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface);
            transition: border-color .15s, background .15s; min-width: 0; }
.opt-tile:hover { border-color: var(--line-2); }
.opt-tile input, .opt-ins-head input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.opt-tile-ic { width: 32px; height: 32px; border-radius: 8px; background: var(--grey-50); color: var(--text-2); flex: none;
               display: flex; align-items: center; justify-content: center; transition: background .15s, color .15s; }
.opt-tile-body, .opt-line-body { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; min-width: 0; flex: 1; }
.opt-tile-body b, .opt-line-body b { font-size: 13px; font-weight: 600; line-height: 1.3; color: var(--text); }
.opt-tile-body small, .opt-line-body small { font-size: 11.5px; line-height: 1.35; color: var(--muted); }
.opt-tile-body .opt-sup, .opt-line-body .opt-sup { margin-top: 3px; }
.opt-check { position: absolute; right: 10px; top: 10px; width: 18px; height: 18px; border-radius: 5px; border: 1.5px solid var(--line-2);
             background: var(--surface); transition: background .15s, border-color .15s; }
.opt-check::after { content: ""; position: absolute; left: 5px; top: 1.5px; width: 5px; height: 10px; border: solid #fff;
                    border-width: 0 2px 2px 0; transform: rotate(45deg); opacity: 0; }
.opt-tile:has(input:checked), .opt-ins:has(.opt-ins-head input:checked) { border-color: var(--brand); background: var(--brand-50); }
.opt-tile:has(input:checked) .opt-tile-ic, .opt-ins-head:has(input:checked) .opt-tile-ic { background: var(--brand); color: #fff; }
.opt-tile input:checked ~ .opt-check, .opt-ins-head input:checked ~ .opt-check { background: var(--brand); border-color: var(--brand); }
.opt-tile input:checked ~ .opt-check::after, .opt-ins-head input:checked ~ .opt-check::after { opacity: 1; }
.opt-tile:has(input:focus-visible), .opt-ins-head:has(input:focus-visible) { box-shadow: 0 0 0 3px var(--brand-100); }
.opt-tile:has(input:disabled), .opt-ins-head:has(input:disabled) { cursor: not-allowed; opacity: .55; }
.opt-tile:has(input:disabled):hover { border-color: var(--line); }

/* Dòng tuỳ chọn có điều khiển bên phải */
.opt-line { display: flex; align-items: center; gap: 10px; padding: 10px; border: 1px solid var(--line); border-radius: 10px;
            background: var(--surface); margin-bottom: 8px; transition: border-color .15s, background .15s; }
.opt-line:last-child { margin-bottom: 0; }
.opt-line-ctl { width: auto; max-width: 48%; min-width: 120px; height: 34px; font-size: 13px; text-overflow: ellipsis; }

/* Bước tăng giảm */
.opt-step { display: inline-flex; align-items: center; border: 1px solid var(--line-2); border-radius: 8px; overflow: hidden; flex: none;
            background: var(--surface); }
.opt-step-btn { width: 32px; height: 32px; border: 0; background: transparent; font: 600 17px/1 var(--font); color: var(--text-2);
                cursor: pointer; }
.opt-step-btn:hover:not(:disabled) { background: var(--grey-50); color: var(--text); }
.opt-step-btn:disabled { color: var(--muted); cursor: not-allowed; }
.opt-step input { width: 36px; height: 32px; border: 0; border-radius: 0; padding: 0; text-align: center; font-weight: 600;
                  font-variant-numeric: tabular-nums; -moz-appearance: textfield; appearance: textfield; background: transparent; }
.opt-step input:focus { box-shadow: none; }
.opt-step input::-webkit-inner-spin-button, .opt-step input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.opt-step:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-50); }

/* Bảo hiểm: thẻ chọn + ô giá trị */
.opt-ins { flex-wrap: wrap; }
.opt-ins-head { flex: 1 1 220px; padding-right: 30px; }
.opt-ins-head .opt-check { right: 0; top: 7px; }
.opt-money { position: relative; display: block; margin: 0; flex: 0 1 160px; min-width: 130px; }
.opt-money input { height: 34px; padding-right: 26px; text-align: right; font-variant-numeric: tabular-nums; font-size: 13.5px;
                   -moz-appearance: textfield; appearance: textfield; }
.opt-money input::-webkit-inner-spin-button, .opt-money input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.opt-money span { position: absolute; right: 10px; top: 8px; font-size: 13px; color: var(--muted); pointer-events: none; }
.opt-money input:placeholder-shown + span { display: none; }
.opt-money input::placeholder { text-align: left; }

/* Mã khuyến mãi + hẹn giờ */
.opt-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.opt-field { display: block; margin: 0; min-width: 0; }
.opt-field > span { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 500; color: var(--text-2); margin-bottom: 5px; }
.opt-field input { height: 38px; font-size: 13.5px; }
.opt-field input[data-o=promo_code] { text-transform: uppercase; letter-spacing: .04em; font-family: var(--mono); }
.opt-field input[data-o=promo_code]::placeholder { text-transform: none; letter-spacing: 0; font-family: var(--font); }
.opt-hint { margin: 0; font-size: 12px; color: var(--muted); line-height: 1.45; }

@media (max-width: 520px) {
  .opt-svc, .opt-grid { grid-template-columns: 1fr; }
  .opt-tile { padding: 10px 36px 10px 12px; }
  .opt-tile .opt-tile-ic { display: none; }
  .opt-line-ctl { max-width: 55%; }
  .opt-money { flex: 1 1 100%; }
  .opt-panel input, .opt-panel select { font-size: 16px; }
}
@media (max-width: 359px) { .opt-tiles { grid-template-columns: 1fr; } }
