/* Shared control details. Keep page colors and native hidden semantics intact. */
:root {
  --control-border: #3b4856;
  --control-surface: #0d151e;
  --control-focus: #a6ed7826;
}

/* Destructive actions remain distinct from normal and primary actions. */
.button.danger:not(:disabled),
.button.danger-button:not(:disabled) {
  color: #f1b6ae;
  border-color: #744b49;
  background: #342323;
  box-shadow: inset 0 1px 0 #ffc7bb0a;
}

@media (hover: hover) {
  .button.danger:hover:not(:disabled),
  .button.danger-button:hover:not(:disabled) {
    color: #ffd4cd;
    background: #462c2b;
    border-color: #a86a64;
  }

  .ssh-host:hover:not(:disabled) { background: #202d38; }
  .ssh-tabs button:hover:not(:disabled) { color: var(--text); }
  .ssh-file:hover { background: #a6ed7805; }
}

:is(.button, .icon-button, .text-button)[aria-busy="true"] {
  cursor: progress;
}

.button[aria-busy="true"] {
  border-style: dashed;
  border-color: #8ca67a;
}

:is(.button, .icon-button, .text-button):disabled,
:is(.button, .icon-button, .text-button):disabled:hover {
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.icon-button:disabled:hover {
  background: transparent;
  color: #8a97a6;
}

.text-button:disabled,
.text-button:disabled:hover { color: #8a97a6; opacity: .62; }

.modal-heading > .icon-button {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border: 1px solid #34414c;
  border-radius: 7px;
}

/* Inputs use the same spacing and focus language in dialogs and SSH pages. */
:is(.form-body, .ssh-form, .scan-form) :is(label, fieldset),
.form-row > *,
.ssh-host-fields > *,
.ssh-credentials > * { min-width: 0; }

:is(.form-body, .ssh-form, .scan-form) :is(input:not([type="checkbox"]):not([type="radio"]):not([type="file"]), select, textarea) {
  max-width: 100%;
  border-color: var(--control-border);
  border-radius: 7px;
  background-color: var(--control-surface);
  line-height: 1.5;
}

.ssh-form :is(input:not([type="checkbox"]), select) { min-height: 40px; }
.ssh-form textarea { resize: vertical; min-height: 100px; }

:is(.form-body, .ssh-form, .scan-form) :is(input, textarea)::placeholder {
  color: #8292a4;
  opacity: 1;
}

:is(.form-body, .ssh-form, .scan-form) :is(input, select, textarea):focus-visible {
  border-color: #95bd79;
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px var(--control-focus);
}

:is(.form-body, .ssh-form, .scan-form) :is(input, select, textarea):disabled {
  background-color: #151c25;
  cursor: not-allowed;
}

.form-body input[readonly] {
  opacity: 1;
  color: #9cabb9;
  border-style: dashed;
}

:is(.form-body, .ssh-form, .scan-form) :is(input, select, textarea)[aria-invalid="true"],
:is(.form-body, .ssh-form, .scan-form) :is(input, select, textarea):user-invalid {
  border-color: #eeaaa1;
  outline-color: #eeaaa1;
}

.form-body label small,
.ssh-form label small,
.ssh-help { color: #94a6b8; line-height: 1.7; }

:is(.form-body, .ssh-form, .scan-form) label:has(> input[type="checkbox"]) {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 9px;
  line-height: 1.7;
}

:is(.form-body, .ssh-form, .scan-form) input[type="checkbox"] {
  width: 16px;
  height: 16px;
  min-height: 16px;
  margin: 2px 0 0;
  padding: 0;
  flex: 0 0 16px;
  accent-color: var(--accent);
}

:is(form, .form-body) .form-error:not(:empty) {
  padding: 10px 12px;
  border: 1px solid #704b48;
  border-radius: 7px;
  background: #ee87860a;
  white-space: pre-wrap;
}

.form-error { scroll-margin-block: 100px; }
.form-row :is(input, select, textarea) { min-width: 0; }
.modal-heading > div { min-width: 0; }
.modal-heading :is(h2, p),
.modal-footer > .muted { overflow-wrap: anywhere; }
.modal-footer { flex-wrap: wrap; }
.modal-footer > .button { max-width: 100%; white-space: normal; }

/* SSH controls need to stay usable with long hostnames and remote paths. */
.ssh-sidebar { scrollbar-width: thin; scrollbar-color: #344253 transparent; }
.ssh-host-filter { padding: 14px; border-bottom: 1px solid var(--control-border); }
.ssh-host-filter label { display: block; margin-bottom: 8px; color: var(--text); font-size: 12px; }
.ssh-host-search-row { display: flex; align-items: center; gap: 8px; }
.ssh-host-search-row input {
  width: 100%; min-width: 0; min-height: 40px; padding: 8px 10px;
  border: 1px solid var(--control-border); border-radius: 6px;
  color: var(--text); background: var(--control-surface); font: inherit; font-size: 12px;
}
.ssh-host-search-row input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ssh-host-search-row .text-button { flex-shrink: 0; min-height: 40px; }
.ssh-host-search-row [hidden] { display: none; }
#ssh-host-filter-status, #ssh-file-filter-status { margin: 8px 0 0; color: var(--muted); font-size: 11px; line-height: 1.7; overflow-wrap: anywhere; }
.ssh-host { scroll-margin-block: 12px; }
.ssh-host.selected { box-shadow: inset 3px 0 0 var(--accent); }
.ssh-host:focus-visible { outline-offset: -3px; }
.ssh-form-heading > div,
.ssh-session-heading > strong { min-width: 0; overflow-wrap: anywhere; }
.ssh-form-heading > .text-button,
.ssh-session-heading > .button { flex-shrink: 0; }
.ssh-form-actions { flex-wrap: wrap; }
.ssh-credentials details { border: 1px solid #34414c; border-radius: 7px; padding: 10px 12px; }
.ssh-credentials summary { color: #c2ced9; cursor: pointer; line-height: 1.7; }
.ssh-tabs { gap: 8px; }
.ssh-tabs button { min-width: 72px; min-height: 44px; padding-inline: 14px; }
.ssh-tabs button:focus-visible { outline-offset: -4px; }
.ssh-file { padding: 10px 8px; gap: 12px; border-radius: 6px; }
.ssh-file > button { white-space: normal; line-height: 1.7; }
.ssh-file > :is(button, a) { min-height: 36px; }
.ssh-file > :is(span, a) { flex-shrink: 0; }
.ssh-file > a { padding: 7px 4px; }
.ssh-file > span { font-variant-numeric: tabular-nums; }
.ssh-file > .ssh-file-mtime { flex-shrink: 1; min-width: 0; overflow-wrap: anywhere; }
.ssh-file-list > .ssh-empty { padding: 24px 12px; text-align: center; }
.ssh-fingerprint { overflow-wrap: anywhere; }

@media (max-width: 760px) {
  .heading-actions { flex-wrap: wrap; }
  .heading-actions > .button { white-space: normal; }
  .filter-tabs { flex-wrap: wrap; justify-content: flex-start; }
  .filter-tabs button { min-height: 36px; }
  .app-toolbar .search-field { min-height: 38px; }
  .ssh-session-heading { flex-wrap: wrap; }
  .ssh-path-form > .button { flex: 1; min-height: 40px; }
  .ssh-form-actions > .button { flex: 1; min-height: 40px; }
  .ssh-form-heading > .text-button { min-height: 36px; }
  .ssh-file { flex-wrap: wrap; gap: 6px 12px; }
  .ssh-file > button { flex-basis: calc(100% - 80px); }
  .ssh-file > span { margin-left: auto; }
  .ssh-file > .ssh-file-mtime { flex-basis: 100%; margin-left: 0; order: 1; }
}

@media (max-width: 430px) {
  .modal-heading { padding: 16px; }
  .form-body { padding: 16px; }
  .modal-footer { padding-inline: 16px; }
  .modal-footer > .button { flex: 1 1 auto; min-height: 40px; }
  .ssh-main > #ssh-host-editor,
  .ssh-main > #ssh-connect-panel,
  #ssh-files-panel { padding: 14px; }
}

@media (pointer: coarse) {
  .ssh-file > :is(button, a),
  .ssh-sidebar .text-button,
  .ssh-form-heading .text-button { min-height: 44px; }
}

@media (forced-colors: active) {
  .button.danger:not(:disabled),
  .button.danger-button:not(:disabled),
  :is(form, .form-body) .form-error:not(:empty) { border-color: CanvasText; }
  .ssh-host.selected { border-color: Highlight; box-shadow: none; }
  :is(.form-body, .ssh-form, .scan-form) :is(input, select, textarea):focus-visible { outline-color: Highlight; }
}
