html,
body {
  height: 100%;
}

.with-transition {
  transition: transform 300ms ease;
}

.noUi-target {
  background: rgba(255, 255, 255, .15);
  border: 0;
  box-shadow: none;
}

.noUi-connect {
  background: #22d3ee;
}

.noUi-handle {
  border: 0;
  background: #22d3ee;
  box-shadow: none;
}

.noUi-horizontal {
  height: 8px;
}

.noUi-handle {
  width: 16px;
  height: 16px;
  right: -8px;
  top: -4px;
  border-radius: 999px;
}

/* Chat theme (updated: user left, bot right, avatars, persistent typing) */
.chat-wrap {
  height: 100%;
  display: grid;
  grid-template-rows: 1fr auto;
  background: linear-gradient(180deg, rgba(255, 255, 255, .02), rgba(255, 255, 255, .01));
}

.chat-msgs {
  padding: 16px 16px 110px;
  overflow: auto;
  scroll-behavior: smooth;
  background: none;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.chat-row {
  display: flex;
  gap: 10px;
  align-items: flex-end
}

.chat-row.user {
  justify-content: flex-start
}

.chat-row.bot {
  justify-content: flex-end
}

.chat-avatar {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  overflow: hidden;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, .12)
}

.chat-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block
}

.chat-bubble {
  max-width: 78%;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, .06)
}

/* Markdown inside chat bubbles */
.chat-bubble .md h1,
.chat-bubble .md h2,
.chat-bubble .md h3 {
  font-weight: 700;
  line-height: 1.25;
  margin: .35rem 0
}

.chat-bubble .md h1 {
  font-size: 1.1rem
}

.chat-bubble .md h2 {
  font-size: 1.05rem
}

.chat-bubble .md h3 {
  font-size: 1rem
}

.chat-bubble .md p {
  margin: .4rem 0
}

.chat-bubble .md ul,
.chat-bubble .md ol {
  margin: .35rem 0 .35rem 1.1rem
}

.chat-bubble .md li {
  margin: .2rem 0
}

.chat-bubble .md a {
  color: #93c5fd;
  text-decoration: underline
}

.chat-bubble .md code {
  background: rgba(255, 255, 255, .08);
  padding: .1rem .3rem;
  border-radius: .35rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .875em
}

.chat-bubble .md pre {
  background: rgba(255, 255, 255, .06);
  padding: .6rem .75rem;
  border-radius: .6rem;
  overflow: auto;
  border: 1px solid rgba(255, 255, 255, .08)
}

.chat-bubble .md pre code {
  background: transparent;
  padding: 0
}

.chat-bubble .md table {
  border-collapse: collapse;
  width: 100%;
  margin: .5rem 0;
  font-size: .95em
}

.chat-bubble .md th,
.chat-bubble .md td {
  border: 1px solid rgba(255, 255, 255, .12);
  padding: .35rem .5rem
}

.chat-bubble .md thead th {
  background: rgba(255, 255, 255, .06)
}

.chat-row.user .chat-bubble {
  background: #2a2f5a;
  color: #e9ecff;
  border-color: rgba(255, 255, 255, .10)
}

.chat-row.bot .chat-bubble {
  background: #1b2046;
  color: #e9ecff;
  border-color: rgba(255, 255, 255, .08)
}

.chat-bar {
  position: sticky;
  bottom: 0;
  z-index: 2;
  padding: 12px;
  background: linear-gradient(180deg, rgba(255, 255, 255, .03), rgba(255, 255, 255, .02));
  border-top: 1px solid rgba(255, 255, 255, .08);
  backdrop-filter: blur(6px);
}

.composer {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: rgba(255, 255, 255, .06);
  border: 1px solid rgba(255, 255, 255, .10);
  border-radius: 14px;
  padding: 8px;
}

.chat-input {
  flex: 1 1 auto;
  min-height: 44px;
  max-height: 160px;
  padding: 10px 12px;
  border: 0;
  outline: none;
  background: transparent;
  color: #e9ecff;
  font-size: 16px;
  line-height: 1.35;
  resize: none;
}

.chat-send {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 44px;
  padding: 0 14px;
  border: 0;
  border-radius: 12px;
  background: #6c8cff;
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}

.chat-send:active {
  transform: translateY(1px);
}

.chat-send[disabled] {
  filter: saturate(.2) brightness(.85);
  cursor: not-allowed;
}

.typing {
  display: inline-grid;
  grid-auto-flow: column;
  gap: 6px;
  align-items: center;
  padding: 2px 4px
}

.dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: #9fb0ff;
  opacity: .75;
  animation: bounce 1s infinite ease-in-out
}

.dot:nth-child(2) {
  animation-delay: .12s
}

.dot:nth-child(3) {
  animation-delay: .24s
}

@keyframes bounce {

  0%,
  80%,
  100% {
    transform: translateY(0);
    opacity: .7
  }

  40% {
    transform: translateY(-5px);
    opacity: 1
  }
}

/* Report table tweaks */
.tbl th,
.tbl td {
  padding: .55rem .65rem;
}

.tbl thead th {
  position: sticky;
  top: 0;
  background: rgba(2, 6, 23, .85);
  backdrop-filter: blur(4px);
}

/* Modal animations */
@keyframes modalIn {
  from {
    opacity: 0;
    transform: translateY(10px) scale(.98);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes modalOut {
  from {
    opacity: 1;
    transform: translateY(0) scale(1);
  }

  to {
    opacity: 0;
    transform: translateY(10px) scale(.98);
  }
}

.modal-enter {
  animation: modalIn .25s ease forwards;
}

.modal-leave {
  animation: modalOut .2s ease forwards;
}

/* Custom Popup Styles */
.custom-popup {
  z-index: 1000;
  pointer-events: none;
  /* Prevent popup from capturing mouse events, which causes flickering */
}

.custom-popup .maplibregl-popup-content {
  background: rgba(23, 23, 23, 0.95);
  /* neutral-900 with opacity */
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 0;
  /* We handle padding in HTML */
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(8px);
}

.custom-popup .maplibregl-popup-tip {
  border-top-color: rgba(23, 23, 23, 0.95);
  border-bottom-color: rgba(23, 23, 23, 0.95);
}

.maplibregl-popup-anchor-top .maplibregl-popup-tip,
.maplibregl-popup-anchor-top-left .maplibregl-popup-tip,
.maplibregl-popup-anchor-top-right .maplibregl-popup-tip {
  border-bottom-color: rgba(23, 23, 23, 0.95);
}

.maplibregl-popup-anchor-bottom .maplibregl-popup-tip,
.maplibregl-popup-anchor-bottom-left .maplibregl-popup-tip,
.maplibregl-popup-anchor-bottom-right .maplibregl-popup-tip {
  border-top-color: rgba(23, 23, 23, 0.95);
}

.maplibregl-popup-anchor-left .maplibregl-popup-tip {
  border-right-color: rgba(23, 23, 23, 0.95);
}

.maplibregl-popup-anchor-right .maplibregl-popup-tip {
  border-left-color: rgba(23, 23, 23, 0.95);
}