/* Niwa AI — Flyout (chat window, header, bubbles) */

/* Flyout — responsive positioning (simple display toggle, GSAP handles animation) */
#za-flyout {
  position: fixed;
  background: var(--niwa-bg) !important;
  backdrop-filter: blur(var(--niwa-blur));
  -webkit-backdrop-filter: blur(var(--niwa-blur));
  border: 1px solid var(--niwa-border);
  border-radius: 24px;
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.25);
  overflow: hidden;
  display: none;
  z-index: 99999;
  max-height: 95vh;
  min-height: 300px
}

#za-flyout.active {
  display: block !important
}

#za-flyout.mobile-center {
  transform: translateX(-50%) !important
}

#za-flyout .za-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 12px;
  background: rgba(255, 255, 255, 0.35) !important;
  color: var(--niwa-text) !important;
  border-bottom: 1px solid var(--niwa-border);
  position: sticky;
  top: 0;
  z-index: 10
}

#za-flyout .za-head .za-head-actions {
  display: flex;
  gap: 6px
}

#za-flyout .za-head .za-head-actions button {
  background: rgba(255, 255, 255, 0.6) !important;
  border: 1px solid var(--niwa-border) !important;
  color: var(--niwa-text) !important;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center
}

#za-flyout .za-head .za-head-actions button:hover {
  background: rgba(255, 255, 255, .16)
}

#za-flyout .za-title {
  font-weight: 700;
  letter-spacing: .2px;
  display: flex;
  align-items: center;
  gap: 10px
}

#za-flyout .za-title .za-head-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15)
}

#za-flyout .za-host,
.za-shortcode .za-host {
  height: calc(100% - 52px);
  display: flex;
  flex-direction: column
}

/* Chat body + input (stabilan input) */
#za-flyout .za-shell,
.za-shortcode .za-shell {
  display: flex;
  flex-direction: column;
  height: 100%
}

#za-flyout .za-window,
.za-shortcode .za-window {
  flex: 1;
  overflow: auto;
  padding: 12px;
  background: transparent !important;
  color: var(--niwa-text);
  white-space: pre-line;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  touch-action: pan-y
}

#za-flyout .za-bubble,
.za-shortcode .za-bubble {
  display: inline-block;
  padding: 10px 12px;
  border-radius: 14px;
  margin: 6px 0;
  line-height: 1.4;
  max-width: 85%;
  border: 1px solid var(--niwa-border) !important;
  box-shadow: var(--za-bubble-shadow) !important
}

#za-flyout .za-bubble strong,
#za-flyout .za-bubble b,
.za-shortcode .za-bubble strong,
.za-shortcode .za-bubble b {
  font-weight: 700;
}

#za-flyout .za-bubble code,
.za-shortcode .za-bubble code {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 6px;
  background: rgba(15, 23, 42, 0.08);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 0.92em;
}

#za-flyout .za-bot,
.za-shortcode .za-bot {
  background: rgba(255, 255, 255, 0.75) !important;
  color: var(--niwa-text) !important;
  border-top-left-radius: 4px
}

#za-flyout .za-user,
.za-shortcode .za-user {
  background: rgba(255, 255, 255, 0.95) !important;
  color: var(--niwa-text) !important;
  border-top-right-radius: 4px;
  float: right;
  clear: both
}

#za-flyout .za-msg,
.za-shortcode .za-msg {
  clear: both
}

/* Device-specific media queries */
/* Mobile (<768px) */
@media (max-width: 767px) {
  #za-flyout {
    /* Ensure responsive behavior */
    max-width: 100vw;
    max-height: 100vh;
  }

  /* Center positioning support */
  #za-flyout.mobile-center {
    left: 50% !important;
    right: auto !important;
  }
}

@media (max-width: 1023px) {

  #za-flyout,
  #za-flyout .za-window,
  #za-flyout .za-input {
    overscroll-behavior: contain;
  }

  #za-flyout .za-input {
    touch-action: manipulation;
  }
}
