@import "@novaclaw/ui/v2/text-input-v2.css";
@import "@novaclaw/ui/v2/button-v2.css";

[data-component="tabs-v2"][data-variant="settings"] {
  height: 100%;
}

[data-component="dialog-v2"][data-variant="settings"] [data-slot="dialog-container"] {
  background: var(--v2-background-bg-base);
}

[data-component="dialog-v2"][data-variant="settings"] [data-slot="dialog-body"] {
  padding: 0;
  overflow: hidden;
}

.settings-v2-dialog {
  position: relative;
}

.settings-v2-close {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  color: var(--v2-text-text-muted);
  cursor: pointer;
}

.settings-v2-close:hover {
  background: var(--v2-overlay-simple-overlay-hover);
  color: var(--v2-text-text-base);
}

.settings-v2-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow-y: auto;
  scrollbar-width: none;
}

.settings-v2-panel::-webkit-scrollbar {
  display: none;
}

.settings-v2-tab-header {
  position: sticky;
  top: 0;
  z-index: 10;
  padding: 40px 40px 32px;
  background: linear-gradient(to bottom, var(--v2-background-bg-base) calc(100% - 24px), transparent);
}

.settings-v2-tab-title {
  font-size: 15px;
  font-weight: 640;
  line-height: 1;
  color: var(--v2-text-text-base);
}

.settings-v2-tab-body {
  display: flex;
  flex-direction: column;
  gap: 36px;
  width: 100%;
  padding: 0 40px 40px;
}

[data-slot="settings-v2-row-description"] a.settings-v2-link {
  color: var(--v2-text-text-accent);
  cursor: pointer;
  text-decoration: none;
}

[data-slot="settings-v2-row-description"] a.settings-v2-link:hover {
  color: var(--v2-text-text-accent-hover);
}

.settings-v2-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.settings-v2-section-title {
  padding-bottom: 8px;
  font-size: 15px;
  font-weight: 640;
  line-height: 1;
  color: var(--v2-text-text-base);
}

.settings-v2-section-title + [data-component="settings-v2-list"] {
  margin-top: -4px;
  margin-bottom: 0;
}

[data-component="settings-v2-list"] {
  border-radius: 8px;
  background-color: var(--v2-background-bg-layer-01);
  padding-inline: 20px;
  box-shadow: inset 0 0 0 0.5px var(--v2-border-border-muted);
}

[data-component="settings-v2-row"] {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  padding-block: 20px;
  border-bottom: 0.5px solid var(--v2-border-border-base);
}

[data-component="settings-v2-row"]:last-child {
  border-bottom: none;
}

@media (min-width: 640px) {
  [data-component="settings-v2-row"] {
    flex-wrap: nowrap;
  }
}

[data-slot="settings-v2-row-copy"] {
  display: flex;
  min-width: 0;
  flex: 1;
  flex-direction: column;
  gap: 8px;
}

[data-slot="settings-v2-row-title"] {
  font-style: normal;
  font-size: 13px;
  font-weight: 530;
  line-height: 1;
  letter-spacing: -0.04px;
  color: var(--v2-text-text-base);
  font-variation-settings: "slnt" 0;
}

[data-slot="settings-v2-row-description"] {
  font-size: 11px;
  font-weight: 440;
  line-height: 1;
  color: var(--v2-text-text-muted);
}

[data-slot="settings-v2-row-control"] {
  display: flex;
  width: 100%;
  justify-content: flex-end;
}

[data-slot="settings-v2-row-control"] > div:has([data-component="switch"]),
[data-slot="settings-v2-row-control"] > [data-component="switch"] {
  display: inline-flex;
  align-items: center;
  padding: 4px;
}

@media (min-width: 640px) {
  [data-slot="settings-v2-row-control"] {
    width: auto;
    flex-shrink: 0;
  }
}

[data-slot="settings-v2-row-control"] [data-component="text-input-v2"] {
  width: 100%;
}

[data-component="dialog-v2"][data-variant="settings"] [data-component="select-v2-root"] {
  width: fit-content;
  max-width: 100%;
}

[data-component="dialog-v2"][data-variant="settings"] [data-component="button-v2"] {
  width: fit-content;
  max-width: 100%;
}

[data-component="tabs-v2"][data-variant="settings"][data-orientation="vertical"] [data-slot="tabs-v2-list"] {
  background-color: var(--v2-background-bg-layer-01);
}

@media (max-width: 639px) {
  .settings-v2[data-component="tabs-v2"][data-variant="settings"][data-orientation="vertical"]
    [data-slot="tabs-v2-list"] {
    width: 144px;
    min-width: 144px;
    padding-inline: 8px;
  }
}

.settings-v2-legacy-panel {
  height: 100%;
  overflow: hidden;
}

.settings-v2-legacy-panel [data-component="dialog"] {
  display: contents;
}

.settings-v2-provider-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-block: 20px;
  border-bottom: 0.5px solid var(--v2-border-border-base);
}

.settings-v2-provider-row:last-child {
  border-bottom: none;
}

@media (min-width: 640px) {
  .settings-v2-provider-row {
    flex-wrap: nowrap;
  }
}

.settings-v2-providers [data-component="provider-icon"] {
  color: var(--v2-icon-icon-base);
}

.settings-v2-provider-lead {
  display: flex;
  min-width: 0;
  flex: 1;
  align-items: flex-start;
  gap: 10px;
}

.settings-v2-provider-lead:not(:has(.settings-v2-provider-copy)) {
  align-items: center;
}

.settings-v2-provider-copy {
  display: flex;
  min-width: 0;
  flex: 1;
  flex-direction: column;
  gap: 6px;
}

.settings-v2-provider-main {
  display: flex;
  min-width: 0;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.settings-v2-provider-name {
  font-size: 13px;
  font-weight: 530;
  line-height: 16px;
  color: var(--v2-text-text-base);
}

.settings-v2-provider-description {
  margin: 0;
  font-size: 13px;
  font-weight: 440;
  line-height: 1;
  color: var(--v2-text-text-muted);
}

.settings-v2-provider-empty {
  padding-block: 20px;
  font-size: 13px;
  font-weight: 440;
  line-height: 1;
  color: var(--v2-text-text-muted);
}

.settings-v2-provider-env-hint {
  padding-right: 12px;
  font-size: 13px;
  font-weight: 440;
  line-height: 1;
  color: var(--v2-text-text-muted);
  opacity: 0;
  transition: opacity 200ms ease;
  cursor: default;
}

.group:hover .settings-v2-provider-env-hint {
  opacity: 1;
}

.settings-v2-providers-view-all {
  margin-top: 20px;
  padding: 0;
  border: 0;
  background: transparent;
  font-size: 13px;
  font-weight: 530;
  line-height: 1;
  color: var(--v2-text-text-accent);
  cursor: pointer;
  text-align: left;
}

.settings-v2-providers-view-all:hover {
  color: var(--v2-text-text-accent-hover);
}

.settings-v2-tab-body.settings-v2-providers {
  gap: 32px;
}

.settings-v2-tab-header:has(+ .settings-v2-tab-body.settings-v2-providers) {
  padding-bottom: 32px;
}

.settings-v2-providers .settings-v2-section-title {
  padding-bottom: 0;
  font-size: 13px;
  font-weight: 530;
  line-height: 1;
}

.settings-v2-providers .settings-v2-section-title + [data-component="settings-v2-list"] {
  margin-top: 16px;
}

.settings-v2-tab-header.settings-v2-tab-header--stacked {
  display: flex;
  flex-direction: column;
  gap: 32px;
  padding-bottom: 32px;
}

.settings-v2-tab-header--stacked > .settings-v2-tab-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.settings-v2-tab-search {
  position: relative;
  width: 100%;
}

.settings-v2-tab-search [data-component="text-input-v2"] {
  width: 100%;
}

.settings-v2-tab-search [data-slot="text-input-v2-input"] {
  padding-right: 28px;
}

.settings-v2-tab-search-clear {
  position: absolute;
  top: 50%;
  right: 6px;
  z-index: 1;
  transform: translateY(-50%);
}

.settings-v2-tab-body.settings-v2-models {
  gap: 24px;
  /* Query container so model rows respond to the PANEL width, not the viewport (the settings dialog
     stays wide even in a small window). */
  container-type: inline-size;
}

/* Stack the per-model action buttons UNDER the name when the panel is narrow, so the name is never
   truncated just to keep the buttons on one line. Inline again once there's room. */
.settings-v2-models [data-component="settings-v2-row"] {
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
}

.settings-v2-models [data-slot="settings-v2-row-control"] {
  width: 100%;
  justify-content: flex-end;
}

.settings-v2-models-row-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

@container (min-width: 600px) {
  .settings-v2-models [data-component="settings-v2-row"] {
    flex-direction: row;
    align-items: center;
    gap: 12px;
  }

  .settings-v2-models [data-slot="settings-v2-row-control"] {
    width: auto;
  }
}

.settings-v2-models-group-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 8px;
}

.settings-v2-models .settings-v2-section-title {
  padding-bottom: 0;
  font-size: 13px;
  font-weight: 530;
  line-height: 16px;
}

.settings-v2-models [data-component="provider-icon"] {
  color: var(--v2-icon-icon-base);
}

.settings-v2-models .settings-v2-section-title + [data-component="settings-v2-list"] {
  margin-top: 0;
}

.settings-v2-models [data-slot="settings-v2-row-description"]:empty {
  display: none;
}

.settings-v2-models [data-slot="settings-v2-row-copy"] {
  gap: 2px;
}

.settings-v2-models [data-slot="settings-v2-row-title"] {
  min-width: 0;
  overflow: hidden;
  font-size: 13px;
  font-weight: 440;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.settings-v2-models-status {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding-block: 48px;
  font-size: 13px;
  font-weight: 440;
  line-height: 1;
  color: var(--v2-text-text-muted);
  text-align: center;
}

.settings-v2-models-status-filter {
  color: var(--v2-text-text-base);
}

/* 2D — introspection tab */
.settings-v2-tab-description {
  font-size: 13px;
  font-weight: 440;
  line-height: 1.4;
  color: var(--v2-text-text-muted);
  margin: 0;
}

.settings-v2-field-description {
  font-size: 12px;
  font-weight: 440;
  line-height: 1.4;
  color: var(--v2-text-text-muted);
  margin: 0 0 8px;
}

.settings-v2-textarea {
  width: 100%;
  min-height: 90px;
  resize: vertical;
  font-size: 13px;
  line-height: 1.45;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--v2-border-border-base);
  background: var(--v2-background-bg-base, transparent);
  color: var(--v2-text-text-base);
}

.settings-v2-textarea:focus-visible {
  /* Real token family is --v2-border-border-* (not the phantom --v2-stroke-*); the focus token IS
     our gold (#e7b62f), so the ring matches the palette instead of the old yellow-500 fallback. */
  outline: 2px solid var(--v2-border-border-focus);
  outline-offset: 1px;
}

/* B15 — per-model probe button + result chip */
.settings-v2-models-row-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.settings-v2-models-probe-result {
  font-size: 12px;
  font-weight: 440;
  line-height: 1;
  white-space: nowrap;
  color: var(--v2-text-text-muted);
}

.settings-v2-models-probe-result[data-status="ok"] {
  color: var(--v2-state-success-text, #22c55e);
}

.settings-v2-models-probe-result[data-status="unreachable"],
.settings-v2-models-probe-result[data-status="auth"],
.settings-v2-models-probe-result[data-status="error"] {
  color: var(--v2-state-danger-text, #ef4444);
}

.settings-v2-models-probe-result[data-status="model-missing"],
.settings-v2-models-probe-result[data-status="no-url"] {
  color: var(--v2-state-warning-text, #eab308);
}

/* Capability-tier picker — rich, educational dropdown options (name + size range + capabilities). */
.settings-v2-tier-option {
  display: flex;
  flex-direction: column;
  gap: 3px;
  max-width: 340px;
}

.settings-v2-tier-option-head {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.settings-v2-tier-option-name {
  font-weight: 560;
}

.settings-v2-tier-option-range {
  font-size: 11px;
  color: var(--v2-text-text-muted);
  font-variant-numeric: tabular-nums;
}

.settings-v2-tier-option-blurb {
  font-size: 12px;
  line-height: 1.35;
  color: var(--v2-text-text-muted);
  white-space: normal;
}

.settings-v2-shortcuts .settings-v2-section {
  gap: 16px;
}

.settings-v2-shortcuts .settings-v2-section-title {
  padding-bottom: 0;
  font-size: 13px;
  font-weight: 530;
  line-height: 1;
}

.settings-v2-shortcuts [data-component="settings-v2-list"] {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 20px;
  border-radius: 6px;
}

.settings-v2-shortcuts [data-component="settings-v2-list"] > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-top: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.settings-v2-shortcuts [data-component="settings-v2-list"] > div:not(:last-child) {
  padding-bottom: 16px;
  margin-bottom: 16px;
  border-bottom: 0.5px solid var(--v2-border-border-base);
}

.settings-v2-shortcuts [data-component="settings-v2-list"] > div > span {
  font-weight: 440;
  font-size: 13px;
  line-height: 1;
  letter-spacing: -0.04px;
  color: var(--v2-text-text-base);
  font-variation-settings: "slnt" 0;
}

.settings-v2-keybind-button {
  box-sizing: border-box;
  flex-shrink: 0;
  padding: 6px 8px;
  margin: -6px -8px;
  border: 0;
  border-radius: 2px;
  background: transparent;
  cursor: pointer;
  font-style: normal;
  font-weight: 530;
  font-size: 11px;
  line-height: 1;
  letter-spacing: 0.05px;
  font-variant-numeric: tabular-nums;
  font-feature-settings:
    "tnum" on,
    "lnum" on;
  font-variation-settings: "slnt" 0;
  color: var(--v2-text-text-faint);
}

.settings-v2-keybind-button:hover {
  background-color: var(--v2-background-bg-layer-02);
}

.settings-v2-keybind-button:focus-visible {
  outline: 2px solid var(--v2-border-border-focus);
  outline-offset: 2px;
}

.settings-v2-keybind-button--active {
  color: var(--v2-text-text-faint);
  border-radius: 2px;
  background-color: var(--v2-background-bg-layer-02);
}

.settings-v2-shortcuts-status {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding-block: 48px;
  font-size: 13px;
  font-weight: 440;
  line-height: 1;
  color: var(--v2-text-text-muted);
  text-align: center;
}

.settings-v2-shortcuts-status-filter {
  color: var(--v2-text-text-base);
}

.settings-v2-tab-body.settings-v2-servers {
  gap: 0;
}

.settings-v2-tab-header.settings-v2-servers-header {
  padding-bottom: 24px;
}

.settings-v2-servers-header .settings-v2-tab-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.settings-v2-tab-header.settings-v2-servers-header.settings-v2-tab-header--stacked {
  gap: 24px;
  padding-bottom: 24px;
}

.settings-v2-servers [data-component="settings-v2-list"] {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 20px;
  border-radius: 6px;
}

/* R7: the discovered-on-LAN section under the saved list. */
.settings-v2-servers-discovered {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 24px;
}

.settings-v2-servers-discovered .settings-v2-tab-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.settings-v2-servers-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.settings-v2-servers-row:not(:last-child) {
  padding-bottom: 16px;
  margin-bottom: 16px;
  border-bottom: 0.5px solid var(--v2-border-border-base);
}

.settings-v2-servers-actions {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.settings-v2-servers-lead {
  display: flex;
  min-width: 0;
  flex: 1;
  align-items: flex-start;
  gap: 10px;
}

.settings-v2-servers-copy {
  display: flex;
  min-width: 0;
  flex: 1;
  flex-direction: column;
  gap: 6px;
}

.settings-v2-servers-name {
  font-size: 13px;
  font-weight: 530;
  line-height: 1;
  color: var(--v2-text-text-base);
}

.settings-v2-servers-meta {
  font-size: 11px;
  font-weight: 440;
  line-height: 1;
  color: var(--v2-text-text-muted);
}

.settings-v2-servers-status {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding-block: 48px;
  font-size: 13px;
  font-weight: 440;
  line-height: 1;
  color: var(--v2-text-text-muted);
  text-align: center;
}

.settings-v2-servers-status-filter {
  color: var(--v2-text-text-base);
}

[data-component="dialog-v2"].settings-v2-server-dialog [data-slot="dialog-container"] {
  width: 480px;
  max-width: calc(100vw - 32px);
  height: auto;
  border-radius: 8px;
  align-items: stretch;
}

[data-component="dialog-v2"].settings-v2-server-dialog [data-slot="dialog-content"] {
  align-items: stretch;
  width: 100%;
}

[data-component="dialog-v2"].settings-v2-server-dialog [data-slot="dialog-header"] {
  align-items: center;
  padding: 24px 24px 16px;
}

[data-component="dialog-v2"].settings-v2-server-dialog [data-slot="dialog-body"] {
  display: flex;
  width: 100%;
  min-width: 0;
  flex-direction: column;
  align-items: stretch;
}

[data-component="dialog-v2"].settings-v2-server-dialog [data-slot="dialog-footer"] {
  padding: 24px;
}

.settings-v2-server-dialog-label {
  font-size: 13px;
  font-weight: 530;
  line-height: 1;
  color: var(--v2-text-text-base);
}

.settings-v2-server-dialog-error {
  font-size: 11px;
  font-weight: 440;
  line-height: 1;
  color: var(--v2-state-fg-danger);
}

/* About tab — a branded wordmark + the third-party license credits. */
.settings-v2-about-brand {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}

.settings-v2-about-title {
  /* The "fancy font": an elegant serif wordmark, distinct from the UI sans, filled with the brand gold
     as a metallic gradient. `color` is the graceful fallback if background-clip: text is unsupported. */
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  font-size: 46px;
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: 0.5px;
  color: var(--v2-text-text-accent);
  background: linear-gradient(
    135deg,
    color-mix(in oklab, var(--v2-text-text-accent) 52%, white) 0%,
    var(--v2-text-text-accent) 48%,
    color-mix(in oklab, var(--v2-text-text-accent) 64%, black) 100%
  );
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 2px 20px color-mix(in oklab, var(--v2-text-text-accent) 22%, transparent);
}

.settings-v2-about-version {
  font-size: 13px;
  font-weight: 530;
  line-height: 1;
  color: var(--v2-text-text-muted);
  font-variant-numeric: tabular-nums;
}

.settings-v2-about-author {
  font-size: 13px;
  font-weight: 440;
  line-height: 1;
  color: var(--v2-text-text-base);
}

.settings-v2-about-divider {
  height: 0;
  margin: 4px 0;
  border-top: 0.5px solid var(--v2-border-border-base);
}

.settings-v2-about-credits {
  margin: 0;
  padding-inline: 20px;
  list-style: none;
  border-radius: 8px;
  background-color: var(--v2-background-bg-layer-01);
  box-shadow: inset 0 0 0 0.5px var(--v2-border-border-muted);
}

.settings-v2-about-credit {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-block: 12px;
  border-bottom: 0.5px solid var(--v2-border-border-base);
}

.settings-v2-about-credit:last-child {
  border-bottom: none;
}

.settings-v2-about-credit-name {
  font-size: 13px;
  font-weight: 530;
  line-height: 1;
  color: var(--v2-text-text-base);
}

.settings-v2-about-credit-meta {
  font-size: 11px;
  font-weight: 440;
  line-height: 1;
  color: var(--v2-text-text-muted);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.settings-v2-about-note {
  margin: 8px 0 0;
  font-size: 12px;
  font-weight: 440;
  line-height: 1.5;
  color: var(--v2-text-text-base);
}

.settings-v2-about-note--muted {
  color: var(--v2-text-text-muted);
}
