/* Appmixer Connector Gallery - plain CSS (design tokens ported from the
   original Tailwind theme). */

:root {
  --background: hsl(220 15% 98%);
  --foreground: hsl(220 13% 9%);
  --card: hsl(0 0% 100%);
  --primary: hsl(221 83% 53%);
  --primary-foreground: hsl(210 40% 98%);
  --secondary: hsl(220 14% 96%);
  --muted-foreground: hsl(220 8.9% 46.1%);
  --destructive: hsl(0 84.2% 60.2%);
  --border: hsl(220 13% 91%);
  --dashboard-bg: hsl(220 27% 98%);
  --cta: hsl(348 92% 47%);
  --cta-hover: hsl(348 92% 40%);
  --radius: 0.75rem;
  --shadow: 0 10px 25px -5px hsl(220 13% 9% / 0.08), 0 4px 10px -6px hsl(220 13% 9% / 0.06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--background);
  color: var(--foreground);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }
img { max-width: 100%; }
h1, h2, h3, h4, p { margin: 0; }

/* Lucide icons (see public/icons/sprite.svg, built by scripts/build-icons.mjs
   from lucide-static). Sized in em so each usage site scales with its own
   font-size, same as the emoji/text characters these replaced. */
.icon {
  display: inline-block;
  width: 1em;
  height: 1em;
  vertical-align: -0.15em;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}
.icon-sm { width: 0.875em; height: 0.875em; }
.icon-lg { width: 1.25em; height: 1.25em; }
.icon-xl { width: 3rem; height: 3rem; }

.container { max-width: 1400px; margin: 0 auto; padding: 0 1.5rem; }
.section { padding: 2rem 1.5rem; }
.muted { color: var(--muted-foreground); }
.small { font-size: 0.8125rem; }
.large { font-size: 1.25rem; }
.huge { font-size: 3rem; }
.bold { font-weight: 600; }
.center { text-align: center; }
.capitalize { text-transform: capitalize; }
.break-all { word-break: break-all; }
.link { color: var(--primary); text-decoration: underline; }
.center-page { min-height: 70vh; display: flex; align-items: center; justify-content: center; }

/* ------------------------------------------------------------ Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: calc(var(--radius) - 4px);
  border: 1px solid transparent;
  background: none;
  color: var(--foreground);
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.btn-primary { background: var(--primary); color: var(--primary-foreground); }
.btn-primary:hover { filter: brightness(0.92); }
.btn-outline { border-color: var(--border); background: var(--card); }
.btn-outline:hover { background: var(--secondary); }
.btn-outline.active { background: var(--primary); border-color: var(--primary); color: var(--primary-foreground); }
.btn-ghost:hover { background: var(--secondary); }
.btn-cta { background: var(--cta); color: #fff; border-radius: 4px; }
.btn-cta:hover { background: var(--cta-hover); }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 999px;
  border: none;
  background: none;
  color: var(--muted-foreground);
  cursor: help;
  opacity: 0.6;
}
.icon-btn:hover { background: var(--secondary); opacity: 1; }

/* ------------------------------------------------------------- Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.125rem 0.625rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 500;
  border: 1px solid transparent;
  vertical-align: middle;
}
.badge-primary { background: var(--primary); color: var(--primary-foreground); }
.badge-secondary { background: var(--secondary); color: var(--foreground); }
.badge-outline { border-color: var(--border); color: var(--foreground); }
.badge-lg { padding: 0.375rem 0.75rem; font-size: 0.8125rem; }
.badge-list { display: flex; flex-wrap: wrap; gap: 0.25rem; margin-top: 0.25rem; }

/* ----------------------------------------------------------- Site nav */
.site-nav {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}
.site-nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  height: 4rem;
  padding: 0 1.5rem;
}
.logo { display: flex; align-items: center; gap: 0.5rem; text-decoration: none; }
.logo img { height: 1.25rem; }
.logo span { font-weight: 600; font-size: 1.125rem; }

.nav-links { display: none; align-items: center; gap: 0.25rem; margin-left: auto; margin-right: 1rem; }
.nav-cta { display: none; align-items: center; gap: 0.75rem; }
.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: #121212;
  border: none;
  background: none;
  cursor: pointer;
  text-decoration: none;
  border-radius: calc(var(--radius) - 4px);
}
.nav-link:hover { color: rgba(18, 18, 18, 0.7); }
.chevron { transition: transform 0.2s; }

.nav-dropdown { position: relative; }
.dropdown-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  padding-top: 0.25rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 2px);
  box-shadow: var(--shadow);
  min-width: 200px;
  padding: 0.5rem 0;
}
.nav-dropdown:hover .dropdown-menu { display: block; }
.dropdown-menu a {
  display: block;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  color: #121212;
  text-decoration: none;
  white-space: nowrap;
}
.dropdown-menu a:hover { background: var(--secondary); }

.mobile-menu-toggle { display: inline-flex; border: none; background: none; padding: 0.25rem; cursor: pointer; color: var(--muted-foreground); }
.mobile-menu { border-top: 1px solid var(--border); background: var(--card); padding: 1rem 1.5rem; }
.mobile-menu a { display: block; padding: 0.5rem 0.5rem; font-size: 0.875rem; font-weight: 500; color: var(--muted-foreground); text-decoration: none; }
.mobile-menu a:hover { color: var(--foreground); }
.mobile-menu .mobile-sub { padding-left: 1.5rem; font-weight: 400; }
.mobile-group { padding: 0.5rem 0.5rem; font-size: 0.875rem; font-weight: 600; }
.mobile-cta { display: flex; flex-direction: column; gap: 0.5rem; padding-top: 0.75rem; }
.mobile-cta .btn { justify-content: center; }

@media (min-width: 1024px) {
  .nav-links, .nav-cta { display: flex; }
  .mobile-menu-toggle, .mobile-menu { display: none; }
}

/* ---------------------------------------------------------- Dashboard */
.page-dashboard { background: var(--dashboard-bg); min-height: 100vh; }
.dashboard-header { background: var(--card); border-bottom: 1px solid var(--border); padding: 2rem 0; }
.dashboard-title-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; }
.dashboard-title-row h1 { font-size: 1.875rem; }
.dashboard-controls { display: flex; flex-direction: column; gap: 1rem; }
.search-input {
  max-width: 28rem;
  width: 100%;
  padding: 0.625rem 0.875rem;
  font-size: 0.875rem;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 4px);
  background: var(--card);
  color: var(--foreground);
}
.search-input:focus { outline: 2px solid var(--primary); outline-offset: -1px; }
.filter-tabs { display: flex; flex-wrap: wrap; gap: 0.5rem; }

/* -------------------------------------------------------------- Tiles */
.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.5rem;
}
/* min-width: 0 overrides the grid item default (min-width: auto), so
   oversized content in a description (see .rich-text) can't force this
   track - and the whole grid - wider than its column. */
.tile-wrap { position: relative; min-width: 0; }
.tile {
  display: block;
  position: relative;
  height: 100%;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  text-align: center;
  transition: border-color 0.3s, box-shadow 0.3s;
  overflow: hidden;
}
.tile:hover { border-color: var(--primary); box-shadow: var(--shadow); }
.tile:hover h3 { color: var(--primary); }
/* The card navigates via a "stretched link": .tile-link is the only real
   anchor (just the title), invisibly expanded with ::after to cover the
   whole card. This - not an <a> wrapping the whole card - is deliberate:
   a description can contain its own <a> (rendered as HTML, see .rich-text),
   and an <a> can never contain another <a> without corrupting the DOM (the
   browser silently closes the outer one, splitting the card in two). */
.tile-link { color: inherit; text-decoration: none; }
/* z-index stays auto on purpose: the overlay then paints in tree order, which
   puts it above all of the card's static content (so the whole card is
   clickable) but below the changelog button, which is a later sibling of
   .tile. Giving it a positive z-index would cover that button and swallow its
   hover - and raising .changelog-hover to compensate would make it a stacking
   context, trapping .popover's z-index below the sticky header. */
.tile-link::after { content: ""; position: absolute; inset: 0; }
/* A link inside the description sits above the stretched overlay, so it's
   independently clickable instead of triggering card navigation. */
.tile-description a { position: relative; z-index: 2; }
.tile:has(.tile-link:focus-visible) { outline: 2px solid var(--primary); outline-offset: 2px; }
.tile-icon {
  width: 4rem;
  height: 4rem;
  margin: 0 auto 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--background), var(--secondary));
}
.tile-icon img { width: 2.5rem; height: 2.5rem; object-fit: contain; }
.icon-fallback {
  width: 2.5rem;
  height: 2.5rem;
  background: var(--primary);
  color: var(--primary-foreground);
  border-radius: calc(var(--radius) - 4px);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 1.125rem;
}
.tile h3 { font-size: 1.125rem; margin-bottom: 0.375rem; transition: color 0.2s; }
.tile-description {
  margin-top: 0.75rem;
  font-size: 0.875rem;
  color: var(--muted-foreground);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.tile-scopes { margin-top: 0.75rem; padding-top: 0.5rem; border-top: 1px solid var(--border); }
.tile-scopes .badge-list { justify-content: center; }

/* --------------------------------------------------- Changelog popover */
.changelog-hover { position: absolute; top: 0.75rem; right: 0.75rem; }
.popover {
  display: none;
  position: absolute;
  right: 0;
  top: 100%;
  margin-top: 0.5rem;
  width: 20rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 2px);
  box-shadow: var(--shadow);
  /* Above .site-nav (z-index: 50) so it's never hidden behind the sticky
     header, and opens downward (not upward) so it never reaches under the
     header in the first place - important for the topmost row of tiles. */
  z-index: 60;
  text-align: left;
}
.changelog-hover:hover .popover { display: block; }
.popover-header { padding: 1rem; border-bottom: 1px solid var(--border); }
.popover-header h4 { font-size: 0.875rem; }
.popover-body { max-height: 16rem; overflow-y: auto; padding: 1rem; }

.changelog-entry { margin-bottom: 1rem; }
.changelog-entry:not(:last-child) { border-bottom: 1px solid var(--border); padding-bottom: 0.75rem; }
.changelog-entry .badge { margin-right: 0.375rem; }
.changelog-entry ul { margin: 0.5rem 0 0; padding-left: 1.125rem; }
.changelog-entry li { font-size: 0.8125rem; color: var(--muted-foreground); margin-bottom: 0.25rem; }

/* -------------------------------------------------------- Empty state */
.empty-state { text-align: center; padding: 3rem 1rem; }
.empty-icon { font-size: 3rem; margin-bottom: 1rem; }
.empty-state h3 { font-size: 1.25rem; margin-bottom: 0.5rem; }
.empty-state .btn { margin-top: 1rem; }

/* -------------------------------------------------------- Page header */
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.page-header-title { display: flex; align-items: center; gap: 1rem; }
.page-header-title h1 { font-size: 1.875rem; }
.page-header-actions { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }

.description-box { background: var(--secondary); border-radius: var(--radius); padding: 1rem; margin-bottom: 1rem; }

/* -------------------------------------------------------------- Cards */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); }
.section-card { padding: 1.25rem; margin-bottom: 2rem; }
.section-card h2 { font-size: 1.25rem; margin-bottom: 1rem; }
.card-title { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 1rem; }
.card-title h2 { font-size: 1.25rem; margin: 0; }
.component-section { margin-bottom: 2rem; }

/* -------------------------------------------------------- Collapsible */
.collapsible { margin-bottom: 2rem; }
.collapsible summary {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem;
  cursor: pointer;
  list-style: none;
}
.collapsible summary::-webkit-details-marker { display: none; }
.collapsible summary h2 { font-size: 1.25rem; }
.collapsible summary:hover { background: var(--secondary); border-radius: var(--radius); }
.collapsible summary .chevron { margin-left: auto; color: var(--muted-foreground); }
.collapsible[open] summary .chevron { transform: rotate(180deg); }
.collapsible-body { border-top: 1px solid var(--border); padding: 1rem; }
.scroll-y { max-height: 24rem; overflow-y: auto; }

/* ------------------------------------------------------------- Tables */
.table-scroll { width: 100%; overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.data-table th {
  text-align: left;
  font-weight: 600;
  color: var(--muted-foreground);
  padding: 0.625rem 0.75rem;
  border-bottom: 1px solid var(--border);
}
.data-table td { padding: 0.625rem 0.75rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.data-table tr:last-child td { border-bottom: none; }

.auth-field { margin-bottom: 0.5rem; font-size: 0.875rem; }
.auth-hub-box {
  border: 1px solid hsl(221 83% 53% / 0.3);
  background: hsl(221 83% 53% / 0.05);
  border-radius: calc(var(--radius) - 4px);
  padding: 0.75rem;
  margin-bottom: 0.75rem;
}
.auth-hub-badges { display: flex; gap: 0.5rem; margin-bottom: 0.375rem; }

/* ----------------------------------------------------- Component page */
.info-grid { display: grid; grid-template-columns: 1fr; gap: 1rem; }
@media (min-width: 768px) { .info-grid { grid-template-columns: 1fr 1fr; } }
.info-grid label, .info-description label { font-size: 0.875rem; font-weight: 500; color: var(--muted-foreground); }
.info-grid p { margin-top: 0.25rem; }
.info-description { margin-top: 1rem; }
.info-description .rich-text { margin-top: 0.25rem; }
.port-name { font-size: 1.0625rem; margin: 1rem 0 0.75rem; }

/* Descriptions/tooltips can contain arbitrary HTML from connector authors.
   Constrain every descendant so nothing (wide image, table, unbroken string)
   can force this element - and the layout around it - wider than its box. */
.rich-text { max-width: 100%; overflow-wrap: break-word; }
.rich-text * { max-width: 100%; }
.rich-text img { height: auto; }
.rich-text pre { overflow-x: auto; white-space: pre-wrap; }
.rich-text table { width: 100%; }
.rich-text code { word-break: break-all; }
.rich-text a { text-decoration: underline; }

.json-view {
  background: var(--secondary);
  border-radius: calc(var(--radius) - 2px);
  padding: 1rem;
  font-size: 0.8125rem;
  line-height: 1.45;
  overflow-x: auto;
  margin: 0;
}

/* Interactive JSON tree (json-formatter-js), hydrated by public/app.js. */
.json-viewer-container {
  background: var(--secondary);
  border-radius: calc(var(--radius) - 2px);
  padding: 1rem;
  font-size: 0.8125rem;
  overflow-x: auto;
}
.json-viewer-container:empty { min-height: 2rem; }
