/* MCPB Forge — its own pages. Colours, buttons, menus, dialogs and toasts come
   from the toolbox (/_toolbox/ui/), as does the page chrome (page.css): top
   bar, panels, forms, tables. */

/* ----------------------------------------------------------- library -- */

.toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) repeat(4, minmax(120px, 170px)) auto;
  gap: 8px;
  align-items: end;
  margin-bottom: 16px;
}

.toolbar label {
  display: grid;
  gap: 4px;
  font-size: 12px;
  color: var(--text-dim);
}

.search {
  position: relative;
}

.search .icon {
  position: absolute;
  left: 9px;
  bottom: 9px;
  color: var(--text-faint);
}

.search input {
  padding-left: 32px !important;
}

.results-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  font-size: 13px;
  color: var(--text-dim);
}

.bundles {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.bundles.grid {
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

.bundle-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  height: 100%;
  padding: 16px;
  color: inherit;
  text-decoration: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 0.12s, box-shadow 0.12s;
}

.bundle-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-sm);
}

.bundle-card:focus-visible {
  outline-offset: 2px;
}

.bundle-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.avatar {
  display: grid;
  flex: none;
  place-items: center;
  width: 36px;
  height: 36px;
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  border-radius: 9px;
}

.avatar.large {
  width: 64px;
  height: 64px;
  font-size: 26px;
  border-radius: 14px;
}

img.avatar {
  object-fit: cover;
  background: var(--surface-sunken);
}

.bundle-title {
  min-width: 0;
}

.bundle-title strong {
  display: block;
  overflow: hidden;
  font-size: 15px;
  color: var(--text);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bundle-desc {
  display: -webkit-box;
  overflow: hidden;
  color: var(--text-dim);
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.bundles.list .bundle-card {
  display: grid;
  grid-template-columns: minmax(200px, 1.1fr) 2fr auto;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
}

.bundles.list .bundle-desc {
  -webkit-line-clamp: 1;
}

.bundles.list .tag-list {
  display: none;
}

.skeleton {
  height: 150px;
  background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 40%, var(--surface) 80%);
  background-size: 200% 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  animation: shimmer 1.3s linear infinite;
}

.bundles.list .skeleton {
  height: 60px;
}

@keyframes shimmer {
  to {
    background-position: -200% 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .skeleton {
    animation: none;
  }
}

.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 20px;
  color: var(--text-dim);
}

/* ------------------------------------------------------------ detail -- */

.detail {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 16px;
  align-items: start;
}

.detail-head {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.detail-head h1 {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.detail-head .lede {
  margin: 6px 0 10px;
}

.install {
  margin: 0;
  padding-left: 20px;
}

.install li + li {
  margin-top: 6px;
}

.tool {
  padding: 14px 0;
  border-top: 1px solid var(--border);
}

.tool:first-of-type {
  border-top: 0;
  padding-top: 0;
}

.tool h3 {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.tool p {
  margin-top: 4px;
  color: var(--text-dim);
}

.params {
  margin-top: 8px;
}

/* ------------------------------------------------------------ wizard -- */

.wizard {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 16px;
  align-items: start;
}

.stepper {
  display: flex;
  gap: 4px;
  margin: 0 0 16px;
  padding: 0;
  overflow-x: auto;
  list-style: none;
  counter-reset: step;
}

.stepper li {
  flex: 1;
  min-width: 120px;
}

.stepper button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  font: inherit;
  font-size: 13px;
  color: var(--text-dim);
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.stepper .num {
  display: grid;
  flex: none;
  place-items: center;
  width: 22px;
  height: 22px;
  font-size: 12px;
  font-weight: 700;
  background: var(--surface-sunken);
  border-radius: 50%;
}

.stepper button[aria-current="step"] {
  color: var(--text);
  border-color: var(--accent);
  box-shadow: inset 0 -2px 0 var(--accent);
}

.stepper button[aria-current="step"] .num {
  color: var(--accent-text);
  background: var(--accent);
}

.stepper button.has-errors .num {
  color: #fff;
  background: var(--danger);
}

.stepper button.is-done .num {
  color: #fff;
  background: var(--ok);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  min-height: 36px;
  padding: 4px 6px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
}

.chips:focus-within {
  border-color: var(--accent);
  outline: 2px solid var(--accent-soft);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px 4px 2px 8px;
  font-size: 12px;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 999px;
}

.chip button {
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  padding: 0;
  color: inherit;
  background: none;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
}

.chip button:hover {
  background: rgb(0 0 0 / 8%);
}

.chip .icon {
  width: 12px;
  height: 12px;
}

main .chips input {
  flex: 1;
  min-width: 120px;
  padding: 4px;
  border: 0;
  outline: none !important;
  background: transparent;
}

.icon-choice {
  display: flex;
  align-items: center;
  gap: 16px;
}

.rows {
  display: grid;
  gap: 10px;
}

.row-card {
  padding: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.row-card .row-head {
  margin-bottom: 10px;
}

.row-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  align-items: start;
}

.row-grid .wide {
  grid-column: 1 / -1;
}

.tools-layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.tool-list {
  display: grid;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.tool-list li {
  display: flex;
  align-items: center;
  gap: 2px;
}

.tool-list .tool-pick {
  flex: 1;
  min-width: 0;
  padding: 7px 9px;
  overflow: hidden;
  font: inherit;
  font-size: 13px;
  color: var(--text);
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
  background: none;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.tool-list .tool-pick:hover {
  background: var(--surface-sunken);
}

.tool-list .tool-pick[aria-current="true"] {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.tool-list .tool-pick.has-errors {
  color: var(--danger);
}

.tool-list li {
  gap: 0;
}

.tool-list .icon-btn {
  width: 24px;
  height: 26px;
}

.tool-list .icon {
  width: 15px;
  height: 15px;
}

.domain-rows {
  display: grid;
  gap: 8px;
}

.domain-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: flex-start;
  padding: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.domain-row > input,
.domain-row > select,
.domain-row > .literal {
  flex: 1 1 140px;
  min-width: 0;
}

.domain-row > .literal {
  display: flex;
  gap: 6px;
  flex-basis: 200px;
}

.domain-row > .literal select {
  flex: 0 0 96px;
}

.domain-row > .icon-btn {
  flex: none;
}

.domain-row .field-error {
  flex-basis: 100%;
}

.preview {
  position: sticky;
  top: 68px;
  display: grid;
  gap: 10px;
}

.preview pre.code {
  max-height: calc(100vh - 170px);
  font-size: 11px;
}

.save-status {
  font-size: 12px;
  color: var(--text-dim);
}

.wizard-nav {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 16px;
}

.issues {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.issue {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 8px 10px;
  font-size: 13px;
  border-radius: var(--radius-sm);
}

.issue .icon {
  flex: none;
  width: 16px;
  height: 16px;
  margin-top: 1px;
}

.issue.error {
  background: var(--danger-soft);
}

.issue.error .icon {
  color: var(--danger);
}

.issue.warning {
  background: var(--surface-sunken);
}

.issue.warning .icon {
  color: var(--warn);
}

.issue .where {
  font-weight: 600;
}

.success-panel {
  display: grid;
  justify-items: start;
  gap: 12px;
}

/* --------------------------------------------------------- responsive -- */

@media (max-width: 1100px) {
  .wizard,
  .detail {
    grid-template-columns: minmax(0, 1fr);
  }

  .preview {
    position: static;
  }

  .toolbar {
    grid-template-columns: 1fr 1fr;
  }

  .toolbar .search {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {

  .tools-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .bundles.list .bundle-card {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .detail-head {
    flex-direction: column;
  }
}

/* ---------------------------------------------------------- templates -- */

.templates {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.template-card {
  display: grid;
  gap: 10px;
  align-content: start;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.template-card h2 {
  font-size: 16px;
}

.group-list {
  display: grid;
  gap: 6px;
  margin-top: 8px;
}

.group-choice,
.tool-option {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.group-choice:hover,
.tool-option:hover {
  background: var(--surface-sunken);
}

.group-choice input,
.tool-option input {
  margin-top: 2px !important;
  flex: none;
}

.tool-picker {
  display: grid;
  gap: 10px;
  max-height: 55vh;
  overflow: auto;
}

.tool-group {
  margin: 0;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.tool-group legend {
  padding: 0 4px;
  font-weight: 600;
}

.tool-list .tool-group-head {
  display: block;
  margin-top: 8px;
  padding: 0 4px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.tool-actions {
  margin: -6px 0 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
