#portal {
  position: fixed;
  top: 0;
}

html {
  /* set base font size to 13px */
  font-size: 50.782% !important;
}

body {
  color: var(--mu-colors-foreground-text-neutral-plain) !important;
  overscroll-behavior-y: none;
}

.hide-scrollbar::-webkit-scrollbar {
  display: none;
}

.hide-scrollbar {
  scrollbar-width: none;
}

.ellipsis {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@keyframes pulse {
  from {
    transform: scale(1);
  }
  to {
    transform: scale(1.2);
  }
}

.animate-copy {
  animation: pulse 0.2s;
  transition: all 0.2s;
}

.remove-icon-background svg {
  background: none !important;
}

.remove-content-padding-top .MuiCardContent-root {
  padding-top: 0 !important;
}

[id*="ScrollableDialog"] .infinite-scroll-component {
  overflow: hidden !important;
}

/* 
  TODO: Remove it when macaw will handle media queries in custom properties
  https://github.com/saleor/macaw-ui/issues/498
*/
@media screen and (max-width: 1024px) {
  .mobile-full-height {
    height: auto !important;
  }
}

[data-portal-for="category-list"] > ul > li {
  display: block;
}

[data-portal-for="category-list"] & li > span {
  display: inline;
}

.noBorder {
  border: none;
}
/* ── AI Agent Chat — Scoped Styles ─────────────────────────────────────────── */
/* All classes are prefixed with .ag- to avoid conflicts with Macaw UI */

.ag-root {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: #fff;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: #111827;
  overflow: hidden;
}
@supports (height: 100dvh) {
  .ag-root { height: 100dvh; }
}

/* ── Topbar ──────────────────────────────────────────────────────────────────*/
.ag-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  border-bottom: 1px solid #f3f4f6;
  flex-shrink: 0;
}
.ag-topbar-left { display: flex; align-items: center; gap: 10px; }
.ag-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: #111827;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; color: #fff;
}
.ag-title { font-size: 16px; font-weight: 700; }
.ag-subtitle { font-size: 12px; color: #9ca3af; }
.ag-topbar-right { display: flex; gap: 8px; align-items: center; }
.ag-btn {
  appearance: none; -webkit-appearance: none; border: none;
  background: none; padding: 0; margin: 0; cursor: pointer;
  font: inherit; color: inherit; outline: none;
}
.ag-btn-settings {
  border-radius: 8px; padding: 7px 14px; font-size: 13px; font-weight: 600;
}
.ag-btn-clear { font-size: 13px; color: #9ca3af; padding: 6px 12px; }

/* ── Messages scroll area ────────────────────────────────────────────────────*/
.ag-messages-wrap {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  scrollbar-width: none;
}
.ag-messages-wrap::-webkit-scrollbar { display: none; }
.ag-messages-inner {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 780px;
  margin: 0 auto;
  padding: 24px 24px 8px;
  min-height: 100%;
}

/* ── Empty state ─────────────────────────────────────────────────────────────*/
.ag-empty {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; height: 100%; gap: 24px; padding: 40px 24px;
  animation: ag-fade-in 0.4s ease;
}
.ag-empty-avatar {
  width: 56px; height: 56px; border-radius: 50%;
  background: #111827;
  display: flex; align-items: center; justify-content: center;
  color: #fff; margin: 0 auto 8px;
}
.ag-empty-title { font-size: 22px; font-weight: 700; text-align: center; }
.ag-empty-sub { font-size: 14px; color: #6b7280; text-align: center; line-height: 1.6; }
.ag-quick-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; max-width: 520px; }
.ag-quick-btn {
  appearance: none; -webkit-appearance: none; border: 1px solid #e5e7eb;
  background: #f9fafb; border-radius: 20px; padding: 7px 16px;
  font-size: 13px; color: #374151; cursor: pointer; font: inherit;
  transition: background 0.15s;
}
.ag-quick-btn:hover { background: #f3f4f6; }
.ag-quick-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.ag-no-settings-banner {
  background: #fffbeb; border: 1px solid #fbbf24; border-radius: 10px;
  padding: 12px 20px; font-size: 13px; color: #92400e; text-align: center; max-width: 400px;
}

/* ── Message row ─────────────────────────────────────────────────────────────*/
.ag-msg-row {
  display: flex; align-items: flex-start; gap: 12px;
  margin-bottom: 20px; animation: ag-fade-in 0.2s ease;
}
.ag-msg-row--user { flex-direction: row-reverse; }
.ag-msg-avatar {
  width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600; margin-top: 2px;
}
.ag-msg-avatar--ai {
  background: #111827; color: #fff;
}
.ag-msg-avatar--user { background: #111827; color: #fff; }

.ag-msg-body { display: flex; flex-direction: column; max-width: calc(100% - 46px); min-width: 0; position: relative; }
.ag-msg-body:hover .ag-msg-actions { opacity: 1; }

/* ── Bubble ──────────────────────────────────────────────────────────────────*/
.ag-bubble {
  padding: 10px 14px; border-radius: 14px; font-size: 14px;
  line-height: 1.65; word-break: break-word;
}
.ag-bubble--user {
  background: #111827; color: #fff;
  border-radius: 18px 18px 4px 18px;
}
.ag-bubble--ai {
  background: transparent; color: #111827;
  border-radius: 0; padding: 0;
}

/* ── Markdown inside AI bubble ───────────────────────────────────────────────*/
.ag-markdown { font-size: 14px; line-height: 1.7; color: #111827; }
.ag-markdown p { margin: 0 0 10px; }
.ag-markdown p:last-child { margin-bottom: 0; }
.ag-markdown h1,.ag-markdown h2,.ag-markdown h3 { font-weight: 700; margin: 16px 0 6px; }
.ag-markdown h1 { font-size: 20px; }
.ag-markdown h2 { font-size: 17px; }
.ag-markdown h3 { font-size: 15px; }
.ag-markdown ul,.ag-markdown ol { padding-left: 20px; margin: 8px 0; }
.ag-markdown li { margin: 3px 0; }
.ag-markdown code {
  background: #f3f4f6; border-radius: 4px; padding: 1px 5px;
  font-size: 13px; font-family: "Fira Code", "Consolas", monospace;
  color: #374151;
}
.ag-markdown pre { margin: 10px 0; }
.ag-markdown pre code { background: none; padding: 0; }
.ag-markdown blockquote {
  border-left: 3px solid #d1d5db; margin: 8px 0; padding: 4px 12px;
  color: #6b7280; font-style: italic;
}
.ag-markdown table { border-collapse: collapse; width: 100%; margin: 10px 0; font-size: 13px; }
.ag-markdown th,.ag-markdown td { border: 1px solid #e5e7eb; padding: 6px 10px; text-align: left; }
.ag-markdown th { background: #f9fafb; font-weight: 600; }
.ag-markdown a { color: #1f2937; text-decoration: underline; }
.ag-markdown hr { border: none; border-top: 1px solid #e5e7eb; margin: 12px 0; }

/* ── Code block ──────────────────────────────────────────────────────────────*/
.ag-code-block {
  border: 1px solid #e5e7eb; border-radius: 10px;
  overflow: hidden; margin: 8px 0; background: #f9fafb;
}
.ag-code-block-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 14px; border-bottom: 1px solid #e5e7eb; background: #f3f4f6;
}
.ag-code-lang { font-size: 12px; color: #6b7280; font-family: monospace; }
.ag-code-copy {
  appearance: none; border: none; background: none; cursor: pointer;
  color: #9ca3af; font-size: 12px; padding: 2px 6px; border-radius: 4px;
  transition: color 0.15s, background 0.15s;
}
.ag-code-copy:hover { color: #374151; background: #e5e7eb; }
.ag-code-content {
  padding: 12px 14px; overflow-x: auto; font-size: 13px; line-height: 1.6;
  font-family: "Fira Code", "Consolas", monospace;
  background: #f9fafb !important;
}
.ag-code-content pre { margin: 0; background: transparent !important; }

/* ── Reasoning (Thinking) ────────────────────────────────────────────────────*/
.ag-reasoning { margin-bottom: 8px; }
.ag-reasoning-header { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.ag-reasoning-toggle {
  appearance: none; border: none; background: none; cursor: pointer;
  display: flex; align-items: center; gap: 6px; padding: 2px 4px;
  font-size: 13px; color: #6b7280; font: inherit; border-radius: 4px;
  transition: color 0.15s;
}
.ag-reasoning-toggle:hover { color: #374151; }
.ag-reasoning-caret {
  transition: transform 0.2s ease; font-size: 10px;
}
.ag-reasoning-caret--open { transform: rotate(180deg); }
.ag-reasoning-body {
  margin-top: 8px; padding-left: 12px;
  border-left: 2px solid #d1d5db;
  overflow: hidden;
}
.ag-reasoning-text {
  font-size: 13px; color: #6b7280; line-height: 1.6; white-space: pre-wrap; word-break: break-word;
}

/* ── Tool invocation card ────────────────────────────────────────────────────*/
.ag-tool-card {
  border: 1px solid #e5e7eb; border-radius: 10px; overflow: hidden; margin: 6px 0;
}
.ag-tool-header {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px;
  cursor: pointer; transition: background 0.15s; background: #f9fafb;
  appearance: none; border: none; width: 100%; text-align: left; font: inherit;
}
.ag-tool-header:hover { background: #f3f4f6; }
.ag-tool-icon { color: #6b7280; flex-shrink: 0; }
.ag-tool-name { font-size: 13px; font-family: monospace; font-weight: 600; flex: 1; color: #374151; }
.ag-tool-badge {
  display: inline-flex; align-items: center; gap: 4px;
  border-radius: 999px; padding: 2px 8px; font-size: 11px; font-weight: 600;
}
.ag-tool-badge--running {
  background: #eff6ff; color: #2563eb; border: 1px solid #bfdbfe;
}
.ag-tool-badge--done {
  background: #f0fdf4; color: #16a34a; border: 1px solid #bbf7d0;
}
.ag-tool-caret { color: #9ca3af; transition: transform 0.2s ease; margin-left: auto; }
.ag-tool-caret--open { transform: rotate(180deg); }
.ag-tool-body { padding: 10px 12px; border-top: 1px solid #e5e7eb; display: flex; flex-direction: column; gap: 10px; }
.ag-tool-section-label { font-size: 11px; font-weight: 600; color: #9ca3af; margin-bottom: 4px; text-transform: uppercase; letter-spacing: 0.05em; }
.ag-tool-section-content {
  background: #f9fafb; border: 1px solid #e5e7eb; border-radius: 6px;
  padding: 8px 10px; font-size: 12px; font-family: monospace;
  max-height: 200px; overflow-y: auto; white-space: pre-wrap; word-break: break-word;
  color: #374151;
}

/* ── Message actions ─────────────────────────────────────────────────────────*/
.ag-msg-actions {
  display: flex; align-items: center; gap: 2px; margin-top: 4px;
  opacity: 0; transition: opacity 0.15s;
}
.ag-msg-action-btn {
  appearance: none; border: none; background: none; cursor: pointer;
  color: #9ca3af; padding: 4px; border-radius: 6px; display: flex;
  align-items: center; justify-content: center; transition: color 0.15s, background 0.15s;
}
.ag-msg-action-btn:hover { color: #374151; background: #f3f4f6; }
.ag-msg-time { font-size: 11px; color: #d1d5db; margin-top: 4px; }

/* ── Typing loader ───────────────────────────────────────────────────────────*/
.ag-loader { display: flex; align-items: center; gap: 4px; padding: 6px 0; }
.ag-loader-dot {
  width: 7px; height: 7px; border-radius: 50%; background: #d1d5db;
  animation: ag-bounce 1.2s ease-in-out infinite;
}
.ag-loader-dot:nth-child(2) { animation-delay: 0.15s; }
.ag-loader-dot:nth-child(3) { animation-delay: 0.3s; }

/* ── Confirmation dialog ─────────────────────────────────────────────────────*/
.ag-confirm {
  background: #fff7ed; border: 1px solid #fb923c; border-radius: 12px;
  padding: 16px 20px; margin-bottom: 12px; animation: ag-fade-in 0.2s ease;
}
.ag-confirm-title { font-weight: 700; color: #9a3412; margin-bottom: 8px; font-size: 14px; }
.ag-confirm-desc { font-size: 13px; color: #7c2d12; margin-bottom: 6px; }
.ag-confirm-args {
  background: rgba(0,0,0,0.05); border-radius: 6px; padding: 6px 10px;
  font-size: 12px; font-family: monospace; color: #374151; margin-bottom: 12px;
  white-space: pre-wrap; word-break: break-word;
}
.ag-confirm-actions { display: flex; gap: 8px; }
.ag-btn-confirm {
  appearance: none; border: none; background: #ea580c; color: #fff;
  border-radius: 8px; padding: 8px 20px; font-size: 13px; font-weight: 700; cursor: pointer; font: inherit;
}
.ag-btn-cancel {
  appearance: none; background: #fff; border: 1px solid #d1d5db;
  border-radius: 8px; padding: 8px 20px; font-size: 13px; color: #374151; cursor: pointer; font: inherit;
}

/* ── Error banner ────────────────────────────────────────────────────────────*/
.ag-error {
  background: #fef2f2; border: 1px solid #fca5a5; border-radius: 10px;
  padding: 12px 16px; font-size: 13px; color: #dc2626; margin-bottom: 12px;
}

/* ── Input area ──────────────────────────────────────────────────────────────*/
.ag-input-wrap {
  padding: 8px 24px 10px;
  border-top: 1px solid #f3f4f6;
  flex-shrink: 0;
  max-width: 828px;
  margin: 0 auto;
  width: 100%;
  box-sizing: border-box;
}
.ag-input-box {
  display: flex; gap: 8px; align-items: center;
  background: #f9fafb; border: 1.5px solid #e5e7eb; border-radius: 14px;
  padding: 6px 10px 6px 16px; transition: border-color 0.15s;
  min-height: 46px;
}
.ag-input-box:focus-within { border-color: #374151; }
.ag-textarea {
  flex: 1; resize: none; border: none; outline: none; background: transparent;
  font-size: 14px; color: #111827; font-family: inherit; line-height: 1.5;
  max-height: 120px; overflow-y: auto;
  padding: 7px 0;
  display: block;
}
.ag-textarea::placeholder { color: #9ca3af; }
.ag-send-btn {
  width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; border: none; transition: background 0.15s;
}
.ag-send-btn--active { background: #111827; }
.ag-send-btn--inactive { background: #e5e7eb; cursor: not-allowed; }
.ag-send-spinner {
  width: 14px; height: 14px; border: 2px solid #9ca3af;
  border-top-color: transparent; border-radius: 50%;
  animation: ag-spin 0.8s linear infinite;
}
.ag-stop-btn {
  background: #111827; border: none; border-radius: 50%; width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  flex-shrink: 0;
}
.ag-disclaimer { font-size: 11px; color: #d1d5db; text-align: center; margin-top: 6px; }

/* ── Settings panel ──────────────────────────────────────────────────────────*/
.ag-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.45);
  display: flex; align-items: center; justify-content: center; z-index: 9999;
}
.ag-panel {
  background: #fff; border-radius: 12px; padding: 28px 32px;
  width: 480px; max-width: 90vw; box-shadow: 0 8px 32px rgba(0,0,0,0.16);
  display: flex; flex-direction: column; gap: 20px;
}
.ag-panel-header { display: flex; align-items: center; justify-content: space-between; }
.ag-panel-title { font-size: 18px; font-weight: 700; }
.ag-label { display: block; font-size: 13px; font-weight: 600; color: #374151; margin-bottom: 6px; }
.ag-input {
  width: 100%; padding: 8px 12px; border: 1.5px solid #d1d5db; border-radius: 7px;
  font-size: 14px; outline: none; box-sizing: border-box; font: inherit;
  color: #111827; background: #f9fafb; transition: border-color 0.15s;
}
.ag-input:focus { border-color: #374151; }
.ag-select { width: 100%; padding: 8px 12px; border: 1.5px solid #d1d5db; border-radius: 7px; font-size: 14px; outline: none; box-sizing: border-box; font: inherit; color: #111827; background: #f9fafb; cursor: pointer; }
.ag-hint { font-size: 12px; color: #9ca3af; margin-top: 4px; }
.ag-panel-footer { display: flex; justify-content: space-between; align-items: center; padding-top: 4px; }
.ag-btn-primary { appearance: none; border: none; background: #111827; color: #fff; border-radius: 8px; padding: 9px 22px; font-size: 14px; font-weight: 600; cursor: pointer; font: inherit; }
.ag-btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.ag-btn-ghost { appearance: none; border: none; background: none; color: #6b7280; font-size: 14px; padding: 9px 16px; cursor: pointer; font: inherit; }
.ag-btn-danger { appearance: none; border: none; background: none; color: #ef4444; font-size: 13px; cursor: pointer; font: inherit; }

/* ── Animations ──────────────────────────────────────────────────────────────*/
@keyframes ag-fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes ag-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-5px); opacity: 1; }
}
@keyframes ag-spin { to { transform: rotate(360deg); } }
