/* === Dantara Chat x Bottom Dock Overrides (last-wins, safe to append) ===
   Purpose: Keep the chat launcher/panel/nudge above a fixed bottom dock whose internals live in a Shadow DOM.
   Works by consuming --dock-h published by dock-height.js. Includes iOS safe-area handling and phone fullscreen rules.
*/

/* Default variable (in case JS hasn't run yet) */
:root { --dock-h: 64px; }

/* Ensure page content clears the dock on phones */
@media (max-width: 767.98px) {
  body { padding-bottom: var(--dock-h); }
  #mobile-dock { z-index: 1020; }
}

/* Launcher sits above dock; huge z-index to beat any stacking context */
#dantara-chat-root .dc-launch {
  position: fixed;
  right: max(20px, env(safe-area-inset-right, 0px));
  bottom: calc(28px + var(--dock-h, 0px) + env(safe-area-inset-bottom, 0px)); /* +28 for visual clearance */
  z-index: 2147483647;
}

/* Panel (desktop/tablet popup mode) */
#dantara-chat-root .dc-panel {
  position: fixed;
  right: max(20px, env(safe-area-inset-right, 0px));
  bottom: calc(96px + var(--dock-h, 0px) + env(safe-area-inset-bottom, 0px)); /* header+footer space above launcher */
  width: min(380px, calc(100svw - 40px - env(safe-area-inset-left,0px) - env(safe-area-inset-right,0px)));
  max-width: 100svw;
  z-index: 2147483647;
  overflow-x: hidden;
  box-sizing: border-box;
  contain: content;
}

/* Nudge chip sits left of the launcher and above the dock */
#dantara-chat-root .dc-nudge {
  position: fixed;
  right: calc(84px + env(safe-area-inset-right, 0px));
  bottom: calc(28px + var(--dock-h, 0px) + env(safe-area-inset-bottom, 0px));
  z-index: 2147483647;
}

/* Phones: force fullscreen while open (ignores dock offset) */
@media (max-width: 640px) {
  #dantara-chat-root .dc-panel {
    right: 0 !important;
    left: 0 !important;
    bottom: 0 !important;
    width: 100svw !important;
    max-width: 100svw !important;
    height: 100dvh !important;
    border-radius: 0 !important;
  }
  /* Keep CTAs flexible on narrow screens */
  #dantara-chat-root .dc-cta { min-width: 0 !important; white-space: normal !important; }
  #dantara-chat-root .dc-cta--chip { min-width: 0 !important; }
}

/* Absolute fallback when svw/svh unsupported */
@supports not (width: 100svw) {
  #dantara-chat-root .dc-panel { width: min(380px, calc(100vw - 40px)); max-width: 100vw; }
  @media (max-width: 640px) {
    #dantara-chat-root .dc-panel { width: 100vw !important; height: 100dvh !important; }
  }
}
