/* Trang Chi tiết đơn: cột thẻ bên trái + bản đồ lớn dính bên phải (mobile: bản đồ lên trên). */

/* ---------- topbar ---------- */
.dt-back { display: inline-flex; align-items: center; gap: 4px; height: 32px; padding: 0 10px 0 6px; margin-left: -6px;
           border-radius: 8px; color: var(--text-2); font-size: 14px; font-weight: 500; text-decoration: none !important; }
.dt-back:hover { background: var(--grey-50); color: var(--text); }
.dt-back { flex: none; }
.dt-top-id { font-size: 16px; padding-left: 10px; border-left: 1px solid var(--line); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-actions:has(.dt-act) { flex: none; }

/* ---------- bố cục ---------- */
.dt { display: grid; grid-template-columns: 420px minmax(0, 1fr); gap: 20px; align-items: start; }
.dt-side { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.dt-map-col { position: sticky; top: calc(var(--topbar-h) + 24px); height: calc(100vh - var(--topbar-h) - 48px); min-height: 420px; }
.dt-map { position: relative; height: 100%; overflow: hidden; isolation: isolate; background: var(--grey-50); }
.dt-leaflet { position: absolute; inset: 0; z-index: 0; }

/* Nhúng trang theo dõi của Ahamove ở bố cục điện thoại (kích thước tính trong detail.js), chỉ chừa phần bản đồ.
   Phụ thuộc bố cục trang của Ahamove: nếu họ đổi thì chỉnh AHA_MAP_FRAC trong detail.js. */
.live-crop { position: absolute; inset: 0; overflow: hidden; background: var(--grey-50); }
.live-crop iframe { position: absolute; top: 0; left: 0; border: 0; transform-origin: 0 0; }

/* Thanh chọn bản đồ; đồng thời che nút chọn ngôn ngữ ở góc trên trái trang Ahamove. */
.dt-map-bar { position: absolute; top: 12px; left: 12px; z-index: 700; display: flex; flex-direction: column; gap: 6px;
              min-width: 150px; padding: 6px; border-radius: 12px; background: var(--surface); box-shadow: var(--shadow); }
.dt-map-bar .seg { display: flex; gap: 2px; padding: 2px; border-radius: 9px; background: var(--grey-50); }
.dt-map-bar .seg button { flex: 1; height: 30px; padding: 0 12px; border: 0; border-radius: 7px; background: none; cursor: pointer;
                          font: inherit; font-size: 13px; font-weight: 500; color: var(--text-2); white-space: nowrap; }
.dt-map-bar .seg button.on { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.12); }
.dt-map-sub { display: flex; align-items: center; gap: 6px; padding: 0 6px 2px; font-size: 12px; color: var(--text-2); }
.dt-map-sub a { margin-left: auto; padding-left: 8px; color: var(--brand); font-weight: 500; white-space: nowrap; }

.dt-map-note { position: absolute; left: 12px; bottom: 12px; z-index: 600; max-width: calc(100% - 72px); /* chừa nút thu phóng bên phải */
               display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 10px;
               background: rgba(255, 255, 255, .95); box-shadow: var(--shadow); font-size: 13px; color: var(--text-2); }
.dt-live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); flex: none; animation: dt-blink 1.6s infinite; }
.dt-live-dot.on { background: var(--ok); }
@keyframes dt-blink { 50% { opacity: .35; } }

@media (max-width: 1180px) { .dt { grid-template-columns: 370px minmax(0, 1fr); } }
@media (max-width: 860px) {
  .dt { grid-template-columns: 1fr; gap: 14px; }
  .dt-map-col { order: -1; position: relative; top: auto; height: 300px; min-height: 0; }
  .dt-top-id { font-size: 13px; padding-left: 8px; }
  .dt-act { height: 34px; padding: 0 12px; font-size: 13px; }
  .dt-wide { display: none; }
  .dt-back span { display: none; }
  .topbar h1:has(.dt-back) .badge { display: none; }
}

/* ---------- thẻ chung ---------- */
.dt-card { overflow: hidden; }
.dt-card-head { display: flex; align-items: center; gap: 8px; padding: 14px 18px 10px; }
.dt-card-head h2 { font-size: 15px; font-weight: 600; }
.dt-count { font-size: 12px; color: var(--muted); font-weight: 500; }
.dt-count:empty { display: none; }
.dt-skel { padding: 18px; display: flex; flex-direction: column; gap: 10px; }
.dt-sm { font-size: 12px; }
.dt-empty-sm { color: var(--muted); font-size: 13px; padding: 4px 0 8px; }
.dt-alert { margin: 0 18px 12px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--danger-50);
            border: 1px solid var(--danger-100); color: var(--danger); font-size: 13px; }
.dt-alert.soft { background: var(--warn-50); border-color: var(--warn-100); color: var(--warn); }
.dt-fold-body .dt-alert { margin: 8px 0; }

/* thẻ thu gọn được */
.dt-fold > summary { list-style: none; cursor: pointer; user-select: none; padding-bottom: 14px; }
.dt-fold > summary::-webkit-details-marker { display: none; }
.dt-fold > summary:hover h2 { color: var(--brand); }
.dt-chev { margin-left: auto; color: var(--muted); transition: transform .15s; }
.dt-fold[open] > summary { padding-bottom: 10px; }
.dt-fold[open] .dt-chev { transform: rotate(180deg); }
.dt-fold-body { padding: 0 18px 14px; }

/* ---------- trạng thái + tiến trình ---------- */
.dt-hero { overflow: hidden; }
.dt-hero-top { padding: 18px 20px 16px; border-bottom: 1px solid var(--line); }
.dt-hero-label { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; }
.dt-hero-label::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.dt-hero-title { font-size: 19px; font-weight: 700; line-height: 1.3; margin-top: 4px; letter-spacing: -.01em; }
.dt-hero-sub { font-size: 13px; color: var(--text-2); margin-top: 4px; }
.tone-info { background: linear-gradient(180deg, var(--info-50), var(--surface)); } .tone-info .dt-hero-label { color: var(--info); }
.tone-warn { background: linear-gradient(180deg, var(--warn-50), var(--surface)); } .tone-warn .dt-hero-label { color: var(--warn); }
.tone-ok { background: linear-gradient(180deg, var(--ok-50), var(--surface)); } .tone-ok .dt-hero-label { color: var(--ok); }
.tone-bad { background: linear-gradient(180deg, var(--danger-50), var(--surface)); } .tone-bad .dt-hero-label { color: var(--danger); }
.dt-hero .dt-alert { margin-top: 12px; }

.dt-steps { list-style: none; margin: 0; padding: 14px 20px 8px; }
.dt-steps li { position: relative; display: grid; grid-template-columns: 18px 1fr auto; gap: 12px; align-items: start; padding-bottom: 14px; }
.dt-steps li:not(:last-child)::after { content: ""; position: absolute; left: 8px; top: 18px; bottom: 0; width: 2px; background: var(--line); }
.dt-steps li.done:not(:last-child)::after { background: var(--brand); }
.dt-dot { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--line-2); background: var(--surface); margin-top: 1px;
          position: relative; z-index: 1; display: inline-flex; align-items: center; justify-content: center; }
.dt-steps li.done .dt-dot { border-color: var(--brand); background: var(--brand); }
.dt-steps li.done .dt-dot::after { content: ""; width: 5px; height: 9px; border: solid #fff; border-width: 0 2px 2px 0; transform: translateY(-1px) rotate(45deg); }
.dt-steps li.cur .dt-dot { border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-50); }
.dt-steps li.cur .dt-dot::after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--brand); animation: dt-blink 1.4s infinite; }
.dt-steps li.bad .dt-dot { border-color: var(--danger); background: var(--danger); }
.dt-steps li.bad .dt-dot::after { content: "×"; color: #fff; font-size: 13px; font-weight: 700; line-height: 1; }
.dt-step-tx b { font-weight: 500; color: var(--text); }
.dt-steps li.todo .dt-step-tx b { color: var(--muted); }
.dt-steps li.cur .dt-step-tx b, .dt-steps li.bad .dt-step-tx b { font-weight: 700; }
.dt-steps li.bad .dt-step-tx b { color: var(--danger); }
.dt-steps time { font-size: 12px; color: var(--text-2); padding-top: 1px; }

/* ---------- tài xế ---------- */
.dt-drv { display: flex; align-items: center; gap: 14px; padding: 16px 18px; }
.dt-avatar { width: 56px; height: 56px; border-radius: 50%; background: var(--brand-50); color: var(--brand); font-weight: 700;
             font-size: 20px; display: flex; align-items: center; justify-content: center; overflow: hidden; flex: none;
             box-shadow: 0 0 0 3px var(--surface), 0 0 0 4px var(--brand-100); }
.dt-avatar img { width: 100%; height: 100%; object-fit: cover; }
.dt-avatar.none { background: var(--grey-50); color: var(--muted); box-shadow: none; }
.dt-drv-main { flex: 1; min-width: 0; }
.dt-drv-name { font-size: 16px; font-weight: 700; line-height: 1.3; }
.dt-drv-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; font-size: 12px; margin-top: 2px; }
.dt-star { color: var(--be); font-weight: 600; }
.dt-plate { font-family: var(--mono); font-size: 12px; font-weight: 600; padding: 1px 6px; border-radius: 4px; border: 1px solid var(--line-2);
            background: var(--surface-2); }
.dt-drv-phone { font-size: 13px; color: var(--text-2); margin-top: 2px; }
.dt-call { width: 44px; height: 44px; border-radius: 50%; background: var(--brand); color: #fff; flex: none;
           display: inline-flex; align-items: center; justify-content: center; box-shadow: 0 4px 12px rgba(0, 135, 90, .3); }
.dt-call:hover { background: var(--brand-600); }
.dt-drv.none .dt-drv-name { font-size: 15px; color: var(--text-2); }
.dt-drv.none .muted, .dt-drv.finding .muted { font-size: 13px; }

.dt-radar { position: relative; width: 56px; height: 56px; flex: none; display: flex; align-items: center; justify-content: center; }
.dt-radar i { position: relative; z-index: 1; width: 40px; height: 40px; border-radius: 50%; background: var(--warn-50); color: var(--warn);
              display: inline-flex; align-items: center; justify-content: center; font-style: normal; }
.dt-radar span { position: absolute; inset: 0; border-radius: 50%; border: 2px solid var(--warn); opacity: 0; animation: dt-pulse 2s infinite; }
.dt-radar span:nth-child(2) { animation-delay: 1s; }
@keyframes dt-pulse { 0% { transform: scale(.55); opacity: .6; } 100% { transform: scale(1.15); opacity: 0; } }

/* ---------- lộ trình ---------- */
.dt-route { list-style: none; margin: 0; padding: 4px 18px 16px; }
.dt-route > li { position: relative; display: grid; grid-template-columns: 24px 1fr; gap: 12px; padding-bottom: 16px; }
.dt-route > li:last-child { padding-bottom: 0; }
.dt-route > li:not(:last-child)::after { content: ""; position: absolute; left: 11px; top: 28px; bottom: 4px;
                                          border-left: 2px dashed var(--line-2); }
.dt-pt { min-width: 0; }
.dt-pt-kind { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); font-weight: 500; line-height: 24px; }
.dt-pt-st { margin: 0; height: 20px; background: var(--info-50); color: var(--info); }
.dt-pt-addr { font-weight: 600; line-height: 1.4; overflow-wrap: anywhere; }
.dt-pt-who { font-size: 13px; color: var(--text-2); margin-top: 2px; }
.dt-pt-who b { color: var(--text); font-weight: 500; }
.dt-sep { margin: 0 6px; color: var(--muted); }
.dt-tel { font-variant-numeric: tabular-nums; }
.dt-pt-extra { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.dt-cod { display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 8px; border-radius: 6px; font-size: 12px;
          background: var(--warn-50); color: var(--warn); }
.dt-cod b { font-weight: 700; }
.dt-note { font-size: 12px; color: var(--text-2); background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px;
           padding: 2px 8px; overflow-wrap: anywhere; }

/* ---------- thanh toán ---------- */
.dt-pay { padding: 0 18px 16px; }
.dt-fee { display: flex; align-items: baseline; justify-content: space-between; padding: 10px 14px; margin-bottom: 8px;
          border-radius: var(--radius-sm); background: var(--brand-50); }
.dt-fee span { font-size: 13px; color: var(--text-2); }
.dt-fee b { font-size: 20px; color: var(--brand-600); }
.dt-kv { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 7px 0; font-size: 13px;
         border-bottom: 1px dashed var(--line); }
.dt-kv:last-of-type { border-bottom: 0; }
.dt-kv > span:first-child { color: var(--text-2); }
.dt-kv > span:last-child { text-align: right; min-width: 0; overflow-wrap: anywhere; }
.dt-chips { margin-top: 8px; }

/* ---------- điều phối ---------- */
.dt-att { list-style: none; margin: 0; padding: 0 18px 16px; display: flex; flex-direction: column; gap: 8px; }
.dt-att li { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.dt-att li.cur { border-color: var(--brand-100); background: var(--brand-50); }
.dt-att li.dead .dt-att-top, .dt-att li.dead .dt-att-sub .order-id { text-decoration: line-through; color: var(--muted); }
.dt-att li.dead { background: var(--surface-2); }
.dt-att li.pending { border-style: dashed; border-color: var(--line-2); }
.dt-att li.pending .dt-att-top { opacity: .8; }
.dt-att-n { width: 22px; height: 22px; border-radius: 50%; background: var(--grey-50); color: var(--text-2); font-size: 12px; font-weight: 600;
            display: inline-flex; align-items: center; justify-content: center; flex: none; }
.dt-att li.cur .dt-att-n { background: var(--brand); color: #fff; }
.dt-att-main { flex: 1; min-width: 0; }
.dt-att-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.dt-att-price { font-weight: 600; }
.dt-att-sub { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 10px; margin-top: 4px; font-size: 12px; color: var(--text-2); }
.dt-tag { display: inline-flex; align-items: center; height: 20px; padding: 0 7px; border-radius: 999px; font-size: 11px; font-weight: 600;
          background: var(--grey-50); color: var(--text-2); }
.dt-tag.cur { background: var(--brand); color: #fff; }

/* ---------- nhật ký ---------- */
.dt-ev { list-style: none; margin: 0; padding: 0; }
.dt-ev li { display: grid; grid-template-columns: 64px 1fr; gap: 10px; padding: 7px 0; font-size: 13px; border-top: 1px solid var(--line); }
.dt-ev li:first-child { border-top: 0; padding-top: 0; }
.dt-ev time { color: var(--muted); font-size: 12px; padding-top: 1px; }
.dt-ev-src { display: inline-block; font-size: 11px; font-weight: 600; color: var(--text-2); background: var(--grey-50);
             border-radius: 4px; padding: 0 6px; margin-right: 6px; }
.dt-more { margin-top: 6px; color: var(--brand); padding: 0 6px; }

/* ---------- nhật ký webhook ---------- */
.dt-cb-tools { display: flex; align-items: center; gap: 8px; font-size: 12px; margin-bottom: 8px; }
.dt-cb-tools .btn { margin-left: auto; }
.dt-cb-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.dt-cb { width: 100%; border-collapse: collapse; font-size: 12px; }
.dt-cb th { text-align: left; font-weight: 600; color: var(--text-2); background: var(--surface-2); padding: 6px 8px; white-space: nowrap; }
.dt-cb td { padding: 6px 8px; border-top: 1px solid var(--line); vertical-align: top; }
.dt-cb td.ok { color: var(--ok); font-weight: 600; }
.dt-cb td.bad { color: var(--danger); font-weight: 600; }

/* ---------- không tìm thấy đơn ---------- */
.dt-404 { max-width: 460px; margin: 48px auto; padding: 36px 28px; text-align: center; }
.dt-404-ic { width: 56px; height: 56px; margin: 0 auto 14px; border-radius: 50%; background: var(--grey-50); color: var(--muted);
             display: flex; align-items: center; justify-content: center; }
.dt-404 h2 { font-size: 17px; margin-bottom: 6px; }
.dt-404 p { margin: 0 0 18px; }
