/* Unified chat window (parent page) for all contexts:
   - Admin chat bar
   - Admin messaging pages (driver/client)
   - Transport details buttons
   - Public "Chat with us" triggers

   This styles the *container that hosts the iframe*, not the chat UI inside the iframe.
*/

#chatModal{
  display: block;
  position: fixed;
  right: 16px;
  bottom: 16px;
  width: min(420px, calc(100vw - 32px));
  height: min(72vh, 680px);
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(11,15,23,0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 30px 90px rgba(0,0,0,0.65);
  overflow: hidden;
  z-index: 10000090;

  /* Closed state */
  opacity: 0;
  transform: translateY(14px) scale(0.98);
  transform-origin: bottom right;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 180ms ease, transform 240ms cubic-bezier(.2,.9,.2,1), visibility 0s linear 240ms;
  will-change: opacity, transform;
}

#chatModal .ds-chat-resize-handle{
  position: absolute;
  width: 10px;
  z-index: 3; /* above iframe */
  cursor: ew-resize;
  /* Invisible by default; shows on hover to hint resizable */
  background: transparent;
}

#chatModal .ds-chat-resize-handle--left{
  top: 0;
  bottom: 0;
  left: 0;
}

#chatModal .ds-chat-resize-handle--top{
  left: 0;
  right: 0;
  top: 0;
  height: 10px;
  width: auto;
  cursor: ns-resize;
}

/* Corner handle to resize both width + height (keep clickable but no marker). */
#chatModal .ds-chat-resize-handle--top-left{
  top: 0;
  left: 0;
  width: 14px;
  height: 14px;
  cursor: nwse-resize;
}

#chatModal:hover .ds-chat-resize-handle{
  /* subtle grab highlight */
  background: linear-gradient(90deg, rgba(255,255,255,0.02), rgba(255,255,255,0.00));
}
/* Keep the corner handle invisible even on hover. */
#chatModal:hover .ds-chat-resize-handle--top-left{
  background: transparent;
}

#chatModal .ds-chat-resize-handle::after{
  content: "";
  position: absolute;
  top: 50%;
  left: 2px;
  width: 4px;
  height: 60px;
  border-radius: 999px;
  transform: translateY(-50%);
  background: rgba(255,255,255,0.22);
  opacity: 0;
  transition: opacity 140ms ease;
}

#chatModal .ds-chat-resize-handle--top::after{
  top: 2px;
  left: 50%;
  width: 60px;
  height: 4px;
  transform: translateX(-50%);
}

/* Remove the visible "grip" for the top-left corner; hit area still works. */
#chatModal .ds-chat-resize-handle--top-left::after{
  content: none;
}
#chatModal:hover .ds-chat-resize-handle::after{
  opacity: 1;
}

#chatModal.resizing{
  user-select: none;
  /* Backdrop blur is expensive to repaint while resizing; disable during drag
     to avoid jank/freezing on some machines. */
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

#chatModal.active{
  opacity: 1;
  transform: translateY(0) scale(1);
  visibility: visible;
  pointer-events: auto;
  transition: opacity 200ms ease, transform 260ms cubic-bezier(.2,.9,.2,1), visibility 0s;
}

#chatModal #chatFrame{
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
  background: rgba(11,15,23,0.92);
}

#chatModal .chat-loader{
  position: absolute;
  inset: 0;
  background: rgba(11,15,23,0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
}

#chatModal .chat-loader.hidden{
  display: none;
}

#chatModal .chat-loader::after{
  content: "";
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255,255,255,0.22);
  border-top-color: rgba(255,255,255,0.92);
  border-radius: 50%;
  animation: ds-chat-spin 0.8s linear infinite;
}

@keyframes ds-chat-spin{
  to{ transform: rotate(360deg); }
}

@media (max-width: 520px){
  #chatModal{
    left: 12px;
    right: 12px;
    bottom: 12px;
    width: auto;
    height: min(78vh, 680px);
    border-radius: 16px;
  }
  #chatModal .ds-chat-resize-handle{
    display: none;
  }
}

/* Scroll locking is handled by JS (only when requested). Keep this inert. */
body.ds-chat-open{
  overflow: auto;
}

