/* Built-in tools page. Kept independent from the settings surface. */

.tools-page,
.tools-page-main {
  min-width: 0;
  min-height: 0;
}

.tools-page {
  height: 100%;
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  background: var(--seg-shell);
}

.tools-top-menu-label {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--seg-text-1);
  font-size: 13px;
  font-weight: 650;
}

.tools-top-menu-label svg {
  width: var(--section-toolbar-icon-size);
  height: var(--section-toolbar-icon-size);
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
}

.tools-top-menu-window-controls {
  align-self: stretch;
  justify-self: end;
  align-items: center;
}

.tools-page-main {
  overflow: hidden;
  padding: 18px 20px 24px;
  display: grid;
  align-content: start;
  gap: 18px;
}

.tools-banner,
.tools-panel,
.tools-empty-state,
.tools-category-item,
.tools-detail-hero,
.tools-toggle-card {
  border: 1px solid var(--seg-border);
  background: var(--seg-panel);
  color: var(--seg-text-1);
  box-shadow: none;
}

.tools-banner {
  padding: 12px 14px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
}

.tools-banner.is-success {
  border-color: rgba(78, 146, 102, 0.36);
  color: #245c3a;
  background: #f4fbf6;
}

.tools-banner.is-error {
  border-color: rgba(197, 97, 78, 0.3);
  color: #8f3127;
  background: #fff6f3;
}

.tools-banner-text {
  min-width: 0;
}

.tools-banner-dismiss {
  min-width: 26px;
  width: 26px;
  height: 26px;
  min-height: 26px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--seg-radius-xs);
  background: transparent;
  color: currentColor;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0.72;
  transition:
    opacity 160ms ease,
    background 160ms ease;
}

.tools-banner-dismiss svg {
  width: 12px;
  height: 12px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tools-banner-dismiss:hover,
.tools-banner-dismiss:focus-visible {
  background: rgba(255, 255, 255, 0.62);
  opacity: 1;
}

.tools-banner-dismiss:focus-visible {
  outline: var(--focus-outline-width) solid var(--focus-outline-color);
  outline-offset: var(--focus-outline-offset);
}

.tools-panel,
.tools-empty-state {
  padding: 18px;
  border-radius: var(--seg-radius-sm);
  display: grid;
  gap: 16px;
}

.tools-empty-state h3,
.tools-detail-header h2,
.tools-detail-hero h3 {
  margin: 0;
  color: var(--seg-text-1);
  letter-spacing: 0;
}

.tools-empty-state p,
.tools-page-copy,
.tools-detail-header p,
.tools-category-item-copy,
.tools-detail-hero p {
  margin: 0;
  color: var(--seg-text-3);
  line-height: 1.55;
}

.tools-layout {
  min-width: 0;
  min-height: 0;
  height: 100%;
  display: grid;
  grid-template-columns: minmax(260px, 0.28fr) minmax(0, 1fr);
  gap: 18px;
  align-items: stretch;
}

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

.tools-category-panel,
.tools-detail-panel {
  min-height: 0;
  display: grid;
  align-content: start;
  gap: 18px;
}

.tools-category-panel {
  grid-template-rows: minmax(0, 1fr);
}

.tools-category-body {
  min-height: 0;
  overflow: hidden;
}

.tools-category-list {
  min-height: 0;
  height: 100%;
  overflow: auto;
  scrollbar-gutter: stable;
  padding-right: 4px;
  display: grid;
  align-content: start;
  gap: 10px;
}

.tools-category-item {
  width: 100%;
  padding: 14px;
  border-radius: var(--seg-radius-xs);
  text-align: left;
  display: grid;
  gap: 8px;
  cursor: pointer;
  color: var(--seg-text-2);
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    background 160ms ease,
    color 160ms ease;
}

.tools-category-item:hover {
  transform: translateY(-1px);
  border-color: rgba(95, 146, 194, 0.6);
  background: #ffffff;
  color: var(--seg-text-1);
}

.tools-category-item.is-active {
  background: #e7f2fb;
  border-color: rgba(95, 146, 194, 0.7);
}

.tools-category-item-header,
.tools-detail-hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.tools-category-item-header {
  align-items: center;
}

.tools-category-item strong {
  color: var(--seg-text-1);
}

.sidebar-view-tools .tools-category-list {
  gap: 4px;
}

.sidebar-view-tools .tools-category-item {
  min-height: 32px;
  padding: 0 8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  box-shadow: none;
  color: #50657a;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transform: none;
}

.sidebar-view-tools .tools-category-item:hover,
.sidebar-view-tools .tools-category-item:focus-visible {
  border-color: transparent;
  background: rgba(84, 96, 109, 0.08);
  color: #20303e;
  transform: none;
  outline: none;
}

.sidebar-view-tools .tools-category-item.is-active {
  background: var(--mix-seg-accent-soft-84-transparent-16);
  color: var(--seg-accent-strong);
}

.tools-detail-panel {
  overflow: auto;
  scrollbar-gutter: stable;
  padding-right: 4px;
  gap: 14px;
}

.tools-detail-hero {
  padding: 18px;
  border-radius: var(--seg-radius-sm);
  flex-wrap: wrap;
}

.tools-detail-hero > div:first-child {
  min-width: min(100%, 420px);
  display: grid;
  gap: 5px;
}

.tools-detail-statuses {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.tools-detail-section,
.tools-card-list {
  min-width: 0;
}

.tools-detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.22);
}

.tools-detail-header p {
  margin-top: 6px;
}

.tools-detail-actions {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.tools-card-list {
  display: grid;
  gap: 10px;
}

.tools-toggle-card {
  width: 100%;
  border-radius: var(--seg-radius-sm);
  text-align: left;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: stretch;
  justify-content: stretch;
  justify-items: stretch;
  gap: 0;
  cursor: default;
  overflow: hidden;
  transition:
    border-color 160ms ease,
    background 160ms ease,
    box-shadow 160ms ease;
}

.tools-toggle-card:hover {
  border-color: var(--mix-seg-accent-34-seg-border-66);
}

.tools-toggle-card:focus-visible {
  border-color: var(--mix-seg-accent-42-seg-border-58);
  outline: none;
}

.tools-toggle-card.is-active {
  border-color: var(--mix-seg-accent-32-seg-border-68);
  background: var(--mix-seg-accent-soft-74-seg-panel-26);
}

.tools-card {
  align-items: stretch;
}

.tools-card-row {
  justify-self: stretch;
  width: 100%;
  box-sizing: border-box;
  min-width: 0;
  min-height: 54px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) max-content;
  align-items: center;
  gap: 12px;
  padding: 10px 18px;
  justify-content: stretch;
}

.tools-card-expander,
.tools-card-toggle-button {
  min-width: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  padding: 0;
}

.tools-card-expander {
  width: 100%;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  cursor: pointer;
}

.tools-card-expander:focus-visible,
.tools-card-toggle-button:focus-visible {
  outline: 2px solid var(--mix-seg-accent-42-seg-border-58);
  outline-offset: 3px;
}

.tools-card-expander-icon {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--seg-text-3);
  flex: 0 0 auto;
}

.tools-card-expander-icon svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
}

.tools-card-title {
  min-width: 0;
  color: var(--seg-text-1);
  font-size: 15px;
  font-weight: 700;
  line-height: 1.3;
  white-space: nowrap;
}

.tools-card-id {
  flex: 1 1 auto;
  min-width: 0;
  color: #728197;
  font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tools-card-row-actions {
  min-width: 0;
  justify-self: end;
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

.tools-card-meta {
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.tools-card-meta-inline {
  flex-wrap: nowrap;
  justify-content: flex-end;
  overflow: hidden;
}

.tools-card-meta-inline .tools-badge {
  flex: 0 0 auto;
}

.tools-card-toggle-button {
  width: 50px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  justify-self: end;
  cursor: pointer;
}

.tools-toggle-control {
  position: relative;
  flex: 0 0 auto;
  width: 48px;
  height: 28px;
  border: 1px solid var(--seg-border);
  border-radius: 999px;
  background: var(--mix-seg-border-72-seg-panel-28);
}

.tools-toggle-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 999px;
  background: var(--seg-panel);
  box-shadow: none;
  transition: transform 160ms ease;
}

.tools-toggle-card.is-active .tools-toggle-control {
  border-color: var(--seg-accent);
  background: var(--seg-accent);
}

.tools-toggle-card.is-active .tools-toggle-thumb {
  transform: translateX(20px);
}

.tools-card-details {
  display: grid;
  gap: 10px;
  padding: 0 18px 16px 46px;
}

.tools-card-detail-grid {
  margin: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.tools-card-detail-item {
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--seg-border);
  border-radius: var(--seg-radius-sm);
  background: var(--mix-seg-panel-72-seg-panel-muted-28);
}

.tools-card-detail-item.is-description {
  grid-column: 1 / -1;
}

.tools-card-detail-grid dt {
  color: var(--seg-text-3);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.tools-card-detail-grid dd {
  margin: 3px 0 0;
  color: var(--seg-text-1);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tools-card-detail-item.is-description dd {
  color: var(--seg-text-2);
  line-height: 1.5;
  overflow: visible;
  text-overflow: clip;
  white-space: normal;
}

.tools-card-input-schema {
  min-width: 0;
  display: grid;
  gap: 8px;
}

.tools-card-detail-label {
  color: var(--seg-text-3);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.tools-card-input-schema pre {
  max-height: 260px;
  margin: 0;
  padding: 12px;
  overflow: auto;
  border: 1px solid var(--seg-border);
  border-radius: var(--seg-radius-sm);
  background: var(--seg-code-bg, var(--mix-seg-panel-72-seg-panel-muted-28));
  color: var(--seg-text-1);
  font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace);
  font-size: 12px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

.tools-detail-empty-state {
  min-height: 100%;
  align-content: center;
}

.tools-badge {
  min-height: 26px;
  padding: 0 10px;
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-radius-pill);
  background: rgba(255, 255, 255, 0.7);
  color: var(--ui-text-2);
  box-shadow: none;
  display: inline-flex;
  align-items: center;
  font-family: "IBM Plex Mono", "JetBrains Mono", "Consolas", monospace;
  font-size: 11px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.tools-badge.is-highlight {
  border-color: rgba(95, 146, 194, 0.7);
  background: rgba(29, 110, 255, 0.12);
  color: var(--ui-accent-strong);
}

.tools-badge.is-warning {
  border-color: rgba(184, 134, 11, 0.35);
  background: #fff7df;
  color: #8a5a00;
}

@media (max-width: 1280px) {
  .tools-layout {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 900px) {
  .tools-detail-header {
    flex-direction: column;
  }

  .tools-detail-actions {
    width: 100%;
    flex: 1 1 auto;
    justify-content: stretch;
  }

  .tools-detail-actions .secondary-button,
  .tools-detail-actions .primary-button {
    flex: 1 1 180px;
  }

  .tools-card-row {
    min-height: 64px;
    grid-template-columns: minmax(0, 1fr);
    align-items: stretch;
  }

  .tools-card-expander {
    min-height: 32px;
  }

  .tools-card-row-actions {
    width: calc(100% - 28px);
    margin-left: 28px;
    justify-self: end;
  }

  .tools-card-meta-inline {
    justify-content: flex-end;
  }

  .tools-card-detail-grid {
    grid-template-columns: 1fr;
  }
}
