/**
 * Self-contained embed UI for the Noumetic frame (widget, iframe, sandbox).
 * Scoped under .ncf-root — no dependency on core/main.css or FlyonUI.
 */

.ncf-root {
  --ncf-font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --ncf-bg: #ffffff;
  --ncf-border: #e5e7eb;
  --ncf-text: #0f172a;
  --ncf-muted: #6b7280;
  --ncf-bubble-user-bg: #f3f4f6;
  --ncf-bubble-user-fg: #0f172a;
  --ncf-bubble-agent-bg: #1f2937;
  --ncf-bubble-agent-fg: #f9fafb;
  --ncf-link: #2563eb;
  --ncf-link-hover: #1d4ed8;
  /* Legacy aliases used by frame.css and inline JS */
  --ncw-bg: var(--ncf-bg);
  --ncw-border: var(--ncf-border);
  display: block;
  font-family: var(--ncf-font);
  color: var(--ncf-text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.ncf-root *,
.ncf-root *::before,
.ncf-root *::after {
  box-sizing: border-box;
}

.ncf-root .hidden {
  display: none !important;
}

/* --- Message rows --- */
.ncf-root .ncf-messages {
  padding-top: 1.5rem;
}

.ncf-root .ncf-messages .ncf-msg {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  row-gap: 0.15rem;
  padding: 0.25rem 0.75rem;
  width: 100%;
}

.ncf-root .ncf-messages .ncf-msg--user {
  align-items: flex-end;
}

.ncf-root .ncf-msg-label {
  order: 2;
  margin-top: 0.15rem;
  font-size: 0.75rem;
  line-height: 1rem;
  color: var(--ncf-muted);
}

.ncf-root .ncf-msg-bubble {
  order: 1;
  display: block;
  width: fit-content;
  max-width: 90%;
  padding: 0.75rem;
  border-radius: 0.75rem;
  font-size: 0.875rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
  word-wrap: break-word;
}

.ncf-root .ncf-msg--agent .ncf-msg-bubble {
  background: var(--ncf-bubble-agent-bg);
  color: var(--ncf-bubble-agent-fg);
  border-bottom-left-radius: 0.25rem;
}

.ncf-root .ncf-msg--user .ncf-msg-bubble {
  background: var(--ncf-bubble-user-bg);
  color: var(--ncf-bubble-user-fg);
  text-align: left;
  border-bottom-right-radius: 0.25rem;
}

.ncf-root .ncf-msg-bubble .markdown-body,
.ncf-root .ncf-msg-bubble .markdown-body a {
  overflow-wrap: anywhere;
  word-wrap: break-word;
}

/* --- Markdown inside bubbles --- */
.ncf-root .ncf-msg-bubble .markdown-body {
  margin: 0;
}

.ncf-root .ncf-msg-bubble .markdown-body p {
  margin: 0.35rem 0;
  white-space: pre-wrap;
  font-size: inherit;
}

.ncf-root .ncf-msg-bubble .markdown-body p:last-child {
  margin-bottom: 0;
}

.ncf-root .ncf-msg-bubble .markdown-body ul {
  list-style: disc;
  list-style-position: outside;
  margin: 0.35rem 0 0.35rem 1rem;
  padding-left: 1rem;
}

.ncf-root .ncf-msg-bubble .markdown-body ol {
  list-style: decimal;
  list-style-position: outside;
  margin: 0.35rem 0 0.35rem 1rem;
  padding-left: 1rem;
}

.ncf-root .ncf-msg-bubble .markdown-body li {
  margin: 0.2rem 0;
}

.ncf-root .ncf-msg-bubble .markdown-body code {
  background: #e5e7eb;
  padding: 0.1rem 0.3rem;
  border-radius: 0.25rem;
  font-size: 0.95em;
}

.ncf-root .ncf-msg-bubble .markdown-body pre {
  background: #0f172a;
  color: #e5e7eb;
  padding: 0.5rem;
  border-radius: 0.5rem;
  overflow: auto;
  margin: 0.35rem 0;
}

.ncf-root .ncf-msg-bubble .markdown-body pre code {
  background: transparent !important;
  color: inherit !important;
  padding: 0;
  border-radius: 0;
  white-space: pre;
}

.ncf-root .ncf-msg-bubble .markdown-body .codehilite {
  background: transparent;
  margin: 0.35rem 0;
}

.ncf-root .ncf-msg-bubble .markdown-body .codehilite pre {
  background: #0f172a;
  color: #e5e7eb;
  padding: 0.5rem;
  border-radius: 0.5rem;
  overflow: auto;
  margin: 0;
}

.ncf-root .ncf-msg-bubble .markdown-body .codehilite pre code {
  background: transparent !important;
  color: inherit !important;
  padding: 0;
  border-radius: 0;
  white-space: pre;
}

.ncf-root .ncf-msg-bubble .markdown-body > :first-child {
  margin-top: 0;
}

.ncf-root .ncf-msg-bubble .markdown-body > :last-child {
  margin-bottom: 0;
}

.ncf-root .ncf-msg-bubble .markdown-body h1,
.ncf-root .ncf-msg-bubble .markdown-body h2,
.ncf-root .ncf-msg-bubble .markdown-body h3,
.ncf-root .ncf-msg-bubble .markdown-body h4,
.ncf-root .ncf-msg-bubble .markdown-body h5,
.ncf-root .ncf-msg-bubble .markdown-body h6 {
  margin: 0.5rem 0 0.35rem 0;
  font-weight: 600;
}

.ncf-root .ncf-msg-bubble .markdown-body h1 { font-size: 1.25rem; }
.ncf-root .ncf-msg-bubble .markdown-body h2 { font-size: 1.125rem; }
.ncf-root .ncf-msg-bubble .markdown-body h3 { font-size: 1rem; }
.ncf-root .ncf-msg-bubble .markdown-body h4 { font-size: 0.9375rem; }
.ncf-root .ncf-msg-bubble .markdown-body h5 { font-size: 0.875rem; }
.ncf-root .ncf-msg-bubble .markdown-body h6 { font-size: 0.8125rem; }

.ncf-root .ncf-msg-bubble .markdown-body blockquote {
  border-left: 3px solid #d1d5db;
  padding-left: 0.75rem;
  margin: 0.35rem 0;
  color: var(--ncf-muted);
}

.ncf-root .ncf-msg-bubble .markdown-body a {
  color: var(--ncf-link);
  text-decoration: underline;
}

.ncf-root .ncf-msg-bubble .markdown-body a:hover {
  color: var(--ncf-link-hover);
}

.ncf-root .ncf-msg-bubble .markdown-body table {
  border-collapse: collapse;
  margin: 0.35rem 0;
  width: 100%;
}

.ncf-root .ncf-msg-bubble .markdown-body table th,
.ncf-root .ncf-msg-bubble .markdown-body table td {
  border: 1px solid var(--ncf-border);
  padding: 0.25rem 0.5rem;
  text-align: left;
}

.ncf-root .ncf-msg-bubble .markdown-body table th {
  background: #f3f4f6;
  font-weight: 600;
}

/* --- Frame form controls (embed-safe resets) --- */
.ncf-root .ncf-input input {
  font-family: inherit;
  font-size: 0.9375rem;
  color: var(--ncf-text);
  background: var(--ncf-bg);
  border: 1px solid var(--ncf-border) !important;
  -webkit-tap-highlight-color: transparent;
}

.ncf-root .ncf-input input::placeholder {
  color: #9ca3af;
}

.ncf-root .ncf-input input:focus,
.ncf-root .ncf-input input:focus-visible {
  outline: none;
  border-color: var(--ncf-border) !important;
  box-shadow: none;
}

/* Toolbar controls — class names avoid "-btn" (host sites often style [class*="btn"]) */
.ncf-root .ncf-tool {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  margin: 0;
  font-family: inherit;
  line-height: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  outline: none;
  color: #9ca3af;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  transition: color 0.15s ease;
}

.ncf-root .ncf-tool:hover {
  color: #374151;
}

.ncf-root .ncf-tool:focus-visible {
  outline: 2px solid #93c5fd;
  outline-offset: 2px;
}

.ncf-root .ncf-tool svg {
  display: block;
  width: 20px;
  height: 20px;
}

/* Smaller tool control (e.g. features icon in product explorer rows) */
.ncf-root .ncf-tool--sm {
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
}

.ncf-root .ncf-tool--sm svg {
  width: 16px;
  height: 16px;
}

/* Send — matches .ncw-starter-send in the widget */
.ncf-root .ncf-input .ncf-send {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  margin: 0;
  font-family: inherit;
  line-height: 0;
  border: 0;
  border-radius: 0.625rem;
  background: #111827;
  color: #fff;
  box-shadow: none;
  outline: none;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  transition: background 0.15s ease, transform 0.08s ease;
}

.ncf-root .ncf-input .ncf-send:hover {
  background: #1f2937;
}

.ncf-root .ncf-input .ncf-send:active {
  transform: scale(0.96);
}

.ncf-root .ncf-input .ncf-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.ncf-root .ncf-input .ncf-send svg {
  display: block;
  width: 20px;
  height: 20px;
}

/* Language: compact code label (no overlapping globe badge) */
.ncf-root .ncf-lang-wrap {
  position: relative;
  display: inline-flex;
  flex-shrink: 0;
}

.ncf-root .ncf-lang {
  min-width: 40px;
  width: auto;
  padding: 0 0.45rem;
  line-height: 1;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.ncf-root .ncf-lang .ncf-lang-code {
  display: block;
  line-height: 1;
}

.ncf-root .ncf-lang-dropdown {
  position: absolute;
  bottom: 100%;
  right: 0;
  margin-bottom: 0.5rem;
  background: var(--ncf-bg);
  border: 1px solid var(--ncf-border);
  border-radius: 0.5rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
  min-width: 10.5rem;
  max-height: 16rem;
  overflow-y: auto;
  display: none;
  z-index: 10000;
  padding: 0.25rem 0;
  box-sizing: border-box;
}

.ncf-root .ncf-lang-option {
  width: 100%;
  padding: 0.5rem 0.75rem;
  text-align: left;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.875rem;
  color: var(--ncf-text);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  -webkit-appearance: none;
  appearance: none;
}

.ncf-root .ncf-lang-option:hover {
  background: #f9fafb !important;
}

.ncf-root .ncf-lang-option.is-active {
  background: #f3f4f6 !important;
  font-weight: 600;
}

.ncf-root .ncf-lang-option svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: #374151;
}

/* Icon-only control for panel headers, explorer rows (no "-btn" in class name) */
.ncf-root .ncf-icon {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  margin: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  outline: none;
  color: #374151;
  cursor: pointer;
  border-radius: 0.5rem;
  line-height: 0;
  font-family: inherit;
  flex-shrink: 0;
  -webkit-appearance: none;
  appearance: none;
  text-decoration: none;
}

.ncf-root .ncf-icon:hover {
  color: #111827;
}

.ncf-root .ncf-icon:focus-visible {
  outline: 2px solid #93c5fd;
  outline-offset: 2px;
}

.ncf-root .ncf-icon svg {
  display: block;
  width: 20px;
  height: 20px;
}

.ncf-root .ncf-icon--sm {
  width: 28px;
  height: 28px;
}

.ncf-root .ncf-icon--sm svg {
  width: 16px;
  height: 16px;
}

/* Markdown code blocks on dark agent bubbles */
.ncf-root .ncf-msg--agent .ncf-msg-bubble .markdown-body code {
  background: rgba(255, 255, 255, 0.12);
  color: inherit;
}

.ncf-root .ncf-msg--agent .ncf-msg-bubble .markdown-body pre,
.ncf-root .ncf-msg--agent .ncf-msg-bubble .markdown-body .codehilite pre {
  background: rgba(0, 0, 0, 0.35);
  color: #f9fafb;
}

.ncf-root .ncf-banner {
  font-family: inherit;
}
