/* Settings, team and visitor administration. */

.settings-page {
  max-width: 920px;
}

.settings-stack {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}

.settings-section-wide {
  grid-column: 1 / -1;
}

.settings-section {
  overflow: hidden;
}

.settings-section .card-header .hint {
  margin-top: 3px;
}

.settings-section-body {
  padding: 18px;
}

.settings-section .loading-block {
  min-height: 130px;
  padding: 22px 0;
}

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

.settings-form-narrow {
  max-width: 460px;
}

.settings-form .toggle-row {
  align-items: center;
  padding: 2px 0;
  border-bottom: 0;
}

.settings-form .switch::before {
  content: "";
  position: absolute;
  inset: -9px -4px;
}

.toggle-copy {
  min-width: 0;
}

.settings-status {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.settings-status:empty,
.visitors-action-status:empty {
  display: none;
}

.settings-save-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 12px;
}

.settings-save-state {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
  transition: color 0.15s var(--ease-out);
}

.settings-save-state.saved {
  color: var(--green-ink);
}

.field-error {
  color: var(--red);
  font-size: 12px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.settings-status .form-error,
.settings-state-line span,
.team-guard span,
.visitors-action-note span {
  overflow-wrap: anywhere;
}

.field .input[aria-invalid="true"],
.field .textarea[aria-invalid="true"] {
  border-color: var(--red);
}

.field .input[aria-invalid="true"]:focus,
.field .textarea[aria-invalid="true"]:focus {
  border-color: var(--red);
  box-shadow: 0 0 0 3px var(--red-soft);
}

.settings-section .input[readonly] {
  background: var(--surface-soft);
  color: var(--muted);
}

.settings-state-line {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  margin: -2px 0 0;
  padding: 9px 11px;
  border: 1px solid var(--amber-line);
  border-radius: 10px;
  background: var(--amber-soft);
  color: var(--amber);
  font-size: 12px;
  line-height: 1.45;
}

.settings-state-line svg {
  margin-top: 1px;
}

/* Integrations */
.integration-list {
  display: flex;
  flex-direction: column;
}

.integration {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.integration:first-child {
  padding-top: 0;
}

.integration:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.integration-icon {
  display: inline-flex;
  width: 32px;
  height: 32px;
  align-items: center;
  justify-content: center;
  border-radius: 9px;
  background: var(--surface-tint);
  color: var(--brand);
}

.integration-copy {
  min-width: 0;
}

.integration-name {
  font-size: 13px;
  font-weight: 550;
}

.integration-meta {
  margin-top: 1px;
  color: var(--muted);
  font-size: 12px;
}

.integration .badge {
  margin-left: auto;
  flex: none;
}

/* Team */
.team-list {
  display: flex;
  flex-direction: column;
}

.team-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
}

.team-row:last-child {
  border-bottom: 0;
}

.team-identity {
  flex: 1;
  min-width: 0;
}

.team-name-row {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.team-name {
  min-width: 0;
  overflow: hidden;
  color: var(--ink);
  font-size: 13px;
  font-weight: 550;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.team-email {
  margin-top: 1px;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.team-meta {
  display: flex;
  flex: none;
  align-items: center;
  gap: 10px;
}

.team-added {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.team-remove {
  flex: none;
}

.team-guard {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 0 18px 14px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--amber-soft);
  color: var(--amber);
  font-size: 12px;
  line-height: 1.45;
}

.team-guard svg {
  margin-top: 1px;
}

.team-notice {
  padding: 14px 18px 0;
}

.team-status {
  padding: 0 18px;
}

.team-status:not(:empty) {
  margin: 14px 0 0;
  padding-bottom: 2px;
}

.team-add {
  padding: 18px;
  border-top: 1px solid var(--line);
  background: var(--surface-soft);
}

.team-add-title {
  margin-bottom: 12px;
  font-size: 13px;
  font-weight: 600;
}

.team-add-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  align-items: start;
}

.team-add .settings-save-row {
  margin-top: 14px;
}

/* Visitors */
.visitors-toolbar {
  gap: 10px 14px;
}

.visitors-count {
  margin-left: auto;
  white-space: nowrap;
}

.visitors-action-status {
  margin: -4px 0 12px;
}

.visitors-action-note {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  margin: 0;
  color: var(--green-ink);
  font-size: 12px;
  line-height: 1.45;
}

.visitors-action-note svg {
  margin-top: 1px;
}

.visitor-cell {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.visitor-identity {
  min-width: 0;
  max-width: 320px;
}

.visitor-email {
  overflow: hidden;
  color: var(--ink);
  font-size: 13px;
  font-weight: 550;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.visitor-name {
  margin-top: 1px;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.visitor-activity {
  margin-top: 2px;
  color: var(--muted-light);
  font-size: 12px;
  white-space: nowrap;
}

.visitor-number {
  width: 72px;
  font-variant-numeric: tabular-nums;
}

.visitor-last-seen {
  color: var(--muted);
  white-space: nowrap;
}

.visitors-table .actions-cell {
  text-align: right;
}

.visitors-page .empty h3 {
  overflow-wrap: anywhere;
}

/* Utility */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 900px) {
  .settings-stack {
    grid-template-columns: minmax(0, 1fr);
  }

  .settings-section-wide {
    grid-column: auto;
  }
}

@media (max-width: 760px) {
  .settings-section-body {
    padding: 16px;
  }

  .form-grid,
  .team-add-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .settings-page .btn-primary,
  .team-add .btn,
  .team-remove {
    height: 40px;
  }

  .team-row {
    display: grid;
    grid-template-columns: 40px minmax(0, 1fr);
    gap: 6px 10px;
  }

  .team-row .avatar {
    grid-row: 1;
    grid-column: 1;
  }

  .team-identity {
    grid-row: 1;
    grid-column: 2;
  }

  .team-meta {
    grid-row: 2;
    grid-column: 2;
  }

  .team-remove {
    grid-row: 3;
    grid-column: 1 / -1;
    width: 100%;
  }

  .team-guard {
    margin: 0 16px 14px;
  }

  .team-status {
    padding: 0 16px;
  }

  .team-notice {
    padding: 14px 16px 0;
  }

  .team-add {
    padding: 16px;
  }

  .visitors-count {
    margin-left: 0;
    width: 100%;
  }

  .visitors-page .page-actions .btn,
  .visitors-page .empty .btn {
    height: 40px;
  }

  .visitors-page .icon-btn {
    width: 40px;
    height: 40px;
  }

  .visitors-card {
    overflow: visible;
    border: 0;
    background: transparent;
    box-shadow: none;
  }

  .visitors-table,
  .visitors-table tbody,
  .visitors-table tr,
  .visitors-table td {
    display: block;
    width: 100%;
  }

  .visitors-table thead {
    display: none;
  }

  .visitors-table tbody tr {
    margin-bottom: 12px;
    padding: 2px 14px 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-xs);
  }

  .visitors-table tbody tr:last-child {
    margin-bottom: 0;
  }

  .visitors-table td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 8px 0;
    border-bottom: 1px solid var(--line);
  }

  .visitors-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 12px;
    font-weight: 550;
  }

  .visitors-table td:first-child {
    display: block;
    padding: 12px 0 10px;
  }

  .visitors-table td:first-child::before {
    display: none;
  }

  .visitors-table td:last-child {
    border-bottom: 0;
  }

  .visitor-identity {
    max-width: none;
  }

  .visitor-number,
  .visitor-last-seen {
    width: auto;
  }

  .visitors-table td.actions-cell {
    display: block;
  }

  .visitors-table td.actions-cell::before {
    display: none;
  }

  .visitor-actions .btn {
    width: 100%;
    height: 40px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .settings-save-state {
    transition: none;
  }
}
