/**
 * Floating decision chrome over the Tianditu map widget.
 * Self-contained — works outside driver_hub theme.
 */

.tdm {
  --tdm-radius: 16px;
  --tdm-ink: #333338;
  --tdm-muted: #8e8e96;
  --tdm-glass: rgba(255, 255, 255, 0.78);
  --tdm-glass-border: rgba(255, 255, 255, 0.55);
  position: relative;
  margin: 0 0 12px;
}

.tdm__frame {
  position: relative;
  min-height: 0;
  height: var(--tdm-map-height, min(52dvh, 420px));
  border-radius: var(--tdm-radius);
  overflow: hidden;
  box-shadow: 0 6px 22px rgba(28, 20, 14, 0.08);
  background: #eef0f4;
}

.tdm__canvas.ch-map-canvas {
  position: absolute;
  inset: 0;
  height: 100% !important;
  min-height: 0;
  width: 100%;
  border-radius: 0;
  z-index: 0;
}

/* Right tools — slightly smaller */
.tdm__tools.ch-map-tools {
  right: max(8px, env(safe-area-inset-right, 0px));
  bottom: max(12px, env(safe-area-inset-bottom, 0px));
  gap: 6px;
  z-index: 12;
}

.tdm--with-hud .tdm__tools.ch-map-tools {
  bottom: max(12px, env(safe-area-inset-bottom, 0px));
}

.tdm .ch-map-loc-btn,
.tdm .ch-map-fs-btn,
.tdm .ch-home-map__hit,
.tdm .ch-map-ai-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
}

.tdm .ch-map-ai-btn {
  height: auto;
  min-height: 36px;
  font-size: 0.58rem;
}

.tdm .ch-home-map__hit {
  font-size: 0.68rem;
}

.tdm .ch-map-loc-btn svg,
.tdm .ch-map-fs-btn svg {
  width: 16px;
  height: 16px;
}

/* Heat legend — hidden on home map HUD */
.tdm__legend.ch-map-heat-legend {
  display: none !important;
}

/* Floating HUD — top of map, glass */
.tdm__hud {
  position: absolute;
  left: 8px;
  right: 8px;
  top: 8px;
  bottom: auto;
  z-index: 14;
  display: grid;
  gap: 6px;
  pointer-events: none;
}

.tdm__hud > * {
  pointer-events: auto;
}

.tdm__decision {
  display: flex;
  align-items: stretch;
  gap: 10px;
  min-width: 0;
  padding: 8px 8px 8px 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.45);
  box-shadow: 0 4px 16px rgba(28, 20, 14, 0.08);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  backdrop-filter: blur(16px) saturate(140%);
  color: var(--tdm-ink);
}

.tdm__decision-main {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1 1 auto;
  text-decoration: none;
  color: inherit;
}

.tdm__badge.ch-go-badge {
  flex: none;
  width: 2.75rem;
  min-width: 2.75rem;
  max-width: 2.75rem;
  padding: 2px 0;
  font-size: 0.62rem;
  border-radius: 999px;
  box-sizing: border-box;
  justify-content: center;
}

.tdm__decision-text {
  display: grid;
  gap: 1px;
  min-width: 0;
  flex: 1 1 auto;
}

.tdm__decision-text strong {
  font-size: 0.88rem;
  font-weight: 650;
  letter-spacing: -0.01em;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--tdm-ink);
}

.tdm__decision-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px;
  min-width: 0;
  white-space: nowrap;
}

.tdm__decision-meta em {
  font-style: normal;
  font-size: 0.68rem;
  color: var(--tdm-muted);
}

.tdm__decision-meta b,
.tdm__orders {
  font-size: 0.72rem;
  font-weight: 650;
  color: var(--tdm-ink);
  font-variant-numeric: tabular-nums;
}

.tdm__orders {
  display: inline-flex;
  align-items: baseline;
  gap: 3px;
}

.tdm__orders-when {
  color: var(--tdm-muted);
  font-size: 0.65rem;
  font-weight: 500;
}

.tdm__orders-range {
  font-size: 0.72rem;
  font-weight: 700;
}

/* Primary radar CTA — prominent rounded square on the far right */
.tdm__radar-btn {
  flex: none;
  align-self: stretch;
  margin-left: auto;
  order: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 3.35rem;
  width: 3.35rem;
  padding: 6px 4px;
  border-radius: 12px;
  font-size: 0.76rem;
  font-weight: 750;
  letter-spacing: 0.04em;
  line-height: 1.15;
  text-align: center;
  text-decoration: none;
  color: #fff;
  background: linear-gradient(180deg, #d66a32 0%, #c45c26 100%);
  box-shadow:
    0 2px 8px rgba(196, 92, 38, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.22);
  -webkit-tap-highlight-color: transparent;
}

.tdm__decision-main {
  order: 1;
}

.tdm__radar-btn:active {
  transform: scale(0.96);
  background: linear-gradient(180deg, #c45c26 0%, #b04f1f 100%);
}

/* Legacy action strip — hidden (radar CTA lives on decision) */
.tdm__actions {
  display: none !important;
}

.tdm__action {
  display: none !important;
}

/* Compact home variant */
.tdm--compact .tdm__frame {
  height: var(--tdm-map-height, min(48dvh, 380px));
}

@media (max-width: 380px) {
  .tdm__radar-btn {
    min-width: 3rem;
    width: 3rem;
    font-size: 0.72rem;
    border-radius: 10px;
  }

  .tdm__decision-text strong {
    font-size: 0.82rem;
  }
}
