/* Floating button (default) */
#docs-ai-fab {
  position: fixed;
  right: 16px;
  bottom: calc(16px + var(--docs-ai-fab-popup-offset, 0px));
  z-index: 99999;
  border: 0;
  cursor: pointer;
  max-width: calc(100vw - 32px);
  transition: bottom .22s ease, transform .18s ease;
}

#docs-ai-fab.docs-ai-fab-pill {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 320px;
  max-width: calc(100vw - 32px);
  box-sizing: border-box;
  padding: 8px 12px 8px 8px;
  border-radius: 999px;
  background: linear-gradient(180deg, #2f69bd 0%, #1d4d94 100%);
  box-shadow: 0 18px 36px rgba(16, 48, 98, .30);
  color: #fff;
}

#docs-ai-fab.docs-ai-fab--mobile-consent-hidden {
  display: none !important;
}

.docs-ai-fab__icon {
  width: 40px;
  height: 40px;
  min-width: 40px;
  border-radius: 999px;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  box-shadow: inset 0 0 0 1px rgba(16, 48, 98, .08);
}

.docs-ai-fab__icon img {
  width: 24px;
  height: 24px;
  object-fit: contain;
  display: block;
}

.docs-ai-fab__icon--fallback .docs-ai-icon {
  width: 22px;
  height: 22px;
}

.docs-ai-fab__field {
  min-width: 0;
  flex: 1 1 auto;
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 16px;
  border-radius: 999px;
  background: rgba(255,255,255,.92);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.26);
}

.docs-ai-fab__label {
  display: inline-block;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.2;
  color: #1d4d94;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.docs-ai-fab__action {
  width: 28px;
  height: 28px;
  min-width: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: rgba(255,255,255,.95);
}

.docs-ai-fab__chevron {
  width: 18px;
  height: 18px;
  display: block;
}

/* Overlay */
#docs-ai-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.18);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
  z-index: 99999;
}
#docs-ai-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

/* Panel (pop over content) */
#docs-ai-panel {
  position: fixed;
  top: auto;
  right: 16px;
  width: 460px;
  max-width: calc(100vw - 20px);
  box-sizing: border-box;
  height: min(660px, calc(100vh - 96px));
  bottom: 92px;
  background: #f8fafc;
  z-index: 100000;
  border-radius: 22px;
  border: 1px solid rgba(148,163,184,.24);
  box-shadow: 0 24px 64px rgba(15,23,42,.18);
  transform: translateX(calc(100% + 24px));
  transition: transform .25s ease;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
#docs-ai-panel.open {
  transform: translateX(0);
}

/* Hide FAB when panel is open (extra safety) */
#docs-ai-panel.open ~ #docs-ai-fab {
  display: none !important;
}

/* Header */
.docs-ai-head {
  min-height: 64px;
  padding: 0 18px;
  border-bottom: 1px solid rgba(148,163,184,.18);
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.docs-ai-head strong { font-size: 16px; color: #1e293b; }
.docs-ai-head__actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.docs-ai-head__btn {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #64748b;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background-color .18s ease, color .18s ease;
}

.docs-ai-head__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  font-weight: 700;
}

.docs-ai-head__icon--clear {
  font-size: 10px;
  letter-spacing: .01em;
  text-transform: uppercase;
}

.docs-ai-head__icon--close {
  font-size: 28px;
}

.docs-ai-head__btn:hover,
.docs-ai-head__btn:focus-visible {
  background: rgba(148,163,184,.12);
  color: #0f172a;
}

/* Title layout (icon + text) */
.docs-ai-title {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

/* Body */
.docs-ai-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  font-size: 14px;
  line-height: 1.55;
  background:
    linear-gradient(180deg, rgba(255,255,255,.96) 0%, rgba(248,250,252,.98) 100%);
}

.docs-ai-msg {
  margin: 0 0 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.docs-ai-msg--user {
  align-items: flex-end;
}

.docs-ai-msg--assistant {
  align-items: flex-start;
}

.docs-ai-role {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .01em;
  color: #64748b;
}

.docs-ai-msg--user .docs-ai-role {
  padding-right: 4px;
}

.docs-ai-bubble {
  max-width: 92%;
  padding: 14px 16px;
  border-radius: 18px;
  background: #ffffff;
  border: 1px solid rgba(148,163,184,.18);
  box-shadow: 0 8px 22px rgba(15,23,42,.06);
  color: #1f2937;
}

.docs-ai-msg--user .docs-ai-bubble {
  background: linear-gradient(180deg, #2f69bd 0%, #1d4d94 100%);
  border-color: rgba(29,78,216,.22);
  color: #ffffff;
  border-top-right-radius: 8px;
}

.docs-ai-msg--assistant .docs-ai-bubble {
  border-top-left-radius: 8px;
}

/* Footer */
.docs-ai-foot {
  padding: 14px 16px 10px;
  border-top: 1px solid rgba(148,163,184,.18);
  background: #ffffff;
}

.docs-ai-composer {
  position: relative;
  width: 100%;
}

.docs-ai-foot textarea {
  width: 100%;
  min-height: 92px;
  resize: none;
  border: 1px solid rgba(148,163,184,.28);
  border-radius: 20px;
  padding: 14px 92px 14px 16px;
  outline: none;
  background: #f8fafc;
  font: inherit;
  transition: border-color .18s ease, box-shadow .18s ease, background-color .18s ease;
}
.docs-ai-foot textarea:focus {
  border-color: rgba(59,130,246,.55);
  box-shadow: 0 0 0 4px rgba(59,130,246,.12);
  background: #ffffff;
}
.docs-ai-foot button {
  position: absolute;
  right: 12px;
  bottom: 12px;
  border: 0;
  min-height: 42px;
  border-radius: 14px;
  padding: 10px 16px;
  cursor: pointer;
  font-weight: 700;
  background: #0f172a;
  color: #fff;
}

.docs-ai-meta {
  padding: 0 16px 14px;
  background: #ffffff;
}

.docs-ai-note {
  margin: 0;
  font-size: 12px;
  line-height: 1.45;
  color: #64748b;
  text-align: center;
}

.docs-ai-session-stats {
  margin: 6px 0 0;
  font-size: 12px;
  line-height: 1.45;
  color: #94a3b8;
  text-align: center;
}

.docs-ai-note a {
  color: #2563eb;
  text-decoration: none;
}

/* === WordPress admin bar compatibility === */
html.admin-bar #docs-ai-panel,
html.admin-bar #docs-ai-overlay {
  top: auto;
  height: min(660px, calc(100vh - 96px));
}

@media screen and (max-width: 782px) {
  html.admin-bar #docs-ai-panel,
  html.admin-bar #docs-ai-overlay {
    top: auto;
    height: min(72svh, 620px);
  }
}

/* Accessibility: screen-reader only text */
.docs-ai-sr {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0);
  white-space: nowrap; border: 0;
}

/* Icon style */
.docs-ai-icon {
  width: 28px;
  height: 28px;
  display: block;
}
.docs-ai-icon--small {
  width: 20px;
  height: 20px;
}

/* Icon-only buttons (shortcode) */
.docs-ai-launch.docs-ai-icon-only {
  background: transparent !important;
  border: 0 !important;
  padding: 0;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.docs-ai-launch .docs-ai-icon {
  width: 32px;
  height: 32px;
  display: block;
}

/* FAB: icon-only, no background */
#docs-ai-fab.docs-ai-icon-only {
  background: transparent !important;
  box-shadow: none !important;
  width: 48px;
  height: 48px;
  padding: 0;
}
#docs-ai-fab svg { display: block; }
#docs-ai-fab:hover svg { transform: scale(1.08); }
#docs-ai-fab svg { transition: transform .18s ease; }

#docs-ai-fab.docs-ai-fab-pill:hover {
  transform: translateY(-1px);
}

#docs-ai-fab.docs-ai-fab-pill:hover .docs-ai-fab__field,
#docs-ai-fab.docs-ai-fab-pill:focus-visible .docs-ai-fab__field {
  background: #ffffff;
  box-shadow:
    inset 0 0 0 1px rgba(255,255,255,.92),
    0 0 0 4px rgba(255,255,255,.14);
}

#docs-ai-fab.docs-ai-fab-pill,
#docs-ai-fab.docs-ai-fab-pill .docs-ai-fab__icon,
#docs-ai-fab.docs-ai-fab-pill .docs-ai-fab__label,
#docs-ai-fab.docs-ai-fab-pill .docs-ai-fab__field {
  transition: transform .18s ease, box-shadow .18s ease, background-color .18s ease;
}

@media (max-width: 767px) {
  #docs-ai-fab {
    left: auto;
    right: 10px;
    bottom: calc(10px + var(--docs-ai-fab-popup-offset, 0px) + env(safe-area-inset-bottom, 0px));
    width: auto;
    max-width: none;
  }

  #docs-ai-fab.docs-ai-fab-pill {
    min-width: 0;
    width: min(60vw, 230px);
    max-width: min(60vw, 230px);
    margin-left: auto;
    padding: 6px 9px 6px 6px;
    gap: 8px;
    min-height: 44px;
  }

  .docs-ai-fab__icon {
    width: 32px;
    height: 32px;
    min-width: 32px;
  }

  .docs-ai-fab__icon img {
    width: 18px;
    height: 18px;
  }

  .docs-ai-fab__field {
    min-height: 28px;
    padding: 0 10px;
  }

  .docs-ai-fab__label {
    font-size: 12px;
  }

  .docs-ai-fab__action {
    width: 20px;
    height: 20px;
    min-width: 20px;
  }

  .docs-ai-fab__chevron {
    width: 14px;
    height: 14px;
  }

  #docs-ai-panel {
    left: 10px;
    right: 10px;
    width: auto !important;
    max-width: none !important;
    top: auto;
    bottom: calc(68px + env(safe-area-inset-bottom, 0px));
    height: min(70svh, 620px);
    transform: translateY(calc(100% + 120px));
    border-radius: 18px;
  }

  #docs-ai-panel.open {
    transform: translateY(0);
  }

  html.admin-bar #docs-ai-panel {
    height: min(66svh, 580px);
  }

  .docs-ai-body,
  .docs-ai-foot,
  .docs-ai-meta,
  .docs-ai-composer,
  .docs-ai-foot textarea {
    box-sizing: border-box;
    max-width: 100%;
  }

  .docs-ai-foot {
    padding: 12px 12px 10px;
  }

  .docs-ai-foot textarea {
    min-height: 88px;
    padding: 14px 78px 14px 14px;
  }

  .docs-ai-foot button {
    right: 10px;
    bottom: 10px;
    min-height: 40px;
    padding: 10px 13px;
  }

  .docs-ai-head {
    padding: 0 12px;
  }

  .docs-ai-body {
    padding: 14px;
  }

  .docs-ai-title {
    min-width: 0;
  }

  .docs-ai-title strong {
    font-size: 15px;
  }

  .docs-ai-head__actions {
    gap: 4px;
  }

  .docs-ai-head__btn {
    width: 32px;
    height: 32px;
  }

  .docs-ai-head__icon--clear {
    font-size: 9px;
  }

  .docs-ai-head__icon--close {
    font-size: 24px;
  }

  .docs-ai-msg {
    max-width: 100%;
  }

  .docs-ai-msg--user,
  .docs-ai-msg--assistant {
    width: 100%;
  }

  .docs-ai-msg--user .docs-ai-bubble,
  .docs-ai-msg--assistant .docs-ai-bubble {
    max-width: 100%;
  }

  .docs-ai-msg__meta {
    gap: 8px;
  }
}

/* ---------------------------
 * Markdown styling
 * --------------------------- */

.docs-ai-bubble h1, .docs-ai-bubble h2, .docs-ai-bubble h3{
  margin: 5px 0 1px;
  font-weight: 700;
  font-size:24px !important;
  line-height: 1.25;
  color: inherit;
}

.docs-ai-bubble p{ margin: 0 0 8px; }
.docs-ai-bubble p:last-child { margin-bottom: 0; }

.docs-ai-bubble ul, .docs-ai-bubble ol{
  margin: 8px 0 8px 22px;
  padding: 0;
}

.docs-ai-bubble li{ margin: 4px 0; }

.docs-ai-bubble blockquote{
  margin: 10px 0;
  padding: 10px 12px;
  border-left: 3px solid rgba(59,130,246,.28);
  background: rgba(148,163,184,.08);
  border-radius: 8px;
}

.docs-ai-pre{
  margin: 10px 0;
  padding: 12px;
  overflow: auto;
  border-radius: 10px;
  background: rgba(15,23,42,.06);
}

.docs-ai-code{
  padding: 2px 6px;
  border-radius: 6px;
  background: rgba(15,23,42,.08);
}

.docs-ai-msg--user .docs-ai-code {
  background: rgba(255,255,255,.16);
}

.docs-ai-search-card {
  background: #ffffff;
  border: 1px solid rgba(148,163,184,.18);
  border-radius: 14px;
  padding: 12px;
  margin-top: 10px;
}

.docs-ai-search-row {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.docs-ai-search-title {
  color: #0f172a;
  font-weight: 700;
  text-decoration: none;
}

.docs-ai-badge {
  font-size: 11px;
  font-weight: 700;
  color: #047857;
  background: #ecfdf5;
  border-radius: 999px;
  padding: 4px 8px;
}

.docs-ai-search-excerpt {
  color: #334155;
}

.docs-ai-readmore {
  color: #2563eb;
  font-weight: 600;
  text-decoration: none;
}

.docs-ai-sources {
  width: 100%;
}

.docs-ai-sources__summary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  list-style: none;
  color: #475569;
  font-size: 13px;
  font-weight: 600;
}

.docs-ai-sources__summary::-webkit-details-marker {
  display: none;
}

.docs-ai-sources__count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  border-radius: 999px;
  background: #f59e0b;
  color: #ffffff;
  font-size: 12px;
  font-weight: 700;
}

.docs-ai-sources__chevron {
  width: 10px;
  height: 10px;
  border-right: 2px solid #64748b;
  border-bottom: 2px solid #64748b;
  transform: rotate(45deg);
  margin-left: 2px;
  transition: transform .18s ease;
}

.docs-ai-sources[open] .docs-ai-sources__chevron {
  transform: rotate(-135deg) translateY(-1px);
}

.docs-ai-sources__list {
  margin-top: 10px;
  display: grid;
  gap: 10px;
}

.docs-ai-source-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 14px;
  border-radius: 14px;
  background: #ffffff;
  border: 1px solid rgba(148,163,184,.22);
  box-shadow: 0 8px 18px rgba(15,23,42,.05);
  text-decoration: none;
}

.docs-ai-source-title {
  color: #0f172a;
  font-weight: 700;
  line-height: 1.4;
}

.docs-ai-source-url {
  color: #2563eb;
  font-size: 12px;
  line-height: 1.4;
  word-break: break-word;
}

.docs-ai-msg__meta {
  margin-top: 10px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
}

.docs-ai-msg__meta-left {
  min-width: 0;
  flex: 1 1 auto;
}

.docs-ai-msg__time {
  flex: 0 0 auto;
  font-size: 12px;
  color: #94a3b8;
  line-height: 22px;
  white-space: nowrap;
}

@media (max-width: 767px) {
  #docs-ai-panel {
    right: 10px;
    left: 10px;
    width: auto;
    max-width: none;
    top: auto;
    bottom: 88px;
    height: min(78vh, 680px);
    border-radius: 20px;
  }

  html.admin-bar #docs-ai-panel {
    top: auto;
    height: min(72vh, 640px);
  }

  .docs-ai-bubble {
    max-width: 100%;
  }
}

/* Search-only cards */
.docs-ai-search-head {
  margin: 8px 0 10px;
}

.docs-ai-search-card {
  border: 1px solid rgba(0,0,0,.10);
  border-radius: 12px;
  padding: 10px 12px;
  margin: 10px 0;
  background: #fff;
}

.docs-ai-search-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.docs-ai-search-title {
  font-weight: 700;
  text-decoration: none;
  color: #111;
}

.docs-ai-search-title:hover {
  text-decoration: underline;
}

.docs-ai-badge {
  display: inline-flex;
  align-items: center;
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid rgba(0,0,0,.12);
  background: rgba(0,0,0,.04);
  white-space: nowrap;
}

.docs-ai-search-excerpt {
  margin-top: 8px;
  color: #1d2327;
  line-height: 1.45;
}

.docs-ai-search-excerpt.muted {
  color: #50575e;
}

.docs-ai-search-more {
  margin-top: 8px;
}

.docs-ai-readmore {
  font-weight: 600;
  text-decoration: none;
}

.docs-ai-readmore:hover {
  text-decoration: underline;
}

.docs-ai-mark {
  padding: 0 2px;
  border-radius: 4px;
  background: rgba(255, 230, 0, 0.35);
}
