/* v0.8.7 · selettore Schede/Tabella e vista tabulare pubblica */

.view-switch {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  flex: 0 0 auto;
  margin-left: auto;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
}

.view-switch-btn {
  min-height: 34px;
  border: 0;
  border-radius: 999px;
  padding: 0 11px;
  background: transparent;
  color: var(--muted);
  font-size: .86rem;
  font-weight: 700;
  white-space: nowrap;
}

.view-switch-btn.active {
  background: var(--surface);
  color: var(--accent);
  box-shadow: 0 1px 4px rgba(24, 53, 58, .12);
}

.contacts-grid.table-view-active {
  display: block;
}

.contacts-table-scroll {
  width: 100%;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.contacts-table {
  width: 100%;
  min-width: 940px;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--surface);
  font-size: .87rem;
}

.contacts-table th,
.contacts-table td {
  padding: 10px 11px;
  text-align: left;
  vertical-align: middle;
}

.contacts-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-2);
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  font-size: .74rem;
  line-height: 1.2;
  letter-spacing: .035em;
  text-transform: uppercase;
  white-space: nowrap;
}

.contacts-table tbody td {
  border-top: 1px solid color-mix(in srgb, var(--border) 72%, transparent);
}

.contacts-table tbody tr:first-child td {
  border-top: 0;
}

.contacts-table tbody tr:hover td {
  background: color-mix(in srgb, var(--accent-2) 35%, var(--surface));
}

.contacts-table .table-name-cell {
  min-width: 190px;
  max-width: 250px;
}

.contacts-table td:nth-child(2) {
  min-width: 115px;
}

.contacts-table td:nth-child(3) {
  min-width: 190px;
  max-width: 260px;
}

.contacts-table td:nth-child(4) {
  min-width: 135px;
}

.table-contact-name {
  display: block;
  color: var(--text);
  font-size: .92rem;
  line-height: 1.25;
}

.table-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.table-badges .scope-badge,
.table-badges .community-badge {
  margin: 0;
  padding: 2px 6px;
  font-size: .66rem;
}

.table-number-cell {
  min-width: 92px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.table-number-link {
  color: var(--accent);
  font-weight: 800;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

.table-empty-cell {
  color: var(--muted);
}

.table-actions-cell {
  width: 1%;
  white-space: nowrap;
}

.table-actions {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.table-action-btn {
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text);
  font-size: 1rem;
  line-height: 1;
}

.table-action-btn:hover:not(:disabled) {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
  color: var(--accent);
}

.table-action-btn:disabled {
  opacity: .38;
  cursor: default;
}

.table-favorite {
  color: var(--muted);
  font-size: 1.16rem;
}

.table-favorite.active {
  color: #b88200;
}

.table-pending-review td:first-child {
  box-shadow: inset 3px 0 0 color-mix(in srgb, #d69a24 72%, var(--border));
}

.table-external-contact td:first-child {
  box-shadow: inset 3px 0 0 color-mix(in srgb, var(--accent) 62%, var(--border));
}

.table-pending-review.table-external-contact td:first-child {
  box-shadow: inset 3px 0 0 color-mix(in srgb, var(--accent) 62%, #d69a24);
}

@media (max-width: 700px) {
  .view-switch {
    margin-left: 0;
  }

  .contacts-table-scroll {
    border-radius: 13px;
  }

  .contacts-table {
    min-width: 880px;
  }
}
