/* Aptly Ask AI — Mintlify-inspired floating toolbar */

#aai-toolbar-root {
  --aai-bg: #0f1117;
  --aai-surface: #1a1d27;
  --aai-border: rgba(255, 255, 255, 0.08);
  --aai-text: #f4f4f5;
  --aai-muted: #a1a1aa;
  --aai-accent: #6366f1;
  --aai-accent-hover: #818cf8;
  --aai-shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
  --aai-radius: 10px;
  --aai-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

  position: fixed;
  bottom: 90px !important;
  right: 24px;
  z-index: 999999;
  font-family: var(--aai-font);
  font-size: 13px;
  line-height: 1.4;
  color: var(--aai-text);
  pointer-events: none;
}

#aai-toolbar-root * {
  box-sizing: border-box;
}

.aai-toolbar {
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.aai-toolbar__trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--aai-bg);
  border: 1px solid var(--aai-border);
  border-radius: var(--aai-radius);
  color: var(--aai-text);
  cursor: pointer;
  box-shadow: var(--aai-shadow);
  font-size: 13px;
  font-weight: 500;
  transition: background 0.15s, border-color 0.15s;
}

.aai-toolbar__trigger:hover,
.aai-toolbar__trigger[aria-expanded="true"] {
  background: var(--aai-surface);
  border-color: rgba(99, 102, 241, 0.4);
}

.aai-toolbar__trigger svg {
  width: 14px;
  height: 14px;
  opacity: 0.7;
  transition: transform 0.2s;
}

.aai-toolbar__trigger[aria-expanded="true"] svg {
  transform: rotate(180deg);
}

.aai-toolbar__menu {
  display: none;
  min-width: 240px;
  background: var(--aai-bg);
  border: 1px solid var(--aai-border);
  border-radius: var(--aai-radius);
  box-shadow: var(--aai-shadow);
  overflow: hidden;
  padding: 6px 0;
}

.aai-toolbar__menu.is-open {
  display: block;
  animation: aai-fade-in 0.15s ease;
}

@keyframes aai-fade-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.aai-toolbar__item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 14px;
  border: none;
  background: transparent;
  color: var(--aai-text);
  text-align: left;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  text-decoration: none;
  transition: background 0.12s;
}

.aai-toolbar__item:hover {
  background: var(--aai-surface);
}

.aai-toolbar__item-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: 0.85;
}

.aai-toolbar__divider {
  height: 1px;
  margin: 6px 0;
  background: var(--aai-border);
}

.aai-toolbar__toast {
  position: fixed;
  bottom: 80px;
  right: 24px;
  padding: 8px 14px;
  background: var(--aai-accent);
  color: #fff;
  border-radius: 8px;
  font-size: 12px;
  box-shadow: var(--aai-shadow);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
  z-index: 1000000;
}

.aai-toolbar__toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* Markdown modal */
.aai-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 1000001;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  pointer-events: auto;
}

.aai-modal {
  width: min(900px, 100%);
  max-height: 85vh;
  background: #fff !important;
  color: #101828;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 12px;
  box-shadow: var(--aai-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.aai-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--aai-border);
}

.aai-modal__title {
  font-weight: 600;
  font-size: 14px;
  margin: 0;
  color: #101828;
}

.aai-modal__actions {
  display: flex;
  gap: 8px;
}

.aai-modal__btn {
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  background: #f4f4f5;
  color: #101828;
  cursor: pointer;
  font-size: 12px;
  font-family: inherit;
}

.aai-modal__btn--primary {
  background: var(--aai-accent);
  border-color: var(--aai-accent);
}

.aai-modal__btn:hover {
  filter: brightness(1.1);
}

.aai-modal__body {
  padding: 18px;
  overflow: auto;
  flex: 1;
}

.aai-modal__pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, "Cascadia Code", "Source Code Pro", Menlo, monospace;
  font-size: 12px;
  line-height: 1.6;
  color: #374151;
}

@media (max-width: 640px) {
  #aai-toolbar-root {
    bottom: 90px !important;
    right: 16px;
  }

  .aai-toolbar__menu {
    min-width: 220px;
  }
}
