/* =========================
   Users
   ========================= */

.users-container {
  max-width: 1400px;
  margin: 0 auto;
}

.users-card {
  background: var(--surface);
  border-radius: var(--r-lg);
  padding: 24px;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border-200);
}

.users-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.users-summary {
  padding: 12px 16px;
  background: color-mix(in srgb, var(--brand-800) 8%, var(--white));
  border-radius: var(--r-sm);
}

.users-summary strong {
  color: var(--brand-800);
}

.users-summary-meta {
  margin-left: 10px;
  font-size: 12px;
  color: var(--text-600);
}

.users-meta {
  font-size: 12px;
  color: var(--text-600);
}

/* =========================
   Filters
   ========================= */
.users-filters {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: flex-end;
  margin-bottom: 18px;
  padding: 14px;
  background: var(--surface-50);
  border-radius: var(--r-sm);
  border: 1px solid var(--border-200);
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 200px;
  flex: 1 1 220px;
}

.filter-group label {
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  color: var(--text-600);
}

.filter-group input,
.filter-group select {
  padding: 8px 10px;
  border: 1px solid var(--border-300);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text-900);
  width: 100%;
}

.filter-group input:focus,
.filter-group select:focus {
  outline: none;
  border-color: color-mix(in srgb, var(--brand-800) 40%, var(--border-200));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-800) 12%, transparent);
}

.filter-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

/* =========================
   Table
   ========================= */
.table-wrap {
  width: 100%;
  overflow-x: auto;
}

.users-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 10px;
}

.users-table thead {
  background: var(--surface-50);
}

.users-table th {
  padding: 12px;
  text-align: left;
  font-weight: 600;
  border-bottom: 2px solid var(--border-300);
  font-size: 14px;
  vertical-align: middle;
}

.users-table td {
  padding: 12px;
  border-bottom: 1px solid var(--border-200);
  font-size: 14px;
  height: 56px;
  vertical-align: middle;
  line-height: 1.25;
}

.users-table td .btn + .btn {
  margin-left: 8px;
}

.users-table tbody tr:hover {
  background: var(--surface-50);
}

.empty-state {
  text-align: center;
  color: var(--text-600);
  padding: 16px;
}

.status-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.status-active {
  background: color-mix(in srgb, var(--success-600) 20%, var(--white));
  color: var(--success-600);
}

.status-inactive {
  background: var(--danger-bg);
  color: var(--danger-600);
}

/* =========================
   Modal form
   ========================= */
.user-form {
  display: grid;
  gap: var(--p-4);
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: var(--p-4);
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.form-group label {
  font-weight: 600;
  font-size: 13px;
  color: var(--text-700);
}

.form-group select {
  padding: 10px 12px;
  border: 1px solid var(--border-300);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text-900);
  width: 100%;
}

.form-group select:focus {
  outline: none;
  border-color: color-mix(in srgb, var(--brand-800) 40%, var(--border-200));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-800) 12%, transparent);
}

.form-group input {
  padding: 10px 12px;
  border: 1px solid var(--border-300);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text-900);
  width: 100%;
}

.form-group input:focus {
  outline: none;
  border-color: color-mix(in srgb, var(--brand-800) 40%, var(--border-200));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-800) 12%, transparent);
}

.form-group input[type='checkbox'] {
  width: auto;
}

.checkbox-group {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  margin-top: 26px;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* =========================
   Access modal
   ========================= */
.modal-content--wide {
  width: min(960px, 100%);
}

.modal-subtitle {
  margin: 6px 0 0;
  color: var(--text-600);
  font-size: 13px;
}

.access-summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--r-sm);
  background: var(--surface-50);
  border: 1px solid var(--border-200);
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.access-summary-text {
  font-weight: 600;
  color: var(--text-800);
}

.access-summary-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.access-list {
  display: grid;
  gap: 12px;
  margin-bottom: 20px;
}

.access-loading {
  padding: 24px;
  text-align: center;
  color: var(--text-600);
  border: 1px dashed var(--border-200);
  border-radius: var(--r-sm);
}

.access-item {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 14px;
  padding: 14px 16px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border-200);
  background: var(--surface);
}

.access-toggle {
  display: flex;
  align-items: flex-start;
  padding-top: 2px;
}

.access-toggle input {
  width: 18px;
  height: 18px;
}

.access-details {
  display: grid;
  gap: 6px;
  cursor: pointer;
}

.access-title {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.access-name {
  font-weight: 600;
  color: var(--text-900);
}

.access-path {
  font-size: 12px;
  color: var(--text-600);
  background: var(--surface-50);
  border: 1px solid var(--border-200);
  padding: 2px 8px;
  border-radius: 999px;
}

.access-description {
  font-size: 13px;
  color: var(--text-700);
}

/* =========================
   Mobile
   ========================= */
@media (max-width: 768px) {
  .users-card {
    padding: 16px;
  }

  .users-filters {
    flex-direction: column;
    align-items: stretch;
  }

  .filter-group {
    min-width: 0;
    width: 100%;
  }

  .filter-actions {
    width: 100%;
  }

  .filter-actions .btn {
    flex: 1;
    justify-content: center;
  }

  .users-table thead {
    display: none;
  }

  .users-table tbody tr {
    display: block;
    background: var(--surface);
    border: 1px solid var(--border-200);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-sm);
    padding: 12px;
    margin-bottom: 12px;
  }

  .users-table tbody td {
    display: grid;
    grid-template-columns: 110px minmax(0, 1fr);
    gap: 10px;
    padding: 10px 0;
    border: 0;
    height: auto;
    min-width: 0;
    align-items: start;
  }

  .users-table tbody td + td {
    border-top: 1px solid var(--border-200);
  }

  .users-table tbody td::before {
    content: attr(data-label);
    font-weight: 700;
    font-size: 12px;
    color: var(--text-600);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    padding-top: 2px;
    min-width: 0;
  }

  .users-table tbody td > * {
    min-width: 0;
  }
}
