/**
 * Floating AI dialog — glass overlay (driver hub) + FAB fallback.
 */

.ts-ai-float {
  position: fixed;
  right: max(1rem, env(safe-area-inset-right, 0px));
  bottom: max(1rem, env(safe-area-inset-bottom, 0px));
  z-index: 1200;
  font-family: "PingFang SC", "Noto Sans SC", system-ui, sans-serif;
}

.ts-ai-float__fab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 3.25rem;
  height: 3.25rem;
  padding: 0 1rem;
  border: 0;
  border-radius: 999px;
  background: #0071e3;
  color: #fff;
  font-weight: 600;
  font-size: 0.92rem;
  box-shadow: 0 8px 24px rgba(0, 113, 227, 0.35);
  cursor: pointer;
}

.ts-ai-float__fab:hover {
  background: #0077ed;
}

.ts-ai-float__panel {
  position: absolute;
  right: 0;
  bottom: calc(100% + 0.65rem);
  width: min(22rem, calc(100vw - 2rem));
  height: min(32rem, calc(100dvh - 6rem));
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: calc(100dvh - 5rem);
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.14);
}

.ts-ai-float__panel[hidden] {
  display: none !important;
}

.ts-ai-float__head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  background: rgba(247, 247, 249, 0.72);
}

.ts-ai-float__head strong {
  flex: 1 1 auto;
  font-size: 0.95rem;
}

.ts-ai-float__expand,
.ts-ai-float__close {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #6e6e73;
  text-decoration: none;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
}

.ts-ai-float__expand:hover,
.ts-ai-float__close:hover {
  background: rgba(0, 0, 0, 0.06);
  color: #1d1d1f;
}

.ts-ai-float__body {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
}

.ts-ai-float__body .ts-ai-chat {
  border: 0;
  border-radius: 0;
  box-shadow: none;
  height: 100%;
  min-height: 0;
  max-height: 100%;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto auto;
  background: transparent;
  --ts-ai-chips-max: min(34vh, 11rem);
}

.ts-ai-float__body .ts-ai-chat__chips {
  min-height: 0;
  max-height: min(38vh, 12.5rem);
  padding-left: 0.7rem;
  padding-right: 0.7rem;
}

.ts-ai-float__body .ts-ai-chat__chip-tab {
  font-size: 0.68rem;
  min-height: 2rem;
  padding: 0.28rem 0.1rem;
}

.ts-ai-float__body .ts-ai-chat__chip-list[hidden],
.ts-ai-float__body .ts-ai-chat__chip-panels > [hidden] {
  display: none !important;
}

/* Driver hub: map「AI问单」opens a glass overlay sheet (no FAB). */
.driver-hub .ts-ai-float {
  inset: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0 0.75rem calc(4.75rem + env(safe-area-inset-bottom, 0px));
  pointer-events: none;
  background: transparent;
  transition: background 0.18s ease;
}

.driver-hub .ts-ai-float.is-open {
  pointer-events: auto;
  background: rgba(20, 24, 32, 0.34);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}

.driver-hub .ts-ai-float__fab {
  display: none;
}

.driver-hub .ts-ai-float__panel {
  position: relative;
  right: auto;
  bottom: auto;
  width: min(26rem, 100%);
  height: min(76dvh, 36rem);
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 18px;
  box-shadow: 0 18px 48px rgba(16, 24, 40, 0.22);
  -webkit-backdrop-filter: blur(22px) saturate(160%);
  backdrop-filter: blur(22px) saturate(160%);
}

.driver-hub .ts-ai-float__head {
  background: rgba(255, 255, 255, 0.42);
  border-bottom-color: rgba(60, 60, 67, 0.1);
}

@media (max-width: 640px) {
  .ts-ai-float__panel {
    width: calc(100vw - 1.25rem);
    height: min(70dvh, 28rem);
  }

  .driver-hub .ts-ai-float__panel {
    width: 100%;
    height: min(78dvh, 34rem);
  }
}

/* Desktop / 车机：居中大对话框，不再用手机底栏窄卡 */
body.dh-layout--wide.driver-hub .ts-ai-float {
  align-items: center;
  justify-content: center;
  padding: 1.25rem 1.5rem calc(1.25rem + env(safe-area-inset-bottom, 0px));
}

body.dh-layout--wide.driver-hub .ts-ai-float__panel {
  width: min(40rem, calc(100vw - 3rem));
  height: min(80dvh, 44rem);
  max-height: calc(100dvh - 2.5rem);
  border-radius: 20px;
}

body.dh-layout--wide.driver-hub .ts-ai-float__head {
  padding: 0.8rem 1rem;
}

body.dh-layout--wide.driver-hub .ts-ai-float__head strong {
  font-size: 1.05rem;
}

body.dh-layout--wide.driver-hub .ts-ai-float__body .ts-ai-chat__chips {
  max-height: min(30vh, 15rem);
  padding-left: 1rem;
  padding-right: 1rem;
}

body.dh-layout--wide.driver-hub .ts-ai-float__body .ts-ai-chat__chip-tabs {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.45rem;
  overflow-x: auto;
  scrollbar-width: none;
}

body.dh-layout--wide.driver-hub .ts-ai-float__body .ts-ai-chat__chip-tabs::-webkit-scrollbar {
  display: none;
}

body.dh-layout--wide.driver-hub .ts-ai-float__body .ts-ai-chat__chip-tab {
  flex: 0 0 auto;
  min-height: 2.25rem;
  padding: 0.35rem 0.85rem;
  font-size: 0.84rem;
  border-radius: 999px;
}

body.dh-layout--wide.driver-hub .ts-ai-float__body .ts-ai-chat__messages {
  padding-left: 1rem;
  padding-right: 1rem;
}

body.dh-layout--wide.driver-hub .ts-ai-float__body .ts-ai-chat__form {
  padding-left: 1rem;
  padding-right: 1rem;
}

@media (min-width: 1100px) {
  body.dh-layout--wide.driver-hub .ts-ai-float__panel {
    width: min(48rem, calc(100vw - 4rem));
    height: min(84dvh, 52rem);
  }

  body.dh-layout--wide.driver-hub .ts-ai-float__body .ts-ai-chat__chips {
    max-height: min(32vh, 16rem);
  }
}

/* Map fullscreen: float above the map layer */
body.dh-map-fs .ts-ai-float {
  z-index: 2400;
}

body.dh-map-fs .ts-ai-float.is-open {
  padding: max(0.75rem, env(safe-area-inset-top, 0px)) 0.75rem calc(0.75rem + env(safe-area-inset-bottom, 0px));
}

@media (min-width: 768px) {
  body.dh-map-fs.dh-layout--wide .ts-ai-float.is-open {
    padding: 1.25rem 1.5rem;
  }

  body.dh-map-fs.dh-layout--wide .ts-ai-float__panel {
    width: min(40rem, calc(100vw - 3rem));
    height: min(80dvh, 44rem);
  }
}
